Saturday, October 3, 2009

AJDT 2.0.1 is released!

Overview

In this service release of AJDT, we have included a number of performance enhancements, as well as a few new features. This is the last scheduled release of the AJDT stream targeting 3.4. The next release, in early 2010, will be targeting the 3.5 stream only. And our second 2010 release will target 3.5. At the same time, we will also release an early development version of AJDT targeting Eclipse 3.6 in time for EclipseCon 2010.

AJDT is available from the following update sites for Eclipse 3.5 and 3.4 respectively:
http://download.eclipse.org/tools/ajdt/35/update
http://download.eclipse.org/tools/ajdt/34/update

Export Feature With AspectJ

A new wizard is available to export features with AspectJ support. This wizard can be initiated from the File -> Export... command:



This wizard supports all of the options that the standard export feature supports. The only difference is that the AspectJ compiler is used to compile the projects instead of the Java compiler:


AJDT support for passing aop.xml file

AJDT now provides UI support to pass aop.xml files to the compiler. AspectJ bug 124460 describes how the AspectJ compiler can use aop.xml files for compile time weaving. And now AJDT provides UI support in the following way.

In project properties of your AspectJ project, select aop.xml management. Here you add and remove aop.xml files that will be sent to the compiler. Note that these files are highlighted using a special icon. Also, note that the name aop.xml is optional. Any xml file can be sent to the compiler in this way. See the following screenshot for an example


In order to use aop.xml files for compile-time configuring of the weaver, you must add the -xmlConfigured option under Non-Standard Compiler Options in the project's AspectJ Compiler options. This work is described in bug 287459.

This work is still experimental. We hope to receive some feedback so that compile time XML configuration of the weaver can be improved. Please send all comments to theAspectJ mailing list, or to bugzilla.

AspectJ 1.6.6

AJDT 2.0.1 contains AspectJ 1.6.6 and this version is available for download separately. See the release notes here.

Bug Fixes

Thirty-four bugs have been addressed in this release. See Bugzilla for the full report.

Thanks!

Thanks to those of you who have submitted patches, bug reports, and contributed to the mailing list for this release. We appreciate your help. Specifically, in this release:

Previous Releases

See here for information on the new features in AJDT 2.0.0.

Tuesday, September 29, 2009

Groovy-Eclipse plugin now supports Eclipse 3.5.1

The Groovy-Eclipse plugin can now be installed into Eclipse 3.5.1. As always, the update site is here:

http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.5/

You can stop reading here if you don't care how I got this to work, or why I am a little bit surprised by this.

The Groovy-Eclipse plugin uses a feature patch on the JDT core bundle in order to achieve a high level of integration with JDT. Typically, feature patches can only apply to a specific version of a feature (e.g., 3.5.0.v20090527-2000-7r88FEeFJePyvYeA33DjZ_c1 or some ugliness). This means that Groovy-Eclipse, until recently could only install in a specific version of Eclipse, the one that ships the JDT feature version 3.5.0.v20090527-2000-7r88FEeFJePyvYeA33DjZ_c1. However, Andrew Niefer describes how to get around this by editing the content.xml file to widen the range that the patch applies to. Excellent stuff, and lucky for me, because I didn't want to branch the Groovy-Eclipse code base every time a new service release of Eclipse comes out.

Unfortunately, his instructions were not entirely accurate. Andrew mentions that the range attribute in the <patchscope> element needs to be widened in order allow the patch to be installable on multiple versions. I tried exactly what he suggested, but could not get my patch to install in both 3.5.0 and 3.5.1. After a little bit of exploration, I found that I also needed to change the range attribute in the <lifecycle> element.

All this meant was adding a single line to my ant script, to be executed after the p2 repository is generated:

    
<replace file="${updateSiteDir}/content.xml"
summary="yes" token="${orig.jdt.feature.version.range}"
value="${new.jdt.feature.version.range}"/>

And this turned out to be very simple. Thanks for the hint!

Thursday, June 25, 2009

AJDT 2.0.0 is released!

We have just released AJDT 2.0.0 for Eclipse 3.5 and 3.4.

Get it now from the update sites:
For Eclipse 3.5: http://download.eclipse.org/tools/ajdt/35/update
For Eclipse 3.4: http://download.eclipse.org/tools/ajdt/34/update

