Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

This page contains some coding conventions for the Groovy-Eclipse project.

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:

  • Add the copied file to the jdt_patch source folder in the plugin. (If this doesn't exist yet, then create it.)
  • Change the package name by prefixing 'greclipse." to the package. Do not change the type name.
  • First line of the file should describe where it comes from (fully qualified name, plugin, etc).
  • If there are visibility problems that mean you cannot change the package name, then leave the package as is and suffix the type name with PATCH. This should be a last resort.
  • Surround all changes (apart from the package statement and imports) with "// GROOVY start" and "// GROOVY end"
  • If suitable, add a textual description of why you are doing what you are doing after "// GROOVY start"
  • If you have been really keen include the bugzilla entry raised against JDT related to the change you are making "prNNNNNN"
  • Where you are replacing existing code with new code, use this format:

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.

Code formatting, templates, and code cleanups

Please import the following files into your Eclipse preferences and use these when making changes to the GRECLIPSE project.

GRECLIPSE code formatting
Code cleanups
Code templates

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) )

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):


  • No labels