Skip to content
Jean-Rémy Falleri edited this page Jun 18, 2015 · 14 revisions

It is possible to process source code file directly from the Java code. Here are some examples.

Parsing a file

String file = "myfile.java"
TreeContext tc = TreeGeneratorRegistry.getInstance().getGenerator(file).generateFromFile(file);
ITree t = tc.getRoot() // return the root of the tree

Getting the mappings between two trees

ITree src, dst;
...
Matcher m = GumtreeMatchers.CompleteGumtreeMatcherFactory.newMatcher(src, dst);
m.match();
MappingStore m = m.getMappings();

Computing the actions between two trees

ITree src, dst;
...
Matcher m = GumtreeMatchers.CompleteGumtreeMatcherFactory.newMatcher(src, dst);
m.match();
ActionGenerator g = new ActionGenerator(src, dst, m);
g.generate();
List<Action> actions = g.getActions();
Clone this wiki locally