From a206255c197cd91a339492614f69c914ef0cfe63 Mon Sep 17 00:00:00 2001 From: Rangeet Pan <23088883+rangeetpan@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:50:22 -0400 Subject: [PATCH] Update codeanalyzer.py to add a new method that can read analysis.json in a string format and returns Japplication --- cldk/analysis/java/codeanalyzer/codeanalyzer.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cldk/analysis/java/codeanalyzer/codeanalyzer.py b/cldk/analysis/java/codeanalyzer/codeanalyzer.py index 7dccd9ba..fbe56f0f 100644 --- a/cldk/analysis/java/codeanalyzer/codeanalyzer.py +++ b/cldk/analysis/java/codeanalyzer/codeanalyzer.py @@ -186,7 +186,16 @@ def _get_codeanalyzer_exec(self) -> List[str]: codeanalyzer_jar_file = self._download_or_update_code_analyzer(codeanalyzer_jar_path) codeanalyzer_exec = shlex.split(f"java -jar {codeanalyzer_jar_file}") return codeanalyzer_exec - + + def init_japplication(self, data: str) -> JApplication: + """Return JApplication giving the stringified JSON as input. + Returns + ------- + JApplication + The application view of the Java code with the analysis results. + """ + return JApplication(**json.loads(data)) + def _init_codeanalyzer(self, analysis_level=1) -> JApplication: """Initializes the Codeanalyzer. Returns @@ -1043,4 +1052,4 @@ def get_all_entry_point_classes(self) -> Dict[str, JType]: symtab = self.get_symbol_table() for val in symtab.values(): class_dict.update((k, v) for k, v in val.type_declarations.items() if v.is_entry_point is True) - return class_dict \ No newline at end of file + return class_dict