Get the sizes of all editscripts.

This commit is contained in:
Kui LIU
2017-07-25 15:56:23 +02:00
parent 9a5d3e0955
commit 97a56960b9
2 changed files with 9 additions and 14 deletions
@@ -33,7 +33,7 @@ public class Parser {
private String astEditScripts = "";
private String patchesSourceCode = "";
private String buggyTrees = "";
private int maxSize = 0;
private String sizes = "";
public void parseFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException {
// GumTree results
@@ -143,9 +143,7 @@ public class Parser {
// 1. First level: AST node type.
String astEditScripts = getASTEditScripts(actionSet);
int size = astEditScripts.split(" ").length;
if (size > maxSize) {
maxSize = size;
}
this.sizes += size + "\n";
this.astEditScripts += astEditScripts + "\n";
// 2. source code: raw tokens
String rawTokenEditScripts = getRawTokenEditScripts(actionSet);
@@ -363,12 +361,11 @@ public class Parser {
return patchesSourceCode;
}
public int getMaxSize() {
return maxSize;
}
public String getBuggyTrees() {
return buggyTrees;
}
public String getSizes() {
return sizes;
}
}
@@ -43,7 +43,7 @@ public class ParseFixPatternWorker extends UntypedActor {
List<MessageFile> files = msg.getMsgFiles();
StringBuilder editScripts = new StringBuilder();
StringBuilder patchesSourceCode = new StringBuilder();
int maxSize = 0;
StringBuilder sizes = new StringBuilder();
for (MessageFile msgFile : files) {
File revFile = msgFile.getRevFile();
File prevFile = msgFile.getPrevFile();
@@ -53,16 +53,14 @@ public class ParseFixPatternWorker extends UntypedActor {
miner.parseFixPatterns(prevFile, revFile, diffentryFile);
editScripts.append(miner.getAstEditScripts());
patchesSourceCode.append(miner.getPatchesSourceCode());
int size = miner.getMaxSize();
if (size > maxSize) {
maxSize = size;
}
sizes.append(miner.getSizes());
log.info("Finish of parsing file: " + revFile.getPath());
}
int id = msg.getId();
FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + id + "_MaxSize=" + maxSize + ".list", editScripts, false);
FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + id + ".list", editScripts, false);
FileHelper.outputToFile(patchesSourceCodeFilePath + "patches" + id + ".list", patchesSourceCode, false);
FileHelper.outputToFile(patchesSourceCodeFilePath + "sizes" + id + ".list", sizes, false);
log.info("Worker #" + id + " finished the work...");
this.getSender().tell("STOP", getSelf());