未验证 提交 ac08b671 编写于 作者: J Joey Robichaud 提交者: GitHub

Merge pull request #34315 from JoeRobich/filter-additive-classifications

Filter out additive classifications in EditorClassifier
......@@ -72,6 +72,14 @@ internal static class EditorClassifier
await delegationService.AddSemanticClassificationsAsync(
classificationService, document, widenedSpan, semanticSpans, cancellationToken).ConfigureAwait(false);
// MergeClassifiedSpans will ultimately filter multiple classifications for the same
// span down to one. We know that additive classifications are there just to
// provide additional information about the true classification. We will remove
// additive ClassifiedSpans until we have support for additive classifications
// in classified spans. https://github.com/dotnet/roslyn/issues/32770
RemoveAdditiveSpans(syntaxSpans);
RemoveAdditiveSpans(semanticSpans);
var classifiedSpans = MergeClassifiedSpans(
syntaxSpans, semanticSpans, widenedSpan, sourceText);
return classifiedSpans;
......@@ -83,6 +91,18 @@ internal static class EditorClassifier
}
}
private static void RemoveAdditiveSpans(List<ClassifiedSpan> spans)
{
for (var i = spans.Count - 1; i >= 0; i--)
{
var span = spans[i];
if (ClassificationTypeNames.AdditiveTypeNames.Contains(span.ClassificationType))
{
spans.RemoveAt(i);
}
}
}
private static ImmutableArray<ClassifiedSpan> MergeClassifiedSpans(
List<ClassifiedSpan> syntaxSpans, List<ClassifiedSpan> semanticSpans,
TextSpan widenedSpan, SourceText sourceText)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册