Problem with @DelegatesTo

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with @DelegatesTo

will_lp
Hey there! I'm having problems with @DelegatesTo on eclipse, if somebody can help, please.

I have two files in the same package. Deleg.groovy:

    @TypeChecked
    class Deleg {
      static main(args) {
        new Email().write {
          message = "my message" // Here eclipse says: Groovy:[Static type checking] - The variable [message] is undeclared.
          send "a@a.com" // Here eclipse says: Groovy:[Static type checking] - Cannot find matching method br.gov.seed.siget.util.Deleg#send(java.lang.String). Please check if the declared type is right and if the method exists.
        }
      }
    }

And Email.groovy:

    @TypeChecked
    class Email {
      String message
      def send(String dest) { println "sending '$message' to $dest" }
     
      def write(@DelegatesTo(Email) Closure c) {
        def sender = c.rehydrate this, this, this
        sender()
      }
    }


The code runs fine in command line. This works in eclipse if both classes are in the same file. The autocomplete in Deleg identifies the available methods in the Email class.


My setup:

Ubuntu 12.04 x86

Eclipse Juno IDE for Java EE Developers    1.5.2.20130211-1820    epp.package.jee
Version: Juno Service Release 2
Build id: 20130225-0426

$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode

My groovy-eclipse is from http://dist.springsource.org/snapshot/GRECLIPSE/e4.2/.
Version: Groovy-Eclipse Feature    2.9.0.xx-20130930-1400-e42-RELEASE

This is a Java EE project (EJB/EJB-client/Web modules) and i'm trying to use this in the Web module. I created a new Groovy Project and the error persists (though it executed correctly in the first time, but now it only throws compilation error).

The "Groovy compiler level for project" is 2.1, as well as the workspace compiler level.

I've read Andrew's mail stating groovy-eclipse supports 2.1's @DelegatesTo, so i'm probably doing something dumb here.


Any help is appreciated. Thanks.