Skip to content

Remove extra sourceFile for findRightmostNode #499

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

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/astnav/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func getTokenAtPosition(
// Check if the rightmost token of prevSubtree should be returned based on the
// `includePrecedingTokenAtEndPosition` callback.
if prevSubtree != nil {
child := findRightmostNode(prevSubtree, sourceFile)
child := findRightmostNode(prevSubtree)
if child.End() == position && includePrecedingTokenAtEndPosition(child) {
// Optimization: includePrecedingTokenAtEndPosition only ever returns true
// for real AST nodes, so we don't run the scanner here.
Expand Down Expand Up @@ -182,7 +182,7 @@ func getPosition(node *ast.Node, sourceFile *ast.SourceFile, allowPositionInLead
return scanner.GetTokenPosOfNode(node, sourceFile, true /*includeJsDoc*/)
}

func findRightmostNode(node *ast.Node, sourceFile *ast.SourceFile) *ast.Node {
func findRightmostNode(node *ast.Node) *ast.Node {
var next *ast.Node
current := node
visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node {
Expand Down