-
Notifications
You must be signed in to change notification settings - Fork 661
Improve go-to-definition and implement go-to-type-definition #1405
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
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 enhances the go-to-definition functionality and implements go-to-type-definition for the TypeScript language server. It adds support for navigating to definitions from various language constructs including override keywords, labels, control flow statements, and call expressions, while also introducing type definition capabilities.
Key changes:
- Extended go-to-definition to handle keywords (override, case, default, return, yield, await) and jump statements
- Added comprehensive go-to-type-definition support with type argument handling
- Moved error range calculation utilities from binder to scanner for better organization
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
internal/scanner/scanner.go | Moved GetErrorRangeForNode function from binder and simplified GetTokenPosOfNode |
internal/lsp/server.go | Added type definition endpoint handling and server capability registration |
internal/ls/utilities.go | Updated range creation to use token position and fixed label handling return type |
internal/ls/findallreferences.go | Updated label reference functions to work with generic nodes instead of identifiers |
internal/ls/definition.go | Major expansion with keyword-based definitions, call resolution, and type definition implementation |
internal/checker/utilities.go | Updated diagnostic creation to use scanner's error range function |
internal/checker/services.go | Added contextual declarations and type argument extraction utilities |
internal/checker/exports.go | Exported new checker methods for index signatures and symbol resolution |
internal/checker/checker.go | Implemented index signature location resolution |
internal/binder/binder.go | Removed GetErrorRangeForNode function (moved to scanner) |
internal/ast/ast.go | Added IsSwitchStatement helper function |
"Required": {}, | ||
"Readonly": {}, | ||
"Pick": {}, | ||
"Omit": {}, |
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.
"Omit": {}, | |
"Omit": {}, | |
"Exclude": {}, |
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.
The types in this list generally operate on object types for which we record source locations. Exclude
and Extract
are almost always used with (unions of) literal types, and we don't record source locations for those.
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.
However, we should include NonNullable<T>
.
This PR implements
override
keyword selects the overridden method declaration.break
orcontinue
statement selects the label definition.case
ordefault
keyword selects the containingswitch
statement.return
,yield
orawait
keyword selects the containing function declaration.T[]
selects both declarations ofT
andArray
.The PR also moves
getErrorRangeForArrowFunction
andGetErrorRangeForNode
frombinder.go
toscanner.go
(where other similar functions reside).