Example #1
0
        public Task <CompletionItem> Handle(CompletionItem completionItem, CancellationToken cancellationToken)
        {
            string markdown = null;

            if (completionItem.TryGetRazorCompletionKind(out var completionItemKind))
            {
                switch (completionItemKind)
                {
                case RazorCompletionItemKind.DirectiveAttribute:
                case RazorCompletionItemKind.DirectiveAttributeParameter:
                    var descriptionInfo = completionItem.GetAttributeDescriptionInfo();
                    _tagHelperDescriptionFactory.TryCreateDescription(descriptionInfo, out markdown);
                    break;
                }
            }
            else
            {
                if (completionItem.IsTagHelperElementCompletion())
                {
                    var descriptionInfo = completionItem.GetElementDescriptionInfo();
                    _tagHelperDescriptionFactory.TryCreateDescription(descriptionInfo, out markdown);
                }

                if (completionItem.IsTagHelperAttributeCompletion())
                {
                    var descriptionInfo = completionItem.GetTagHelperAttributeDescriptionInfo();
                    _tagHelperDescriptionFactory.TryCreateDescription(descriptionInfo, out markdown);
                }
            }


            if (markdown != null)
            {
                var documentation = new StringOrMarkupContent(
                    new MarkupContent()
                {
                    Kind  = MarkupKind.Markdown,
                    Value = markdown,
                });
                completionItem.Documentation = documentation;
            }

            return(Task.FromResult(completionItem));
        }