@@ -124,6 +124,22 @@ def _init_japplication(data: str) -> JApplication:
124124
125125 # set_trace()
126126 return JApplication (** json .loads (data ))
127+
128+ @staticmethod
129+ def check_exisiting_analysis_file_level (analysis_json_path_file : Path , analysis_level : int ) -> bool :
130+ analysis_file_compatible = True
131+ if not analysis_json_path_file .exists ():
132+ analysis_file_compatible = False
133+ else :
134+ with open (analysis_json_path_file ) as f :
135+ data = json .load (f )
136+ if analysis_level == 2 and "call_graph" not in data :
137+ analysis_file_compatible = False
138+ elif analysis_level == 1 and "symbol_table" not in data :
139+ analysis_file_compatible = False
140+ return analysis_file_compatible
141+
142+
127143
128144 def _init_codeanalyzer (self , analysis_level = 1 ) -> JApplication :
129145 """Should initialize the Codeanalyzer.
@@ -170,7 +186,7 @@ def _init_codeanalyzer(self, analysis_level=1) -> JApplication:
170186 )
171187 is_run_code_analyzer = True
172188 else :
173- if not analysis_json_path_file . exists ( ) or self .eager_analysis :
189+ if not self . check_exisiting_analysis_file_level ( analysis_json_path_file , analysis_level ) or self .eager_analysis :
174190 # If the analysis file does not exist, we'll run the analysis. Alternately, if the eager_analysis
175191 # flag is set, we'll run the analysis every time the object is created. This will happen regradless
176192 # of the existence of the analysis file.
0 commit comments