This page contains some coding conventions for the Groovy-Eclipse project. This is still a work in progress. If you feel there are some conventions that are missing from here, please raise a jira issue for it.

We are only trying to coordinate some high level conventions that maintain the quality of the project across releases and when there are multiple developers. For anything that is not specified here, use your common sense. If you think that there is a major issue of concern, send a message to the eclipse-plugin-dev@groovy.codehaus.org mailing list.

Copying code from Eclipse and JDT

In general, we want to avoid copying code from JDT and Eclipse. Instead, the preferred way to extend or borrow Eclipse functionality is to use sub-classing and reflection. Where this approach is not possible or it is unwieldy, it may be reasonable to copy an entire file. Here are the guidelines for doing this:

// GROOVY start: ...reason for the change.. pr131072
/*{
...old code...
}*/
...new code...
// GROOVY end

This ensures comparisons and merges are easier because the old code will precisely match what is in the original file. If the old code includes /* */ comments just apply common sense and think what will be easiest to merge again later.

In some cases, you may want to copy code from JDT as a starting point, but you have no intention of keeping the versions synchronized across Eclipse releases. This situation is fine, but you must keep the original EPL license at the top of the file.

Code formatting, templates, and code cleanups

The Groovy-Eclipse plugins use a set of pre-defined code formatting, templates, and code cleanups. They are set in each project. Also, copies of these preferences are included in the org.codehaus.groovy.eclipse.core project. When creating a new project, be sure to use these preferences.

Task tags in code

Do not use TODO tags. Instead use something like FIXADE (where instead of ADE, use your initials). And after the FIXADE tag, you can optionally include a version number that this change should be applied to (eg- // FIXADE (2.1.0) ). You may also want to add the tag as one that is recognized by the JDT compiler. Go to: Preferences -> Java Compiler -> Task Tags and add what you need.

Error handling

In general, unless there is a good reason not to, errors should be logged to the error log. To do this, in the catch clause, add the following code:

GroovyCore.logException(String, Throwable)

And when in the org.eclipse.jdt.groovy.core project, use this instead (or one of the variants of the method):

org.eclipse.jdt.internal.core.util.Util.log(Throwable)

Jira

The version field of an issue should be the version of Groovy-Eclipse that the issue was raised against. If unknown, choose the most recently released version. If raised against the latest dev build, also choose the most recently released version.

Only assign an issue to yourself if you intend to work on it in the near future.

Mark the issue as "In Progress" once you are starting to write code.