Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ahejlsberg merged 2 commits intomainfrommore-go-to-def
Jul 17, 2025

Conversation

ahejlsberg
Copy link
Member

@ahejlsbergahejlsberg commentedJul 15, 2025
edited
Loading

This PR implements

  • Go-to-def onoverride keyword selects the overridden method declaration.
  • Go-to-def on a modifier or keyword that starts a declaration works the same as go-to-def on the declaration name.
  • Go-to-def on label inbreak orcontinue statement selects the label definition.
  • Go-to-def oncase ordefault keyword selects the containingswitch statement.
  • Go-to-def onreturn,yield orawait keyword selects the containing function declaration.
  • Go-to-def on a call expression selects the the signature chosen by overload resolution.
  • Go-to-def on a property in an object literal with a contextual type selects the declaration in the contextual type.
  • Go-to-def on a property with no explicit declaration selects the index signature(s) for the property.
  • Go-to-type-definition on a variable or property selects the associated type(s).
  • Go-to-type-definition on a variable with a generic type such asT[] selects both declarations ofT andArray.

The PR also movesgetErrorRangeForArrowFunction andGetErrorRangeForNode frombinder.go toscanner.go (where other similar functions reside).

@CopilotCopilotAI review requested due to automatic review settingsJuly 15, 2025 20:27
Copy link
Contributor

@CopilotCopilotAI left a 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
FileDescription
internal/scanner/scanner.goMovedGetErrorRangeForNode function from binder and simplifiedGetTokenPosOfNode
internal/lsp/server.goAdded type definition endpoint handling and server capability registration
internal/ls/utilities.goUpdated range creation to use token position and fixed label handling return type
internal/ls/findallreferences.goUpdated label reference functions to work with generic nodes instead of identifiers
internal/ls/definition.goMajor expansion with keyword-based definitions, call resolution, and type definition implementation
internal/checker/utilities.goUpdated diagnostic creation to use scanner's error range function
internal/checker/services.goAdded contextual declarations and type argument extraction utilities
internal/checker/exports.goExported new checker methods for index signatures and symbol resolution
internal/checker/checker.goImplemented index signature location resolution
internal/binder/binder.goRemovedGetErrorRangeForNode function (moved to scanner)
internal/ast/ast.goAddedIsSwitchStatement helper function

"Required": {},
"Readonly": {},
"Pick": {},
"Omit": {},
Copy link
Member

@RyanCavanaughRyanCavanaughJul 15, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
"Omit": {},
"Omit": {},
"Exclude": {},

Copy link
MemberAuthor

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 andExtract are almost always used with (unions of) literal types, and we don't record source locations for those.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

However, we should includeNonNullable<T>.

@ahejlsbergahejlsberg added this pull request to themerge queueJul 17, 2025
Merged via the queue intomain with commit4fd6eb1Jul 17, 2025
22 checks passed
@ahejlsbergahejlsberg deleted the more-go-to-def branchJuly 17, 2025 22:15
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@RyanCavanaughRyanCavanaughRyanCavanaugh approved these changes

@DanielRosenwasserDanielRosenwasserAwaiting requested review from DanielRosenwasser

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ahejlsberg@RyanCavanaugh

[8]ページ先頭

©2009-2025 Movatter.jp