Partial Program Analysis for Eclipse

PPA for Eclipse produces a typed Abstract Syntax Tree from an arbitrary Java source file. PPA for Eclipse uses the Eclipse JDT compiler as the frontend and is compatible with the Eclipse JDT Binding API: the compilation unit is an instanceof org.eclipse.jdt.core.dom.CompilationUnit and the type bindings are compatible with the hierarchy of org.eclipse.jdt.core.dom.IBinding.

This version supports Java 5 syntax and can take as input 1) a Java source file in a Java project, 2) an arbitrary Java source file taken from the file system, or 3) a snippet of code in a String variable or in a text file.

You can follow the development of PPA on BitBucket and ohloh.



June 29th 2010 - Version 1.2.0 is out! It supports Eclipse 3.6 and brings all the improvements of 1.1.2 such as multi-threaded environment, better support for Java 5 generics and anonymous classes, etc.

Return to the top


The current version of PPA for Eclipse is 1.2.0 and it requires Eclipse 3.6 (Helios). This version is actively maintained: feature requests will be considered.

To download PPA for Eclipse, use the following update site:

To download the current development release (might be unstable), use the following update site:

To download the previous version of PPA for Eclipse, which requires Eclipse 3.5, use the following update site:

PPA is available under the GNU Lesser General Public License and Eclipse is available under the Eclipse Public License.

Return to the top

2-minute Tutorial

This tutorial shows how to get a typed CompilationUnit instance from a single Java file (potentially referring to other unavailable source files). We only give the high-level details here. For a complete tutorial, see PPA Tutorial.

This example assumes that you are in a plug-in project that imports the two following plug-ins: org.eclipse.jdt.core and ca.mcgill.cs.swevo.ppa.ui . The example also assumes that the plug-in fragment ca.mcgill.cs.swevo.ppa is loaded (this is done automatically if you import jdt.core and you have installed PPA for Eclipse).

All PPA plug-ins include the source code so you can browse the code and the API using Eclipse (either Ctrl-Click on a type or use the type dialog using Ctrl-T).

import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.Name;
import ca.mcgill.cs.swevo.ppa.PPAOptions;
import ca.mcgill.cs.swevo.ppa.ui.PPAUtil;

public class PPAClient {

  // This must be called in an Eclipse plug-in, not in a 
  // standalone Java application.
  public void usePPA() {
    // The source file.
    File srcFile = new File("/tmp/");
    // Obtaining a compilation unit using the default options.
    CompilationUnit cu = PPAUtil.getCU(file, new PPAOptions());
    // Walk through the compilation unit.

    // Obtain a name object and the corresponding binding
    Name nameNode = ...
    IBinding binding = nameNode.resolveBinding();
    ITypeBinding typeBinding = nameNode.resolveTypeBinding();

Return to the top

GUI Tools Tutorial

You can execute PPA on any java source files or code snippets in your Eclipse workspace: PPA will traverse the abstract syntax tree of the java source file and print the type of each node in the console.

These GUI tools enable you to try PPA without writing a single line of code. You can also use this tool to submit a bug report by providing the actual output of PPA and telling us the output you expect.

PPA GUI Tools Tutorial

Return to the top

PPA Tutorial

In this tutorial, you will create an Eclipse plug-in project that analyzes a partial program and that prints the type associated to the nodes of the abstract syntax tree of the program. To invoke the analysis, you will push a button in the main toolbar.

No prior knowledge of Eclipse is required, but you should be familiar with programming language concepts such as type and abstract syntax trees.

  1. Part 1 - Installing Eclipse and PPA
  2. Part 2 - Creating an Eclipse plug-in
  3. Part 3 - Using PPA in the plug-in
  4. Part 4 - Going Headless (Running your plug-in on the command line, without displaying the Eclipse GUI)

Return to the top


Return to the top

Bugs and Feature Requests

If you have any question or comment about PPA, the documentation or this website, you can contact Barthélémy at: bart at cs dot mcgill dot ca.

To fill a bug report or a feature request, please enter an issue report on the PPA bitbucket repository.

Return to the top

Change log