diff --git a/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj b/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj index 4369095c0de1408cd5472c9aee6b9c9703abbd91..508f732f4d6cb38ac4d77df10723b16fb96f2594 100644 --- a/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj +++ b/src/EditorFeatures/CSharp/CSharpEditorFeatures.csproj @@ -136,12 +136,14 @@ + + diff --git a/src/EditorFeatures/CSharp/HighlightReferences/CSharpDocumentHighlightsService.cs b/src/EditorFeatures/CSharp/HighlightReferences/CSharpDocumentHighlightsService.cs new file mode 100644 index 0000000000000000000000000000000000000000..c1f3baf669ed04f29b150e4541d5ad55fb89677f --- /dev/null +++ b/src/EditorFeatures/CSharp/HighlightReferences/CSharpDocumentHighlightsService.cs @@ -0,0 +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. + +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/Features/CSharp/Portable/DocumentHighlighting/CSharpDocumentHighlightsService.cs b/src/EditorFeatures/CSharp/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.cs similarity index 70% rename from src/Features/CSharp/Portable/DocumentHighlighting/CSharpDocumentHighlightsService.cs rename to src/EditorFeatures/CSharp/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.cs index 4788978fd5719e6adabab4255094d600688cf24b..2321c81cc552ec071d6d818b9d4c65e24de6062d 100644 --- a/src/Features/CSharp/Portable/DocumentHighlighting/CSharpDocumentHighlightsService.cs +++ b/src/EditorFeatures/CSharp/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.cs @@ -1,31 +1,32 @@ // 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.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.DocumentHighlighting; +using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting; 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] - internal class CSharpDocumentHighlightsService : AbstractDocumentHighlightsService + [ExportLanguageService(typeof(IReferenceHighlightingAdditionalReferenceProvider), LanguageNames.CSharp), Shared] + internal class ReferenceHighlightingAdditionalReferenceProvider : IReferenceHighlightingAdditionalReferenceProvider { - protected override async Task> GetAdditionalReferencesAsync( + public 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 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 // 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. - var results = ArrayBuilder.GetInstance(); + List results = null; if (symbol is INamedTypeSymbol && symbol.Name != "var") { @@ -51,13 +52,18 @@ internal class CSharpDocumentHighlightsService : AbstractDocumentHighlightsServi if (originalSymbol.Equals(boundSymbol)) { + if (results == null) + { + results = new List(); + } + results.Add(type.GetLocation()); } } } } - return results.ToImmutableAndFree(); + return results ?? SpecializedCollections.EmptyEnumerable(); } } -} \ No newline at end of file +} diff --git a/src/EditorFeatures/Core/EditorFeatures.csproj b/src/EditorFeatures/Core/EditorFeatures.csproj index e7809e7b20f5aed54848f8f2f550d0bd15db6f84..3a5b371a27e547efdfa2152c73fea7dc841c0a6e 100644 --- a/src/EditorFeatures/Core/EditorFeatures.csproj +++ b/src/EditorFeatures/Core/EditorFeatures.csproj @@ -168,14 +168,6 @@ - - - - - - - - @@ -638,6 +630,8 @@ + + @@ -649,6 +643,15 @@ + + + + + + + + + diff --git a/src/EditorFeatures/Core/Implementation/Preview/PreviewReferenceHighlightingTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Preview/PreviewReferenceHighlightingTaggerProvider.cs index 5c90ff6b8f17938aedfbb5c943a3c814ac49450e..29a2060e254e3a0024b13b9796cc030718690f3b 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.ReferenceHighlighting; +using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting; namespace Microsoft.CodeAnalysis.Editor.Implementation.Preview { diff --git a/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs similarity index 82% rename from src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs index 91b1933bd76929519a735e9ee72ab4cae5dece16..8a90b0062620fb3fab1dc954887658e7a6f817d0 100644 --- a/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs @@ -14,47 +14,12 @@ using Microsoft.CodeAnalysis.Text; 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> 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); @@ -76,11 +41,11 @@ internal abstract partial class AbstractDocumentHighlightsService : IDocumentHig // 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 static async Task GetSymbolToSearchAsync(Document document, int position, SemanticModel semanticModel, ISymbol symbol, CancellationToken cancellationToken) + private 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); @@ -117,7 +82,7 @@ private static async Task GetSymbolToSearchAsync(Document document, int return ImmutableArray.Empty; } - private static bool ShouldConsiderSymbol(ISymbol symbol) + private bool ShouldConsiderSymbol(ISymbol symbol) { switch (symbol.Kind) { @@ -167,13 +132,19 @@ private static bool ShouldConsiderSymbol(ISymbol symbol) documentsToSearch, cancellationToken).ConfigureAwait(false); } - protected virtual Task> GetAdditionalReferencesAsync( + private Task> GetAdditionalReferencesAsync( Document document, ISymbol symbol, CancellationToken cancellationToken) { - return SpecializedTasks.EmptyImmutableArray(); + var additionalReferenceProvider = document.Project.LanguageServices.GetService(); + if (additionalReferenceProvider != null) + { + return additionalReferenceProvider.GetAdditionalReferencesAsync(document, symbol, cancellationToken); + } + + return Task.FromResult(SpecializedCollections.EmptyEnumerable()); } - private static async Task> CreateSpansAsync( + private async Task> CreateSpansAsync( Solution solution, ISymbol symbol, IEnumerable references, @@ -281,7 +252,7 @@ private static bool ShouldIncludeDefinition(ISymbol symbol) return true; } - private static async Task AddLocationSpan(Location location, Solution solution, HashSet spanSet, MultiDictionary tagList, HighlightSpanKind kind, CancellationToken cancellationToken) + private 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)) @@ -291,7 +262,7 @@ private static async Task AddLocationSpan(Location location, Solution solution, } } - private static async Task GetLocationSpanAsync( + private async Task GetLocationSpanAsync( Solution solution, Location location, CancellationToken cancellationToken) { try diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTag.cs similarity index 88% rename from src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTag.cs index 0b974c620bfa2f83b81c0d92b2b6fc269c837c75..2f5873a759429635efe22743f3e221899a6130b0 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTag.cs @@ -2,7 +2,7 @@ using Microsoft.CodeAnalysis.Editor.Shared.Tagging; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { internal class DefinitionHighlightTag : NavigableHighlightTag { diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTagDefinition.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTagDefinition.cs similarity index 92% rename from src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTagDefinition.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTagDefinition.cs index 5580291757cf87d795b20e39efd284f77f03b8fa..b5a8023f8297e300e1c6fa018fd442d010ebd3dd 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTagDefinition.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/DefinitionHighlightTagDefinition.cs @@ -5,7 +5,7 @@ using Microsoft.VisualStudio.Text.Classification; using Microsoft.VisualStudio.Utilities; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { [Export(typeof(EditorFormatDefinition))] [Name(DefinitionHighlightTag.TagId)] diff --git a/src/Features/Core/Portable/DocumentHighlighting/IDocumentHighlightsService.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs similarity index 95% rename from src/Features/Core/Portable/DocumentHighlighting/IDocumentHighlightsService.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs index 0e08d4418c4f55e12074877f1ed5d1dc5c0cc431..f86be931963c1cff0e11159a4a5eac49ebd0efe2 100644 --- a/src/Features/Core/Portable/DocumentHighlighting/IDocumentHighlightsService.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs @@ -1,12 +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. +using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Text; -namespace Microsoft.CodeAnalysis.DocumentHighlighting +namespace Microsoft.CodeAnalysis.Editor { internal enum HighlightSpanKind { diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IReferenceHighlightingAdditionalReferenceProvider.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IReferenceHighlightingAdditionalReferenceProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..694a5b6e505a27f3d8e567c9158dd27b83c24b03 --- /dev/null +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IReferenceHighlightingAdditionalReferenceProvider.cs @@ -0,0 +1,14 @@ +// 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/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs similarity index 87% rename from src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs index 125416fd75162cb247e0a5d848cfddd09d9a0701..76b72d5268f3bb56aef5f8dfea8249922420aace 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.StartComparer.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Microsoft.VisualStudio.Text; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { internal partial class NavigateToHighlightReferenceCommandHandler { diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs similarity index 98% rename from src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs index 07a6b67793a85644c53354f3d27c493e09d54d34..a0997e4009c8a0176678bf023eb517ea33507666 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/NagivateToHighlightReferenceCommandHandler.cs @@ -14,7 +14,7 @@ using Microsoft.VisualStudio.Text.Tagging; using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { [ExportCommandHandler(PredefinedCommandHandlerNames.NavigateToHighlightedReference, ContentTypeNames.RoslynContentType)] diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightTag.cs similarity index 87% rename from src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightTag.cs index 299c701a9878037af0dba4aa08362fd4e318b3e6..6c7d2cddc337bb50f58bce3f43ca9df87c685d7a 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightTag.cs @@ -2,7 +2,7 @@ using Microsoft.CodeAnalysis.Editor.Shared.Tagging; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { internal class ReferenceHighlightTag : NavigableHighlightTag { diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs similarity index 98% rename from src/EditorFeatures/Core/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs index e2367ad5f5d3de2b313a1046520578c9566c928d..cbad756b7bd6aec2b4c6963220b5ed4fe9127da9 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.cs @@ -6,7 +6,6 @@ using System.ComponentModel.Composition; using System.Linq; 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; @@ -22,7 +21,7 @@ using Microsoft.VisualStudio.Utilities; using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { [Export(typeof(IViewTaggerProvider))] [ContentType(ContentTypeNames.RoslynContentType)] diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs similarity index 88% rename from src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs index d6f8df3342be571c9928fa554f17525dd5784b02..b4d35d64ae6b186b7e3b9424e85e39e466c99a90 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs @@ -2,7 +2,7 @@ using Microsoft.CodeAnalysis.Editor.Shared.Tagging; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { internal class WrittenReferenceHighlightTag : NavigableHighlightTag { diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTagDefinition.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs similarity index 91% rename from src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTagDefinition.cs rename to src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs index 74323824a50568f56a8b5772a0601a56e94239a2..8db19cc5cb2b434bff2e6391bc8b9527b1f7ff81 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTagDefinition.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs @@ -5,7 +5,7 @@ using Microsoft.VisualStudio.Text.Classification; using Microsoft.VisualStudio.Utilities; -namespace Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting { [Export(typeof(EditorFormatDefinition))] [Name(WrittenReferenceHighlightTag.TagId)] diff --git a/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb b/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb index 7c9591274611fd4ae584d09a27125e9d7af4380b..ab5ab6a8ab80be99bf54a1fc679d42fd94c19db8 100644 --- a/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb +++ b/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb @@ -1,8 +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. Imports System.Threading -Imports Microsoft.CodeAnalysis.DocumentHighlighting -Imports Microsoft.CodeAnalysis.Editor.ReferenceHighlighting +Imports Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting Imports Microsoft.CodeAnalysis.Editor.Shared.Extensions Imports Microsoft.CodeAnalysis.Editor.Shared.Options Imports Microsoft.CodeAnalysis.Editor.Shared.Tagging @@ -17,17 +16,9 @@ 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 79ee5ff8d6c4c5c8d8f86bde27d5f0717bb94426..531d79a604a6f70d27de0d3a8dc8b41232a82804 100644 --- a/src/EditorFeatures/VisualBasic/BasicEditorFeatures.vbproj +++ b/src/EditorFeatures/VisualBasic/BasicEditorFeatures.vbproj @@ -129,6 +129,7 @@ + @@ -154,6 +155,7 @@ + diff --git a/src/Features/VisualBasic/Portable/DocumentHighlighting/VisualBasicDocumentHighlightsService.vb b/src/EditorFeatures/VisualBasic/HighlightReferences/VisualBasicDocumentHighlightsService.vb similarity index 73% rename from src/Features/VisualBasic/Portable/DocumentHighlighting/VisualBasicDocumentHighlightsService.vb rename to src/EditorFeatures/VisualBasic/HighlightReferences/VisualBasicDocumentHighlightsService.vb index 2f925d3749ed38f80643170978212f5695955e8c..b0693439b5de748d8555c4749c7da6c93c3b18d3 100644 --- a/src/Features/VisualBasic/Portable/DocumentHighlighting/VisualBasicDocumentHighlightsService.vb +++ b/src/EditorFeatures/VisualBasic/HighlightReferences/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.DocumentHighlighting +Imports Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting Imports Microsoft.CodeAnalysis.Host.Mef -Namespace Microsoft.CodeAnalysis.VisualBasic.DocumentHighlighting +Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.HighlightReferences Friend Class VisualBasicDocumentHighlightsService Inherits AbstractDocumentHighlightsService End Class -End Namespace \ No newline at end of file +End Namespace diff --git a/src/EditorFeatures/VisualBasic/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.vb b/src/EditorFeatures/VisualBasic/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.vb new file mode 100644 index 0000000000000000000000000000000000000000..2c95b09d3a2fb1b2edd86ee99f2c0f181016a035 --- /dev/null +++ b/src/EditorFeatures/VisualBasic/ReferenceHighlighting/ReferenceHighlightingAdditionalReferenceProvider.vb @@ -0,0 +1,18 @@ +' 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 0e91914a13210cb56ddf65596ef90b3fa596964c..07d23798af9ff0ee33a6ef53c88af4a1c9f525b2 100644 --- a/src/Features/CSharp/Portable/CSharpFeatures.csproj +++ b/src/Features/CSharp/Portable/CSharpFeatures.csproj @@ -81,7 +81,6 @@ - diff --git a/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService_Remote.cs b/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService_Remote.cs deleted file mode 100644 index 7efad4a9663df2994222f59129e4becd80f1983f..0000000000000000000000000000000000000000 --- a/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService_Remote.cs +++ /dev/null @@ -1,30 +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.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 deleted file mode 100644 index 0363999301f110067e2d7d8bf45a3a9738b3b0d4..0000000000000000000000000000000000000000 --- a/src/Features/Core/Portable/DocumentHighlighting/DocumentHighlightingOptions.cs +++ /dev/null @@ -1,15 +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 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/IRemoteDocumentHighlights.cs b/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs deleted file mode 100644 index b58c6f35a18fd281e54a896e2401a0b51c208e33..0000000000000000000000000000000000000000 --- a/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs +++ /dev/null @@ -1,94 +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.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 25a06421f4352bac052ed0df392529d66897887d..cff5327a8c52d04b40edb0daf8d1b968ace56b8f 100644 --- a/src/Features/Core/Portable/Features.csproj +++ b/src/Features/Core/Portable/Features.csproj @@ -132,7 +132,6 @@ - @@ -158,10 +157,6 @@ - - - - diff --git a/src/Features/VisualBasic/Portable/BasicFeatures.vbproj b/src/Features/VisualBasic/Portable/BasicFeatures.vbproj index 884a29b8778a49bd34a97419602484d9a9a10fe5..7369bfd880ca4b8dd7c406b10c46961b07b49942 100644 --- a/src/Features/VisualBasic/Portable/BasicFeatures.vbproj +++ b/src/Features/VisualBasic/Portable/BasicFeatures.vbproj @@ -66,7 +66,6 @@ InternalUtilities\LambdaUtilities.vb - diff --git a/src/VisualStudio/Core/Next/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs b/src/VisualStudio/Core/Next/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs index c8cf14161ae4b31519967a24e0f910c953c3ee35..e593f2f5ab5968efccd46dd0e7c722f998f09725 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.DocumentHighlighting; +using Microsoft.CodeAnalysis.Editor; 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 765612f4c86b254b0f0f7cf95437ba30b7ac3f5e..9973893c2464d25fe036e9546d60554523692165 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.DocumentHighlighting; +using Microsoft.CodeAnalysis.Editor; 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 2456a495cfef65e061a3dd039887aa36b2ef54f8..5a5f6a2b02bf84098c0f8c7447c519431c41fff9 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.DocumentHighlighting; +using Microsoft.CodeAnalysis.Editor; 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 f32bade84b9c23b1df423c9fcc30bad586189866..68c45919b30eb35b38599fc4f4fad35b73b89afa 100644 --- a/src/VisualStudio/Core/Next/FindReferences/Entries/DocumentSpanEntry.cs +++ b/src/VisualStudio/Core/Next/FindReferences/Entries/DocumentSpanEntry.cs @@ -7,11 +7,10 @@ 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.ReferenceHighlighting; +using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Preview; using Microsoft.CodeAnalysis.FindUsages; @@ -19,6 +18,7 @@ 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; diff --git a/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs b/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs index 8f527cbb55af5c56b78fe15e9c53538193121c68..627ac96efc079a8e6925741e56da064b4e4eca62 100644 --- a/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs +++ b/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; +using Microsoft.CodeAnalysis.Editor.Implementation.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 86a0a05fec482d16079fca62f3a03b8518bbd441..873349a13f9996adfe98d867e76723283394a87c 100644 --- a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs +++ b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; +using Microsoft.CodeAnalysis.Editor.Implementation.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 98dd6cba799a048aca19ba8e5687b706616bb03e..d765685a409f38f7aacae9d981d9b409a5ab75cc 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.ReferenceHighlighting; +using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting; namespace Microsoft.VisualStudio.IntegrationTest.Utilities { diff --git a/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj b/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj index 68fe27e68b2f4764b8209e5fcb6422943e140481..1d5b8a990240a8a42c2014d83c27fa878a655a86 100644 --- a/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj +++ b/src/Workspaces/Remote/ServiceHub/ServiceHub.csproj @@ -73,7 +73,6 @@ - diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs deleted file mode 100644 index b98c8e58a914639996f41da129b2b0b7cf1c232d..0000000000000000000000000000000000000000 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs +++ /dev/null @@ -1,28 +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.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