Closed Feng-Jay closed 1 year ago
Hi!
I cannot reproduce this problem with my version of GumTree, sorry.
W.r.t. to your question, by using GumTree's Java API you have both ASTs with the textual position of every node, would it suffice?
Cheers.
Thanks for your reply.
I tried the example again by doing this:
String srcFile = "/path/to/test1.java";
String dstFile = "/path/to/test2.java";
Tree t1 = new JdtTreeGenerator().generateFrom().file(srcFile).getRoot();
Tree t2 = new JdtTreeGenerator().generateFrom().file(dstFile).getRoot();
Matcher defaultMatcher = new CompositeMatchers.SimpleGumtree();
MappingStore mappings = defaultMatcher.match(t1, t2);
EditScriptGenerator editScriptGenerator = new SimplifiedChawatheScriptGenerator();
EditScript actions = editScriptGenerator.computeActions(mappings);
for(Action ac : actions){
System.out.println("action: "+ac.toString().replace("\n"," "));
}
It seems the IF-STATMENT in second example will cheat GTD that these are two different method, like it exceeds some threshold or something else.
I have solved my problem by utilizing the textual information of AST and GTD's action outcomes.😄
Thanks!
Hi! Thanks for the timely reply to #318 .
I got two more questions when using GTD.
The outcome is:
It seems GTD treat test2's method which named test as a brand new one and not the modification on example1's method.
I don't know whether it is a bug but the output like this is not normal.
Apart from this confusing output, I want to know is there any way to get the insertion position in the old code(when comparing old code and new code ) when encoutered with an insert-tree action.
Now, I get the insertion position by:
TypeDeclaration [0,172] at 4
from=== insert-node --- MethodDeclaration [87,214] to TypeDeclaration [0,172] at 4
It is a little miscellaneous and may have more potential bugs. So I want to know is there any better way to do this.