Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0-rc-3
    • Component/s: stub generation
    • Labels:
      None
    • Number of attachments :
      1

      Description

      Groovy files that contain code outside of a class definition result in grammar-errors. Errors that I've witnessed include
      Unknown AST: VARIABLE_DEF
      Unknown AST: EXPR
      Unknown AST: ASSERT

      The attached file contains a minimalistic maven project that reproduces the error when running
      mvn compile

        Activity

        Hide
        Bart Robeyns added a comment - - edited

        That was actually the error using the old groovy-maven-plugin. The new gmaven (org.codehaus.groovy.maven:gmaven-plugin:jar:1.0-rc-3-SNAPSHOT) essentially gives the same error, but in a different format: Unexpected node: Node[1:1,27,EXPR]

        Show
        Bart Robeyns added a comment - - edited That was actually the error using the old groovy-maven-plugin. The new gmaven (org.codehaus.groovy.maven:gmaven-plugin:jar:1.0-rc-3-SNAPSHOT) essentially gives the same error, but in a different format: Unexpected node: Node [1:1,27,EXPR]
        Hide
        Jason Dillon added a comment -

        Um... I'm really not sure what the desired behavior is here when giving a groovy-script to the stub-compiler. I mean, the bits in there are intended to be transformed into Java-compatible thingys. Anyways, I'm not sure at the moment what the proper way to generate a stub for this is. I suppose it should be possible to support, but not IMO its not very meaningful.

        Show
        Jason Dillon added a comment - Um... I'm really not sure what the desired behavior is here when giving a groovy-script to the stub-compiler. I mean, the bits in there are intended to be transformed into Java-compatible thingys. Anyways, I'm not sure at the moment what the proper way to generate a stub for this is. I suppose it should be possible to support, but not IMO its not very meaningful.
        Hide
        Bart Robeyns added a comment -

        I think there are two problems at the moment:
        a: putting a script in your source-tree fails the build
        b: Scripts might contain multiple classes; while it is probably not very interesting to call the generated script-class from java-code, it might be handy to call the contained classes.

        Anyway, I think simply ignoring scripts in the stub-generator (thus solving a and ignoring b) would be easy to implement and solves a rather hard to track issue (I've spent some time figuring out what was wrong).
        If a warning along the lines of 'script X skipped for stub-generation' is displayed, any users trying to access script-contained classes can know what's wrong and can easily alter their implementation (just move the class out of the script-file).

        Show
        Bart Robeyns added a comment - I think there are two problems at the moment: a: putting a script in your source-tree fails the build b: Scripts might contain multiple classes; while it is probably not very interesting to call the generated script-class from java-code, it might be handy to call the contained classes. Anyway, I think simply ignoring scripts in the stub-generator (thus solving a and ignoring b) would be easy to implement and solves a rather hard to track issue (I've spent some time figuring out what was wrong). If a warning along the lines of 'script X skipped for stub-generation' is displayed, any users trying to access script-contained classes can know what's wrong and can easily alter their implementation (just move the class out of the script-file).
        Hide
        Jochen Hinrichsen added a comment -

        I'm running into the same problem:

        Unexpected node: Node[37:1,27,EXPR]

        even with a fresh svn co, mvn install on rc3-SNAPSHOT.

        I have a bunch of groovy files, both regular classes (public class A in A.groovy) and script snippets (println "Hello world"). Up to now i did not care about the difference, groovy just runs both types.

        Does the error mean i have to rewrite my 77 scripts with 8000+ lines to make them all proper classes?

        Show
        Jochen Hinrichsen added a comment - I'm running into the same problem: Unexpected node: Node [37:1,27,EXPR] even with a fresh svn co, mvn install on rc3-SNAPSHOT. I have a bunch of groovy files, both regular classes (public class A in A.groovy) and script snippets (println "Hello world"). Up to now i did not care about the difference, groovy just runs both types. Does the error mean i have to rewrite my 77 scripts with 8000+ lines to make them all proper classes?
        Hide
        Jason Dillon added a comment -

        I will figure out what the right stub stuff is soon... sorry, if anyone knows before I figure it out please chime in.

        Show
        Jason Dillon added a comment - I will figure out what the right stub stuff is soon... sorry, if anyone knows before I figure it out please chime in.
        Hide
        Jason Dillon added a comment -

        Almost sorted, just need to figure out how to make it less likely to cause errors for cases I'm not directly testing for.

        Show
        Jason Dillon added a comment - Almost sorted, just need to figure out how to make it less likely to cause errors for cases I'm not directly testing for.

          People

          • Assignee:
            Jason Dillon
            Reporter:
            Bart Robeyns
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: