@@ -117,15 +117,18 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
117
117
SymbolTable .extractAll (Paths .get (input ));
118
118
119
119
symbolTable = symbolTableExtractionResult .getLeft ();
120
- /*
121
- * if (output != null) {
122
- * Path outputPath = Paths.get(output);
123
- * if (!Files.exists(outputPath)) {
124
- * Files.createDirectories(outputPath);
125
- * }
126
- * gson.toJson(symbolTableExtractionResult.getRight(), new FileWriter(new File(outputPath.toString(), "parse_errors.json")));
120
+
121
+ if (output != null ) {
122
+ Path outputPath = Paths .get (output );
123
+ if (!Files .exists (outputPath )) {
124
+ Files .createDirectories (outputPath );
125
+ }
126
+ String parseError = gson .toJson (symbolTableExtractionResult .getRight ());
127
+ emit (parseError , "parse_errors.json" );
128
+ /* gson.toJson(symbolTableExtractionResult.getRight(), new FileWriter(new File(outputPath.toString(), "parse_errors.json")));
127
129
* }
128
130
**/
131
+ }
129
132
130
133
if (analysisLevel > 1 ) {
131
134
// Save SDG, and Call graph as JSON
@@ -155,15 +158,15 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
155
158
combinedJsonObject .add ("symbol_table" , symbolTableJSON );
156
159
157
160
String consolidatedJSONString = gson .toJson (combinedJsonObject );
158
- emit (consolidatedJSONString );
161
+ emit (consolidatedJSONString , "analysis.json" );
159
162
}
160
163
161
- private static void emit (String consolidatedJSONString ) throws IOException {
164
+ private static void emit (String consolidatedJSONString , String filename ) throws IOException {
162
165
if (output == null ) {
163
166
System .out .println (consolidatedJSONString );
164
167
} else {
165
168
// If output is not null, export to a file
166
- File file = new File (output , "analysis.json" );
169
+ File file = new File (output , filename );
167
170
try (FileWriter fileWriter = new FileWriter (file )) {
168
171
fileWriter .write (consolidatedJSONString );
169
172
Log .done ("Analysis output saved at " + output );
0 commit comments