Skip to content
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

Catchup with ConstantPathNode change #27

Merged
merged 2 commits into from
May 5, 2024

Conversation

tompng
Copy link
Member

@tompng tompng commented May 4, 2024

In prism-0.28.0, ConstantPathNode#child is deprecated

Prism.parse('A::B').value.statements.body.first.child
# DEPRECATED: ConstantPathNode#child is deprecated and will be removed in the next major version. Use ConstantPathNode#name/ConstantPathNode#name_loc instead. Called from (irb):1:in `<top (required)>'.
=> 
@ ConstantReadNode (location: (1,3)-(1,4))
└── name: :B

And ConstantPathNode#child does not appear in child_nodes anymore.

Prism.parse('A::B').value.statements.body.first.child_nodes
=>
[@ ConstantReadNode (location: (1,0)-(1,1))
 └── name: :A]

# it was
[@ ConstantReadNode (location: (1,0)-(1,1))
 └── name: :A]
[@ ConstantReadNode (location: (1,3)-(1,4))
 └── name: :B]

So completion target node search for constant path completion is failing now. This pull request fixes it.

ConstantPathNode#child is deprecated and does not appear in child_nodes
@@ -1042,7 +1043,8 @@ def evaluate_write(node, value, scope, evaluated_receivers)
scope[node.name.to_s] = value
when Prism::ConstantPathTargetNode
receiver = evaluated_receivers&.[](node.parent) || evaluate(node.parent, scope) if node.parent
const_path_write receiver, node.child.name.to_s, value, scope
name = node.respond_to?(:name) ? node.name.to_s : node.child.name.to_s
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Feels like this could be a helper method?

@tompng tompng merged commit 1e93b22 into main May 5, 2024
34 checks passed
@tompng tompng deleted the catchup_with_constant_path_node_change branch May 5, 2024 07:23
@tompng tompng mentioned this pull request May 5, 2024
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.

None yet

2 participants