提交 98e2c233 编写于 作者: C CyrusNajmabadi

Revert "Merge pull request #18972 from CyrusNajmabadi/docHighlights2"

This reverts commit 8262112e, reversing
changes made to 837ca214.
上级 8262112e
...@@ -136,12 +136,14 @@ ...@@ -136,12 +136,14 @@
<Compile Include="Highlighting\KeywordHighlighters\UnsafeStatementHighlighter.cs" /> <Compile Include="Highlighting\KeywordHighlighters\UnsafeStatementHighlighter.cs" />
<Compile Include="Highlighting\KeywordHighlighters\UsingStatementHighlighter.cs" /> <Compile Include="Highlighting\KeywordHighlighters\UsingStatementHighlighter.cs" />
<Compile Include="Highlighting\KeywordHighlighters\YieldStatementHighlighter.cs" /> <Compile Include="Highlighting\KeywordHighlighters\YieldStatementHighlighter.cs" />
<Compile Include="HighlightReferences\CSharpDocumentHighlightsService.cs" />
<Compile Include="InlineRename\CSharpEditorInlineRenameService.cs" /> <Compile Include="InlineRename\CSharpEditorInlineRenameService.cs" />
<Compile Include="LanguageServices\CSharpContentTypeLanguageService.cs" /> <Compile Include="LanguageServices\CSharpContentTypeLanguageService.cs" />
<Compile Include="LineSeparators\CSharpLineSeparatorService.cs" /> <Compile Include="LineSeparators\CSharpLineSeparatorService.cs" />
<Compile Include="NavigationBar\CSharpNavigationBarItemService.cs" /> <Compile Include="NavigationBar\CSharpNavigationBarItemService.cs" />
<Compile Include="QuickInfo\SemanticQuickInfoProvider.cs" /> <Compile Include="QuickInfo\SemanticQuickInfoProvider.cs" />
<Compile Include="QuickInfo\SyntacticQuickInfoProvider.cs" /> <Compile Include="QuickInfo\SyntacticQuickInfoProvider.cs" />
<Compile Include="ReferenceHighlighting\ReferenceHighlightingAdditionalReferenceProvider.cs" />
<Compile Include="RenameTracking\CSharpRenameTrackingCodeFixProvider.cs" /> <Compile Include="RenameTracking\CSharpRenameTrackingCodeFixProvider.cs" />
<Compile Include="RenameTracking\CSharpRenameTrackingLanguageHeuristicsService.cs" /> <Compile Include="RenameTracking\CSharpRenameTrackingLanguageHeuristicsService.cs" />
<Compile Include="SplitStringLiteral\SplitStringLiteralCommandHandler.cs" /> <Compile Include="SplitStringLiteral\SplitStringLiteralCommandHandler.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Composition;
using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Host.Mef;
namespace Microsoft.CodeAnalysis.Editor.CSharp.HighlightReferences
{
[ExportLanguageService(typeof(IDocumentHighlightsService), LanguageNames.CSharp), Shared]
internal class CSharpDocumentHighlightsService : AbstractDocumentHighlightsService
{
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable; using System.Collections.Generic;
using System.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Host.Mef;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.DocumentHighlighting namespace Microsoft.CodeAnalysis.Editor.CSharp.ReferenceHighlighting
{ {
[ExportLanguageService(typeof(IDocumentHighlightsService), LanguageNames.CSharp), Shared] [ExportLanguageService(typeof(IReferenceHighlightingAdditionalReferenceProvider), LanguageNames.CSharp), Shared]
internal class CSharpDocumentHighlightsService : AbstractDocumentHighlightsService internal class ReferenceHighlightingAdditionalReferenceProvider : IReferenceHighlightingAdditionalReferenceProvider
{ {
protected override async Task<ImmutableArray<Location>> GetAdditionalReferencesAsync( public async Task<IEnumerable<Location>> GetAdditionalReferencesAsync(
Document document, ISymbol symbol, CancellationToken cancellationToken) Document document, ISymbol symbol, CancellationToken cancellationToken)
{ {
// The FindRefs engine won't find references through 'var' for performance reasons. // The FindRefs engine won't find references through 'var' for performance reasons.
// Also, they are not needed for things like rename/sig change, and the normal find refs // Also, they are not needed for things like rename/sig change, and the normal find refs
// feature. However, we would like the results to be highlighted to get a good experience // feature. However, we would lke the results to be highlighted to get a good experience
// while editing (especially since highlighting may have been invoked off of 'var' in // while editing (especially since highlighting may have been invoked off of 'var' in
// the first place). // the first place).
// //
// So we look for the references through 'var' directly in this file and add them to the // So we look for the references through 'var' directly in this file and add them to the
// results found by the engine. // results found by the engine.
var results = ArrayBuilder<Location>.GetInstance(); List<Location> results = null;
if (symbol is INamedTypeSymbol && symbol.Name != "var") if (symbol is INamedTypeSymbol && symbol.Name != "var")
{ {
...@@ -51,13 +52,18 @@ internal class CSharpDocumentHighlightsService : AbstractDocumentHighlightsServi ...@@ -51,13 +52,18 @@ internal class CSharpDocumentHighlightsService : AbstractDocumentHighlightsServi
if (originalSymbol.Equals(boundSymbol)) if (originalSymbol.Equals(boundSymbol))
{ {
if (results == null)
{
results = new List<Location>();
}
results.Add(type.GetLocation()); results.Add(type.GetLocation());
} }
} }
} }
} }
return results.ToImmutableAndFree(); return results ?? SpecializedCollections.EmptyEnumerable<Location>();
} }
} }
} }
\ No newline at end of file
...@@ -168,14 +168,6 @@ ...@@ -168,14 +168,6 @@
<Compile Include="Implementation\Structure\BlockTagState.cs" /> <Compile Include="Implementation\Structure\BlockTagState.cs" />
<Compile Include="Implementation\Suggestions\SuggestedActionSetComparer.cs" /> <Compile Include="Implementation\Suggestions\SuggestedActionSetComparer.cs" />
<Compile Include="Implementation\Suggestions\SuggestedActionsSource.cs" /> <Compile Include="Implementation\Suggestions\SuggestedActionsSource.cs" />
<Compile Include="ReferenceHighlighting\NagivateToHighlightReferenceCommandHandler.cs" />
<Compile Include="ReferenceHighlighting\NagivateToHighlightReferenceCommandHandler.StartComparer.cs" />
<Compile Include="ReferenceHighlighting\ReferenceHighlightingViewTaggerProvider.cs" />
<Compile Include="ReferenceHighlighting\Tags\DefinitionHighlightTag.cs" />
<Compile Include="ReferenceHighlighting\Tags\DefinitionHighlightTagDefinition.cs" />
<Compile Include="ReferenceHighlighting\Tags\ReferenceHighlightTag.cs" />
<Compile Include="ReferenceHighlighting\Tags\WrittenReferenceHighlightTag.cs" />
<Compile Include="ReferenceHighlighting\Tags\WrittenReferenceHighlightTagDefinition.cs" />
<Compile Include="SymbolSearch\IAddReferenceDatabaseWrapper.cs" /> <Compile Include="SymbolSearch\IAddReferenceDatabaseWrapper.cs" />
<Compile Include="SymbolSearch\IDatabaseFactoryService.cs" /> <Compile Include="SymbolSearch\IDatabaseFactoryService.cs" />
<Compile Include="SymbolSearch\IDelayService.cs" /> <Compile Include="SymbolSearch\IDelayService.cs" />
...@@ -638,6 +630,8 @@ ...@@ -638,6 +630,8 @@
<Compile Include="Implementation\Peek\PeekableItemSource.cs" /> <Compile Include="Implementation\Peek\PeekableItemSource.cs" />
<Compile Include="Implementation\Peek\PeekableItemSourceProvider.cs" /> <Compile Include="Implementation\Peek\PeekableItemSourceProvider.cs" />
<Compile Include="Implementation\Peek\PeekHelpers.cs" /> <Compile Include="Implementation\Peek\PeekHelpers.cs" />
<Compile Include="Implementation\ReferenceHighlighting\WrittenReferenceHighlightTag.cs" />
<Compile Include="Implementation\ReferenceHighlighting\WrittenReferenceHighlightTagDefinition.cs" />
<Compile Include="Implementation\RenameTracking\IRenameTrackingLanguageHeuristicsService.cs" /> <Compile Include="Implementation\RenameTracking\IRenameTrackingLanguageHeuristicsService.cs" />
<Compile Include="Implementation\RenameTracking\RenameTrackingCancellationCommandHandler.cs" /> <Compile Include="Implementation\RenameTracking\RenameTrackingCancellationCommandHandler.cs" />
<Compile Include="Implementation\RenameTracking\RenameTrackingTagDefinition.cs" /> <Compile Include="Implementation\RenameTracking\RenameTrackingTagDefinition.cs" />
...@@ -649,6 +643,15 @@ ...@@ -649,6 +643,15 @@
<Compile Include="Implementation\Preview\PreviewConflictViewTaggerProvider.cs" /> <Compile Include="Implementation\Preview\PreviewConflictViewTaggerProvider.cs" />
<Compile Include="Implementation\Preview\PreviewFactoryService.cs" /> <Compile Include="Implementation\Preview\PreviewFactoryService.cs" />
<Compile Include="Implementation\Preview\PreviewWarningViewTaggerProvider.cs" /> <Compile Include="Implementation\Preview\PreviewWarningViewTaggerProvider.cs" />
<Compile Include="Implementation\ReferenceHighlighting\AbstractDocumentHighlightsService.cs" />
<Compile Include="Implementation\ReferenceHighlighting\DefinitionHighlightTag.cs" />
<Compile Include="Implementation\ReferenceHighlighting\DefinitionHighlightTagDefinition.cs" />
<Compile Include="Implementation\ReferenceHighlighting\IDocumentHighlightsService.cs" />
<Compile Include="Implementation\ReferenceHighlighting\IReferenceHighlightingAdditionalReferenceProvider.cs" />
<Compile Include="Implementation\ReferenceHighlighting\NagivateToHighlightReferenceCommandHandler.cs" />
<Compile Include="Implementation\ReferenceHighlighting\NagivateToHighlightReferenceCommandHandler.StartComparer.cs" />
<Compile Include="Implementation\ReferenceHighlighting\ReferenceHighlightingViewTaggerProvider.cs" />
<Compile Include="Implementation\ReferenceHighlighting\ReferenceHighlightTag.cs" />
<Compile Include="Implementation\RenameTracking\AbstractRenameTrackingCodeFixProvider.cs" /> <Compile Include="Implementation\RenameTracking\AbstractRenameTrackingCodeFixProvider.cs" />
<Compile Include="Implementation\RenameTracking\RenameTrackingDiagnosticAnalyzer.cs" /> <Compile Include="Implementation\RenameTracking\RenameTrackingDiagnosticAnalyzer.cs" />
<Compile Include="Implementation\RenameTracking\RenameTrackingTaggerProvider.cs" /> <Compile Include="Implementation\RenameTracking\RenameTrackingTaggerProvider.cs" />
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging; using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
namespace Microsoft.CodeAnalysis.Editor.Implementation.Preview namespace Microsoft.CodeAnalysis.Editor.Implementation.Preview
{ {
......
...@@ -14,47 +14,12 @@ ...@@ -14,47 +14,12 @@
using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities; using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.DocumentHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
internal abstract partial class AbstractDocumentHighlightsService : IDocumentHighlightsService internal abstract class AbstractDocumentHighlightsService : IDocumentHighlightsService
{ {
public async Task<ImmutableArray<DocumentHighlights>> GetDocumentHighlightsAsync( public async Task<ImmutableArray<DocumentHighlights>> GetDocumentHighlightsAsync(
Document document, int position, IImmutableSet<Document> documentsToSearch, CancellationToken cancellationToken) Document document, int position, IImmutableSet<Document> documentsToSearch, CancellationToken cancellationToken)
{
var (succeeded, highlights) = await GetDocumentHighlightsInRemoteProcessAsync(
document, position, documentsToSearch, cancellationToken).ConfigureAwait(false);
if (succeeded)
{
return highlights;
}
return await GetDocumentHighlightsInCurrentProcessAsync(
document, position, documentsToSearch, cancellationToken).ConfigureAwait(false);
}
private async Task<(bool succeeded, ImmutableArray<DocumentHighlights> highlights)> GetDocumentHighlightsInRemoteProcessAsync(
Document document, int position, IImmutableSet<Document> documentsToSearch, CancellationToken cancellationToken)
{
using (var session = await TryGetRemoteSessionAsync(
document.Project.Solution, cancellationToken).ConfigureAwait(false))
{
if (session == null)
{
return (succeeded: false, ImmutableArray<DocumentHighlights>.Empty);
}
var result = await session.InvokeAsync<SerializableDocumentHighlights[]>(
nameof(IRemoteDocumentHighlights.GetDocumentHighlightsAsync),
document.Id,
position,
documentsToSearch.Select(d => d.Id).ToArray()).ConfigureAwait(false);
return (true, SerializableDocumentHighlights.Rehydrate(result, document.Project.Solution));
}
}
private async Task<ImmutableArray<DocumentHighlights>> GetDocumentHighlightsInCurrentProcessAsync(
Document document, int position, IImmutableSet<Document> documentsToSearch, CancellationToken cancellationToken)
{ {
// use speculative semantic model to see whether we are on a symbol we can do HR // use speculative semantic model to see whether we are on a symbol we can do HR
var span = new TextSpan(position, 0); var span = new TextSpan(position, 0);
...@@ -76,11 +41,11 @@ internal abstract partial class AbstractDocumentHighlightsService : IDocumentHig ...@@ -76,11 +41,11 @@ internal abstract partial class AbstractDocumentHighlightsService : IDocumentHig
// Get unique tags for referenced symbols // Get unique tags for referenced symbols
return await GetTagsForReferencedSymbolAsync( return await GetTagsForReferencedSymbolAsync(
new SymbolAndProjectId(symbol, document.Project.Id), documentsToSearch, new SymbolAndProjectId(symbol, document.Project.Id), documentsToSearch,
solution, cancellationToken).ConfigureAwait(false); solution, cancellationToken).ConfigureAwait(false);
} }
private static async Task<ISymbol> GetSymbolToSearchAsync(Document document, int position, SemanticModel semanticModel, ISymbol symbol, CancellationToken cancellationToken) private async Task<ISymbol> GetSymbolToSearchAsync(Document document, int position, SemanticModel semanticModel, ISymbol symbol, CancellationToken cancellationToken)
{ {
// see whether we can use the symbol as it is // see whether we can use the symbol as it is
var currentSemanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var currentSemanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
...@@ -117,7 +82,7 @@ private static async Task<ISymbol> GetSymbolToSearchAsync(Document document, int ...@@ -117,7 +82,7 @@ private static async Task<ISymbol> GetSymbolToSearchAsync(Document document, int
return ImmutableArray<DocumentHighlights>.Empty; return ImmutableArray<DocumentHighlights>.Empty;
} }
private static bool ShouldConsiderSymbol(ISymbol symbol) private bool ShouldConsiderSymbol(ISymbol symbol)
{ {
switch (symbol.Kind) switch (symbol.Kind)
{ {
...@@ -167,13 +132,19 @@ private static bool ShouldConsiderSymbol(ISymbol symbol) ...@@ -167,13 +132,19 @@ private static bool ShouldConsiderSymbol(ISymbol symbol)
documentsToSearch, cancellationToken).ConfigureAwait(false); documentsToSearch, cancellationToken).ConfigureAwait(false);
} }
protected virtual Task<ImmutableArray<Location>> GetAdditionalReferencesAsync( private Task<IEnumerable<Location>> GetAdditionalReferencesAsync(
Document document, ISymbol symbol, CancellationToken cancellationToken) Document document, ISymbol symbol, CancellationToken cancellationToken)
{ {
return SpecializedTasks.EmptyImmutableArray<Location>(); var additionalReferenceProvider = document.Project.LanguageServices.GetService<IReferenceHighlightingAdditionalReferenceProvider>();
if (additionalReferenceProvider != null)
{
return additionalReferenceProvider.GetAdditionalReferencesAsync(document, symbol, cancellationToken);
}
return Task.FromResult(SpecializedCollections.EmptyEnumerable<Location>());
} }
private static async Task<ImmutableArray<DocumentHighlights>> CreateSpansAsync( private async Task<ImmutableArray<DocumentHighlights>> CreateSpansAsync(
Solution solution, Solution solution,
ISymbol symbol, ISymbol symbol,
IEnumerable<ReferencedSymbol> references, IEnumerable<ReferencedSymbol> references,
...@@ -281,7 +252,7 @@ private static bool ShouldIncludeDefinition(ISymbol symbol) ...@@ -281,7 +252,7 @@ private static bool ShouldIncludeDefinition(ISymbol symbol)
return true; return true;
} }
private static async Task AddLocationSpan(Location location, Solution solution, HashSet<DocumentSpan> spanSet, MultiDictionary<Document, HighlightSpan> tagList, HighlightSpanKind kind, CancellationToken cancellationToken) private async Task AddLocationSpan(Location location, Solution solution, HashSet<DocumentSpan> spanSet, MultiDictionary<Document, HighlightSpan> tagList, HighlightSpanKind kind, CancellationToken cancellationToken)
{ {
var span = await GetLocationSpanAsync(solution, location, cancellationToken).ConfigureAwait(false); var span = await GetLocationSpanAsync(solution, location, cancellationToken).ConfigureAwait(false);
if (span != null && !spanSet.Contains(span.Value)) if (span != null && !spanSet.Contains(span.Value))
...@@ -291,7 +262,7 @@ private static async Task AddLocationSpan(Location location, Solution solution, ...@@ -291,7 +262,7 @@ private static async Task AddLocationSpan(Location location, Solution solution,
} }
} }
private static async Task<DocumentSpan?> GetLocationSpanAsync( private async Task<DocumentSpan?> GetLocationSpanAsync(
Solution solution, Location location, CancellationToken cancellationToken) Solution solution, Location location, CancellationToken cancellationToken)
{ {
try try
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Tagging; using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
internal class DefinitionHighlightTag : NavigableHighlightTag internal class DefinitionHighlightTag : NavigableHighlightTag
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
using Microsoft.VisualStudio.Text.Classification; using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
[Export(typeof(EditorFormatDefinition))] [Export(typeof(EditorFormatDefinition))]
[Name(DefinitionHighlightTag.TagId)] [Name(DefinitionHighlightTag.TagId)]
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.DocumentHighlighting namespace Microsoft.CodeAnalysis.Editor
{ {
internal enum HighlightSpanKind internal enum HighlightSpanKind
{ {
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{
internal interface IReferenceHighlightingAdditionalReferenceProvider : ILanguageService
{
Task<IEnumerable<Location>> GetAdditionalReferencesAsync(Document document, ISymbol symbol, CancellationToken cancellationToken);
}
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
internal partial class NavigateToHighlightReferenceCommandHandler internal partial class NavigateToHighlightReferenceCommandHandler
{ {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
using Microsoft.VisualStudio.Text.Tagging; using Microsoft.VisualStudio.Text.Tagging;
using Roslyn.Utilities; using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
[ExportCommandHandler(PredefinedCommandHandlerNames.NavigateToHighlightedReference, [ExportCommandHandler(PredefinedCommandHandlerNames.NavigateToHighlightedReference,
ContentTypeNames.RoslynContentType)] ContentTypeNames.RoslynContentType)]
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Tagging; using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
internal class ReferenceHighlightTag : NavigableHighlightTag internal class ReferenceHighlightTag : NavigableHighlightTag
{ {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.Editor.Shared.Options; using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.Editor.Shared.Tagging; using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
using Microsoft.CodeAnalysis.Editor.Tagging; using Microsoft.CodeAnalysis.Editor.Tagging;
...@@ -22,7 +21,7 @@ ...@@ -22,7 +21,7 @@
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities; using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
[Export(typeof(IViewTaggerProvider))] [Export(typeof(IViewTaggerProvider))]
[ContentType(ContentTypeNames.RoslynContentType)] [ContentType(ContentTypeNames.RoslynContentType)]
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Tagging; using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
internal class WrittenReferenceHighlightTag : NavigableHighlightTag internal class WrittenReferenceHighlightTag : NavigableHighlightTag
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
using Microsoft.VisualStudio.Text.Classification; using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{ {
[Export(typeof(EditorFormatDefinition))] [Export(typeof(EditorFormatDefinition))]
[Name(WrittenReferenceHighlightTag.TagId)] [Name(WrittenReferenceHighlightTag.TagId)]
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading Imports System.Threading
Imports Microsoft.CodeAnalysis.DocumentHighlighting Imports Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
Imports Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
Imports Microsoft.CodeAnalysis.Editor.Shared.Extensions Imports Microsoft.CodeAnalysis.Editor.Shared.Extensions
Imports Microsoft.CodeAnalysis.Editor.Shared.Options Imports Microsoft.CodeAnalysis.Editor.Shared.Options
Imports Microsoft.CodeAnalysis.Editor.Shared.Tagging Imports Microsoft.CodeAnalysis.Editor.Shared.Tagging
...@@ -17,17 +16,9 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting ...@@ -17,17 +16,9 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting
Public MustInherit Class AbstractReferenceHighlightingTests Public MustInherit Class AbstractReferenceHighlightingTests
Protected Async Function VerifyHighlightsAsync(test As XElement, Optional optionIsEnabled As Boolean = True) As Tasks.Task Protected Async Function VerifyHighlightsAsync(test As XElement, Optional optionIsEnabled As Boolean = True) As Tasks.Task
Await VerifyHighlightsAsync(test, optionIsEnabled, outOfProcess:=False)
Await VerifyHighlightsAsync(test, optionIsEnabled, outOfProcess:=True)
End Function
Private Async Function VerifyHighlightsAsync(test As XElement, optionIsEnabled As Boolean, outOfProcess As Boolean) As Tasks.Task
Using workspace = TestWorkspace.Create(test) Using workspace = TestWorkspace.Create(test)
WpfTestCase.RequireWpfFact($"{NameOf(AbstractReferenceHighlightingTests)}.VerifyHighlightsAsync creates asynchronous taggers") WpfTestCase.RequireWpfFact($"{NameOf(AbstractReferenceHighlightingTests)}.VerifyHighlightsAsync creates asynchronous taggers")
workspace.Options = workspace.Options.WithChangedOption(
DocumentHighlightingOptions.OutOfProcessAllowed, outOfProcess)
Dim tagProducer = New ReferenceHighlightingViewTaggerProvider( Dim tagProducer = New ReferenceHighlightingViewTaggerProvider(
workspace.GetService(Of IForegroundNotificationService), workspace.GetService(Of IForegroundNotificationService),
workspace.GetService(Of ISemanticChangeNotificationService), workspace.GetService(Of ISemanticChangeNotificationService),
......
...@@ -129,6 +129,7 @@ ...@@ -129,6 +129,7 @@
<Compile Include="Highlighting\KeywordHighlighters\XmlEmbeddedExpressionHighlighter.vb" /> <Compile Include="Highlighting\KeywordHighlighters\XmlEmbeddedExpressionHighlighter.vb" />
<Compile Include="Highlighting\KeywordHighlighters\XmlProcessingInstructionHighlighter.vb" /> <Compile Include="Highlighting\KeywordHighlighters\XmlProcessingInstructionHighlighter.vb" />
<Compile Include="Highlighting\KeywordHighlightingHelpers.vb" /> <Compile Include="Highlighting\KeywordHighlightingHelpers.vb" />
<Compile Include="HighlightReferences\VisualBasicDocumentHighlightsService.vb" />
<Compile Include="ImplementAbstractClass\ImplementAbstractClassCommandHandler.vb" /> <Compile Include="ImplementAbstractClass\ImplementAbstractClassCommandHandler.vb" />
<Compile Include="ImplementInterface\ImplementInterfaceCommandHandler.vb" /> <Compile Include="ImplementInterface\ImplementInterfaceCommandHandler.vb" />
<Compile Include="InlineRename\VisualBasicEditorInlineRenameService.vb" /> <Compile Include="InlineRename\VisualBasicEditorInlineRenameService.vb" />
...@@ -154,6 +155,7 @@ ...@@ -154,6 +155,7 @@
<Compile Include="NavigationBar\GenerateMethodItem.vb" /> <Compile Include="NavigationBar\GenerateMethodItem.vb" />
<Compile Include="NavigationBar\VisualBasicNavigationBarItemService.vb" /> <Compile Include="NavigationBar\VisualBasicNavigationBarItemService.vb" />
<Compile Include="QuickInfo\SemanticQuickInfoProvider.vb" /> <Compile Include="QuickInfo\SemanticQuickInfoProvider.vb" />
<Compile Include="ReferenceHighlighting\ReferenceHighlightingAdditionalReferenceProvider.vb" />
<Compile Include="RenameTracking\BasicRenameTrackingLanguageHeuristicsService.vb" /> <Compile Include="RenameTracking\BasicRenameTrackingLanguageHeuristicsService.vb" />
<Compile Include="RenameTracking\RenameTrackingCodeFixProvider.vb" /> <Compile Include="RenameTracking\RenameTrackingCodeFixProvider.vb" />
<Compile Include="TextStructureNavigation\TextStructureNavigatorProvider.vb" /> <Compile Include="TextStructureNavigation\TextStructureNavigatorProvider.vb" />
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition Imports System.Composition
Imports Microsoft.CodeAnalysis.DocumentHighlighting Imports Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.Host.Mef
Namespace Microsoft.CodeAnalysis.VisualBasic.DocumentHighlighting Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.HighlightReferences
<ExportLanguageService(GetType(IDocumentHighlightsService), LanguageNames.VisualBasic), [Shared]> <ExportLanguageService(GetType(IDocumentHighlightsService), LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicDocumentHighlightsService Friend Class VisualBasicDocumentHighlightsService
Inherits AbstractDocumentHighlightsService Inherits AbstractDocumentHighlightsService
End Class End Class
End Namespace End Namespace
\ No newline at end of file
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
Imports Microsoft.CodeAnalysis.Host.Mef
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.ReferenceHighlighting
<ExportLanguageService(GetType(IReferenceHighlightingAdditionalReferenceProvider), LanguageNames.VisualBasic), [Shared]>
Friend Class ReferenceHighlightingAdditionalReferenceProvider
Implements IReferenceHighlightingAdditionalReferenceProvider
Public Function GetAdditionalReferencesAsync(document As Document, symbol As ISymbol, cancellationToken As CancellationToken) As Task(Of IEnumerable(Of Location)) Implements IReferenceHighlightingAdditionalReferenceProvider.GetAdditionalReferencesAsync
Return SpecializedTasks.EmptyEnumerable(Of Location)()
End Function
End Class
End Namespace
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
</Compile> </Compile>
<Compile Include="DesignerAttributes\CSharpDesignerAttributeService.cs" /> <Compile Include="DesignerAttributes\CSharpDesignerAttributeService.cs" />
<Compile Include="Completion\CompletionProviders\DeclarationNameCompletionProvider.cs" /> <Compile Include="Completion\CompletionProviders\DeclarationNameCompletionProvider.cs" />
<Compile Include="DocumentHighlighting\CSharpDocumentHighlightsService.cs" />
<Compile Include="ImplementAbstractClass\CSharpImplementAbstractClassCodeFixProvider.cs" /> <Compile Include="ImplementAbstractClass\CSharpImplementAbstractClassCodeFixProvider.cs" />
<Compile Include="ImplementInterface\CSharpImplementInterfaceCodeFixProvider.cs" /> <Compile Include="ImplementInterface\CSharpImplementInterfaceCodeFixProvider.cs" />
<Compile Include="InitializeParameter\CSharpAddParameterCheckCodeRefactoringProvider.cs" /> <Compile Include="InitializeParameter\CSharpAddParameterCheckCodeRefactoringProvider.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Remote;
namespace Microsoft.CodeAnalysis.DocumentHighlighting
{
internal abstract partial class AbstractDocumentHighlightsService : IDocumentHighlightsService
{
private static async Task<RemoteHostClient.Session> TryGetRemoteSessionAsync(
Solution solution, CancellationToken cancellationToken)
{
var outOfProcessAllowed = solution.Workspace.Options.GetOption(DocumentHighlightingOptions.OutOfProcessAllowed);
if (!outOfProcessAllowed)
{
return null;
}
var client = await solution.Workspace.TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (client == null)
{
return null;
}
return await client.TryCreateCodeAnalysisServiceSessionAsync(
solution, cancellationToken).ConfigureAwait(false);
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.DocumentHighlighting
{
internal static class DocumentHighlightingOptions
{
private const string LocalRegistryPath = @"Roslyn\Features\DocumentHighlighting\";
public static readonly Option<bool> OutOfProcessAllowed = new Option<bool>(
nameof(DocumentHighlightingOptions), nameof(OutOfProcessAllowed), defaultValue: false,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(OutOfProcessAllowed)));
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.DocumentHighlighting
{
internal interface IRemoteDocumentHighlights
{
Task<SerializableDocumentHighlights[]> GetDocumentHighlightsAsync(
DocumentId documentId, int position, DocumentId[] documentIdsToSearch);
}
internal struct SerializableDocumentHighlights
{
public DocumentId DocumentId;
public SerializableHighlightSpan[] HighlightSpans;
public static ImmutableArray<DocumentHighlights> Rehydrate(SerializableDocumentHighlights[] array, Solution solution)
{
var result = ArrayBuilder<DocumentHighlights>.GetInstance(array.Length);
foreach (var dehydrated in array)
{
result.Push(dehydrated.Rehydrate(solution));
}
return result.ToImmutableAndFree();
}
private DocumentHighlights Rehydrate(Solution solution)
=> new DocumentHighlights(solution.GetDocument(DocumentId), SerializableHighlightSpan.Rehydrate(HighlightSpans));
public static SerializableDocumentHighlights[] Dehydrate(ImmutableArray<DocumentHighlights> array)
{
var result = new SerializableDocumentHighlights[array.Length];
var index = 0;
foreach (var highlights in array)
{
result[index] = Dehydrate(highlights);
index++;
}
return result;
}
private static SerializableDocumentHighlights Dehydrate(DocumentHighlights highlights)
=> new SerializableDocumentHighlights
{
DocumentId = highlights.Document.Id,
HighlightSpans = SerializableHighlightSpan.Dehydrate(highlights.HighlightSpans)
};
}
internal struct SerializableHighlightSpan
{
public TextSpan TextSpan;
public HighlightSpanKind Kind;
internal static SerializableHighlightSpan[] Dehydrate(ImmutableArray<HighlightSpan> array)
{
var result = new SerializableHighlightSpan[array.Length];
var index = 0;
foreach (var span in array)
{
result[index] = Dehydrate(span);
index++;
}
return result;
}
private static SerializableHighlightSpan Dehydrate(HighlightSpan span)
=> new SerializableHighlightSpan
{
Kind = span.Kind,
TextSpan = span.TextSpan
};
internal static ImmutableArray<HighlightSpan> Rehydrate(SerializableHighlightSpan[] array)
{
var result = ArrayBuilder<HighlightSpan>.GetInstance(array.Length);
foreach (var dehydrated in array)
{
result.Push(dehydrated.Rehydrate());
}
return result.ToImmutableAndFree();
}
private HighlightSpan Rehydrate()
=> new HighlightSpan(TextSpan, Kind);
}
}
\ No newline at end of file
...@@ -132,7 +132,6 @@ ...@@ -132,7 +132,6 @@
<Compile Include="Diagnostics\DiagnosticArguments.cs" /> <Compile Include="Diagnostics\DiagnosticArguments.cs" />
<Compile Include="Diagnostics\DiagnosticResultSerializer.cs" /> <Compile Include="Diagnostics\DiagnosticResultSerializer.cs" />
<Compile Include="Diagnostics\SymbolAnalysisContextExtensions.cs" /> <Compile Include="Diagnostics\SymbolAnalysisContextExtensions.cs" />
<Compile Include="DocumentHighlighting\DocumentHighlightingOptions.cs" />
<Compile Include="EncapsulateField\EncapsulateFieldRefactoringProvider.cs" /> <Compile Include="EncapsulateField\EncapsulateFieldRefactoringProvider.cs" />
<Compile Include="ExtractInterface\ExtractInterfaceCodeRefactoringProvider.cs" /> <Compile Include="ExtractInterface\ExtractInterfaceCodeRefactoringProvider.cs" />
<Compile Include="CodeFixes\FixAllOccurrences\FixSomeCodeAction.cs" /> <Compile Include="CodeFixes\FixAllOccurrences\FixSomeCodeAction.cs" />
...@@ -158,10 +157,6 @@ ...@@ -158,10 +157,6 @@
<Compile Include="GenerateFromMembers\SelectedMemberInfo.cs" /> <Compile Include="GenerateFromMembers\SelectedMemberInfo.cs" />
<Compile Include="ImplementType\ImplementTypeOptions.cs" /> <Compile Include="ImplementType\ImplementTypeOptions.cs" />
<Compile Include="ImplementType\ImplementTypeOptionsProvider.cs" /> <Compile Include="ImplementType\ImplementTypeOptionsProvider.cs" />
<Compile Include="DocumentHighlighting\AbstractDocumentHighlightsService.cs" />
<Compile Include="DocumentHighlighting\AbstractDocumentHighlightsService_Remote.cs" />
<Compile Include="DocumentHighlighting\IDocumentHighlightsService.cs" />
<Compile Include="DocumentHighlighting\IRemoteDocumentHighlights.cs" />
<Compile Include="RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsCodeFixProvider.cs" /> <Compile Include="RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsCodeFixProvider.cs" />
<Compile Include="RemoveUnnecessaryImports\IUnnecessaryImportsService.cs" /> <Compile Include="RemoveUnnecessaryImports\IUnnecessaryImportsService.cs" />
<Compile Include="NavigateTo\AbstractNavigateToSearchService.SearchResult.cs" /> <Compile Include="NavigateTo\AbstractNavigateToSearchService.SearchResult.cs" />
......
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
<Link>InternalUtilities\LambdaUtilities.vb</Link> <Link>InternalUtilities\LambdaUtilities.vb</Link>
</Compile> </Compile>
<Compile Include="AddPackage\VisualBasicAddSpecificPackageCodeFixProvider.vb" /> <Compile Include="AddPackage\VisualBasicAddSpecificPackageCodeFixProvider.vb" />
<Compile Include="DocumentHighlighting\VisualBasicDocumentHighlightsService.vb" />
<Compile Include="InitializeParameter\InitializeParameterHelpers.vb" /> <Compile Include="InitializeParameter\InitializeParameterHelpers.vb" />
<Compile Include="InitializeParameter\VisualBasicAddParameterCheckCodeRefactoringProvider.vb" /> <Compile Include="InitializeParameter\VisualBasicAddParameterCheckCodeRefactoringProvider.vb" />
<Compile Include="ChangeSignature\ChangeSignatureFormattingRule.vb" /> <Compile Include="ChangeSignature\ChangeSignatureFormattingRule.vb" />
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.FindUsages; using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.FindUsages; using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Completion; using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.FindUsages; using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.VisualStudio.Shell.FindAllReferences; using Microsoft.VisualStudio.Shell.FindAllReferences;
using Roslyn.Utilities; using Roslyn.Utilities;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.FindUsages; using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.VisualStudio.Shell.FindAllReferences; using Microsoft.VisualStudio.Shell.FindAllReferences;
using Roslyn.Utilities; using Roslyn.Utilities;
......
...@@ -7,11 +7,10 @@ ...@@ -7,11 +7,10 @@
using System.Windows.Media; using System.Windows.Media;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.FindUsages; using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo; using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo;
using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Preview; using Microsoft.CodeAnalysis.Editor.Shared.Preview;
using Microsoft.CodeAnalysis.FindUsages; using Microsoft.CodeAnalysis.FindUsages;
...@@ -19,6 +18,7 @@ ...@@ -19,6 +18,7 @@
using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions; using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions;
using Microsoft.VisualStudio.PlatformUI; using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Editor;
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.IntegrationTest.Utilities; using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities; using Roslyn.Test.Utilities;
using Xunit; using Xunit;
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.IntegrationTest.Utilities; using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities; using Roslyn.Test.Utilities;
using Xunit; using Xunit;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
namespace Microsoft.VisualStudio.IntegrationTest.Utilities namespace Microsoft.VisualStudio.IntegrationTest.Utilities
{ {
......
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
</Compile> </Compile>
<Compile Include="Services\CodeAnalysisService_CodeLens.cs" /> <Compile Include="Services\CodeAnalysisService_CodeLens.cs" />
<Compile Include="Services\CodeAnalysisService_DesignerAttributes.cs" /> <Compile Include="Services\CodeAnalysisService_DesignerAttributes.cs" />
<Compile Include="Services\CodeAnalysisService_DocumentHighlights.cs" />
<Compile Include="Services\CodeAnalysisService_TodoComments.cs" /> <Compile Include="Services\CodeAnalysisService_TodoComments.cs" />
<Compile Include="Services\CodeAnalysisService_SymbolFinder.cs" /> <Compile Include="Services\CodeAnalysisService_SymbolFinder.cs" />
<Compile Include="Services\RemoteSymbolSearchUpdateEngine.cs" /> <Compile Include="Services\RemoteSymbolSearchUpdateEngine.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.Remote
{
// root level service for all Roslyn services
internal partial class CodeAnalysisService : IRemoteDocumentHighlights
{
public async Task<SerializableDocumentHighlights[]> GetDocumentHighlightsAsync(
DocumentId documentId, int position, DocumentId[] documentIdsToSearch)
{
var solution = await GetSolutionAsync().ConfigureAwait(false);
var document = solution.GetDocument(documentId);
var documentsToSearch = ImmutableHashSet.CreateRange(documentIdsToSearch.Select(solution.GetDocument));
var service = document.GetLanguageService<IDocumentHighlightsService>();
var result = await service.GetDocumentHighlightsAsync(
document, position, documentsToSearch, CancellationToken).ConfigureAwait(false);
return SerializableDocumentHighlights.Dehydrate(result);
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册