Get the max size of edit scripts.
This commit is contained in:
@@ -15,7 +15,6 @@ public class AkkaMiner {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(AkkaMiner.class);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void main(String[] args) {
|
||||
// input data
|
||||
log.info("Get the input data...");
|
||||
@@ -59,14 +58,6 @@ public class AkkaMiner {
|
||||
if (revFile.getName().endsWith(".java")) {
|
||||
File prevFile = new File(projectFolder + "/prevFiles/prev_" + revFile.getName());// previous file
|
||||
File diffentryFile = new File(projectFolder + "/DiffEntries/" + revFile.getName().replace(".java", ".txt")); // DiffEntry file
|
||||
// if (!prevFile.exists()) {
|
||||
// log.info("======" + prevFile.getPath());
|
||||
// continue;
|
||||
// }
|
||||
// if (!diffentryFile.exists()) {
|
||||
// log.info("======" + diffentryFile.getPath());
|
||||
// continue;
|
||||
// }
|
||||
MessageFile msgFile = new MessageFile(revFile, prevFile, diffentryFile);
|
||||
msgFiles.add(msgFile);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public class MineFixPatternActor extends UntypedActor {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onReceive(Object message) throws Exception {
|
||||
if (message instanceof WorkMessage) {
|
||||
|
||||
@@ -38,21 +38,22 @@ public class MineFixPatternWorker extends UntypedActor {
|
||||
List<MessageFile> files = msg.getMsgFiles();
|
||||
StringBuilder editScripts = new StringBuilder();
|
||||
StringBuilder patchesSourceCode = new StringBuilder();
|
||||
int maxSize = 0;
|
||||
for (MessageFile msgFile : files) {
|
||||
File revFile = msgFile.getRevFile();
|
||||
File prevFile = msgFile.getPrevFile();
|
||||
File diffentryFile = msgFile.getDiffEntryFile();
|
||||
if (!prevFile.exists()) {
|
||||
System.out.println("Previous File:" + prevFile.getPath());
|
||||
continue;
|
||||
}
|
||||
Miner miner = new Miner();
|
||||
miner.mineFixPatterns(prevFile, revFile, diffentryFile);
|
||||
editScripts.append(miner.getAstEditScripts());
|
||||
patchesSourceCode.append(miner.getPatchesSourceCode());
|
||||
int size = miner.getMaxSize();
|
||||
if (size > maxSize) {
|
||||
maxSize = size;
|
||||
}
|
||||
}
|
||||
|
||||
FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + msg.getId() + ".list", editScripts, false);
|
||||
FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + msg.getId() + "_MaxSize=" + maxSize + ".list", editScripts, false);
|
||||
FileHelper.outputToFile(patchesSourceCodeFilePath + "patches" + msg.getId() + ".list", patchesSourceCode, false);
|
||||
|
||||
this.getSender().tell("STOP", getSelf());
|
||||
|
||||
@@ -31,6 +31,7 @@ import edu.lu.uni.serval.utils.FileHelper;
|
||||
public class Miner {
|
||||
private String astEditScripts = "";
|
||||
private String patchesSourceCode = "";
|
||||
private int maxSize = 0;
|
||||
|
||||
public void mineFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException {
|
||||
// GumTree results
|
||||
@@ -131,6 +132,10 @@ public class Miner {
|
||||
*/
|
||||
// 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);
|
||||
@@ -232,7 +237,6 @@ public class Miner {
|
||||
String lineNum = line.substring(4, plusIndex);
|
||||
String[] nums = lineNum.split(",");
|
||||
if (nums.length != 2) {
|
||||
System.out.println("Line Num: " + line + ", Old line: " + startLineNum + " - " + endLineNum);
|
||||
continue;
|
||||
}
|
||||
startLine = Integer.parseInt(nums[0].trim());
|
||||
@@ -248,7 +252,6 @@ public class Miner {
|
||||
lineNum2 = lineNum2.substring(1, lineNum2.length() - 2);
|
||||
String[] nums2 = lineNum2.split(",");
|
||||
if (nums2.length != 2) {
|
||||
System.out.println("Line Num: " + line + ", New line: " + startLineNum2 + " - " + endLineNum2);
|
||||
startLine = 0;
|
||||
range = 0;
|
||||
continue;
|
||||
@@ -350,4 +353,8 @@ public class Miner {
|
||||
return patchesSourceCode;
|
||||
}
|
||||
|
||||
public int getMaxSize() {
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user