diff --git a/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java b/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java index 6989548..a400421 100644 --- a/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java +++ b/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java @@ -32,14 +32,7 @@ public class FixedViolationHunkParser extends FixedViolationParser { @SuppressWarnings("unused") private static Logger log = LoggerFactory.getLogger(FixedViolationHunkParser.class); public String testingInfo = ""; - /* - * ResultType: - * 0: normal GumTree results. - * 1: null GumTree result. - * 2: No source code changes. - * 3: useless violations - */ - public int resultType = 0; + public int nullMappingGumTreeResult = 0; public int pureDeletions = 0; public int largeHunk = 0; @@ -59,14 +52,10 @@ public class FixedViolationHunkParser extends FixedViolationParser { // TODO remove the modification of variable names or not? FIXME List actionSets = parseChangedSourceCodeWithGumTree2(prevFile, revFile); // only remove non-statement source code, eg. method declaration - if (actionSets == null) { - this.resultType = 1; - } else if (actionSets.size() == 0) { - this.resultType = 2; - } else { + if (actionSets != null && actionSets.size() != 0) { List violations = readViolations(revFile.getName()); if (violations.size() == 0) { - this.resultType = 3; + this.resultType = 4; return; } // List diffentryHunks1 = new DiffEntryReader().readHunks2(diffentryFile); diff --git a/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationParser.java b/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationParser.java index fe13d9b..d1ab8b5 100644 --- a/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationParser.java +++ b/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationParser.java @@ -29,6 +29,16 @@ public class FixedViolationParser extends Parser { private static Logger log = LoggerFactory.getLogger(FixedViolationParser.class); + /* + * ResultType: + * 0: normal GumTree results. + * 1: null GumTree result. + * 2: No source code changes. + * 3: No Statement Change. + * 4: useless violations + */ + public int resultType = 0; + private File positionFile = null; protected String alarmTypes = ""; protected List uselessViolations; @@ -53,9 +63,11 @@ public class FixedViolationParser extends Parser { // GumTree results List gumTreeResults = new GumTreeComparer().compareTwoFilesWithGumTree(prevFile, revFile); if (gumTreeResults == null) { + this.resultType = 1; return null; } else if (gumTreeResults.size() == 0){ System.err.println("#NoSourceCodeChange: " + revFile.getName()); + this.resultType = 2; return actionSets; } else { // Regroup GumTre results. @@ -75,6 +87,7 @@ public class FixedViolationParser extends Parser { actionSets = sorter.sortAscending(); if (actionSets.size() == 0) { + this.resultType = 3; System.err.println("#NoStatementChange: " + revFile.getName()); } 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 a954aee..96f6a6e 100644 --- a/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java +++ b/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java @@ -77,6 +77,7 @@ public class ParseFixPatternWorker extends UntypedActor { int nullGumTreeResults = 0; int nullMappingGumTreeResults = 0; int noSourceCodeChanges = 0; + int noStatementChanges = 0; int pureDeletion = 0; int expNums = 0; int largeHunk = 0; @@ -124,6 +125,8 @@ public class ParseFixPatternWorker extends UntypedActor { System.err.println("#NullGumTreeResult: " + revFile.getName()); } else if (parser.resultType == 2) { noSourceCodeChanges += countAlarms(positionFile); + } else if (parser.resultType == 3) { + noStatementChanges += countAlarms(positionFile); } } else { editScripts.append(editScript); @@ -185,7 +188,7 @@ public class ParseFixPatternWorker extends UntypedActor { } String statistic = "testAlarms: " + testAlarms + "\nnullGumTreeResults: " + nullGumTreeResults + "\nnullMappingGumTreeResults: " + nullMappingGumTreeResults + "\nnoSourceCodeChanges: " + noSourceCodeChanges + "\npureDeletion: " + pureDeletion + "\nTimeout: " + expNums + - "\nlargeHunk: " + largeHunk + "\nnullSourceCode: " + nullSourceCode; + "\nlargeHunk: " + largeHunk + "\nnullSourceCode: " + nullSourceCode + "\nnoStatementChanges: " + noStatementChanges; FileHelper.outputToFile("OUTPUT/statistic_" + id + ".list", statistic, false); log.info("Worker #" + id +"Finish of parsing " + counter + " files..."); diff --git a/src/main/java/edu/lu/uni/serval/statistics/Statistic.java b/src/main/java/edu/lu/uni/serval/statistics/Statistic.java index a558ef3..f49d27f 100644 --- a/src/main/java/edu/lu/uni/serval/statistics/Statistic.java +++ b/src/main/java/edu/lu/uni/serval/statistics/Statistic.java @@ -63,6 +63,7 @@ public class Statistic { int noSourceCodeChagnes = 0; int largeHunk = 0; int nullSourceCode = 0; + int noStatementChanges = 0; for (File file : files) { String content = FileHelper.readFile(file); BufferedReader reader = new BufferedReader(new StringReader(content)); @@ -85,7 +86,9 @@ public class Statistic { largeHunk += Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim()); } else if (line.startsWith("nullSourceCode")) { nullSourceCode += Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim()); - } + } else if (line.startsWith("noStatementChanges")) { + noStatementChanges += Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim()); + } } } catch (IOException e) { e.printStackTrace(); @@ -121,6 +124,7 @@ public class Statistic { System.out.println("noSourceCodeChange: " + noSourceCodeChagnes); System.out.println("largeHunk: " + largeHunk); System.out.println("nullSourceCode: " + nullSourceCode); + System.out.println("noStatementChanges: " + noStatementChanges); } public static void statistics(String fileName, String type) throws IOException {