What's new in AJDT 1.2

Here are some of the more interesting or significant changes made to the AspectJ Developement Tools since the 1.1.12 release:

AspectJ editor The AspectJ editor has been significantly improved and now offers the following features:
  • Folding
  • Code formatting
  • Add import
  • Organize imports
  • Code completion (within advice and method bodies)
  • Early error indication (syntax errors only)

The default arrangement is to use the AspectJ editor only for .aj files and to use the standard Java editor for .java files.

Outline view The standard outline view shows the structure of your aspects and is updated as you type. Filters are available to hide pointcuts, advice, declare statements, and introductions. The same aspect structure is also shown in the package explorer and in the quick outline view in the AspectJ editor.

Screenshot showing the structure of an aspect in the outline view

Cross References The new Cross References view shows how a given element is related to other elements. For example, which advice is affecting a given method or the places advised by a given piece of advice. The view responds to selections in the editor and the outline view.

Screenshot showing the Cross References view

If you select a method the Cross References view shows you the relationships involving that method plus any that involve code elements within the method (such as when the setting of a field is advised). If you select a class or aspect you will see the relationships involving that class/aspect plus any that involve the methods contained in the class/aspect.

The view supports navigation; you can double-click an element to open the containing resource in the editor with that element selected. There are buttons available to disable the link with the editor and to toggle between showing crosscutting information for the current element or the entire file.

Like the outline view there is also a quick version of the view that appears in-place over the editor. This is available from the Navigate menu or via the default "Ctrl+Alt+X" key binding.

The quick form of the Cross References view

Advice Decorator An image decorator has been added to indicate which Java elements are being advised. A small orange arrow to the left of the icon is used as shown in the enlargement below. This decorator is used anywhere that the standard Java decorator is used which includes the package explorer, the outline view, the Cross Reference view, and the members view in the Java browsing perspective. A preference page option is available if you wish to disable this function.

An example of the image decorator for advice

Source markers Markers are added to the left-hand edge of the editor to indicate where advice will take effect at runtime (or may take effect, if there is a dynamic test to the pointcut). In addition to these, markers are also added at the source of these relationships, namely the advice itself. Selecting the context menu from one of these markers will show an "Advises" menu, similar to the "Advised By" menu shown at the other end of the relationship. As well as being more consistent, these new markers provide an additional means of navigating the aspect-oriented structure of your code. Similar markers are added for the source and target of declare statements, such as inter-type declarations. All of these markers are present with both the AspectJ and Java editors.

An example advises marker

The advises context menu

Incremental compilation Incremental compilation is now set as the default mode of operation. Both the generated class files and the structure model (used to display the advice markers and to populate the Cross References view and Visualiser etc) will be incrementally updated as required.

Simple changes to classes will result in a fast incremental build of the project and any dependent projects, whereas changes to aspects will trigger a full build. A chain of large projects dependent on each other will have high memory requirements.

Incremental mode can be set either for the whole workspace or per-project via the AspectJ Compiler > Other tab.

File Extensions The best arrangement for your source code is to only put pure Java code in .java files and to use .aj files for aspects (and for classes containing inner aspects or pointcuts). You can select a file or files in the package explorer and right-click to convert their file extension. You can also convert all of the source files in a project in one go using a wizard. This is available by right-clicking on a project and selecting Convert File Extensions...
AspectPath Directories You can now specify directories on the aspect-path instead of just jars or zips. Simply right-click on a project and select Properties, then go to the AspectJ Aspect Path section. On the Libraries tab there is now a Add Class Folder... button which you can use to add the output "bin" directory of another project for example. This allows you to apply the aspects from another project without requiring that other project to send its class files to an output jar.
Launch configuration You can now do Run As > AspectJ/Java Application. This looks and behaves exactly like the basic Java launch configuration with the following two additions:
  • Main methods inside aspects are detected. This means when you press the Search... button in the Main class section of the run configuration dialog, or when you do Run As > AspectJ/Java Application directly, you are presented with a selection dialog containing all main methods in both classes and aspects.
  • On the Classpath tab of the run configuration dialog there is an additional classpath entry for Aspect Path. If the aspect-path for a project has been set (via Properties > AspectJ Aspect Path) then the same entries will automatically appear here.

The AspectJ Launch Configuration

Visible project options Project-specific AspectJ compiler options and other project settings are now saved in preference files under a ".settings" folder in the project. This enables the settings to be shared between workspaces and other developers by committing the preference files to CVS.
Plug-in projects If you have an AspectJ-enabled plug-in project you can now generate a build.xml file that can build the project correctly using the iajc ant task. This operation is available by right-clicking on your plugin.xml file and selecting PDE tools > Create Ant Build File with AspectJ support.
New docs The documentation provided in the Eclipse help system has been overhauled. The "AspectJ Development User Guide" has been rewritten to reflect the changes in AJDT 1.2 and to be more consistent with other Eclipse documentation. The documentation from the AspectJ project is available as the "AspectJ Language Guide".
The Visualiser A large number of improvements have been made to the Visualiser:
  • The graphical rendering is faster and better able to cope with less memory / larger projects.
  • The appearance of the columns is more in keeping with the rest of Eclipse 3.0
  • Alternative drawing styles and color palettes are available and new ones can be implemented using the defined extension points.
  • The drawing preferences page has been changed to handle the new options and to provide a preview of the changes.
  • A selection mechanism allows columns, bars, and stripes to be selected using the mouse or keyboard.
  • The results of any AspectJ declare error and declare warning statements are now shown as stripes in the Visualiser in colors matching the usual Eclipse colors for errors and warnings. There are toggles on the Visualiser menu toolbar to hide these stripes.
  • If you change the color of a stripe in the Visualiser then that setting will be preserved such that an aspect of that name, in the same project, will continue to use that color even across workbench sessions. There is a menu option to reset this color memory back to the default of the current palette.
  • A new provider has been added to the Visualiser to show the location of Eclipse markers (such as bookmarks, breakpoints, tasks, etc).

Screenshot of the new Visualiser

Legal notices