-
-
Notifications
You must be signed in to change notification settings - Fork 726
feat(ast): add MemberExpressionKind::is_assigned_to_in_parent method
#12596
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
feat(ast): add MemberExpressionKind::is_assigned_to_in_parent method
#12596
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #12596 will not alter performanceComparing Summary
Footnotes |
Merge activity
|
#12596) The removal of `AstKind::SimpleAssignmentTarget` (#12401) has made it harder to determine if a node is being assigned to, because you can no longer check if the parent `AstNode` is `AstKind::SimpleAssignmentTarget`. Add a method to `MemberExpressionKind` which determines whether the parent assigns to it. Covers all possible positions where a `MemberExpression` gets assigned to - `x.y = value`, `x.y++`, `[x.y] = arr` etc. We can use this method to avoid repeating this complicated logic in many places.
c957caa to
c763e0e
Compare
3279c53 to
106f56f
Compare
…thod (#12597) Similar to #12596. Add a method `AstKind::ident_reference_is_assigned_to_in_parent`. Given an `AstKind` representing an `IdentifierReference`, and an `AstKind` representing its parent, this method determines whether the identifier is being assigned to. Covers all possible positions where an `IdentifierReference` gets assigned to - `x = value`, `x++`, `[...x] = arr` etc. Note: This method is slightly different to `MemberExpressionKind::is_assigned_to_in_parent` - it includes additional match arm for `AssignmentTargetPropertyIdentifier` as parent. This can't be parent of a `MemberExpression`, but *can* be the parent of an `IdentifierReference`.

The removal of
AstKind::SimpleAssignmentTarget(#12401) has made it harder to determine if a node is being assigned to, because you can no longer check if the parentAstNodeisAstKind::SimpleAssignmentTarget.Add a method to
MemberExpressionKindwhich determines whether the parent assigns to it. Covers all possible positions where aMemberExpressiongets assigned to -x.y = value,x.y++,[x.y] = arretc.We can use this method to avoid repeating this complicated logic in many places.