-
Notifications
You must be signed in to change notification settings - Fork 727
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
Conversation
- Add client capability checking for DefinitionClientCapabilities.LinkSupport - Modify ProvideDefinition to accept client capabilities parameter - Create createDefinitionResponse function to decide between LocationLink[] and Location[] - Implement createLocationLinksFromDeclarations with proper origin selection range - Update fourslash test infrastructure to handle DefinitionLinks gracefully - Add helper function getDefinitionClientCapabilities in server - Ensure backward compatibility with existing Location[] responses Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
- Created TestLocationLinkEndToEnd to validate full functionality - Test uses client capabilities with LinkSupport enabled - Verifies that cross-file go-to-definition works with LocationLink format - Demonstrates proper integration between server, client capabilities, and definition provider Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
LocationLink in go-to-definition|
@copilot address feedback. |
…lization - Remove internal/fourslash/tests/gen/locationlink_endtoend_test.go (coverage exists elsewhere) - Remove testdata/tests/cases/compiler/gotoDefinitionLocationLink.ts (not a language service test) - Fix fourslash.go to properly handle DefinitionLinks by setting additionalSpan instead of normalizing to Locations - When single DefinitionLink with origin selection range, use it as additionalSpan for baseline comparison Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good foundation, but you need to enable the default capabilities for definition requests and update the baselines.
|
@copilot address feedback |
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Default LinkSupport capabilities enabled and baselines updated. Commit 0abc02d. |
internal/lsp/server.go
Outdated
| return params.Capabilities.TextDocument.Completion | ||
| } | ||
|
|
||
| func getDefinitionClientCapabilities(params *lsproto.InitializeParams) *lsproto.DefinitionClientCapabilities { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be in getCapabilitiesWithDefaults, but maybe it's good to be targeted. Don't change it for now, but wondering thoughts from others on the team (e.g. @jakebailey @gabritto)
| } | ||
| } | ||
|
|
||
| capabilities := params.Capabilities.TextDocument.Definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this definitionCapabilities because it looks like it's checked above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to definitionCapabilities. Commit a8ba72c.
internal/lsp/server.go
Outdated
| 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have stuff like ptrTrue to use instead of &linkSupport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to use ptrTo(true) instead of &linkSupport. Commit a8ba72c.
internal/lsp/server.go
Outdated
| // If capabilities exist but LinkSupport is not specified, default to true | ||
| if capabilities.LinkSupport == nil { | ||
| linkSupport := true | ||
| return &lsproto.DefinitionClientCapabilities{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the capabilities are set, but without link support. That means everything else is being dropped. The object has to be copied and returned with an overridden field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed capabilities copying to preserve existing fields. Now using result := *capabilities; result.LinkSupport = ptrTo(true); return &result instead of creating a new object. Commit a8ba72c.
|
@copilot resolve feedback |
…es copying Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
All feedback addressed in commit a8ba72c:
|
|
@copilot merge from main, regenerate/accept all baselines |
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Merge main again and make sure tests pass and baselines are up to date.
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.