diff --git a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs index ae0e0f428e240..5e9a8286c2fc1 100644 --- a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs +++ b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs @@ -191,4 +191,22 @@ internal static class PredefinedCommandHandlerNames /// Command handler name for showing the Callstack Explorer tool window. /// public const string ShowCallstackExplorer = "Show Callstack Explorer"; + + /// + /// Command handler name for LSP Go To Definition. + /// This name is agreed upon externally and cannot be changed. + /// + public const string LspGoToDefinition = "LSP GoToDefinitionCommandHandler"; + + /// + /// Command handler name for LSP Find References. + /// This name is agreed upon externally and cannot be changed. + /// + public const string LspFindReferences = "LSP FindReferenceCommandHandler"; + + /// + /// Command handler name for LSP Go To Implementation. + /// This name is agreed upon externally and cannot be changed. + /// + public const string LspGoToImplementation = "LSP GoToImplementationCommandHandler"; } diff --git a/src/EditorFeatures/Core/GoOrFind/FindReferences/FindReferencesCommandHandler.cs b/src/EditorFeatures/Core/GoOrFind/FindReferences/FindReferencesCommandHandler.cs index 0cdb681762bc1..2a2a4eaf7e7e2 100644 --- a/src/EditorFeatures/Core/GoOrFind/FindReferences/FindReferencesCommandHandler.cs +++ b/src/EditorFeatures/Core/GoOrFind/FindReferences/FindReferencesCommandHandler.cs @@ -15,6 +15,7 @@ namespace Microsoft.CodeAnalysis.FindReferences; [Export(typeof(ICommandHandler))] [ContentType(ContentTypeNames.RoslynContentType)] [Name(PredefinedCommandHandlerNames.FindReferences)] +[Order(Before = PredefinedCommandHandlerNames.LspFindReferences)] [method: ImportingConstructor] [method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] internal sealed class FindReferencesCommandHandler(FindReferencesNavigationService navigationService) diff --git a/src/EditorFeatures/Core/GoOrFind/GoToImplementation/GoToImplementationCommandHandler.cs b/src/EditorFeatures/Core/GoOrFind/GoToImplementation/GoToImplementationCommandHandler.cs index e6b6690fcdd55..86c63bb02dcdf 100644 --- a/src/EditorFeatures/Core/GoOrFind/GoToImplementation/GoToImplementationCommandHandler.cs +++ b/src/EditorFeatures/Core/GoOrFind/GoToImplementation/GoToImplementationCommandHandler.cs @@ -16,6 +16,7 @@ namespace Microsoft.CodeAnalysis.GoToImplementation; [Export(typeof(ICommandHandler))] [ContentType(ContentTypeNames.RoslynContentType)] [Name(PredefinedCommandHandlerNames.GoToImplementation)] +[Order(Before = PredefinedCommandHandlerNames.LspGoToImplementation)] [method: ImportingConstructor] [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] internal sealed class GoToImplementationCommandHandler(GoToImplementationNavigationService navigationService) diff --git a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs index 53ea8f72ba43c..560f4c7c7c1d2 100644 --- a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs +++ b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs @@ -28,6 +28,7 @@ namespace Microsoft.CodeAnalysis.GoToDefinition; [Export(typeof(ICommandHandler))] [ContentType(ContentTypeNames.RoslynContentType)] [Name(PredefinedCommandHandlerNames.GoToDefinition)] +[Order(Before = PredefinedCommandHandlerNames.LspGoToDefinition)] [method: ImportingConstructor] [method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] internal sealed class GoToDefinitionCommandHandler( diff --git a/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs b/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs index 02eab5ccc1cb0..4ac976af47db0 100644 --- a/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs +++ b/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs @@ -118,6 +118,15 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa serverCapabilities.SpellCheckingProvider = true; + // Enable go to definition, find all references, and go to implementation capabilities for experimentation. + // These are enabled regardless of the LSP feature flag to allow clients to call these handlers. + serverCapabilities.DefinitionProvider = true; + serverCapabilities.ReferencesProvider = new ReferenceOptions + { + WorkDoneProgress = true, + }; + serverCapabilities.ImplementationProvider = true; + return serverCapabilities; }