diff --git a/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj b/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj
index 508f732f4d6cb..4369095c0de14 100644
--- a/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj
+++ b/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj
@@ -136,14 +136,12 @@
-
-
diff --git a/src/EditorFeatures/CSharp/HighlightReferences/CSharpDocumentHighlightsService.cs b/src/EditorFeatures/CSharp/HighlightReferences/CSharpDocumentHighlightsService.cs
deleted file mode 100644
index c1f3baf669ed0..0000000000000
--- a/src/EditorFeatures/CSharp/HighlightReferences/CSharpDocumentHighlightsService.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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
- {
- }
-}
diff --git a/src/EditorFeatures/Core/EditorFeatures.csproj b/src/EditorFeatures/Core/EditorFeatures.csproj
index ebf13ede91907..f794046716f55 100644
--- a/src/EditorFeatures/Core/EditorFeatures.csproj
+++ b/src/EditorFeatures/Core/EditorFeatures.csproj
@@ -165,10 +165,19 @@
+
+
+
+
+
+
+
+
+
@@ -632,8 +641,6 @@
-
-
@@ -645,15 +652,6 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/EditorFeatures/Core/Implementation/Preview/PreviewReferenceHighlightingTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Preview/PreviewReferenceHighlightingTaggerProvider.cs
index 29a2060e254e3..5c90ff6b8f179 100644
--- a/src/EditorFeatures/Core/Implementation/Preview/PreviewReferenceHighlightingTaggerProvider.cs
+++ b/src/EditorFeatures/Core/Implementation/Preview/PreviewReferenceHighlightingTaggerProvider.cs
@@ -6,7 +6,7 @@
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
-using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
+using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting;
namespace Microsoft.CodeAnalysis.Editor.Implementation.Preview
{
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IReferenceHighlightingAdditionalReferenceProvider.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IReferenceHighlightingAdditionalReferenceProvider.cs
deleted file mode 100644
index 694a5b6e505a2..0000000000000
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IReferenceHighlightingAdditionalReferenceProvider.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// 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> GetAdditionalReferencesAsync(Document document, ISymbol symbol, CancellationToken cancellationToken);
- }
-}
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs b/src/EditorFeatures/Core/ReferenceHighlighting/IDocumentHighlightsService.cs
similarity index 76%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/IDocumentHighlightsService.cs
index f86be931963c1..c36aaed9954cd 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/IDocumentHighlightsService.cs
@@ -1,6 +1,6 @@
-// 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;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
@@ -41,9 +41,13 @@ public DocumentHighlights(Document document, ImmutableArray highl
}
}
+ ///
+ /// Note: kept around for back compat until F# and TypeScript move over to
+ /// .
+ ///
internal interface IDocumentHighlightsService : ILanguageService
{
Task> GetDocumentHighlightsAsync(
Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken);
}
-}
+}
\ No newline at end of file
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs b/src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs
similarity index 87%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs
index 76b72d5268f3b..125416fd75162 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs
@@ -3,7 +3,7 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
internal partial class NavigateToHighlightReferenceCommandHandler
{
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs b/src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs
similarity index 98%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs
index a0997e4009c8a..07a6b67793a85 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs
@@ -14,7 +14,7 @@
using Microsoft.VisualStudio.Text.Tagging;
using Roslyn.Utilities;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
[ExportCommandHandler(PredefinedCommandHandlerNames.NavigateToHighlightedReference,
ContentTypeNames.RoslynContentType)]
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs b/src/EditorFeatures/Core/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs
similarity index 68%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs
index cbad756b7bd6a..94ab3331cb668 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs
@@ -5,13 +5,17 @@
using System.Collections.Immutable;
using System.ComponentModel.Composition;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
using Microsoft.CodeAnalysis.Editor.Tagging;
+using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Notification;
using Microsoft.CodeAnalysis.Options;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
@@ -21,7 +25,7 @@
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
[Export(typeof(IViewTaggerProvider))]
[ContentType(ContentTypeNames.RoslynContentType)]
@@ -110,13 +114,12 @@ protected override Task ProduceTagsAsync(TaggerContext co
}
// Otherwise, we need to go produce all tags.
- return ProduceTagsAsync(context, caretPosition, workspace, document);
+ return ProduceTagsAsync(context, caretPosition, document);
}
internal async Task ProduceTagsAsync(
TaggerContext context,
SnapshotPoint position,
- Workspace workspace,
Document document)
{
var cancellationToken = context.CancellationToken;
@@ -127,25 +130,73 @@ internal async Task ProduceTagsAsync(
{
if (document != null)
{
- var documentHighlightsService = document.Project.LanguageServices.GetService();
- if (documentHighlightsService != null)
+ // As we transition to the new API (defined at the Features layer) we support
+ // calling into both it and the old API (defined at the EditorFeatures layer).
+ //
+ // Once TypeScript and F# can move over, then we can remove the calls to the old
+ // API.
+ await TryNewServiceAsync(context, position, document).ConfigureAwait(false);
+ await TryOldServiceAsync(context, position, document).ConfigureAwait(false);
+ }
+ }
+ }
+
+ private Task TryOldServiceAsync(TaggerContext context, SnapshotPoint position, Document document)
+ {
+ return TryServiceAsync(
+ context, position, document,
+ (s, d, p, ds, c) => s.GetDocumentHighlightsAsync(d, p, ds, c));
+ }
+
+ private Task TryNewServiceAsync(
+ TaggerContext context, SnapshotPoint position, Document document)
+ {
+ return TryServiceAsync(
+ context, position, document,
+ async (service, doc, point, documents, cancellation) =>
+ {
+ // Call into the new service.
+ var newHighlights = await service.GetDocumentHighlightsAsync(doc, point, documents, cancellation).ConfigureAwait(false);
+
+ // then convert the result to the form the old service would return.
+ return ConvertHighlights(newHighlights);
+ });
+ }
+
+ private async Task TryServiceAsync(
+ TaggerContext context, SnapshotPoint position, Document document,
+ Func, CancellationToken, Task>> getDocumentHighlightsAsync)
+ where T : class, ILanguageService
+ {
+ var cancellationToken = context.CancellationToken;
+ var documentHighlightsService = document.GetLanguageService();
+ if (documentHighlightsService != null)
+ {
+ // We only want to search inside documents that correspond to the snapshots
+ // we're looking at
+ var documentsToSearch = ImmutableHashSet.CreateRange(context.SpansToTag.Select(vt => vt.Document).WhereNotNull());
+ var documentHighlightsList = await getDocumentHighlightsAsync(
+ documentHighlightsService, document, position, documentsToSearch, cancellationToken).ConfigureAwait(false);
+ if (documentHighlightsList != null)
+ {
+ foreach (var documentHighlights in documentHighlightsList)
{
- // We only want to search inside documents that correspond to the snapshots
- // we're looking at
- var documentsToSearch = ImmutableHashSet.CreateRange(context.SpansToTag.Select(vt => vt.Document).WhereNotNull());
- var documentHighlightsList = await documentHighlightsService.GetDocumentHighlightsAsync(document, position, documentsToSearch, cancellationToken).ConfigureAwait(false);
- if (documentHighlightsList != null)
- {
- foreach (var documentHighlights in documentHighlightsList)
- {
- await AddTagSpansAsync(context, solution, documentHighlights).ConfigureAwait(false);
- }
- }
+ await AddTagSpansAsync(
+ context, document.Project.Solution, documentHighlights).ConfigureAwait(false);
}
}
}
}
+ private ImmutableArray ConvertHighlights(ImmutableArray newHighlights)
+ => newHighlights.SelectAsArray(
+ documentHighlights => new DocumentHighlights(
+ documentHighlights.Document,
+ documentHighlights.HighlightSpans.SelectAsArray(
+ highlightSpan => new HighlightSpan(
+ highlightSpan.TextSpan,
+ (HighlightSpanKind)highlightSpan.Kind))));
+
private async Task AddTagSpansAsync(
TaggerContext context,
Solution solution,
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTag.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs
similarity index 88%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTag.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs
index 2f5873a759429..0b974c620bfa2 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTag.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs
@@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
internal class DefinitionHighlightTag : NavigableHighlightTag
{
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTagDefinition.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTagDefinition.cs
similarity index 92%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTagDefinition.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTagDefinition.cs
index b5a8023f8297e..5580291757cf8 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTagDefinition.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTagDefinition.cs
@@ -5,7 +5,7 @@
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
[Export(typeof(EditorFormatDefinition))]
[Name(DefinitionHighlightTag.TagId)]
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightTag.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs
similarity index 87%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightTag.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs
index 6c7d2cddc337b..299c701a98780 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightTag.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs
@@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
internal class ReferenceHighlightTag : NavigableHighlightTag
{
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs
similarity index 88%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs
index b4d35d64ae6b1..d6f8df3342be5 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs
@@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
internal class WrittenReferenceHighlightTag : NavigableHighlightTag
{
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTagDefinition.cs
similarity index 91%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs
rename to src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTagDefinition.cs
index 8db19cc5cb2b4..74323824a5056 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs
+++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTagDefinition.cs
@@ -5,7 +5,7 @@
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
{
[Export(typeof(EditorFormatDefinition))]
[Name(WrittenReferenceHighlightTag.TagId)]
diff --git a/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb b/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb
index ab5ab6a8ab80b..7c9591274611f 100644
--- a/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb
+++ b/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb
@@ -1,7 +1,8 @@
' 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 Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+Imports Microsoft.CodeAnalysis.DocumentHighlighting
+Imports Microsoft.CodeAnalysis.Editor.ReferenceHighlighting
Imports Microsoft.CodeAnalysis.Editor.Shared.Extensions
Imports Microsoft.CodeAnalysis.Editor.Shared.Options
Imports Microsoft.CodeAnalysis.Editor.Shared.Tagging
@@ -16,9 +17,17 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting
Public MustInherit Class AbstractReferenceHighlightingTests
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)
WpfTestCase.RequireWpfFact($"{NameOf(AbstractReferenceHighlightingTests)}.VerifyHighlightsAsync creates asynchronous taggers")
+ workspace.Options = workspace.Options.WithChangedOption(
+ DocumentHighlightingOptions.OutOfProcessAllowed, outOfProcess)
+
Dim tagProducer = New ReferenceHighlightingViewTaggerProvider(
workspace.GetService(Of IForegroundNotificationService),
workspace.GetService(Of ISemanticChangeNotificationService),
diff --git a/src/EditorFeatures/VisualBasic/BasicEditorFeatures.vbproj b/src/EditorFeatures/VisualBasic/BasicEditorFeatures.vbproj
index 531d79a604a6f..79ee5ff8d6c4c 100644
--- a/src/EditorFeatures/VisualBasic/BasicEditorFeatures.vbproj
+++ b/src/EditorFeatures/VisualBasic/BasicEditorFeatures.vbproj
@@ -129,7 +129,6 @@
-
@@ -155,7 +154,6 @@
-
diff --git a/src/EditorFeatures/VisualBasic/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.vb b/src/EditorFeatures/VisualBasic/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.vb
deleted file mode 100644
index 2c95b09d3a2fb..0000000000000
--- a/src/EditorFeatures/VisualBasic/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.vb
+++ /dev/null
@@ -1,18 +0,0 @@
-' 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
-
- 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
diff --git a/src/Features/CSharp/Portable/CSharpFeatures.csproj b/src/Features/CSharp/Portable/CSharpFeatures.csproj
index 7b94fcf958c1a..b29c06030bb9f 100644
--- a/src/Features/CSharp/Portable/CSharpFeatures.csproj
+++ b/src/Features/CSharp/Portable/CSharpFeatures.csproj
@@ -81,6 +81,7 @@
+
diff --git a/src/EditorFeatures/CSharp/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.cs b/src/Features/CSharp/Portable/DocumentHighlighting/CSharpDocumentHighlightsService.cs
similarity index 70%
rename from src/EditorFeatures/CSharp/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.cs
rename to src/Features/CSharp/Portable/DocumentHighlighting/CSharpDocumentHighlightsService.cs
index 2321c81cc552e..4788978fd5719 100644
--- a/src/EditorFeatures/CSharp/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.cs
+++ b/src/Features/CSharp/Portable/DocumentHighlighting/CSharpDocumentHighlightsService.cs
@@ -1,32 +1,31 @@
// 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.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
+using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.Host.Mef;
-using Roslyn.Utilities;
-namespace Microsoft.CodeAnalysis.Editor.CSharp.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.CSharp.DocumentHighlighting
{
- [ExportLanguageService(typeof(IReferenceHighlightingAdditionalReferenceProvider), LanguageNames.CSharp), Shared]
- internal class ReferenceHighlightingAdditionalReferenceProvider : IReferenceHighlightingAdditionalReferenceProvider
+ [ExportLanguageService(typeof(IDocumentHighlightsService), LanguageNames.CSharp), Shared]
+ internal class CSharpDocumentHighlightsService : AbstractDocumentHighlightsService
{
- public async Task> GetAdditionalReferencesAsync(
+ protected override async Task> GetAdditionalReferencesAsync(
Document document, ISymbol symbol, CancellationToken cancellationToken)
{
// 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
- // feature. However, we would lke the results to be highlighted to get a good experience
+ // feature. However, we would like the results to be highlighted to get a good experience
// while editing (especially since highlighting may have been invoked off of 'var' in
// the first place).
//
// So we look for the references through 'var' directly in this file and add them to the
// results found by the engine.
- List results = null;
+ var results = ArrayBuilder.GetInstance();
if (symbol is INamedTypeSymbol && symbol.Name != "var")
{
@@ -52,18 +51,13 @@ public async Task> GetAdditionalReferencesAsync(
if (originalSymbol.Equals(boundSymbol))
{
- if (results == null)
- {
- results = new List();
- }
-
results.Add(type.GetLocation());
}
}
}
}
- return results ?? SpecializedCollections.EmptyEnumerable();
+ return results.ToImmutableAndFree();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs b/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs
similarity index 82%
rename from src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs
rename to src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs
index 8a90b0062620f..91b1933bd7692 100644
--- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs
+++ b/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs
@@ -14,12 +14,47 @@
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
-namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+namespace Microsoft.CodeAnalysis.DocumentHighlighting
{
- internal abstract class AbstractDocumentHighlightsService : IDocumentHighlightsService
+ internal abstract partial class AbstractDocumentHighlightsService : IDocumentHighlightsService
{
public async Task> GetDocumentHighlightsAsync(
Document document, int position, IImmutableSet 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 highlights)> GetDocumentHighlightsInRemoteProcessAsync(
+ Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken)
+ {
+ using (var session = await TryGetRemoteSessionAsync(
+ document.Project.Solution, cancellationToken).ConfigureAwait(false))
+ {
+ if (session == null)
+ {
+ return (succeeded: false, ImmutableArray.Empty);
+ }
+
+ var result = await session.InvokeAsync(
+ 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> GetDocumentHighlightsInCurrentProcessAsync(
+ Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken)
{
// use speculative semantic model to see whether we are on a symbol we can do HR
var span = new TextSpan(position, 0);
@@ -41,11 +76,11 @@ public async Task> GetDocumentHighlightsAsync
// Get unique tags for referenced symbols
return await GetTagsForReferencedSymbolAsync(
- new SymbolAndProjectId(symbol, document.Project.Id), documentsToSearch,
+ new SymbolAndProjectId(symbol, document.Project.Id), documentsToSearch,
solution, cancellationToken).ConfigureAwait(false);
}
- private async Task GetSymbolToSearchAsync(Document document, int position, SemanticModel semanticModel, ISymbol symbol, CancellationToken cancellationToken)
+ private static async Task GetSymbolToSearchAsync(Document document, int position, SemanticModel semanticModel, ISymbol symbol, CancellationToken cancellationToken)
{
// see whether we can use the symbol as it is
var currentSemanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
@@ -82,7 +117,7 @@ await SymbolFinder.FindReferencesAsync(
return ImmutableArray.Empty;
}
- private bool ShouldConsiderSymbol(ISymbol symbol)
+ private static bool ShouldConsiderSymbol(ISymbol symbol)
{
switch (symbol.Kind)
{
@@ -132,19 +167,13 @@ private async Task> FilterAndCreateSpansAsync
documentsToSearch, cancellationToken).ConfigureAwait(false);
}
- private Task> GetAdditionalReferencesAsync(
+ protected virtual Task> GetAdditionalReferencesAsync(
Document document, ISymbol symbol, CancellationToken cancellationToken)
{
- var additionalReferenceProvider = document.Project.LanguageServices.GetService();
- if (additionalReferenceProvider != null)
- {
- return additionalReferenceProvider.GetAdditionalReferencesAsync(document, symbol, cancellationToken);
- }
-
- return Task.FromResult(SpecializedCollections.EmptyEnumerable());
+ return SpecializedTasks.EmptyImmutableArray();
}
- private async Task> CreateSpansAsync(
+ private static async Task> CreateSpansAsync(
Solution solution,
ISymbol symbol,
IEnumerable references,
@@ -252,7 +281,7 @@ private static bool ShouldIncludeDefinition(ISymbol symbol)
return true;
}
- private async Task AddLocationSpan(Location location, Solution solution, HashSet spanSet, MultiDictionary tagList, HighlightSpanKind kind, CancellationToken cancellationToken)
+ private static async Task AddLocationSpan(Location location, Solution solution, HashSet spanSet, MultiDictionary tagList, HighlightSpanKind kind, CancellationToken cancellationToken)
{
var span = await GetLocationSpanAsync(solution, location, cancellationToken).ConfigureAwait(false);
if (span != null && !spanSet.Contains(span.Value))
@@ -262,7 +291,7 @@ private async Task AddLocationSpan(Location location, Solution solution, HashSet
}
}
- private async Task GetLocationSpanAsync(
+ private static async Task GetLocationSpanAsync(
Solution solution, Location location, CancellationToken cancellationToken)
{
try
diff --git a/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService_Remote.cs b/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService_Remote.cs
new file mode 100644
index 0000000000000..7efad4a9663df
--- /dev/null
+++ b/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService_Remote.cs
@@ -0,0 +1,30 @@
+// 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 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
diff --git a/src/Features/Core/Portable/DocumentHighlighting/DocumentHighlightingOptions.cs b/src/Features/Core/Portable/DocumentHighlighting/DocumentHighlightingOptions.cs
new file mode 100644
index 0000000000000..0363999301f11
--- /dev/null
+++ b/src/Features/Core/Portable/DocumentHighlighting/DocumentHighlightingOptions.cs
@@ -0,0 +1,15 @@
+// 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 OutOfProcessAllowed = new Option(
+ nameof(DocumentHighlightingOptions), nameof(OutOfProcessAllowed), defaultValue: false,
+ storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(OutOfProcessAllowed)));
+ }
+}
\ No newline at end of file
diff --git a/src/Features/Core/Portable/DocumentHighlighting/IDocumentHighlightsService.cs b/src/Features/Core/Portable/DocumentHighlighting/IDocumentHighlightsService.cs
new file mode 100644
index 0000000000000..52ec389940a5a
--- /dev/null
+++ b/src/Features/Core/Portable/DocumentHighlighting/IDocumentHighlightsService.cs
@@ -0,0 +1,52 @@
+// 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;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.Host;
+using Microsoft.CodeAnalysis.Text;
+
+namespace Microsoft.CodeAnalysis.DocumentHighlighting
+{
+ internal enum HighlightSpanKind
+ {
+ None,
+ Definition,
+ Reference,
+ WrittenReference,
+ }
+
+ internal struct HighlightSpan
+ {
+ public TextSpan TextSpan { get; }
+ public HighlightSpanKind Kind { get; }
+
+ public HighlightSpan(TextSpan textSpan, HighlightSpanKind kind) : this()
+ {
+ this.TextSpan = textSpan;
+ this.Kind = kind;
+ }
+ }
+
+ internal struct DocumentHighlights
+ {
+ public Document Document { get; }
+ public ImmutableArray HighlightSpans { get; }
+
+ public DocumentHighlights(Document document, ImmutableArray highlightSpans)
+ {
+ this.Document = document;
+ this.HighlightSpans = highlightSpans;
+ }
+ }
+
+ ///
+ /// Note: This is the new version of the language service and superceded the same named type
+ /// in the EditorFeatures layer.
+ ///
+ internal interface IDocumentHighlightsService : ILanguageService
+ {
+ Task> GetDocumentHighlightsAsync(
+ Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken);
+ }
+}
\ No newline at end of file
diff --git a/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs b/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs
new file mode 100644
index 0000000000000..b58c6f35a18fd
--- /dev/null
+++ b/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs
@@ -0,0 +1,94 @@
+// 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 GetDocumentHighlightsAsync(
+ DocumentId documentId, int position, DocumentId[] documentIdsToSearch);
+ }
+
+ internal struct SerializableDocumentHighlights
+ {
+ public DocumentId DocumentId;
+ public SerializableHighlightSpan[] HighlightSpans;
+
+ public static ImmutableArray Rehydrate(SerializableDocumentHighlights[] array, Solution solution)
+ {
+ var result = ArrayBuilder.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 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 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 Rehydrate(SerializableHighlightSpan[] array)
+ {
+ var result = ArrayBuilder.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
diff --git a/src/Features/Core/Portable/Features.csproj b/src/Features/Core/Portable/Features.csproj
index f0392415bc4d6..fcee5c48cd89f 100644
--- a/src/Features/Core/Portable/Features.csproj
+++ b/src/Features/Core/Portable/Features.csproj
@@ -132,6 +132,7 @@
+
@@ -157,6 +158,10 @@
+
+
+
+
diff --git a/src/Features/VisualBasic/Portable/BasicFeatures.vbproj b/src/Features/VisualBasic/Portable/BasicFeatures.vbproj
index f8df520cf1959..ac0829cdeb9c3 100644
--- a/src/Features/VisualBasic/Portable/BasicFeatures.vbproj
+++ b/src/Features/VisualBasic/Portable/BasicFeatures.vbproj
@@ -66,6 +66,7 @@
InternalUtilities\LambdaUtilities.vb
+
diff --git a/src/EditorFeatures/VisualBasic/HighlightReferences/VisualBasicDocumentHighlightsService.vb b/src/Features/VisualBasic/Portable/DocumentHighlighting/VisualBasicDocumentHighlightsService.vb
similarity index 73%
rename from src/EditorFeatures/VisualBasic/HighlightReferences/VisualBasicDocumentHighlightsService.vb
rename to src/Features/VisualBasic/Portable/DocumentHighlighting/VisualBasicDocumentHighlightsService.vb
index b0693439b5de7..2f925d3749ed3 100644
--- a/src/EditorFeatures/VisualBasic/HighlightReferences/VisualBasicDocumentHighlightsService.vb
+++ b/src/Features/VisualBasic/Portable/DocumentHighlighting/VisualBasicDocumentHighlightsService.vb
@@ -1,13 +1,13 @@
' 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 Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
+Imports Microsoft.CodeAnalysis.DocumentHighlighting
Imports Microsoft.CodeAnalysis.Host.Mef
-Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.HighlightReferences
+Namespace Microsoft.CodeAnalysis.VisualBasic.DocumentHighlighting
Friend Class VisualBasicDocumentHighlightsService
Inherits AbstractDocumentHighlightsService
End Class
-End Namespace
+End Namespace
\ No newline at end of file
diff --git a/src/VisualStudio/Core/Next/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs b/src/VisualStudio/Core/Next/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs
index e593f2f5ab596..c8cf14161ae4b 100644
--- a/src/VisualStudio/Core/Next/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs
+++ b/src/VisualStudio/Core/Next/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs
@@ -7,7 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editor;
+using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Text;
diff --git a/src/VisualStudio/Core/Next/FindReferences/Contexts/WithReferencesFindUsagesContext.cs b/src/VisualStudio/Core/Next/FindReferences/Contexts/WithReferencesFindUsagesContext.cs
index 9973893c2464d..765612f4c86b2 100644
--- a/src/VisualStudio/Core/Next/FindReferences/Contexts/WithReferencesFindUsagesContext.cs
+++ b/src/VisualStudio/Core/Next/FindReferences/Contexts/WithReferencesFindUsagesContext.cs
@@ -8,7 +8,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Completion;
-using Microsoft.CodeAnalysis.Editor;
+using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.VisualStudio.Shell.FindAllReferences;
using Roslyn.Utilities;
diff --git a/src/VisualStudio/Core/Next/FindReferences/Contexts/WithoutReferencesFindUsagesContext.cs b/src/VisualStudio/Core/Next/FindReferences/Contexts/WithoutReferencesFindUsagesContext.cs
index 5a5f6a2b02bf8..2456a495cfef6 100644
--- a/src/VisualStudio/Core/Next/FindReferences/Contexts/WithoutReferencesFindUsagesContext.cs
+++ b/src/VisualStudio/Core/Next/FindReferences/Contexts/WithoutReferencesFindUsagesContext.cs
@@ -3,7 +3,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editor;
+using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.VisualStudio.Shell.FindAllReferences;
using Roslyn.Utilities;
diff --git a/src/VisualStudio/Core/Next/FindReferences/Entries/DocumentSpanEntry.cs b/src/VisualStudio/Core/Next/FindReferences/Entries/DocumentSpanEntry.cs
index 68c45919b30eb..9e47ed3ffeb80 100644
--- a/src/VisualStudio/Core/Next/FindReferences/Entries/DocumentSpanEntry.cs
+++ b/src/VisualStudio/Core/Next/FindReferences/Entries/DocumentSpanEntry.cs
@@ -7,10 +7,11 @@
using System.Windows.Media;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Classification;
+using Microsoft.CodeAnalysis.DocumentHighlighting;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo;
-using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
+using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Preview;
using Microsoft.CodeAnalysis.FindUsages;
@@ -18,9 +19,9 @@
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions;
using Microsoft.VisualStudio.PlatformUI;
-using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
+using DocumentHighlighting = Microsoft.CodeAnalysis.DocumentHighlighting;
namespace Microsoft.VisualStudio.LanguageServices.FindUsages
{
@@ -33,14 +34,14 @@ internal partial class StreamingFindUsagesPresenter
///
private class DocumentSpanEntry : AbstractDocumentSpanEntry
{
- private readonly HighlightSpanKind _spanKind;
+ private readonly DocumentHighlighting.HighlightSpanKind _spanKind;
private readonly ClassifiedSpansAndHighlightSpan _classifiedSpansAndHighlights;
public DocumentSpanEntry(
AbstractTableDataSourceFindUsagesContext context,
RoslynDefinitionBucket definitionBucket,
DocumentSpan documentSpan,
- HighlightSpanKind spanKind,
+ DocumentHighlighting.HighlightSpanKind spanKind,
string documentName,
Guid projectGuid,
SourceText sourceText,
@@ -53,9 +54,9 @@ public DocumentSpanEntry(
protected override IList CreateLineTextInlines()
{
- var propertyId = _spanKind == HighlightSpanKind.Definition
+ var propertyId = _spanKind == DocumentHighlighting.HighlightSpanKind.Definition
? DefinitionHighlightTag.TagId
- : _spanKind == HighlightSpanKind.WrittenReference
+ : _spanKind == DocumentHighlighting.HighlightSpanKind.WrittenReference
? WrittenReferenceHighlightTag.TagId
: ReferenceHighlightTag.TagId;
@@ -163,9 +164,9 @@ private ITextBuffer CreateNewBuffer()
_sourceText.ToString(), contentType);
// Create an appropriate highlight span on that buffer for the reference.
- var key = _spanKind == HighlightSpanKind.Definition
+ var key = _spanKind == DocumentHighlighting.HighlightSpanKind.Definition
? PredefinedPreviewTaggerKeys.DefinitionHighlightingSpansKey
- : _spanKind == HighlightSpanKind.WrittenReference
+ : _spanKind == DocumentHighlighting.HighlightSpanKind.WrittenReference
? PredefinedPreviewTaggerKeys.WrittenReferenceHighlightingSpansKey
: PredefinedPreviewTaggerKeys.ReferenceHighlightingSpansKey;
textBuffer.Properties.RemoveProperty(key);
diff --git a/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs b/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs
index 627ac96efc079..8f527cbb55af5 100644
--- a/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs
+++ b/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs
@@ -3,11 +3,10 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
+using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
-using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using Xunit;
diff --git a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs
index 873349a13f999..86a0a05fec482 100644
--- a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs
+++ b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs
@@ -3,11 +3,10 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
+using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
-using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using Xunit;
diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownTagNames.cs b/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownTagNames.cs
index d765685a409f3..98dd6cba799a0 100644
--- a/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownTagNames.cs
+++ b/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownTagNames.cs
@@ -1,7 +1,7 @@
// 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 Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
+using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting;
namespace Microsoft.VisualStudio.IntegrationTest.Utilities
{
diff --git a/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj b/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj
index d6d11f07df18b..025bf020370a5 100644
--- a/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj
+++ b/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj
@@ -73,6 +73,7 @@
+
diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs
new file mode 100644
index 0000000000000..b98c8e58a9146
--- /dev/null
+++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs
@@ -0,0 +1,28 @@
+// 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 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();
+ var result = await service.GetDocumentHighlightsAsync(
+ document, position, documentsToSearch, CancellationToken).ConfigureAwait(false);
+
+ return SerializableDocumentHighlights.Dehydrate(result);
+ }
+ }
+}
\ No newline at end of file