Output the simple tree of buggy code.

This commit is contained in:
Kui LIU
2017-07-25 15:35:17 +02:00
parent e7a4fd6eca
commit d04b041ff2
@@ -23,7 +23,7 @@ import edu.lu.uni.serval.gumtree.utils.CUCreator;
import edu.lu.uni.serval.utils.FileHelper;
/**
* Parse fix patterns with GumTree..
* Parse fix patterns with GumTree.
*
* @author kui.liu
*
@@ -32,6 +32,7 @@ public class Parser {
private String astEditScripts = "";
private String patchesSourceCode = "";
private String buggyTrees = "";
private int maxSize = 0;
public void mineFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException {
@@ -115,22 +116,25 @@ public class Parser {
actionSet.setStartLineNum(startLineNum);
actionSet.setEndLineNum(endLineNum);
// Source Code of patches.
String patchSourceCode = getPatchSourceCode(sourceCode, startLineNum, endLineNum, startLineNum2,
endLineNum2);
if (patchSourceCode != null) {
patchesSourceCode += "PATCH###Num\n" + patchSourceCode;
patchesSourceCode += actionSet.toString() + "\n";
/**
/*
* Convert the ITree of buggy code to a simple tree.
* TODO: it will be used to compute the similarity.
* It will be used to compute the similarity.
*/
SimplifyTree abstractIdentifier = new SimplifyTree();
abstractIdentifier.abstractTree(actionSet);
SimpleTree simpleTree = actionSet.getSimpleTree();
SimpleTree abstractSimpleTree = actionSet.getAbstractSimpleTree();
clearITree(actionSet);
if (simpleTree == null) { // Failed to get the simple tree for INS actions.
continue;
}
this.buggyTrees += "BUGGY_TREE###\n" + simpleTree.toString() + "\n";
// Source Code of patches.
String patchSourceCode = getPatchSourceCode(sourceCode, startLineNum, endLineNum, startLineNum2,
endLineNum2);
if (patchSourceCode == null) continue;
patchesSourceCode += "PATCH###\n" + patchSourceCode;
patchesSourceCode += actionSet.toString() + "\n";
/**
* Select edit scripts for deep learning.
@@ -153,7 +157,6 @@ public class Parser {
}
}
}
}
private String getSemiSourceCodeEditScripts(HierarchicalActionSet actionSet) {
// TODO Auto-generated method stub
@@ -364,4 +367,8 @@ public class Parser {
return maxSize;
}
public String getBuggyTrees() {
return buggyTrees;
}
}