Output the simple tree of buggy code.
This commit is contained in:
@@ -23,7 +23,7 @@ import edu.lu.uni.serval.gumtree.utils.CUCreator;
|
|||||||
import edu.lu.uni.serval.utils.FileHelper;
|
import edu.lu.uni.serval.utils.FileHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse fix patterns with GumTree..
|
* Parse fix patterns with GumTree.
|
||||||
*
|
*
|
||||||
* @author kui.liu
|
* @author kui.liu
|
||||||
*
|
*
|
||||||
@@ -32,6 +32,7 @@ public class Parser {
|
|||||||
|
|
||||||
private String astEditScripts = "";
|
private String astEditScripts = "";
|
||||||
private String patchesSourceCode = "";
|
private String patchesSourceCode = "";
|
||||||
|
private String buggyTrees = "";
|
||||||
private int maxSize = 0;
|
private int maxSize = 0;
|
||||||
|
|
||||||
public void mineFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException {
|
public void mineFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException {
|
||||||
@@ -115,41 +116,43 @@ public class Parser {
|
|||||||
actionSet.setStartLineNum(startLineNum);
|
actionSet.setStartLineNum(startLineNum);
|
||||||
actionSet.setEndLineNum(endLineNum);
|
actionSet.setEndLineNum(endLineNum);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert the ITree of buggy code to a simple tree.
|
||||||
|
* It will be used to compute the similarity.
|
||||||
|
*/
|
||||||
|
SimplifyTree abstractIdentifier = new SimplifyTree();
|
||||||
|
abstractIdentifier.abstractTree(actionSet);
|
||||||
|
SimpleTree simpleTree = actionSet.getSimpleTree();
|
||||||
|
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.
|
// Source Code of patches.
|
||||||
String patchSourceCode = getPatchSourceCode(sourceCode, startLineNum, endLineNum, startLineNum2,
|
String patchSourceCode = getPatchSourceCode(sourceCode, startLineNum, endLineNum, startLineNum2,
|
||||||
endLineNum2);
|
endLineNum2);
|
||||||
if (patchSourceCode != null) {
|
if (patchSourceCode == null) continue;
|
||||||
patchesSourceCode += "PATCH###Num\n" + patchSourceCode;
|
patchesSourceCode += "PATCH###\n" + patchSourceCode;
|
||||||
patchesSourceCode += actionSet.toString() + "\n";
|
patchesSourceCode += actionSet.toString() + "\n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the ITree of buggy code to a simple tree.
|
* Select edit scripts for deep learning.
|
||||||
* TODO: it will be used to compute the similarity.
|
* Edit scripts will be used to mine common fix patterns.
|
||||||
*/
|
*/
|
||||||
SimplifyTree abstractIdentifier = new SimplifyTree();
|
// 1. First level: AST node type.
|
||||||
abstractIdentifier.abstractTree(actionSet);
|
String astEditScripts = getASTEditScripts(actionSet);
|
||||||
SimpleTree simpleTree = actionSet.getSimpleTree();
|
int size = astEditScripts.split(" ").length;
|
||||||
SimpleTree abstractSimpleTree = actionSet.getAbstractSimpleTree();
|
if (size > maxSize) {
|
||||||
clearITree(actionSet);
|
maxSize = size;
|
||||||
|
|
||||||
/**
|
|
||||||
* Select edit scripts for deep learning.
|
|
||||||
* Edit scripts will be used to mine common fix patterns.
|
|
||||||
*/
|
|
||||||
// 1. First level: AST node type.
|
|
||||||
String astEditScripts = getASTEditScripts(actionSet);
|
|
||||||
int size = astEditScripts.split(" ").length;
|
|
||||||
if (size > maxSize) {
|
|
||||||
maxSize = size;
|
|
||||||
}
|
|
||||||
this.astEditScripts += astEditScripts + "\n";
|
|
||||||
// 2. source code: raw tokens
|
|
||||||
String rawTokenEditScripts = getRawTokenEditScripts(actionSet);
|
|
||||||
// 3. abstract identifiers:
|
|
||||||
String abstractIdentifiersEditScripts = getAbstractIdentifiersEditScripts(actionSet);
|
|
||||||
// 4. semi-source code:
|
|
||||||
String semiSourceCodeEditScripts = getSemiSourceCodeEditScripts(actionSet);
|
|
||||||
}
|
}
|
||||||
|
this.astEditScripts += astEditScripts + "\n";
|
||||||
|
// 2. source code: raw tokens
|
||||||
|
String rawTokenEditScripts = getRawTokenEditScripts(actionSet);
|
||||||
|
// 3. abstract identifiers:
|
||||||
|
String abstractIdentifiersEditScripts = getAbstractIdentifiersEditScripts(actionSet);
|
||||||
|
// 4. semi-source code:
|
||||||
|
String semiSourceCodeEditScripts = getSemiSourceCodeEditScripts(actionSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,4 +367,8 @@ public class Parser {
|
|||||||
return maxSize;
|
return maxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBuggyTrees() {
|
||||||
|
return buggyTrees;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user