Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Compiler Integration
    • Labels:
    • Environment:
      Eclipse 3.7; Groovy-Eclipse plugin Version: 2.5.1.xx-20110628-1600-e37
    • Number of attachments :
      0

      Description

      The following code:

      import groovy.transform.Field
      
      @Field List awe = [1, 2, 3]
      def awesum() { awe.sum() }
      assert awesum() == 6
      

      leads to error in the editor: 'Groovy:Error: annotation @Field can only be used within a Script body.'. When creating Groovy Class, I marked 'Create Script' checkbox.

        Issue Links

          Activity

          Hide
          Andrew Eisenberg added a comment -

          I am not seeing the editor problem that you are. I am running on the latest dev snapshot where things may have changed a bit. However, in the editor an in the inferencing engine, the @Field transform has not been applied. Currently, this is by design since there are many transforms out there that are not well behaved (such as @Lazy). Applying them in the editor will break editing functionality. We are considering a way to selectively run some transforms in the editor. See GRECLIPSE-1179.

          That being said, is the compiler problem that you are seeing only appearing in the editor or do you see it in the problems view as well?

          Show
          Andrew Eisenberg added a comment - I am not seeing the editor problem that you are. I am running on the latest dev snapshot where things may have changed a bit. However, in the editor an in the inferencing engine, the @Field transform has not been applied. Currently, this is by design since there are many transforms out there that are not well behaved (such as @Lazy). Applying them in the editor will break editing functionality. We are considering a way to selectively run some transforms in the editor. See GRECLIPSE-1179 . That being said, is the compiler problem that you are seeing only appearing in the editor or do you see it in the problems view as well?
          Andrew Eisenberg made changes -
          Field Original Value New Value
          Link This issue depends upon GRECLIPSE-1179 [ GRECLIPSE-1179 ]
          Hide
          Dominik Leszyk added a comment -

          Compiler problem appears in both: in the editor (error marker) and in the Problems view. Previously I haven't bothered to run this script but now I see it works when started with Run As Groovy Script.

          Show
          Dominik Leszyk added a comment - Compiler problem appears in both: in the editor (error marker) and in the Problems view. Previously I haven't bothered to run this script but now I see it works when started with Run As Groovy Script.
          Andrew Eisenberg made changes -
          Labels web
          Andrew Eisenberg made changes -
          Component/s Compiler Integration [ 14686 ]
          Andrew Eisenberg made changes -
          Labels web wish
          Andrew Eisenberg made changes -
          Labels wish stability
          Andrew Eisenberg made changes -
          Fix Version/s 2.8.0.Release [ 18618 ]
          Andrew Eisenberg made changes -
          Assignee Andrew Eisenberg [ werdna ]
          Hide
          Andrew Eisenberg added a comment -

          It will be possible to get this working by enabling a few flags internally to ensure AST transforms are run during reconcile and then to add this transform to your project build settings. I added a 2.8.0 resolve version to see if we should enable this by default.

          Show
          Andrew Eisenberg added a comment - It will be possible to get this working by enabling a few flags internally to ensure AST transforms are run during reconcile and then to add this transform to your project build settings. I added a 2.8.0 resolve version to see if we should enable this by default.
          Hide
          Andrew Eisenberg added a comment -

          So, if you manually edit your project's .settings/org.eclipse.jdt.core.prefs file and add a line like this:

          org.eclipse.jdt.core.compiler.groovy.groovyTransformsToRunOnReconcile=org.codehaus.groovy.transform.FieldASTTransformation
          

          You will get it to work. But, only after I make a change in Groovy-Eclipse to respect that setting.

          Show
          Andrew Eisenberg added a comment - So, if you manually edit your project's .settings/org.eclipse.jdt.core.prefs file and add a line like this: org.eclipse.jdt.core.compiler.groovy.groovyTransformsToRunOnReconcile=org.codehaus.groovy.transform.FieldASTTransformation You will get it to work. But, only after I make a change in Groovy-Eclipse to respect that setting.
          Andrew Eisenberg made changes -
          Fix Version/s 2.9.0.Release [ 19323 ]
          Fix Version/s 2.8.0.Release [ 18618 ]
          Kris De Volder made changes -
          Assignee Andrew Eisenberg [ werdna ]
          Kris De Volder made changes -
          Fix Version/s 2.9.0.Release [ 19323 ]
          Hide
          Denis Murashev added a comment -

          Looks like already fixed (at least in version 2.9.0.RELEASE).

          Show
          Denis Murashev added a comment - Looks like already fixed (at least in version 2.9.0.RELEASE).
          Denis Murashev made changes -
          Labels stability stability triaged

            People

            • Assignee:
              Unassigned
              Reporter:
              Dominik Leszyk
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: