views:

317

answers:

2

I've been using the newest version of the groovy eclipse plugin (for eclipse 3.4) and I noticed that when I run organize imports on the file, it actually removes some of the imports that I need. It seems to remove the ones in my project, not java.* imports. Any ideas why?

thanks, Jeff

+1  A: 

That may be related to the underlying JDT "organize import" mechanism, which does have some issue in eclipse3.4:

  • bug 87950: issue with type inferencing -- which is important with groovy, combined with
  • bug 235253: Organize imports removes needed import statement -- unresolved in 3.4.
  • bug 252379: Organize imports deletes needed static import -- unresolved in 3.4(.1)

Can you make the Groovy plugin work in eclipse3.5, and if yes, do you still have the same issue?
If you do, one of those bugs need to be completed/reactivated.

VonC
I'll upgrade to Eclipse 3.5 and give it a try. Thanks.
Jeff Storey
I thought it was fixed, turns out it's not. It happens when I run organize imports and format from the project's top level
Jeff Storey
+3  A: 

This functionality has been fixed in the 3.5 stream of the Groovy Eclipse plugin. Or at least it is fixed when running organize imports from the editor. So, running Ctrl-Shift-O inside the editor, or running format after save will work. However, running Organize imports from the package explorer or any other view will not.

The reason for this is that we need a way to hook in special groovy functionality. When running organize imports from inside the editor, this is possible to do. Hwoever, we have not figured out a general way to co-opt JDT's organize imports when running outside the editor. It is worth raising a bug for this. http://jira.codehaus.org/greclipse

Before the release of 2.0.0M1 (before the end of September), we will port this functionality back to 3.4, but we are finding that not many people are using 3.4, so we have not kept it up to date with the 3.5 stream.

Andrew Eisenberg
To confirm, it does work from ctrl-shift-o does in fact work, but the organize imports from the package explorer does not. I tried going to the jira to open a bug but the site was not available.
Jeff Storey
You are correct. You cannot organize Groovy Imports from the Package explorer. When you do it from here, the JDT organize imports is executed. We have not yet implemented that part of the plugin (it isn't quite as easy as it sounds).Stupid jira server. It has been going up and down for days (still doing so). It is up now.
Andrew Eisenberg