-
Notifications
You must be signed in to change notification settings - Fork 150
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
Add full_name to ConstantPathNode
and ConstantPathTargetNode
#1619
Add full_name to ConstantPathNode
and ConstantPathTargetNode
#1619
Conversation
Ahh yeah these methods should go in node_ext.rb |
30c98be
to
f53f3b2
Compare
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.
I added a couple of suggestions that I think will make this easier to maintain.
Right now we're duplicating the logic to extract the full name between the target and the path nodes. If we share it, it will only be in one place, which is slightly nicer.
I'd like to also split up the logic between extracting the names versus joining them with ::
. I've seen a couple of use cases where we want just the symbols, and it'll be easier if we provide them without having to split on ::
again.
Also, would you mind adding documentation for these methods?
9e30d43
to
d506704
Compare
d506704
to
375234f
Compare
lib/prism/node_ext.rb
Outdated
@@ -52,4 +52,48 @@ def options | |||
o | |||
end | |||
end | |||
|
|||
class ConstantReadNode < Node | |||
# Returns the list of parts for the full name of this constant. For example: ["Foo"] |
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.
Last thing, these examples should have symbols in the arrays
375234f
to
b390553
Compare
Add
full_name
to bothConstantPathNode
andConstantPathTargetNode
, so that one can easily figure out the complete name of the constant being referenced.