Announcement Announcement Module
Collapse
No announcement yet.
groovy enum problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • groovy enum problem

    Hi -

    I am brand new to the STS, using it for grails development. I have a groovy enum which gets the following error from STS:

    Groovy:The class java.lang.Enum refers to the class java.lang.Enum and uses 1 parameters, but the referred class takes no parameters YAxisType.groovy

    Any ideas on why it thinks this is a java enum and not a groovy enum? Anybody else have this problem? Thanks!

    - rube

    p.s. The file contents (YAxisType.groovy):

    package com.vms.charts

    public enum YAxisType {
    HITS("Hits", "hits", ""),
    AUDIENCE("Audience", "audience", ""),
    MEDIA_VALUE("Media Value", "media_value", "\$");

    private String displayName
    private String queryColumnName
    private String prefix

    YAxisType(String displayName, String queryColumnName, String prefix){
    this.displayName = displayName
    this.queryColumnName = queryColumnName
    this.prefix = prefix
    }
    }

  • #2
    Hi,

    Are you on the latest groovy eclipse? (or which version of STS?)

    Are you just running with the default groovy 1.7 compiler configuration or have you reverted to 1.6?

    When you say you get that error, what resource is it against, is it against the enum or is it recorded against something else?

    I created a basic groovy project, defined your enum and it compiles just fine. Are you able to do the same?

    However, I half suspect there is a bug here as we have limited enum testing. I'll carry on playing to try and cause it to appear.

    cheers,
    Andy
    ---
    Andy Clement
    Groovy Eclipse

    Comment


    • #3
      Hi Andy -

      Thanks for the prompt reply.

      inline:

      [QUOTE=Andy Clement;277129]Hi,

      Are you on the latest groovy eclipse? (or which version of STS?)

      2.3.0.RELEASE

      Are you just running with the default groovy 1.7 compiler configuration or have you reverted to 1.6?

      I tried both. Neither one worked. (although i switched between them using the IDE and it says it's experimental to do it that way)

      When you say you get that error, what resource is it against, is it against the enum or is it recorded against something else?

      The resource is the file: YAxisType.groovy

      I created a basic groovy project, defined your enum and it compiles just fine. Are you able to do the same?

      I haven't tried singling out the enum. It is part of a grails project, under the src/groovy/<my domain>/YAxisType.groovy

      However, I half suspect there is a bug here as we have limited enum testing. I'll carry on playing to try and cause it to appear.

      The odd thing is that I'm also getting other errors, which I wasn't getting earlier and nothing has changed. Now it can't resolve my domain class either (my domain class does not use this enum, btw).

      I tell the IDe to ignore the problem when I debug and everything runs just fine, but it's aggravating to not be able to depend on the IDE for errors.

      Comment


      • #4
        Hi,

        Are you on the latest groovy eclipse? (or which version of STS?)
        2.3.0.RELEASE
        Sounds good, how would you feel about installing RC4 of the groovy eclipse plugin just to ensure you have the most up to date groovy support? The update site is here: http://dist.springsource.org/milestone/GRECLIPSE/e3.5/

        However, I don't know that it includes anything to address your issue, it is just our latest greatest version.

        Are you just running with the default groovy 1.7 compiler configuration or have you reverted to 1.6?
        I tried both. Neither one worked. (although i switched between them using the IDE and it says it's experimental to do it that way)
        Yes, if switching in the UI rather than 'manually' you may not successfully switch down to 1.6, you have to check back in the dialog what version it thinks it is running. If you can't make it switch via the UI it links to some instructions for doing it manually. I'd *probably* say the kind of problem you are seeing is independent of the compiler version.

        When you say you get that error, what resource is it against, is it against the enum or is it recorded against something else?
        The resource is the file: YAxisType.groovy
        I was hoping it was recorded against a resource referencing the enum, but I guess not.

        Are you able to give it a quick go singling out the enum so I can determine if it is something to do with being in a grails project?

        The odd thing is that I'm also getting other errors, which I wasn't getting earlier and nothing has changed. Now it can't resolve my domain class either (my domain class does not use this enum, btw).
        I can imagine once in an erroneous state with the enum problem, other problems could cascade on incremental builds. A full build ought to get you back to something consistent.

        I tell the IDe to ignore the problem when I debug and everything runs just fine, but it's aggravating to not be able to depend on the IDE for errors.
        Absolutely, I agree, you must be able to rely on the IDE.

        I do want to address it, it is just until I can recreate, I've really no idea what the problem might be. I'll try putting it into a grails project now.

        cheers,
        Andy

        Comment


        • #5
          works for me on sts/windows

          the code below works for me (also works in a package) on 2.3.0 relase. can be called from another groovy program.

          thanks

          public enum YAxisType {
          HITS("Hits", "hits", ""),
          AUDIENCE("Audience", "audience", ""),
          MEDIA_VALUE("Media Value", "media_value", "\$");

          private String displayName
          private String queryColumnName
          private String prefix

          YAxisType(String displayName, String queryColumnName, String prefix){
          this.displayName = displayName
          this.queryColumnName = queryColumnName
          this.prefix = prefix
          }
          public static main(args) {
          println YAxisType.values()
          }
          }

          Comment


          • #6
            Broken enum support (tested on Mac)

            Hi,

            I am also having problems with enum support in STS. Here is how to reproduce:

            1. Download and install STS 2.3.0 (Mac OS X), install Grails/Groovy STS extensions, and configure path to Groovy 1.2.1
            2. Create new Grails Project 'Test'
            3. Create the following 2 groovy domain classes in grails-app/domain:

            // File: Test1.groovy
            class Test1 {
            }

            // File: Test2.groovy
            enum Test2 {
            }

            4. Now right-click Test1.groovy in Package Explorer, and select Refactor -> Rename
            5. Try to rename to Test3.groovy, see error "An unexpected exception occurred while performing refactoring. See the error log for details"
            6. Open Plugin-Development Perspective, and see following in error log:

            java.lang.reflect.InvocationTargetException
            at org.eclipse.jface.operation.ModalContext.run(Modal Context.java:421)
            at
            [...]
            Caused by: java.lang.StackOverflowError
            at org.codehaus.groovy.ast.ClassNode.redirect(ClassNo de.java:192)
            at org.codehaus.groovy.ast.ClassNode.getName(ClassNod e.java:489)
            at org.codehaus.groovy.eclipse.refactoring.core.utils .astScanner.RefactoringCodeVisitorSupport.analyzeG enerics(RefactoringCodeVisitorSupport.java:222)
            at
            [...]

            Can you help?

            Comment


            • #7
              Hi,

              I just recreated your problem in a pure Groovy project, so it is a Groovy-Eclipse bug rather than a grails issue. I have raised it as:

              http://jira.codehaus.org/browse/GRECLIPSE-651

              cheers,
              Andy
              ---
              Andy Clement
              Groovy Eclipse Development

              Comment

              Working...
              X