Skip to content

Commit efb4b2c

Browse files
pmbittneribbem
authored andcommitted
feat: add error reporting to UnparseAnalysis
1 parent 5bdb8f1 commit efb4b2c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/main/java/org/variantsync/diffdetective/experiments/thesis_es/UnparseAnalysis.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ public class UnparseAnalysis implements Analysis.Hooks {
2525

2626
private StringBuilder csv;
2727

28+
// for debugging
29+
private int errorCount = 0;
30+
2831
@Override
2932
public void initializeResults(Analysis analysis) {
3033
Analysis.Hooks.super.initializeResults(analysis);
3134

3235
csv = new StringBuilder();
3336
csv.append(UnparseEvaluation.makeHeader(CSV.DEFAULT_CSV_DELIMITER)).append(StringUtils.LINEBREAK);
37+
38+
errorCount = 0;
3439
}
3540

3641
@Override
@@ -67,7 +72,8 @@ public boolean analyzeVariationDiff(Analysis analysis) throws Exception {
6772
}
6873
if (!boolOr(treeBeforeTest)) {
6974
error = error * 3;
70-
errorSave[1] = codeBefore;
75+
reportErrorToFile(analysis, codeBefore);
76+
// errorSave[1] = codeBefore;
7177
}
7278
if (!boolOr(treeAfterTest)) {
7379
error = error * 5;
@@ -98,6 +104,13 @@ public void endBatch(Analysis analysis) throws IOException {
98104
csv.toString());
99105
}
100106

107+
private void reportErrorToFile(Analysis analysis, String errorMessage) throws IOException {
108+
IO.write(
109+
FileUtils.addExtension(analysis.getOutputFile().resolve("_error" + errorCount), ".txt"),
110+
errorMessage);
111+
++errorCount;
112+
}
113+
101114
public static String removeWhitespace1(String string) {
102115
string = string.replaceAll("\n(\\s*\n)+", "\n");
103116
string = string.replaceAll("\n\\s+", "\n");

0 commit comments

Comments
 (0)