Skip to content

Commit 1fe7ba2

Browse files
authored
Merge branch 'main' into main
2 parents 9558d64 + 1f9c575 commit 1fe7ba2

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/main/java/com/ibm/northstar/CodeAnalyzer.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
import java.io.File;
3030
import java.io.FileWriter;
3131
import java.io.IOException;
32-
import java.nio.charset.StandardCharsets;
3332
import java.nio.file.Files;
3433
import java.nio.file.Path;
3534
import java.nio.file.Paths;
3635
import java.util.List;
3736
import java.util.Map;
38-
import java.util.zip.GZIPOutputStream;
3937

4038
/**
4139
* The type Code analyzer.
@@ -61,9 +59,6 @@ public class CodeAnalyzer implements Runnable {
6159
@Option(names = {"-a", "--analysis-level"}, description = "Level of analysis to perform. Options: 1 (for just symbol table) or 2 (for call graph). Default: 1")
6260
private static int analysisLevel = 1;
6361

64-
@Option(names = {"-d", "--dependencies"}, description = "Path to the application 3rd party dependencies that may be helpful in analyzing the application.")
65-
private static String dependencies;
66-
6762
@Option(names = {"-v", "--verbose"}, description = "Print logs to console.")
6863
private static boolean verbose = false;
6964

@@ -107,9 +102,11 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
107102
}
108103

109104
else {
110-
111105
// download library dependencies of project for type resolution
112-
if (!BuildProject.downloadLibraryDependencies(input)) {
106+
String dependencies = null;
107+
if (BuildProject.downloadLibraryDependencies(input)) {
108+
dependencies = String.valueOf(BuildProject.libDownloadPath);
109+
} else {
113110
Log.warn("Failed to download library dependencies of project");
114111
}
115112
// construct symbol table for project, write parse problems to file in output directory if specified
@@ -123,8 +120,8 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
123120
if (!Files.exists(outputPath)) {
124121
Files.createDirectories(outputPath);
125122
}
126-
String parseError = gson.toJson(symbolTableExtractionResult.getRight());
127-
emit(parseError, "parse_errors.json");
123+
// String parseError = gson.toJson(symbolTableExtractionResult.getRight());
124+
// emit(parseError, "parse_errors.json");
128125
/* gson.toJson(symbolTableExtractionResult.getRight(), new FileWriter(new File(outputPath.toString(), "parse_errors.json")));
129126
* }
130127
**/

src/main/java/com/ibm/northstar/SystemDependencyGraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public static String construct(
206206

207207
// Initialize scope
208208
AnalysisScope scope = ScopeUtils.createScope(input, dependencies, build);
209-
IClassHierarchy cha = ClassHierarchyFactory.makeWithRoot(scope,
209+
IClassHierarchy cha = ClassHierarchyFactory.make(scope,
210210
new ECJClassLoaderFactory(scope.getExclusions()));
211211
Log.done("There were a total of " + cha.getNumberOfClasses() + " classes of which "
212212
+ AnalysisUtils.getNumberOfApplicationClasses(cha) + " are application classes.");

src/main/java/com/ibm/northstar/utils/BuildProject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
public class BuildProject {
1515

16-
private static final String LIB_DEPS_DOWNLOAD_DIR = "_libdeps";
17-
16+
public static Path libDownloadPath;
17+
private static final String LIB_DEPS_DOWNLOAD_DIR = ".library-dependencies";
1818
private static final String MAVEN_CMD = System.getProperty("os.name").toLowerCase().contains("windows") ? "mvn.cmd" : "mvn";
1919
private static final String GRADLE_CMD = System.getProperty("os.name").toLowerCase().contains("windows") ? "gradlew.bat" : "gradlew";
2020

@@ -129,7 +129,7 @@ public static List<Path> buildProjectAndStreamClassFiles(String projectPath, Str
129129
*/
130130
public static boolean downloadLibraryDependencies(String projectPath) {
131131
// created download dir if it does not exist
132-
Path libDownloadPath = Paths.get(projectPath, LIB_DEPS_DOWNLOAD_DIR);
132+
libDownloadPath = Paths.get(projectPath, LIB_DEPS_DOWNLOAD_DIR);
133133
if (!Files.exists(libDownloadPath)) {
134134
try {
135135
Files.createDirectory(libDownloadPath);

0 commit comments

Comments
 (0)