未验证 提交 a2acd415 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #34261 from sharwell/fix-quick-info

Update async completion and quick info to share BuildClassifiedTextElements
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion;
......@@ -10,7 +11,6 @@
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
......@@ -256,7 +256,19 @@ public async Task<object> GetDescriptionAsync(IAsyncCompletionSession session, V
var description = await service.GetDescriptionAsync(document, roslynItem, cancellationToken).ConfigureAwait(false);
return IntelliSense.Helpers.BuildClassifiedTextElement(description.TaggedParts);
var elements = IntelliSense.Helpers.BuildClassifiedTextElements(description.TaggedParts).ToArray();
if (elements.Length == 0)
{
return new ClassifiedTextElement();
}
else if (elements.Length == 1)
{
return elements[0];
}
else
{
return new ContainerElement(ContainerElementStyle.Stacked | ContainerElementStyle.VerticalPadding, elements);
}
}
private VSCompletionItem Convert(
......
......@@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.QuickInfo;
using Microsoft.VisualStudio.Text.Adornments;
using Roslyn.Utilities;
......@@ -11,13 +9,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
{
internal static class Helpers
{
internal static ClassifiedTextElement BuildClassifiedTextElement(ImmutableArray<TaggedText> taggedTexts)
{
return new ClassifiedTextElement(taggedTexts.Select(
part => new ClassifiedTextRun(part.Tag.ToClassificationTypeName(), part.Text)) ?? Enumerable.Empty<ClassifiedTextRun>());
}
internal static IEnumerable<object> BuildClassifiedTextElements(QuickInfoSection section)
internal static IEnumerable<object> BuildClassifiedTextElements(ImmutableArray<TaggedText> taggedTexts)
{
// This method produces a sequence of zero or more paragraphs
var paragraphs = new List<object>();
......@@ -28,7 +20,7 @@ internal static IEnumerable<object> BuildClassifiedTextElements(QuickInfoSection
// Each line is constructed from one or more inline elements
var currentRuns = new List<ClassifiedTextRun>();
foreach (var part in section.TaggedParts)
foreach (var part in taggedTexts)
{
if (part.Tag == TextTags.LineBreak)
{
......
......@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Adornments;
using Roslyn.Utilities;
using CodeAnalysisQuickInfoItem = Microsoft.CodeAnalysis.QuickInfo.QuickInfoItem;
using IntellisenseQuickInfoItem = Microsoft.VisualStudio.Language.Intellisense.QuickInfoItem;
......@@ -47,7 +46,7 @@ internal static class IntellisenseQuickInfoBuilder
if (descSection != null)
{
var isFirstElement = true;
foreach (var element in Helpers.BuildClassifiedTextElements(descSection))
foreach (var element in Helpers.BuildClassifiedTextElements(descSection.TaggedParts))
{
if (isFirstElement)
{
......@@ -69,7 +68,7 @@ internal static class IntellisenseQuickInfoBuilder
if (documentationCommentSection != null)
{
var isFirstElement = true;
foreach (var element in Helpers.BuildClassifiedTextElements(documentationCommentSection))
foreach (var element in Helpers.BuildClassifiedTextElements(documentationCommentSection.TaggedParts))
{
if (isFirstElement)
{
......@@ -93,7 +92,7 @@ internal static class IntellisenseQuickInfoBuilder
// Add the remaining sections as Stacked style
elements.AddRange(
quickInfoItem.Sections.Where(s => s.Kind != QuickInfoSectionKinds.Description && s.Kind != QuickInfoSectionKinds.DocumentationComments)
.SelectMany(Helpers.BuildClassifiedTextElements));
.SelectMany(s => Helpers.BuildClassifiedTextElements(s.TaggedParts)));
// build text for RelatedSpan
if (quickInfoItem.RelatedSpans.Any())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册