// Internal for testing
        internal static List <RazorCompletionItem> GetDirectiveCompletionItems(RazorSyntaxTree syntaxTree)
        {
            var defaultDirectives = FileKinds.IsComponent(syntaxTree.Options.FileKind) ? Array.Empty <DirectiveDescriptor>() : DefaultDirectives;
            var directives        = syntaxTree.Options.Directives.Concat(defaultDirectives);
            var completionItems   = new List <RazorCompletionItem>();

            foreach (var directive in directives)
            {
                var completionDisplayText = directive.DisplayName ?? directive.Directive;
                var completionItem        = new RazorCompletionItem(
                    completionDisplayText,
                    directive.Directive,
                    RazorCompletionItemKind.Directive);
                var completionDescription = new DirectiveCompletionDescription(directive.Description);
                completionItem.SetDirectiveCompletionDescription(completionDescription);
                completionItems.Add(completionItem);
            }

            return(completionItems);
        }
Пример #2
0
        public static void SetDirectiveCompletionDescription(this RazorCompletionItem completionItem, DirectiveCompletionDescription attributeCompletionDescription)
        {
            if (completionItem is null)
            {
                throw new ArgumentNullException(nameof(completionItem));
            }

            completionItem.Items[s_directiveCompletionDescriptionKey] = attributeCompletionDescription;
        }