Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.7-beta-1
-
None
-
None
-
All
Description
CodeVisitorSupport is an abstract class that is used as a Visitor Pattern over a tree of ASTNode elements. It provides hooks to intercept almost all subtypes of ASTNode.
When walking AST, some of the nodes are ASTNode subtypes, and some are Variable subtypes. And the Variable interface has a method called getInitialExpression() which returns an Expression (ASTNode subtype).
So, it is common when walking the tree to want to walk through a Variable and into the initial values nodes. HOwever, the visitor doesn't have a visit method for any of the Variable types. I've hit this issue twice and handrolled my own solution both times.
We should add visit methods to CodeVisitorSupport to make walking through Variables easier. This should not affect deployed subclasses of CodeVisitorSupport.
We should not add it to GroovyCodeVisitor because that is an interface and would break backwards compatibility.