Skip to content

implement getContextNode for ForOf, ForIn, and Switch statements#4450

Open
aamoghS wants to merge 1 commit into
microsoft:mainfrom
aamoghS:fix/context-node-for-switch-forin-forof
Open

implement getContextNode for ForOf, ForIn, and Switch statements#4450
aamoghS wants to merge 1 commit into
microsoft:mainfrom
aamoghS:fix/context-node-for-switch-forin-forof

Conversation

@aamoghS

@aamoghS aamoghS commented Jun 26, 2026

Copy link
Copy Markdown

This PR fixes a bug where getContextNode returns nil for ForOfStatement, ForInStatement, and SwitchStatement, which caused cross-project Find All References and Go To Definition to fail in certain contexts. The fix aligns the Go port more closely with the original TypeScript compiler.

Copilot AI review requested due to automatic review settings June 26, 2026 02:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes language-service context determination for ForOfStatement, ForInStatement, and SwitchStatement nodes so getContextNode no longer returns nil, addressing failures in cross-project Find All References and Go To Definition in those syntactic contexts and bringing behavior closer to upstream TypeScript.

Changes:

  • Implemented getContextNode handling for ForOfStatement and ForInStatement by returning the statement node instead of nil.
  • Implemented getContextNode handling for SwitchStatement by returning the statement node instead of nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants