Skip to content

Commit 84c9fbe

Browse files
Copilotdibarbet
andcommitted
Enable LSP go-to-definition and find-all-references capabilities with command handler ordering
Co-authored-by: dibarbet <[email protected]>
1 parent a6810ee commit 84c9fbe

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,14 @@ internal static class PredefinedCommandHandlerNames
191191
/// Command handler name for showing the Callstack Explorer tool window.
192192
/// </summary>
193193
public const string ShowCallstackExplorer = "Show Callstack Explorer";
194+
195+
/// <summary>
196+
/// Command handler name for LSP Go To Definition.
197+
/// </summary>
198+
public const string LspGoToDefinition = "LSP Go To Definition Command Handler";
199+
200+
/// <summary>
201+
/// Command handler name for LSP Find References.
202+
/// </summary>
203+
public const string LspFindReferences = "LSP Find References Command Handler";
194204
}

src/EditorFeatures/Core/GoOrFind/FindReferences/FindReferencesCommandHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace Microsoft.CodeAnalysis.FindReferences;
1515
[Export(typeof(ICommandHandler))]
1616
[ContentType(ContentTypeNames.RoslynContentType)]
1717
[Name(PredefinedCommandHandlerNames.FindReferences)]
18+
[Order(Before = PredefinedCommandHandlerNames.LspFindReferences)]
1819
[method: ImportingConstructor]
1920
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
2021
internal sealed class FindReferencesCommandHandler(FindReferencesNavigationService navigationService)

src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace Microsoft.CodeAnalysis.GoToDefinition;
2828
[Export(typeof(ICommandHandler))]
2929
[ContentType(ContentTypeNames.RoslynContentType)]
3030
[Name(PredefinedCommandHandlerNames.GoToDefinition)]
31+
[Order(Before = PredefinedCommandHandlerNames.LspGoToDefinition)]
3132
[method: ImportingConstructor]
3233
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
3334
internal sealed class GoToDefinitionCommandHandler(

src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa
118118

119119
serverCapabilities.SpellCheckingProvider = true;
120120

121+
// Enable go to definition and find all references capabilities for experimentation.
122+
// These are enabled regardless of the LSP feature flag to allow clients to call these handlers.
123+
serverCapabilities.DefinitionProvider = true;
124+
serverCapabilities.ReferencesProvider = new ReferenceOptions
125+
{
126+
WorkDoneProgress = true,
127+
};
128+
121129
return serverCapabilities;
122130
}
123131

0 commit comments

Comments
 (0)