In addition to a new Push In refactoring and ITD-aware navigation and Javadocs, you can find out about what's included in this release at our New & Noteworthy page.

AJDT 2.0.0 will also be available in the upcoming SpringSource Tool Suite 2.1.0.

This release would not have been possible with out help from the AspectJ and AJDT community. So, thank you for your bug reports, patches, discussions and being warm and welcoming to newcomers.

Wednesday, June 3, 2009

Update on Greclipse 2.0 (Groovy support in Eclipse)

Today, I decided to run EclEmma on the Groovy-Eclipse plugin test suite. Shockingly, I found that JUnit support, content assist, and code navigation are completely test-fress. So, I took a stab at creating a solid and flexible test infrastructure that makes it easy to write plugin tests, especially ones that exercise the Java model.

How did I do this? I did it by hooking into existing JDT functionality, just like I have been doing for the rest of my work on Greclipse. I downloaded the JDT core tests from CVS and used what I needed. Now, I can write extremely concise tests that exercise the code I want it to. For example, I wrote the following test case that tests code selection on a closure in a groovy script (i.e., this is the code that is executed when you perform Open Declaration in an editor):


public void testCodeSelectClosure() throws Exception {
IPath projectPath = createGenericProject();
IPath root = projectPath.append("src");
String contents =
"def x = {\n"+
"t -> print t\n"+
"}\n"+
"x('hello')\n";
env.addGroovyClass(root, "Script", contents);
GroovyCompilationUnit unit = getGroovyCompilationUnit(root, "Script.groovy");
IJavaElement[] elts = unit.codeSelect(contents.lastIndexOf('x'), 1);
assertEquals("Should have found a selection", 1, elts.length);
assertEquals("Should have found local variable 'x'", "x", elts[0].getElementName());
}


I have written many tests for JUnit support (or is that GUnit?), and some for code selection. I still need to work on content assist. So, I can now be confident that as we make changes towards the 2.0 release, we are not sliding back in functionality. There is a lot of good work that has already been put into the plugin (including groovy-aware type inference for content assist) and we need to make sure that this does not regress as we go forward.

Wednesday, May 27, 2009

Push in refactoring for AJDT

I just finished implementing the new Push In refactoring for the AJDT plugin, available in the latest dev build.

Essentially, the refactoring pushes intertype declarations into their target types. So, when a push in refactoring is applied to the following aspect and class:


aspect Foo {
int Bar.x;
declare parents : Bar implements I;
declare @type : Bar : @Baz;
}

class Bar { }


the result is:


@Baz
class Bar implements I {
int x;
}


The Foo aspect is deleted because it is empty.

It is simple to use. Select the ITDs or set of ITDs that you want to push in. You can select an entire project, source folder, or package to push all of its ITDs into the target types:



And then follow the wizard:



...and...




The result is that all ITDs have been successfully pushed in and all aspects that are made empty because of this refactoring have been deleted.



And undo works, too:



It is also possible to execute the refactoring from an editor. Just select all or part of the ITD you want to push in. However, the command itself is in a different sub-menu:




Please try it out and let me know if it works for you. We are working on adding more refactorings to AJDT. Next on the list is the analogous refactoring pull-out.

Sunday, May 17, 2009

Is it Groovy or is it Java? Do we really care?

Well, I care, but the editor doesn't. Following up on the work that Andy Clement has done to modify the JDT compiler so that it can process Groovy as well as Java, I've spent the last few weeks working on editor support for Groovy in Eclipse. Yes, there is already an Eclipse plugin for Groovy, but this particular plugin is tied to a split compiler (JDT for Java files and Groovy compiler for Groovy files). And I wanted to see if we could use the joint compiler to drive Groovy tool support.

So far, with minimal changes it seems that it is possible. I've been able to implement much of the standard Java editing support for Groovy files (e.g., open declaration, search, syntax highlighting, content assist, etc) as long as the editor is passed the right kind of structure.

