public override async Task <TooltipInformation> CreateTooltipInformation(bool smartWrap, CancellationToken cancelToken)
        {
            var description = await completionService.GetDescriptionAsync(doc, CompletionItem);

            var markup      = new StringBuilder();
            var theme       = DefaultSourceEditorOptions.Instance.GetEditorTheme();
            var taggedParts = description.TaggedParts;
            int i           = 0;

            while (i < taggedParts.Length)
            {
                if (taggedParts[i].Tag == "LineBreak")
                {
                    break;
                }
                i++;
            }
            if (i + 1 >= taggedParts.Length)
            {
                markup.AppendTaggedText(theme, taggedParts);
            }
            else
            {
                markup.AppendTaggedText(theme, taggedParts.Take(i));
                markup.Append("<span font='" + FontService.SansFontName + "' size='small'>");
                markup.AppendLine();
                markup.AppendLine();
                markup.AppendTaggedText(theme, taggedParts.Skip(i + 1), 0, 50);
                markup.Append("</span>");
            }
            return(new TooltipInformation {
                SignatureMarkup = markup.ToString()
            });
        }
Beispiel #2
0
 public static Task <CompletionDescription?> GetDescriptionAsync(
     this CompletionService completionService,
     Document document,
     CompletionItem item,
     OmniSharpCompletionOptions options,
     CancellationToken cancellationToken)
 {
     return(completionService.GetDescriptionAsync(document, item, options.ToCompletionOptions(), SymbolDescriptionOptions.Default, cancellationToken));
 }
Beispiel #3
0
 private async Task <NeedContextItemsArgs.ContextItem> GetContextItem(CompletionItem c)
 {
     return(new NeedContextItemsArgs.ContextItem()
     {
         Name = c.DisplayText,
         Descr = (await completion.GetDescriptionAsync(doc, c)).Text,
         IsChildModel = false,
         IsEvent = false,
         IsMethod = true,
     });
 }
Beispiel #4
0
        private static async Task <ImmutableArray <TaggedText> > GetDescriptionAsync(CompletionService completionService, Document document, CompletionItem completionItem)
        {
            try
            {
                var desc = await completionService.GetDescriptionAsync(document, completionItem);

                var res = desc.TaggedParts;
                // var res = (await Task.Run(async () => )).TaggedParts;
                return(res);
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                return(default);
        /// <summary>
        /// Gets the description or null if none
        /// </summary>
        /// <param name="completion">Completion</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns></returns>
        public Task <CompletionDescription> GetDescriptionAsync(RoslynCompletion completion, CancellationToken cancellationToken = default)
        {
            if (completion == null)
            {
                throw new ArgumentNullException(nameof(completion));
            }

            var info = CompletionInfo.Create(textView.TextSnapshot);

            if (info == null)
            {
                return(Task.FromResult <CompletionDescription>(null));
            }

            return(completionService.GetDescriptionAsync(info.Value.Document, completion.CompletionItem, cancellationToken));
        }
        async Task GetSymbolComments(CompletionItem item)
        {
            await UpdateScrollViewer();

            CompletionDescription description = await CompletionService.GetDescriptionAsync(Document, item);

            SourceText currText = await Document.GetTextAsync();

            SourceText newText = currText.Replace(item.Span, item.DisplayText);

            SyntaxTree tree = await Document.WithText(newText).GetSyntaxTreeAsync();

            CSharpCompilation comp  = CSharpCompilation.Create("documentation", new[] { tree }, References);
            SemanticModel     model = comp.GetSemanticModel(tree);

            TextSpan targetSpan = new TextSpan(item.Span.Start, item.DisplayText.Length);

            string documentationXml = "";

            IEnumerable <SyntaxNode> nodes = tree.GetRoot().DescendantNodes(targetSpan);

            if (nodes.Any())
            {
                SyntaxNode node = nodes.FirstOrDefault(n => (targetSpan.Contains(n.Span) && !n.IsKind(SyntaxKind.IncompleteMember)));

                if (node != null)
                {
                    SymbolInfo info = model.GetSymbolInfo(node);

                    ISymbol symbol = info.Symbol ?? (info.CandidateSymbols.Length > 0 ? info.CandidateSymbols[0] : null);

                    if (symbol != null)
                    {
                        string documentationId = symbol.GetDocumentationCommentId();
                        documentationXml = symbol.GetDocumentationCommentXml();

                        if (string.IsNullOrEmpty(documentationXml) && !string.IsNullOrEmpty(documentationId))
                        {
                            (await Utils.GetReferenceDocumentation()).TryGetValue(documentationId, out documentationXml);
                        }
                    }
                }
            }

            ShowDocumentationComments(description, documentationXml, EffectiveSelectedIndex * 20 - this.FindControl <ScrollViewer>("ItemsScrollViewer").Offset.Y);
        }
Beispiel #7
0
        public override async Task <TooltipInformation> CreateTooltipInformation(bool smartWrap, CancellationToken cancelToken)
        {
            CompletionDescription description;

            if (CommonCompletionItem.HasDescription(CompletionItem))
            {
                description = CommonCompletionItem.GetDescription(CompletionItem);
            }
            else
            {
                description = await Task.Run(() => completionService.GetDescriptionAsync(doc, CompletionItem)).ConfigureAwait(false);
            }
            var markup      = new StringBuilder();
            var theme       = SyntaxHighlightingService.GetIdeFittingTheme(DefaultSourceEditorOptions.Instance.GetEditorTheme());
            var taggedParts = description.TaggedParts;
            int i           = 0;

            while (i < taggedParts.Length)
            {
                if (taggedParts [i].Tag == "LineBreak")
                {
                    break;
                }
                i++;
            }
            if (i + 1 >= taggedParts.Length)
            {
                markup.AppendTaggedText(theme, taggedParts);
            }
            else
            {
                markup.AppendTaggedText(theme, taggedParts.Take(i));
                markup.Append("<span font='" + FontService.SansFontName + "' size='small'>");
                markup.AppendLine();
                markup.AppendLine();
                markup.AppendTaggedText(theme, taggedParts.Skip(i + 1));
                markup.Append("</span>");
            }
            return(new TooltipInformation {
                SignatureMarkup = markup.ToString()
            });
        }
Beispiel #8
0
 private static async Task <ImmutableArray <TaggedText> > GetDescriptionAsync(CompletionService completionService, Document document, CompletionItem completionItem)
 {
     return((await Task.Run(async() => await completionService.GetDescriptionAsync(document, completionItem))).TaggedParts);
 }
 public Task <CompletionDescription?> GetCompletionDescriptionAsync(CompletionItem item, CancellationToken cancellationToken)
 {
     return(_completionService.GetDescriptionAsync(Document, item, cancellationToken: cancellationToken));
 }