-
Notifications
You must be signed in to change notification settings - Fork 583
LSP: Jump to the function name #792
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
base: main
Are you sure you want to change the base?
Conversation
@@ -15,25 +16,70 @@ func (l *LanguageService) ProvideDefinitions(fileName string, position int) []Lo | |||
} | |||
|
|||
checker := program.GetTypeChecker() | |||
calledDeclaration := tryGetSignatureDeclaration(checker, node) |
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 tried to port the logic from src/services/goToDefinition.ts
in the TypeScript repository.
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.
Pull Request Overview
This PR improves the “Go to Definition” command so that it now jumps directly to a function’s name instead of its leading keyword. Key changes include:
- Updating the definition lookup in internal/ls/definition.go to focus on the function name.
- Renaming several helper functions to exported versions (e.g., GetResolvedSignature, IsCallLikeExpression) for consistency.
- Adding new utility functions in internal/ast/utilities.go to support the enhanced navigation.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/ls/definition.go | Refactored definition location logic and added helper functions. |
internal/checker/utilities.go | Renamed and added exported helper functions for signature checks. |
internal/checker/jsx.go | Updated signature resolution to use exported helper functions. |
internal/checker/flow.go | Updated calls to use the exported GetResolvedSignature function. |
internal/checker/checker.go | Replaced internal function calls with their exported counterparts. |
internal/ast/utilities.go | Added a utility to determine property access context. |
Comments suppressed due to low confidence (4)
internal/ls/definition.go:19
- [nitpick] Consider renaming 'tryGetSignatureDeclaration' to better convey its intent (e.g., 'getSignatureDeclaration') if it always returns a declaration or nil.
calledDeclaration := tryGetSignatureDeclaration(checker, node)
internal/checker/utilities.go:1297
- Ensure that the change to an exported function name is accompanied by updated documentation comments to clarify its usage.
func IsCallLikeExpression(node *ast.Node) bool {
internal/checker/checker.go:7904
- [nitpick] Verify that all calls to the renamed 'GetResolvedSignature' are updated consistently and that its behavior is properly documented.
func (c *Checker) GetResolvedSignature(node *ast.Node, candidatesOutArray *[]*Signature, checkMode CheckMode) *Signature {
internal/ast/utilities.go:2654
- [nitpick] Add a documentation comment for 'IsRightSideOfPropertyAccess' to clearly describe its purpose and usage in the codebase.
func IsRightSideOfPropertyAccess(node *Node) bool {
3e7d636
to
fb9f909
Compare
Improved the "Go to Definition" command to jump to the function name instead of the beginning of the
function
keyword.Example: