AST: starting visiting comments#13421
Merged
MarcusDenker merged 9 commits intopharo-project:Pharo12from Apr 14, 2023
Merged
Conversation
because comments can be outside, and testing out of range is also nice
Custom visitors hijacking the visitor infrastructure is bad
Member
|
YES! \0/ This is on my todo list since 4 years now (but not enough time…). Thank you :) |
78 tasks
MarcusDenker
approved these changes
Apr 14, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tries to make comments, first-class citizens of the AST. Or at least second-class citizens... Still better than the cargo hold.
This includes:
childrenAndCommentsto have both (direct) children and (direct) commentsnodesDo:(and related) visit commentsnodeForOffset:can return a comment nodevisitCommentNode:to theRBProgramNodeVisitor.The first three should be safe since clients using them cannot expect specific nodes and just select what they need.
The last one should also be safe because comments are not automatically visited (yet!), but it might allow custom clients to use the hook for custom visit.
The API of
RBProgramNodeVisitorneed love, but there are a lot of clients, so it's not simple to improve it.Maybe a simpler approach could be having a second visitor, then switch clients one by one.