groovy
  1. groovy
  2. GROOVY-3653

CodeVisitorSupport should support visiting classes of type Variable, not just ASTNode

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.7-beta-1
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      All
    • Number of attachments :
      0

      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.

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Hamlet D'Arcy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 4 hours
              4h
              Remaining:
              Remaining Estimate - 4 hours
              4h
              Logged:
              Time Spent - Not Specified
              Not Specified