Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6968

Improve @ASTTest to support multiple phases

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4.0-beta-2
    • None
    • None

    Description

      @ASTTest allows checking the state of the AST at one phase, but sometimes it would be nice to do the same at various phases. It would be nice to check that if "phase" is absent, then it means run at all phases.

      An example:

      import groovy.transform.ASTTest
      import groovy.transform.CompileStatic
      import groovy.transform.Immutable
      import org.codehaus.groovy.ast.ClassNode
      import org.codehaus.groovy.control.CompilePhase
       
      @ASTTest(value={
          println "Compile phase: $compilePhase"
          ClassNode cn = node
          System.err.println "Global AST xforms: ${compilationUnit.ASTTransformationsContext.globalTransformNames}"
          CompilePhase.values().each {
              def transforms = cn.getTransforms(it)
              if (transforms) {
                  System.err.println "Ast xforms for phase $it:"
                  transforms.each { map ->
                      System.err.println(map)
                  }
              }
          }
      })
      @CompileStatic
      @Immutable
      class Foo {
      }
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: