Skip to end of metadata
Go to start of metadata

We have just released Groovy-Eclipse 2.0.2. This release includes a number of exciting new features, Groovy 1.7.3, and fixes for over 80 jira issues. For this release, we have two streams available: an Eclipse 3.5 (Galileo) stream and an Eclipse 3.6 (Helios) stream. To install 2.0.2, you can add one of the following release URLs to your Eclipse update manager:

Groovy-Eclipse update site for Eclipse 3.5


Groovy-Eclipse update site for Eclipse 3.6


The theme of this release is Refactoring, Refactoring, Formatting.


Refactoring support

For this release, we have done some work on refactoring. In the past, there was a separate Groovy Refactoring menu, which was the only place Groovy refactorings could be invoked from. Now, we have integrated the refactorings into the JDT refactoring support. Now, Groovy refactorings can be invoked using the same keyboard commands and menu items as their Java counterparts.

Extract Local Variable Refactoring

The extract local variable refactoring allows programmers to select an expression and convert it into a local variable:

  • Initial code:
  • This refactoring also supports replacing all occurrences of the expression:
  • Preview:
  • See the results:

The keyboard binding for this refactoring is the same as it is for the Java variant of the refactoring (e.g., CMD-Alt-L on Macs).

Extract Constant Refactoring

Extract constant expression allows a programmer to select a static expression, and pull it out as a constant in the current class. This refactoring is also available from the refactoring context menu.

  • To invoke this refactoring, select a static expression and select the Extract Constant... refactoring:

  • In the refactoring wizard, you can choose to replace all occurrences with the constant, and you can also choose to qualify references to the constant with the class name. Also notice that the refactoring provides a reasonable suggestion for an initial name:

  • As with extract local, you can see the preview:

  • And the result is what you would expect with all text properly replaced:

There are two caveats to be aware of:

  • Extract constant inside of scripts is disallowed
  • All sub-expressions of the expression to extract must be static

Extract Method Refactoring

Extract method refactoring was available in version 2.0.0 and earlier, but was removed for 2.0.1 because it depended on deprecated internal APIs that had been removed.

  • For 2.0.2, we have reimplemented extract the method refactoring and linked it to the standard Java method refactoring in the editor:

  • This refactoring supports reordering and renaming of the parameters of the extracted method:

  • As expected, the result properly extract the selected statements into a new method, taking into account new parameters and the return statement:

The limitations to this refactoring are the following:

  • Only complete statements or groups of complete statements can be refactored.
  • Multiple return values are not supported.

Rename Refactoring

Although originally introduced in the 2.0.1 version, rename refactoring is now available from the context menu:

And the menu bar:

or keyboard commands (e.g., Alt-CMD-R on Macos).

Groovy Editor

Code Formatting and Indentation

In this release, we focused on fixing issues that directly affect a user's day-to-day experience, such as typing, copying and pasting. We have integrated a number of "smart" editing transformations into the Groovy Editor. In the past, we inherited some of the Java-like editing transformations, which would sometimes fail due to incompatibilities between the Groovy and Java grammars.

In this release we are providing a new groovy-specific implementations for three smart editor features:

  • Smart paste: attempt to preserve relative indentation of code pasted into a Groovy editor.
  • Smart newline: try to put the cursor in a sensible place after the user presses newline.
  • Smart tab: correct the indentation of the current line when pressing tab at start of a line.

Like their Java counterparts, these implementations rely on heuristics rather than a full parser, so they should work even when the document in the editor is not parsable. These implementations are brand new and we are looking forward to getting your feedback on how to make them work better and polish them up.

Besides these "on-line" algorithms that get invoked while typing and pasting. The Groovy editor also provides an "off-line" formatter that can be invoked explicitly by pressing CTRL-I or CTRL-SHIFT-F. Numerous bugfixes and small improvements have been made to the of-line Groovy formatter and indentor as well.


The Groovy editor now properly recognizes GroovyDocs in Groovy code. This means you will now have the same support for highlighting and editing GroovyDoc as for JavaDoc in the Java editor. This includes content assist for GroovyDoc tags and Groovy classes.

Expand and contract selection

An often-requested feature has been to implement expand and contract selection from within the Groovy editor. This is now available, and uses the same keyboard combination as expand/contract selection in the Java editor uses:

You can use the Expand Selection to -> Enclosing Element command to select the surrounding expression, statement or declaration, and then you can return to the previous selection by using the Expand Selection to -> Restore Last Selection command (keyboard shortcuts vary across OS's, and see previous screenshot for the shortcuts on Macs).

As an example:



Better AST Transform support

In previous versions of Groovy-Eclipse, AST Transforms would often mangle source code and source locations to the extent that the Groovy Editor could no longer find the lexical location of Groovy code elements. We have solved this problem in 2.0.2. For more information, see GRECLIPSE-617.

What's next?

The Groovy-Eclipse team will continue to work on improving the development experience of writing Groovy code in Eclipse as we move towards the 2.1.0 release in early Autumn. You can find more details on the Groovy-Eclipse Roadmap, where you can comment on proposed features and see our release schedule.

We appreciate all the community support and feedback we have had through the version 2.0.2 development cycle. If you wish to join the discussion about Groovy-Eclipse then please sign up for the mailing list. For any issues you have (or enhancements you'd like to see), please raise them in our issue tracker.

  • No labels