Correct the ranges of buggy code and fixed code.

This commit is contained in:
Kui LIU
2017-08-11 23:34:31 +02:00
parent c71f70551c
commit 1587adf88b
@@ -133,9 +133,13 @@ public class FixedViolationHunkParser extends FixedViolationParser {
int actionFixEnd = hunkActionSet.getFixEndLineNum();
if (bugStartLine == 0) {
bugStartLine = actionBugStart;
} else if (actionBugStart != 0 && actionBugStart < bugStartLine) {
bugStartLine = actionBugStart;
}
if (fixStartLine == 0) {
fixStartLine = actionFixStart;
} else if (actionFixStart != 0 && actionFixStart < fixStartLine) {
fixStartLine = actionFixStart;
}
if (bugEndLine < actionBugEnd) bugEndLine = actionBugEnd;
if (fixEndLine < actionFixEnd) fixEndLine = actionFixEnd;
@@ -164,10 +168,12 @@ public class FixedViolationHunkParser extends FixedViolationParser {
// Source Code of patches.
String patchSourceCode = getPatchSourceCode(prevFile, revFile, bugStartLine, bugEndLine, fixStartLine, fixEndLine, isInsert);
if ("".equals(patchSourceCode)) continue;
int size = astEditScripts.split(" ").length;
if (size == 1) continue;
counter ++;
String patchPosition = "";//"###:" + counter + "\n" + revFile.getName() + "\nPosition: " + violation.getStartLineNum() + " --> " + violation.getEndLineNum() + "\n@@ -" + bugStartLine + ", " + bugEndLine + " +" + fixStartLine + ", " + fixEndLine + "@@\n";
this.patchesSourceCode += Configuration.PATCH_SIGNAL + "\n" + patchPosition + patchSourceCode + "\nAST diff:\n" + getAstEditScripts(hunkActionSets) + "\n";
int size = astEditScripts.split(" ").length;
this.sizes += size + "\n";
this.astEditScripts += astEditScripts + "\n";
this.alarmTypes += violation.getAlarmType() + "\n";