Test.
This commit is contained in:
+40
-6
@@ -51,9 +51,26 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
||||
// GumTree results
|
||||
// TODO remove the modification of variable names or not? FIXME
|
||||
List<HierarchicalActionSet> actionSets = parseChangedSourceCodeWithGumTree2(prevFile, revFile); // only remove non-statement source code, eg. method declaration
|
||||
|
||||
if (actionSets != null && actionSets.size() != 0) {
|
||||
List<Violation> violations = readViolations(revFile.getName());
|
||||
List<Violation> violations = readViolations(revFile.getName());
|
||||
if (this.resultType != 0) {
|
||||
String type = "";
|
||||
switch (this.resultType) {
|
||||
case 1:
|
||||
type = "#NullGumTreeResult:";
|
||||
break;
|
||||
case 2:
|
||||
type = "#NoSourceCodeChange:";
|
||||
break;
|
||||
case 3:
|
||||
type = "#NoStatementChange:";
|
||||
break;
|
||||
}
|
||||
for (Violation v : violations) {
|
||||
System.err.println(type + revFile.getName().replace("#", "/") + ":" + v.getStartLineNum() + ":" + v.getEndLineNum() + ":" + v.getAlarmType());
|
||||
}
|
||||
} else {
|
||||
// }
|
||||
// if (actionSets != null && actionSets.size() != 0) {
|
||||
if (violations.size() == 0) {
|
||||
this.resultType = 4;
|
||||
return;
|
||||
@@ -180,6 +197,8 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
||||
if (fixStartLine == 0) {
|
||||
// pure delete actions.
|
||||
this.pureDeletions ++;
|
||||
System.err.println("#PureDeletion: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
||||
// continue;
|
||||
}
|
||||
|
||||
@@ -203,7 +222,10 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
||||
}
|
||||
if (bugEndLine - bugStartLine > Configuration.HUNK_SIZE || fixEndLine - fixStartLine > Configuration.HUNK_SIZE) {
|
||||
this.largeHunk ++;
|
||||
System.err.println("#LargeHunk: " + revFile.getName());
|
||||
if (fixStartLine != 0) {
|
||||
System.err.println("#LargeHunk:" + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -214,6 +236,10 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
||||
String patchSourceCode = getPatchSourceCode(prevFile, revFile, bugStartLine, bugEndLine, fixStartLine, fixEndLine, isInsert);
|
||||
if ("".equals(patchSourceCode)) {
|
||||
this.nullSourceCode ++;
|
||||
if (fixStartLine != 0) {
|
||||
System.err.println("#NullSourceCode:" + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -243,8 +269,12 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
||||
|
||||
if (!"SE_NO_SERIALVERSIONID".equals(alarmType)) {
|
||||
if (containsFiledDeclaration(hunkActionSets)) {
|
||||
this.nullMappingGumTreeResult ++;
|
||||
// this.nullMappingGumTreeResult ++; //TODO
|
||||
this.testingInfo += info + revFile.getName() + "\n";
|
||||
if (fixStartLine != 0) {
|
||||
this.testingInfo += "#TestingInfo: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -262,8 +292,12 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
||||
} else if (containSpecialStmt(hunkActionSets, bugEndPosition, fixEndPosition)) {
|
||||
|
||||
} else {
|
||||
this.nullMappingGumTreeResult ++;
|
||||
// this.nullMappingGumTreeResult ++; // TODO
|
||||
this.testingInfo += info + revFile.getName() + "\n";
|
||||
if (fixStartLine != 0) {
|
||||
this.testingInfo += "#TestingInfo: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ public class FixedViolationParser extends Parser {
|
||||
this.resultType = 1;
|
||||
return null;
|
||||
} else if (gumTreeResults.size() == 0){
|
||||
System.err.println("#NoSourceCodeChange: " + revFile.getName());
|
||||
this.resultType = 2;
|
||||
return actionSets;
|
||||
} else {
|
||||
@@ -88,7 +87,6 @@ public class FixedViolationParser extends Parser {
|
||||
|
||||
if (actionSets.size() == 0) {
|
||||
this.resultType = 3;
|
||||
System.err.println("#NoStatementChange: " + revFile.getName());
|
||||
}
|
||||
|
||||
return actionSets;
|
||||
|
||||
@@ -82,6 +82,7 @@ public class ParseFixPatternWorker extends UntypedActor {
|
||||
int expNums = 0;
|
||||
int largeHunk = 0;
|
||||
int nullSourceCode = 0;
|
||||
int illegalV = 0;
|
||||
|
||||
for (MessageFile msgFile : files) {
|
||||
File revFile = msgFile.getRevFile();
|
||||
@@ -89,8 +90,7 @@ public class ParseFixPatternWorker extends UntypedActor {
|
||||
File diffentryFile = msgFile.getDiffEntryFile();
|
||||
File positionFile = msgFile.getPositionFile();
|
||||
if (revFile.getName().toLowerCase().contains("test")) {
|
||||
testAlarms += countAlarms(positionFile);
|
||||
System.err.println("#TestViolation: " + revFile.getName());
|
||||
testAlarms += countAlarms(positionFile, "#TestViolation:");
|
||||
// continue;
|
||||
}
|
||||
// Parser parser = null;
|
||||
@@ -121,12 +121,14 @@ public class ParseFixPatternWorker extends UntypedActor {
|
||||
String editScript = parser.getAstEditScripts();
|
||||
if ("".equals(editScript)) {
|
||||
if (parser.resultType == 1) {
|
||||
nullGumTreeResults += countAlarms(positionFile);
|
||||
System.err.println("#NullGumTreeResult: " + revFile.getName());
|
||||
nullGumTreeResults += countAlarms(positionFile, "");
|
||||
// System.err.println("#NullGumTreeResult:" + revFile.getName());
|
||||
} else if (parser.resultType == 2) {
|
||||
noSourceCodeChanges += countAlarms(positionFile);
|
||||
noSourceCodeChanges += countAlarms(positionFile, "");
|
||||
} else if (parser.resultType == 3) {
|
||||
noStatementChanges += countAlarms(positionFile);
|
||||
noStatementChanges += countAlarms(positionFile, "");
|
||||
} else if (parser.resultType == 4) {
|
||||
illegalV += countAlarms(positionFile, "");
|
||||
}
|
||||
} else {
|
||||
editScripts.append(editScript);
|
||||
@@ -156,16 +158,16 @@ public class ParseFixPatternWorker extends UntypedActor {
|
||||
} catch (TimeoutException e) {
|
||||
// err.println("task timed out");
|
||||
future.cancel(true);
|
||||
expNums += countAlarms(positionFile);
|
||||
System.err.println("#Timeout: " + revFile.getName());
|
||||
expNums += countAlarms(positionFile, "#Timeout:");
|
||||
// System.err.println("#Timeout: " + revFile.getName());
|
||||
} catch (InterruptedException e) {
|
||||
expNums += countAlarms(positionFile);
|
||||
expNums += countAlarms(positionFile, "#TimeInterrupted:");
|
||||
// err.println("task interrupted");
|
||||
System.err.println("#TimeInterrupted: " + revFile.getName());
|
||||
// System.err.println("#TimeInterrupted: " + revFile.getName());
|
||||
} catch (ExecutionException e) {
|
||||
expNums += countAlarms(positionFile);
|
||||
expNums += countAlarms(positionFile, "#TimeAborted:");
|
||||
// err.println("task aborted");
|
||||
System.err.println("#TimeAborted: " + revFile.getName());
|
||||
// System.err.println("#TimeAborted: " + revFile.getName());
|
||||
} finally {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
@@ -188,7 +190,7 @@ public class ParseFixPatternWorker extends UntypedActor {
|
||||
}
|
||||
String statistic = "testAlarms: " + testAlarms + "\nnullGumTreeResults: " + nullGumTreeResults + "\nnullMappingGumTreeResults: " + nullMappingGumTreeResults +
|
||||
"\nnoSourceCodeChanges: " + noSourceCodeChanges + "\npureDeletion: " + pureDeletion + "\nTimeout: " + expNums +
|
||||
"\nlargeHunk: " + largeHunk + "\nnullSourceCode: " + nullSourceCode + "\nnoStatementChanges: " + noStatementChanges;
|
||||
"\nlargeHunk: " + largeHunk + "\nnullSourceCode: " + nullSourceCode + "\nnoStatementChanges: " + noStatementChanges + "\nIllegalV: " + illegalV;
|
||||
FileHelper.outputToFile("OUTPUT/statistic_" + id + ".list", statistic, false);
|
||||
|
||||
log.info("Worker #" + id +"Finish of parsing " + counter + " files...");
|
||||
@@ -231,13 +233,18 @@ public class ParseFixPatternWorker extends UntypedActor {
|
||||
return uselessViolations;
|
||||
}
|
||||
|
||||
private int countAlarms(File positionFile) {
|
||||
private int countAlarms(File positionFile, String type) {
|
||||
int counter = 0;
|
||||
String content = FileHelper.readFile(positionFile);
|
||||
BufferedReader reader = new BufferedReader(new StringReader(content));
|
||||
String line = null;
|
||||
try {
|
||||
while (reader.readLine() != null) {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
counter ++;
|
||||
if (!"".equals(type)) {
|
||||
String[] elements = line.split(":");
|
||||
System.err.println(type + positionFile.getName().replaceAll("#", "/").replace(".txt", ".java") + ":" + elements[1] + ":" + elements[2] + ":" + elements[0]);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -440,8 +440,8 @@ public class HunkActionFilter {
|
||||
violation.getActionSets().addAll(matchedActionSets);
|
||||
selectedViolations.add(violation);
|
||||
} else {
|
||||
System.err.println("#NullMatchedGumTreeResult: " + revFile.getName().replace("#", "/") + " : " +violation.getStartLineNum() + " : " +
|
||||
violation.getEndLineNum() + " : " + violation.getAlarmType());
|
||||
System.err.println("#NullMatchedGumTreeResult:" + revFile.getName().replace("#", "/") + ":" +violation.getStartLineNum() + ":" +
|
||||
violation.getEndLineNum() + ":" + violation.getAlarmType());
|
||||
}
|
||||
}
|
||||
return selectedViolations;
|
||||
|
||||
Reference in New Issue
Block a user