Example #1
0
        private static CompletionItem ConvertCompletionItem(Document document, Microsoft.CodeAnalysis.Completion.CompletionRules completionRules, CodeAnalysis.Completion.CompletionItem item)
        {
            var description = CommonCompletionItem.GetDescription(item);

            // A bit hacky: everything before the line break is the Detail, everything after is the Documentation.
            var detail        = string.Empty;
            var documentation = string.Empty;
            var seenLineBreak = false;

            foreach (var taggedText in description.TaggedParts)
            {
                if (seenLineBreak)
                {
                    documentation += taggedText.Text;
                }
                else
                {
                    if (taggedText.Text.ContainsLineBreak())
                    {
                        seenLineBreak = true;
                    }
                    else
                    {
                        detail += taggedText.Text;
                    }
                }
            }

            return(new CompletionItem
            {
                Label = item.DisplayText,
                SortText = item.SortText,
                FilterText = item.FilterText,
                Kind = GetKind(item.Glyph),
                TextEdit = new TextEdit
                {
                    NewText = item.DisplayText,
                    Range = Helpers.ToRange(document.SourceText, item.Span)
                },
                Detail = detail,
                Documentation = documentation,
                CommitCharacters = completionRules.DefaultCommitCharacters.Select(x => x.ToString()).ToArray()
            });
        }
Example #2
0
 internal CompletionRules(Microsoft.CodeAnalysis.Completion.CompletionRules inner)
 {
     _inner = inner;
 }