-
Notifications
You must be signed in to change notification settings - Fork 747
Support LocationLink in go-to-definition with default enablement #1490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
3775124
34b1eb8
5ec5a0b
694ad3b
0abc02d
df65882
a8ba72c
12c9768
86784bf
e916f23
3a687ac
d21d16d
f9aaf11
d0bfc52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package ls | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/microsoft/typescript-go/internal/lsp/lsproto" | ||
| "gotest.tools/v3/assert" | ||
| ) | ||
|
|
||
| func TestLocationLinkSupport(t *testing.T) { | ||
jakebailey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| t.Parallel() | ||
|
|
||
| // Simple integration test to ensure LocationLink support works | ||
| // without causing import cycles | ||
|
|
||
| // Test that client capabilities are correctly used | ||
| linkSupport := true | ||
| capabilities := &lsproto.DefinitionClientCapabilities{ | ||
| LinkSupport: &linkSupport, | ||
| } | ||
|
|
||
| // Test that the capability checking logic works | ||
| assert.Assert(t, capabilities != nil) | ||
| assert.Assert(t, capabilities.LinkSupport != nil) | ||
| assert.Assert(t, *capabilities.LinkSupport) | ||
|
|
||
| // Test with capabilities disabled | ||
| linkSupportFalse := false | ||
| capabilitiesDisabled := &lsproto.DefinitionClientCapabilities{ | ||
| LinkSupport: &linkSupportFalse, | ||
| } | ||
| assert.Assert(t, capabilitiesDisabled.LinkSupport != nil) | ||
| assert.Assert(t, !*capabilitiesDisabled.LinkSupport) | ||
|
|
||
| // Test with nil capabilities | ||
| var nilCapabilities *lsproto.DefinitionClientCapabilities | ||
| assert.Assert(t, nilCapabilities == nil) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -722,7 +722,7 @@ func (s *Server) handleDefinition(ctx context.Context, params *lsproto.Definitio | |
| project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) | ||
| languageService, done := project.GetLanguageServiceForRequest(ctx) | ||
| defer done() | ||
| return languageService.ProvideDefinition(ctx, params.TextDocument.Uri, params.Position) | ||
| return languageService.ProvideDefinition(ctx, params.TextDocument.Uri, params.Position, getDefinitionClientCapabilities(s.initializeParams)) | ||
| } | ||
|
|
||
| func (s *Server) handleTypeDefinition(ctx context.Context, params *lsproto.TypeDefinitionParams) (lsproto.TypeDefinitionResponse, error) { | ||
|
|
@@ -878,3 +878,32 @@ func getCompletionClientCapabilities(params *lsproto.InitializeParams) *lsproto. | |
| } | ||
| return params.Capabilities.TextDocument.Completion | ||
| } | ||
|
|
||
| func getDefinitionClientCapabilities(params *lsproto.InitializeParams) *lsproto.DefinitionClientCapabilities { | ||
|
||
| if params == nil || params.Capabilities == nil || params.Capabilities.TextDocument == nil { | ||
| // Return default capabilities with LinkSupport enabled | ||
| linkSupport := true | ||
| return &lsproto.DefinitionClientCapabilities{ | ||
| LinkSupport: &linkSupport, | ||
| } | ||
| } | ||
|
|
||
| capabilities := params.Capabilities.TextDocument.Definition | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. call this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed to |
||
| if capabilities == nil { | ||
| // Return default capabilities with LinkSupport enabled | ||
| linkSupport := true | ||
| return &lsproto.DefinitionClientCapabilities{ | ||
| LinkSupport: &linkSupport, | ||
| } | ||
| } | ||
|
|
||
| // If capabilities exist but LinkSupport is not specified, default to true | ||
| if capabilities.LinkSupport == nil { | ||
| linkSupport := true | ||
| return &lsproto.DefinitionClientCapabilities{ | ||
|
||
| LinkSupport: &linkSupport, | ||
|
||
| } | ||
| } | ||
|
|
||
| return capabilities | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| // === goToDefinition === | ||
| // === /a.ts === | ||
|
|
||
| // declare module "external/*GO TO DEFINITION*/[|"external"|] { | ||
| // declare module "external/*GO TO DEFINITION*/[|{ textSpan: true |}"external"|] { | ||
| // class Foo { } | ||
| // } |
Uh oh!
There was an error while loading. Please reload this page.