Update.
This commit is contained in:
+3
-14
@@ -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<HierarchicalActionSet> 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<Violation> violations = readViolations(revFile.getName());
|
||||
if (violations.size() == 0) {
|
||||
this.resultType = 3;
|
||||
this.resultType = 4;
|
||||
return;
|
||||
}
|
||||
// List<DiffEntryHunk> diffentryHunks1 = new DiffEntryReader().readHunks2(diffentryFile);
|
||||
|
||||
@@ -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<Violation> uselessViolations;
|
||||
@@ -53,9 +63,11 @@ public class FixedViolationParser extends Parser {
|
||||
// GumTree results
|
||||
List<Action> 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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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...");
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user