Let's recap what Andy has done so far...
After getting a little intro to groovy joint compilation (and groovy compiler structure) from Jochen Theodorou, I wondered how hard it would be to go about things slightly differently. Let the Eclipse JDT compiler take control of building a mixed code base but whenever it needed to deal with groovy - call the groovy compiler. If JDT could take control I could see all sorts of things 'just working' in Eclipse, problems upon which we are still expending large amounts of efforts to try and solve for AspectJ. If I could just plug groovy type reference resolution and classfile generation into JDT correctly then references between java and groovy artifacts would work and JDT would ensure incremental compilation worked, even across restarts of eclipse (this latter problem still hasn't been solved for AspectJ).
So originally, this worked great for joint compilation, but as soon as you try to open this in an editor, things just don't behave correctly...



The outline view is out of order, problems and errors don't show up where you expect them to, and source code navigation is broken.

After a bit of mucking around, I found that there is a single root to this problem: source locations. The JDT tooling and the editor is very specific about the source locations that it requires. JDT requires the start and end locations of identifiers, method and type bodies, and all declarations. However, the Groovy compiler (which builds its AST from antlr), only provides line and column information for AST nodes. Although it is possible to translate from line/column to file offset, offsets for identifiers are lost.

And, with a little bit of hacking, I was able to recreate source offsets for field, method, and class names and declarations. It turns out that this is enough to spring to like much of your favorite editor functionality:



Same program, same error as before, but now the outline view is correct, the error marker is in the proper location,* "Open Declaration" and searches navigate to the proper location. And even source hovers work:



So, let's take a deeper look at how this works.

The JDT uses three representations of abstract syntax of a Java file. There is the compiler AST, which is used to generate byte code and perform analysis. There is DOM (document object model) AST, which is used for refactoring and source code manipulation. And, there is the model (the IJavaElement hierarchy), which is more abstract, and is used for navigation and in places like the Package Explorer and Outline views.

There is also support to translate from the compiler AST to either of the other two ASTs. Earlier, I described (or rather Andy described) the way JDT can be used to drive the joint compilation of Groovy source code. The result is a JDT compiler AST with (crucially) the right source code offsets. This, when translated to the right kind of AST at the right time, can be fed to the different parts of JDT that require it. And, thereby, things just work.

A few caveats, of course. Right now, we are only generating a minimal compiler AST (class, method and field declarations only---method bodies are ignored for now). This, however, does seem to be enough for this basic functionality. Also, there are some major differences between Groovy and Java syntax (closures, regular expressions, and lists operations). We are currently sidestepping this problem by ignoring method bodies, statements and expressions.

At some point, however, we are going to have to tackle these loose ends. We will need to be more complete about our ASTs and fill in method bodies (this part is *just* lots of coding). And also, we will need to figure out how to translate Groovy-specific syntax into JDT AST, probably by sub-classing the existing API (this will require some thorough design work *and* lots of coding). So, there is still a lot of work to be done.

What does this mean? Well for one thing it means that the implementation of the Groovy editor is just this:


public class GroovyEditor extends CompilationUnitEditor {
private GroovyImageDecorator decorator = new GroovyImageDecorator();

@Override
public Image getTitleImage() {
return decorator.decorateImage(null, getEditorInput().getAdapter(IFile.class));
}
}

Yes, it is just a minimal subclass of the standard CompilationUnitEditor that merely ensures that the icon in the title bar indicates Groovy, not Java.

So, who cares if it's Groovy or Java? Certainly not the editor.

* There are currently Groovy compiler limitations with error reporting in that error locations only include the character or two of the error.

Tuesday, March 17, 2009

Aspects Everywhere: Using Equinox Aspects to Provide Language Developers with Deep Eclipse Integration...

...and other EclipseCon talks.

To shamelessly self promote, I wanted to mention my EclispeCon talk entitled Aspects Everywhere: Using Equinox Aspects to Provide Language Developers with Deep Eclipse Integration. It is about how we (the AJDT team) have used AspectJ and Equinox Aspects to overcome the limitations of JDT and make it more extensible to third parties.

You may want to check this out if:
  • You use AspectJ or AJDT
  • You are interested in using Equinox Aspects and want to find out how it can be used
  • You are a language developer who wants to integrate tooling support into Eclipse and JDT
No knowledge of AspectJ is required for this talk.

And if you are interested in anything Spring or AspectJ, please join us for our Bof: Spring on Eclipse: AspectJ, STS, and SpringIDE.

Some other talks that I am planning on attending are:
There are so many excellent talks that it is difficult to choose what to go to. It is going to be a great conference.