[apex] Make apex visitor generic#2661
Merged
Merged
Conversation
Generated by 🚫 Danger |
This was referenced Aug 7, 2020
adangel
reviewed
Aug 22, 2020
| /** | ||
| * @author Clément Fournier | ||
| */ | ||
| public class ApexParserVisitorReducedAdapter extends ApexParserVisitorAdapter { |
Member
There was a problem hiding this comment.
Since we deleting this on pmd7, should we deprecate this on pmd6?
Member
Author
There was a problem hiding this comment.
Yes, I think the equivalent is already deprecated in the Java module
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.
Describe the PR
Make the apex visitor generic. This also changes some conventions:
The method
visit(ApexNode<?> node, P data)is now calledvisitApexNode. This avoids overloading all the othervisitmethods, so that it is clearer what method gets called.visit((ApexNode<?>) node, data), now you can callvisitApexNode(node, data). You can't mess it up anymore, and mistakenly forget the cast, which would select another overloadacceptVisitorcannot select visitApexNode by mistake now. This spots cases, where we add a node and forget to add a method to the visitor. This mistake was present forASTApexFile(refs [apex] Make apex have a single RootNode #2491):jjtAcceptwas copypasted and calledvisitor.visit(node, data).ASTApexFile, so the selected overload was the defaultvisitApexNodebehavior, but this was silent.Similarly, the implementation of
acceptVisitorwith the more specificApexVisitorparameter is namedacceptApexVisitorto avoid overload selection conflicts, that need to be resolved through caststhe umbrella
visitmethods, eg the common method to whichvisit(ASTUserClassandvisit(ASTUserInterfacedelegate, is also renamed so as not to overload othervisitmethods. Eg here it's calledvisitTypeDecl.With this scheme
visitacceptVisitorcode, then it will fail to compile and warn us that the visitor needs a new methodvisitTypeDecl,visitApexNode,visitNodeI think this naming scheme should be used in other modules too. Especially with the newer java grammar, where there are a few more instances of visitor method delegation (eg for expressions, etc)
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by travis)