This commit is contained in:
Kui LIU
2017-11-22 15:17:27 +01:00
parent 3d5f3b65e8
commit 834ced05d0
3 changed files with 36 additions and 21 deletions
@@ -407,7 +407,12 @@ public abstract class Parser implements ParserInterface {
} }
} }
} else { } else {
singleEdit += " " + actionSet.getAstNodeType()+ "exp"; ITree nodeTree = actionSet.getNode();
if (nodeTree.getChildren().size() > 0) {
singleEdit += " " + actionSet.getAstNodeType()+ "exp";
} else {
singleEdit += " " + nodeTree.getLabel().replaceAll(" ", "");
}
} }
} }
} }
@@ -144,13 +144,17 @@ public class FixedViolationHunkParser extends FixedViolationParser {
} }
// Obtain Source Code of patches from DiffEntries. // Obtain Source Code of patches from DiffEntries.
// String patchSourceCode = getPatchSourceCode(prevFile, revFile, bugStartLine, bugEndLine, fixStartLine, fixEndLine, isPureInsert);
String patchSourceCode = this.readPatchSourceCode(violation, bugStartLine, bugEndLine, fixStartLine, fixEndLine); String patchSourceCode = this.readPatchSourceCode(violation, bugStartLine, bugEndLine, fixStartLine, fixEndLine);
if ("".equals(patchSourceCode)) { if ("".equals(patchSourceCode)) {
this.nullSourceCode ++; patchSourceCode = getPatchSourceCode(prevFile, revFile, bugStartLine, bugEndLine, fixStartLine, fixEndLine, isPureInsert);
this.unfixedViolations += "#NullSourceCode:" + revFile.getName() + ":" + violation.getStartLineNum() if ("".equals(patchSourceCode)) {
+ ":" + violation.getEndLineNum() + ":" + violation.getViolationType() + "\n"; this.nullSourceCode ++;
continue; this.unfixedViolations += "#NullSourceCode:" + revFile.getName() + ":" + violation.getStartLineNum()
+ ":" + violation.getEndLineNum() + ":" + violation.getViolationType() + "\n";
// continue;
patchSourceCode = getPatchSourceCode(prevFile, revFile, bugStartLine, bugEndLine, fixStartLine, fixEndLine, isPureInsert);
}
} }
/** /**
@@ -71,18 +71,18 @@ public class Statistic {
/** /**
* Do statistics from two files: * Do statistics from two files:
*/ */
statistics("../FPM_Violations/RQ1/all-leafnodes-per-project-vtype.csv", "", map1, 16918530, 730); // statistics("../FPM_Violations/RQ1/all-leafnodes-per-project-vtype.csv", "", map1, 16918530, 730);
// statistics("../FPM_Violations/RQ1/distinct-fixed-summary-per-project-vtype.csv", "Fixed"); //// statistics("../FPM_Violations/RQ1/distinct-fixed-summary-per-project-vtype.csv", "Fixed");
statistics("../FPM_Violations/RQ1/fixedViolations-v-1.0.csv", "Fixed_1.0", map2, 88927, 548); // statistics("../FPM_Violations/RQ1/fixedViolations-v-1.0.csv", "Fixed_1.0", map2, 88927, 548);
// fixedVSunfixed(); //// fixedVSunfixed();
StringBuilder builder = new StringBuilder(); // StringBuilder builder = new StringBuilder();
for (Map.Entry<String, Integer> entry : map1.entrySet()) { // for (Map.Entry<String, Integer> entry : map1.entrySet()) {
String key = entry.getKey(); // String key = entry.getKey();
builder.append(key + "," + entry.getValue() + "," + (map2.containsKey(key) ? map2.get(key) : 0) + "\n"); // builder.append(key + "," + entry.getValue() + "," + (map2.containsKey(key) ? map2.get(key) : 0) + "\n");
} // }
FileHelper.outputToFile(Configuration.ROOT_PATH + "RQ2/quantity-ratios.csv", builder, false); // FileHelper.outputToFile(Configuration.ROOT_PATH + "RQ2/quantity-ratios.csv", builder, false);
// statisticsOfFixedViolations(); statisticsOfFixedViolations();
//rsync -avP gaia-cluster:/work/users/kliu/FixPattern/FPM_Violations/UnfixedViolations/BC_UNCONFIRMED_CAST/Sizes.list Sizes/Sizes1.list //rsync -avP gaia-cluster:/work/users/kliu/FixPattern/FPM_Violations/UnfixedViolations/BC_UNCONFIRMED_CAST/Sizes.list Sizes/Sizes1.list
// String s = "rsync -avP gaia-cluster:/work/users/kliu/FixPattern/FPM_Violations/UnfixedViolations_RQ3/"; // String s = "rsync -avP gaia-cluster:/work/users/kliu/FixPattern/FPM_Violations/UnfixedViolations_RQ3/";
@@ -120,7 +120,7 @@ public class Statistic {
} }
public static void statisticsOfFixedViolations() { public static void statisticsOfFixedViolations() {
String statistic = "../FPM_Violations/OUTPUT"; String statistic = "../FPM_Violations/OUTPUT2/";
List<File> files = FileHelper.getAllFiles(statistic, ".list"); List<File> files = FileHelper.getAllFiles(statistic, ".list");
int positions = 0; int positions = 0;
@@ -201,6 +201,9 @@ public class Statistic {
} else { } else {
types1.put(type, 1); types1.put(type, 1);
} }
if (line.startsWith("#NullSourceCode:")) {
System.out.println(line);
}
} }
} catch(IOException e) { } catch(IOException e) {
e.printStackTrace(); e.printStackTrace();
@@ -241,14 +244,17 @@ public class Statistic {
// } // }
int sum3 = 0; int sum3 = 0;
int sum4 = 0; int sum4 = 0;
int sum5 = 0;
for (Map.Entry<String, Integer> entry : types1.entrySet()) { for (Map.Entry<String, Integer> entry : types1.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue()); System.out.println(entry.getKey() + ": " + entry.getValue());
if (!entry.getKey().startsWith("#PureDeletion")) { if (!entry.getKey().startsWith("#PureDeletion")) {
if (!entry.getKey().startsWith("#Timeout") && !entry.getKey().startsWith("#TestViolation")) if (!entry.getKey().startsWith("#Timeout") && !entry.getKey().startsWith("#TestViolation"))
sum3 += entry.getValue(); sum3 += entry.getValue();
else sum4 += entry.getValue(); else sum4 += entry.getValue();
sum5+= entry.getValue();
} }
} }
System.out.println(sum5);
System.out.println(i); System.out.println(i);
System.out.println("\n\nStatistics:\nPositions: " + positions); System.out.println("\n\nStatistics:\nPositions: " + positions);
@@ -268,9 +274,9 @@ public class Statistic {
// System.out.println("B: " + (numV + testAlarms + timeout)); // System.out.println("B: " + (numV + testAlarms + timeout));
System.out.println(testAlarms + nullGumTreeResults + noSourceCodeChagnes + noStatementChanges + System.out.println(testAlarms + nullGumTreeResults + noSourceCodeChagnes + noStatementChanges +
nullDiffentry + nullMappingGumTreeResults + nullSourceCode + timeout + TestingInfo); nullDiffentry + nullMappingGumTreeResults + nullSourceCode + timeout + TestingInfo);
System.out.println(nullGumTreeResults + noSourceCodeChagnes + noStatementChanges + // System.out.println(nullGumTreeResults + noSourceCodeChagnes + noStatementChanges +
nullDiffentry + nullMappingGumTreeResults + nullSourceCode + TestingInfo); // nullDiffentry + nullMappingGumTreeResults + nullSourceCode + TestingInfo);
System.out.println(testAlarms + timeout); // System.out.println(testAlarms + timeout);
// System.out.println(sum); // System.out.println(sum);
// System.out.println(sum2); // System.out.println(sum2);
System.out.println(sum3); System.out.println(sum3);