Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/main/java/com/ibm/northstar/CodeAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,18 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
SymbolTable.extractAll(Paths.get(input));

symbolTable = symbolTableExtractionResult.getLeft();
/*
* if (output != null) {
* Path outputPath = Paths.get(output);
* if (!Files.exists(outputPath)) {
* Files.createDirectories(outputPath);
* }
* gson.toJson(symbolTableExtractionResult.getRight(), new FileWriter(new File(outputPath.toString(), "parse_errors.json")));

if (output != null) {
Path outputPath = Paths.get(output);
if (!Files.exists(outputPath)) {
Files.createDirectories(outputPath);
}
String parseError = gson.toJson(symbolTableExtractionResult.getRight());
emit(parseError, "parse_errors.json");
/* gson.toJson(symbolTableExtractionResult.getRight(), new FileWriter(new File(outputPath.toString(), "parse_errors.json")));
* }
**/
}

if (analysisLevel > 1) {
// Save SDG, and Call graph as JSON
Expand Down Expand Up @@ -155,15 +158,15 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
combinedJsonObject.add("symbol_table", symbolTableJSON);

String consolidatedJSONString = gson.toJson(combinedJsonObject);
emit(consolidatedJSONString);
emit(consolidatedJSONString, "analysis.json");
}

private static void emit(String consolidatedJSONString) throws IOException {
private static void emit(String consolidatedJSONString, String filename) throws IOException {
if (output == null) {
System.out.println(consolidatedJSONString);
} else {
// If output is not null, export to a file
File file = new File(output, "analysis.json");
File file = new File(output, filename);
try (FileWriter fileWriter = new FileWriter(file)) {
fileWriter.write(consolidatedJSONString);
Log.done("Analysis output saved at " + output);
Expand Down