diff --git a/src/main/java/edu/lu/uni/serval/FixPatternParser/Parser.java b/src/main/java/edu/lu/uni/serval/FixPatternParser/Parser.java index a7bfe44..14d445c 100644 --- a/src/main/java/edu/lu/uni/serval/FixPatternParser/Parser.java +++ b/src/main/java/edu/lu/uni/serval/FixPatternParser/Parser.java @@ -35,7 +35,7 @@ public class Parser { private String buggyTrees = ""; private int maxSize = 0; - public void mineFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException { + public void parseFixPatterns(File prevFile, File revFile, File diffEntryFile) throws FileNotFoundException, IOException { // GumTree results List gumTreeResults = new GumTreeComparer().compareTwoFilesWithGumTree(prevFile, revFile); diff --git a/src/main/java/edu/lu/uni/serval/FixPatternParser/TestParser.java b/src/main/java/edu/lu/uni/serval/FixPatternParser/TestParser.java index 96decb7..0ffa8c4 100644 --- a/src/main/java/edu/lu/uni/serval/FixPatternParser/TestParser.java +++ b/src/main/java/edu/lu/uni/serval/FixPatternParser/TestParser.java @@ -35,7 +35,7 @@ public class TestParser { Parser parser = new Parser(); try { - parser.mineFixPatterns(prevFile, revFile, diffentryFile); + parser.parseFixPatterns(prevFile, revFile, diffentryFile); astEditScriptsBuilder.append(parser.getAstEditScripts()); sourceCodeBuilder.append(parser.getPatchesSourceCode()); } catch (FileNotFoundException e) { diff --git a/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternActor.java b/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternActor.java index b4a7f9f..d1842b6 100644 --- a/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternActor.java +++ b/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternActor.java @@ -61,9 +61,7 @@ public class ParseFixPatternActor extends UntypedActor { logger.info("Assign a task to worker #" + (i + 1) + "..."); } } else if ("STOP".equals(message.toString())) { - counter ++; - logger.info("Worker #" + counter + " finished the work..."); - if (counter >= numberOfWorkers) { + if (++ counter >= numberOfWorkers) { this.getContext().stop(mineRouter); this.getContext().stop(getSelf()); this.getContext().system().shutdown(); diff --git a/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java b/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java index 7fd5d07..d3e5cbe 100644 --- a/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java +++ b/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java @@ -3,6 +3,9 @@ package edu.lu.uni.serval.MultipleThreadsParser; import java.io.File; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import akka.actor.Props; import akka.actor.UntypedActor; import akka.japi.Creator; @@ -10,6 +13,7 @@ import edu.lu.uni.serval.FixPatternParser.Parser; import edu.lu.uni.serval.utils.FileHelper; public class ParseFixPatternWorker extends UntypedActor { + private static Logger log = LoggerFactory.getLogger(ParseFixPatternActor.class); private String editScriptsFilePath; private String patchesSourceCodeFilePath; @@ -45,18 +49,22 @@ public class ParseFixPatternWorker extends UntypedActor { File prevFile = msgFile.getPrevFile(); File diffentryFile = msgFile.getDiffEntryFile(); Parser miner = new Parser(); - miner.mineFixPatterns(prevFile, revFile, diffentryFile); + log.info("Start to parse file: " + revFile.getPath()); + miner.parseFixPatterns(prevFile, revFile, diffentryFile); editScripts.append(miner.getAstEditScripts()); patchesSourceCode.append(miner.getPatchesSourceCode()); int size = miner.getMaxSize(); if (size > maxSize) { maxSize = size; } + log.info("Finish of parsing file: " + revFile.getPath()); } - FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + msg.getId() + "_MaxSize=" + maxSize + ".list", editScripts, false); - FileHelper.outputToFile(patchesSourceCodeFilePath + "patches" + msg.getId() + ".list", patchesSourceCode, false); + int id = msg.getId(); + FileHelper.outputToFile(editScriptsFilePath + "edistScripts" + id + "_MaxSize=" + maxSize + ".list", editScripts, false); + FileHelper.outputToFile(patchesSourceCodeFilePath + "patches" + id + ".list", patchesSourceCode, false); + log.info("Worker #" + id + " finished the work..."); this.getSender().tell("STOP", getSelf()); } else { unhandled(message);