Skip to content

Commit

Permalink
Use new QuickInfoUtilities helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoertz-msft committed Mar 24, 2021
1 parent 1d7aabe commit 202e9a9
Showing 1 changed file with 10 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
using Microsoft.CodeAnalysis.DocumentationComments;
using Microsoft.CodeAnalysis.Editor.Xaml;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.QuickInfo;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.VisualStudio.LanguageServices.Xaml.Implementation.LanguageServer.Extensions
{
Expand Down Expand Up @@ -52,51 +54,17 @@ public static async Task<IEnumerable<TaggedText>> GetDescriptionAsync(this ISymb
return Enumerable.Empty<TaggedText>();
}

var description = await symbolDisplayService.ToDescriptionPartsAsync(codeProject.Solution.Workspace, semanticModel, position: 0, ImmutableArray.Create(symbol), SymbolDescriptionGroups.MainDescription, cancellationToken).ConfigureAwait(false);

var quickInfo = await QuickInfoUtilities.CreateQuickInfoItemAsync(codeProject.Solution.Workspace, semanticModel, TextSpan.FromBounds(0, 0), ImmutableArray.Create(symbol), cancellationToken).ConfigureAwait(false);
var builder = new List<TaggedText>();
builder.AddRange(description.ToTaggedText());

var documentation = symbol.GetDocumentationParts(semanticModel, position: 0, formatter, cancellationToken);
if (documentation.Any())
{
builder.AddLineBreak();
builder.AddRange(documentation);
}

var remarksDocumentation = symbol.GetRemarksDocumentationParts(semanticModel, position: 0, formatter, cancellationToken);
if (remarksDocumentation.Any())
{
builder.AddLineBreak();
builder.AddLineBreak();
builder.AddRange(remarksDocumentation);
}

var returnsDocumentation = symbol.GetReturnsDocumentationParts(semanticModel, position: 0, formatter, cancellationToken);
if (returnsDocumentation.Any())
{
builder.AddLineBreak();
builder.AddLineBreak();
builder.AddText(FeaturesResources.Returns_colon);
builder.AddLineBreak();
builder.Add(new TaggedText(TextTags.ContainerStart, " "));
builder.AddRange(returnsDocumentation);
builder.Add(new TaggedText(TextTags.ContainerEnd, string.Empty));
}

var valueDocumentation = symbol.GetValueDocumentationParts(semanticModel, position: 0, formatter, cancellationToken);
if (valueDocumentation.Any())
foreach (var section in quickInfo.Sections)
{
builder.AddLineBreak();
builder.AddLineBreak();
builder.AddText(FeaturesResources.Value_colon);
builder.AddLineBreak();
builder.Add(new TaggedText(TextTags.ContainerStart, " "));
builder.AddRange(valueDocumentation);
builder.Add(new TaggedText(TextTags.ContainerEnd, string.Empty));
if (builder.Any())
{
builder.AddLineBreak();
}
builder.AddRange(section.TaggedParts);
}

return builder;
return builder.ToImmutableArray();
}
}
}

0 comments on commit 202e9a9

Please sign in to comment.