Groovy unresolved expression - inspection + compilation error?

Hi,

I'm fairly new to Groovy and was wondering about IntellIJ's support for unresolved Groovy expression's

I'm currently undergoing a fairly sizable refactor on a fairly large codebase, and as a result some of my groovy references are now unresolved.

I think I have been pushing the extent of IntelliJ's groovy capability with what I'm trying to do -- I'd appreciate if someone has any more tips to offer.

Inspections

  • With IntelliJ current functionality, I've changed my inspection so that unresolved expressions show as an error.  However it appears this is only enabled on a per project basis -- is there a way to get this to be a global setting?


Compilation

  • Is there an inspection / setting where I can make unresolved Groovy references throw a compile error?  It seems that if IntelliJ is smart enough to know that my spring bean app context references are not correct and gives me compilation errors / warnings, this should be available for Groovy as well?


Thanks

7 comments
Comment actions Permalink

1. There is a global default inspection profile (Default in the combobox in Inspections settings page). You could use it and modify as you need to.

2. No, currently there isn't a compile-time validation support for Groovy. You have at least the following options:
- use Groovy++ (http://code.google.com/p/groovypptest/)
- file a YouTrack request
- contribute to IDEA yourself to get the desired functionality

Though I must warn you that compile-time validation doesn't come for free. It leads to great lags during compilation which may slow the IDE responsiveness during, for example, typing

0
Comment actions Permalink

Hi Peter,

Thanks for the suggestions.  I'm downloading groovy right now.

I've been searching around for an intellliJ press release, etc. regarding groovy++ features but can't find one.

Just another couple of questions:
- does IntelliJ groovy++ functionality work seamlessly with IntelliJ groovy features?
- is hot swap supported with groovy++ in Intellij?

Thanks

0
Comment actions Permalink

Sure. If you spot any problems, don't hesitate to report them

0
Comment actions Permalink

Guy,

If you don't have any tests for your code, then I suggest you tread lightly and be fearful.

Groovy is a dynamic language. There will always be times where a variable cannot be resolved and that is perfectly OK at compile time. Your post says you’re considering Groovy++, but that is not always a drop in replacement for Groovy. It is a slightly different language with slightly different semantics than Groovy. If you do not have test coverage on your code, then I think swapping out Groovy for Groovy++ is a bad idea because there will be differences in behavior at runtime. It is like trying to swap out Java for Groovy… yes it is possible, but there are different semantics in the language around types and conversions (like BigDecimal stuff). I would be scared to do this myself without an extensive battery of tests. But perhaps I am wrong, and the current state of Groovy++ has no semantic differences with Groovy, however to my knowledge it does.

As for unresolved references… you’re making a big refactoring without tests. My advice is to spend some time writing high level acceptance tests that run before and after, then make the refactoring. Sorry, that may not be what you want to hear.

0
Comment actions Permalink

Hamlet – thanks…I’m aware of the things you are saying, but one cannot control what one inherits.

Personally, I think this is a problem that is begging to be solved. Imagine if you can have static type compilation & checking & refactor goodness on a dynamic language?

There’s a GAP in the market for someone who is a can do as opposed to cannot do

0
Comment actions Permalink

Hi Peter,

I have been working with IntelliJ 9 with Groovy++ and all seems ok.

I'm just upgrading this morning to IntelliJ 10, and I did not re-import my settings.  So while re-adding my settings, the Groovy++ plugin option is no longer available for IntelliJ 10.  Pls advise

Screenshot attached.



Attachment(s):
intellij 10 plugins.PNG
0
Comment actions Permalink

Groovy++ support is included into Groovy plugin in IDEA 10, no need to set up anything else

0

Please sign in to leave a comment.