@@ -117,15 +117,18 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
117117 SymbolTable .extractAll (Paths .get (input ));
118118
119119 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")));
127129 * }
128130 **/
131+ }
129132
130133 if (analysisLevel > 1 ) {
131134 // Save SDG, and Call graph as JSON
@@ -155,15 +158,15 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
155158 combinedJsonObject .add ("symbol_table" , symbolTableJSON );
156159
157160 String consolidatedJSONString = gson .toJson (combinedJsonObject );
158- emit (consolidatedJSONString );
161+ emit (consolidatedJSONString , "analysis.json" );
159162 }
160163
161- private static void emit (String consolidatedJSONString ) throws IOException {
164+ private static void emit (String consolidatedJSONString , String filename ) throws IOException {
162165 if (output == null ) {
163166 System .out .println (consolidatedJSONString );
164167 } else {
165168 // If output is not null, export to a file
166- File file = new File (output , "analysis.json" );
169+ File file = new File (output , filename );
167170 try (FileWriter fileWriter = new FileWriter (file )) {
168171 fileWriter .write (consolidatedJSONString );
169172 Log .done ("Analysis output saved at " + output );
0 commit comments