Skip to content

Commit

Permalink
Remove dependency on EditorFeatures from Remote.ServiceHub project (#…
Browse files Browse the repository at this point in the history
…59059)

* DelayTimeSpan

* StackTraceExplorer

* FindUsages

* CompilationAvailableHelpers

* SymbolSearch

* Move StackTraceExplorerOptions

* Fix StackTraceExplorerOptions
  • Loading branch information
tmat authored Jan 27, 2022
1 parent 6115a50 commit 3b32fc3
Show file tree
Hide file tree
Showing 117 changed files with 480 additions and 409 deletions.
2 changes: 1 addition & 1 deletion eng/targets/Services.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.UnusedReferenceAnalysis" ClassName="Microsoft.CodeAnalysis.Remote.RemoteUnusedReferenceAnalysisService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.ProcessTelemetry" ClassName="Microsoft.CodeAnalysis.Remote.RemoteProcessTelemetryService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.CompilationAvailable" ClassName="Microsoft.CodeAnalysis.Remote.RemoteCompilationAvailableService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.StackTraceExplorer" ClassName="Microsoft.CodeAnalysis.Remote.Services.StackTraceExplorer.RemoteStackTraceExplorerService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.StackTraceExplorer" ClassName="Microsoft.CodeAnalysis.Remote.RemoteStackTraceExplorerService+Factory" />
</ItemGroup>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private static Document PerformDecompilation(Document document, string fullName,

if (file is null && assemblyLocation is null)
{
throw new NotSupportedException(EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret);
throw new NotSupportedException(FeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret);
}

file ??= new PEFile(assemblyLocation, PEStreamOptions.PrefetchEntireImage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Composition;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;

namespace Microsoft.CodeAnalysis.Editor.CSharp.FindUsages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;
using System.Composition;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;

namespace Microsoft.CodeAnalysis.Editor.CSharp.FindUsages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindSymbols;
Expand All @@ -20,6 +19,7 @@
using Roslyn.Utilities;
using VSCommanding = Microsoft.VisualStudio.Commanding;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.FindUsages;

namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigationCommandHandlers
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindUsages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Internal.Log;
Expand All @@ -19,6 +18,7 @@
using VSCommanding = Microsoft.VisualStudio.Commanding;
using Microsoft.CodeAnalysis.Host.Mef;
using System.Threading;
using Microsoft.CodeAnalysis.FindUsages;

namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigationCommandHandlers
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand Down
3 changes: 1 addition & 2 deletions src/EditorFeatures/Core.Wpf/Peek/PeekableItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Peek;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.MetadataAsSource;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Language.Intellisense;

namespace Microsoft.CodeAnalysis.Editor.Implementation.Peek
Expand Down
9 changes: 0 additions & 9 deletions src/EditorFeatures/Core/EditorFeaturesResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,6 @@ Do you want to proceed?</value>
<data name="Go_To_Base" xml:space="preserve">
<value>Go To Base</value>
</data>
<data name="The_symbol_has_no_implementations" xml:space="preserve">
<value>The symbol has no implementations.</value>
</data>
<data name="New_name_colon_0" xml:space="preserve">
<value>New name: {0}</value>
</data>
Expand All @@ -742,12 +739,6 @@ Do you want to proceed?</value>
<data name="Suggestion_ellipses" xml:space="preserve">
<value>Suggestion ellipses (…)</value>
</data>
<data name="_0_references" xml:space="preserve">
<value>'{0}' references</value>
</data>
<data name="_0_implementations" xml:space="preserve">
<value>'{0}' implementations</value>
</data>
<data name="_0_declarations" xml:space="preserve">
<value>'{0}' declarations</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
using System.ComponentModel.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
Expand Down
3 changes: 1 addition & 2 deletions src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;

Expand All @@ -23,7 +22,7 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon
if (symbolAndProjectOpt == null)
{
await context.ReportMessageAsync(
EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret, cancellationToken).ConfigureAwait(false);
FeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret, cancellationToken).ConfigureAwait(false);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.FindUsages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal static bool TryExecuteCommand(Document document, int caretPosition, IGo
return true;
}

errorMessage = EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret;
errorMessage = FeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret;
}

if (errorMessage != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.FindSymbols;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.CommandHandlers;
using Microsoft.CodeAnalysis.Editor.Commanding.Commands;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.FindUsages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public TagComputer(
_typeMap = typeMap;
_diffTimeout = diffTimeout;
_workQueue = new AsyncBatchingWorkQueue<ITextSnapshot>(
TimeSpan.FromMilliseconds(TaggerConstants.NearImmediateDelay),
DelayTimeSpan.NearImmediate,
ProcessChangesAsync,
equalityComparer: null,
asyncListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.GoToDefinition;
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.MetadataAsSource;
using Microsoft.CodeAnalysis.Navigation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.LanguageServer.CustomProtocol;
using Microsoft.CodeAnalysis.MetadataAsSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ public NavigationBarController(
_asyncListener = asyncListener;

_computeModelQueue = new AsyncBatchingWorkQueue<bool, NavigationBarModel?>(
TimeSpan.FromMilliseconds(TaggerConstants.ShortDelay),
DelayTimeSpan.Short,
ComputeModelAndSelectItemAsync,
EqualityComparer<bool>.Default,
asyncListener,
_cancellationTokenSource.Token);

_selectItemQueue = new AsyncBatchingWorkQueue(
TimeSpan.FromMilliseconds(TaggerConstants.NearImmediateDelay),
DelayTimeSpan.NearImmediate,
SelectItemAsync,
asyncListener,
_cancellationTokenSource.Token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
<ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" Aliases="Scripting,global" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Elfie" Version="$(MicrosoftCodeAnalysisElfieVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Language.StandardClassification" Version="$(MicrosoftVisualStudioLanguageStandardClassificationVersion)" />
<PackageReference Include="Microsoft.VisualStudio.RemoteControl" Version="$(MicrosoftVisualStudioRemoteControlVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Text.UI" Version="$(MicrosoftVisualStudioTextUIVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" />
<!-- The ImageCatalog reference is only used at compile time, not at runtime, because it is not supported on Mac.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Tagging
{
internal static class TaggerConstants
{
internal const int NearImmediateDelay = 50;
internal const int ShortDelay = 250;
internal const int MediumDelay = 500;
internal const int IdleDelay = 1500;
internal const int NonFocusDelay = 3000;

internal static TimeSpan ComputeTimeDelay(this TaggerDelay behavior, ITextBuffer textBufferOpt)
{
if (TextBufferAssociatedViewService.AnyAssociatedViewHasFocus(textBufferOpt))
Expand All @@ -25,16 +19,16 @@ internal static TimeSpan ComputeTimeDelay(this TaggerDelay behavior, ITextBuffer
return ComputeTimeDelay(behavior);
}

return TimeSpan.FromMilliseconds(NonFocusDelay);
return DelayTimeSpan.NonFocus;
}

internal static TimeSpan ComputeTimeDelay(this TaggerDelay behavior)
=> behavior switch
{
TaggerDelay.NearImmediate => TimeSpan.FromMilliseconds(NearImmediateDelay),
TaggerDelay.Short => TimeSpan.FromMilliseconds(ShortDelay),
TaggerDelay.Medium => TimeSpan.FromMilliseconds(MediumDelay),
_ => TimeSpan.FromMilliseconds(IdleDelay),
TaggerDelay.NearImmediate => DelayTimeSpan.NearImmediate,
TaggerDelay.Short => DelayTimeSpan.Short,
TaggerDelay.Medium => DelayTimeSpan.Medium,
_ => DelayTimeSpan.Idle,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Remote;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Tagging;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.Tagging
{

/// <summary>
/// Tagger event that fires once the compilation is available in the remote OOP process for a particular project.
/// Used to trigger things such as:
Expand All @@ -27,7 +26,7 @@ namespace Microsoft.CodeAnalysis.Editor.Tagging
/// <item>recomputation of inheritance margin items due to frozen-partial compilations being used.</item>
/// </list>
/// </summary>
internal class CompilationAvailableTaggerEventSource : ITaggerEventSource
internal sealed class CompilationAvailableTaggerEventSource : ITaggerEventSource
{
private readonly ITextBuffer _subjectBuffer;
private readonly IAsynchronousOperationListener _asyncListener;
Expand Down Expand Up @@ -114,7 +113,7 @@ private void OnEventSourceChanged(object? sender, TaggerEventArgs args)
else
{
// if we can't get the client, just compute the compilation locally and fire the event once we have it.
await ComputeCompilationInCurrentProcessAsync(document.Project, cancellationToken).ConfigureAwait(false);
await CompilationAvailableHelpers.ComputeCompilationInCurrentProcessAsync(document.Project, cancellationToken).ConfigureAwait(false);
}

// now that we know we have an full compilation, retrigger the tagger so it can show accurate results with the
Expand All @@ -123,9 +122,5 @@ private void OnEventSourceChanged(object? sender, TaggerEventArgs args)
}, cancellationToken);
task.CompletesAsyncOperation(token);
}

// this method is super basic. but it ensures that the remote impl and the local impl always agree.
public static Task ComputeCompilationInCurrentProcessAsync(Project project, CancellationToken cancellationToken)
=> project.GetCompilationAsync(cancellationToken);
}
}
Loading

0 comments on commit 3b32fc3

Please sign in to comment.