JavalibSawja

The Sawja Eclipse Plugin: your analysis as a Plug-in for Eclipse

Presentation

The Sawja Eclipse Plugin enables developers to add any analysis based on the Sawja library to the Eclipse environment, simply by adding an executable file in the Sawja Eclipse Plugin folder.

This executable file only needs to comply with some of the Sawja library interfaces to be compatible with the plugin:

Note: the installation of a new analysis in the Sawja Eclipse Plugin does not require the developer to write any supporting Java code.

There are two kinds of visual representations for the results of an analysis:

Installation

To install the Sawja Eclipse Plugin, simply add the URL http://javalib.gforge.inria.fr/plugin as a Software Site (menu Help -> Install New Software...), and follow the standard installation procedure.

The example analysis from the Sawja plugin tutorial is downloaded and installed alongside the plugin, so that you can try it directly.

Add an analysis in the Sawja Eclipse Plugin

How to develop an analysis for the plugin:

Use the Sawja library interfaces: the ArgPlugin and JPrintPlugin modules described in the Sawja API. A tutorial with an example analysis is available here, and the source files of the tutorial are included with Sawja source files (see src/dataflow_analyses/README).

How to add an analysis to the plugin:

The name of your executable must end with .linux, .macos or .exe (depending of your Operating System: Linux, Mac OS or Windows).

The executable has to be copied in the <plugins_folder>/sp_1.0.0.X/exec/. The <plugins_folder> is the plugins/ folder of your Eclipse installation, which can be found either in the folder where Eclipse is installed or in the folder $(HOME)/.eclipse/<eclipse_platform_URI>/ (under Linux). X is a date (at format YYMMDDhhmm): choose the more recent date if several are existing. <eclipse_platform_URI> depends of your Eclipse installation.

Restart Eclipse if it was started before the copy.

Using an analysis

Configuring and enabling an analysis

Analyzes can be enabled and configured for each Java project in your Eclipse workspace. To configure an analysis, use the contextual menu of the Java project (right-click on the project name in the Package Explorer view) and select first Properties, then Sawja Analyzes.

Sawja Analyzes Properties

If you use the Run automatically option for some of your analyzes, these analyzes are launched at each compilation of the Java project. As a consequence, if Build automatically is activated for your project and the project compiles correctly, the analyzes are launched each time a Java class is saved.

Conversely, if you do not use the Run automatically option for some of your analyzes, these analyzes can only be launched on demand. Use the contextual menu of the Java project and select in the Sawja Analyzes submenu the analysis you wish to launch (as shown on screenshot below). Caution: the results of any analysis launched on demand are only kept until the next project compilation happens!

Sawja Analyzes On Demand

How to use the results of an analysis

When analyzes are running, their activity is visible in the Progress view of Eclipse.

Sawja Analyzes Progress View

Once an analysis has completed its execution, you can see all of the warnings produced in the Problems view of Eclipse the Sawja (use Group by Type to separate them from the Java Problems). You can use the warnings exactly like the Eclipse warnings. The name of the analysis that has generated the warning is indicated in the Location column.

Sawja Analyzes Problem View

The warnings are shown like other warnings in the Java editor, albeit with a different icon than standard Eclipse warnings.

Sawja Analyzes Editor

Last but not least, you can view information given by the analysis in the Sawja Info view. The view can be activated by using the contextual menu of the Java editor Sawja Analyzes -> Show Sawja Info view, or using the Eclipse menu Window -> Show view -> Other and then select the Sawja Info view under Sawja Analyzes.

Sawja Analyzes Info View

You can select the information you want to access with the text cursor (keyboard and mouse) or with the mouse cursor (leaving mouse at the same position for a while). Information can be present on class declarations, field declarations, method signatures or on any line of source code.

Last modification: