-
Notifications
You must be signed in to change notification settings - Fork 807
Consistently map reparsed JSDoc nodes in GetReparsedNodeForNode
#2586
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
DanielRosenwasser
left a comment
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.
Looks like there are some nice improvements on find-all-references/go-to-definition, so that's great.
Can you add both examples (the original repro from the issue, and the one you are trying to fix with the parent cache) to the test suite?
Would you say that generally all exposed checker methods should guard on nodes and try to get the reparsed node?
internal/ast/ast.go
Outdated
| key := TokenCacheKey{Loc: loc, Parent: parent} | ||
| if token, ok := node.tokenCache[key]; ok { |
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.
Do we know precisely what was happening that requires caching on the parent?
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.
Yes, I'm realizing that the completions logic is asking for tokens in both JSDoc comments and their reparsed clones. Such nodes have the same location but different parents. I'm changing the logic to only ask for tokens in the original JSDoc nodes. That will then allow me to get rid of the parent in the cache key.
| // === /foo.js === | ||
| // /** | ||
| // * @overload | ||
| // * @param {number} [|x|] |
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.
Not sure if this is a regression - what changed here?
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
@copilot try again |
|
@DanielRosenwasser I've opened a new pull request, #2588, to work on those changes. Once the pull request is ready, I'll request review from you. |
With this PR we track reparsed clones of JSDoc nodes such that
ast.GetReparsedNodeForNodecan consistently map from JSDoc nodes to their reparsed clones (which are the ones that are assigned symbols by the binder). The PR changes thechecker.GetSymbolAtLocationandchecker.TryGetThisTypeAtExfunctions to useast.GetReparsedNodeFromNode.Fixes #2490.