Groovy
  1. Groovy
  2. GROOVY-3481

Groovy Support for annotations on local variable declarations

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7-beta-1
    • Fix Version/s: 1.7.0
    • Component/s: ast builder
    • Labels:
      None
    • Environment:
      All

      Description

      Groovy should support annotations on local variable declarations. It is syntactically legal to annotate a local variable, but the AST produced does not carry that annotation.

      My use case with the AST builder. Either we'd like to annotate a local variable, like this:

      @AstSource(CompilePhase.CONVERSION)
      def source = { println "compiled on: ${new Date()}" }
      

      Or annotate a property within a closure (which is a DeclarationExpression), like this:

      def result = new AstBuilder().build {
                 phase = CompilePhase.CONVERSION
                 @AstSource
                 source = { println "compiled on: ${new Date()}" }
       }
      

      A getAnnotations() method should probably be added to DeclarationExpression to support this.

        Issue Links

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development