Java – Eclipse abstract syntax tree programmatic access

Eclipse abstract syntax tree programmatic access… here is a solution to the problem.

Eclipse abstract syntax tree programmatic access

Can you provide an example of programmatically accessing an Eclipse abstract syntax tree for a given piece of code?

For example, to get the AST:


Class1.java

package parseable;

public class Class1 {

/**
 * @param args
 */
public static void main(String[] args) {
    System.out.println("Hello world!");
}

Solution

This isn’t an exact answer, but might give you a place to start:

As stated in this question,

A complete example is provided in this Eclipse Corner article, see Eclipse Help for more details. In slide 59 of this presentation , you’ll see how to apply the changes to your source code.

Related Problems and Solutions