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

Add full_name to ConstantPathNode and ConstantPathTargetNode #1619

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

vinistock
Copy link
Contributor

@vinistock vinistock commented Oct 3, 2023

Add full_name to both ConstantPathNode and ConstantPathTargetNode, so that one can easily figure out the complete name of the constant being referenced.

@kddnewton
Copy link
Collaborator

Ahh yeah these methods should go in node_ext.rb

@vinistock vinistock force-pushed the vs/add_full_name_to_constant_path branch from 30c98be to f53f3b2 Compare October 3, 2023 19:29
Copy link
Collaborator

@kddnewton kddnewton left a 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?

lib/prism/node_ext.rb Outdated Show resolved Hide resolved
lib/prism/node_ext.rb Outdated Show resolved Hide resolved
lib/prism/node_ext.rb Outdated Show resolved Hide resolved
@vinistock vinistock force-pushed the vs/add_full_name_to_constant_path branch from 9e30d43 to d506704 Compare October 5, 2023 20:16
@vinistock vinistock requested a review from kddnewton October 5, 2023 20:17
@vinistock vinistock force-pushed the vs/add_full_name_to_constant_path branch from d506704 to 375234f Compare October 5, 2023 20:21
@@ -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"]
Copy link
Collaborator

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

@vinistock vinistock force-pushed the vs/add_full_name_to_constant_path branch from 375234f to b390553 Compare October 5, 2023 21:09
@kddnewton kddnewton merged commit dc8279a into ruby:main Oct 6, 2023
46 checks passed
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.

2 participants