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

@ASTTest AST transformation

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0-beta-3
    • None
    • None

    Description

      When we develop AST transformations, it is often difficult to check that a particular transformation performs what is necessary. For example, we would like, in type checking, to verify that after the type checker has performed its work, a particular AST node contains metadata about the inferred type. Checking this currently requires compilation trickery which is not user-friendly. We propose to add an AST transformation which allows embedding tests. For example, we could test the @Field AST transformation this way:

      import groovy.transform.*
      
      @ASTTest(value = {
          def owner = node.declaringClass
          assert owner.fields.any { it.name == 'x' }
      }
      @Field int x
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: