33from typing import Dict , List , Tuple , Set
44from networkx import DiGraph
55
6- from cldk .analysis import SymbolTable , CallGraph
6+ from cldk .analysis import SymbolTable , CallGraph , AnalysisLevel
77from cldk .models .java import JCallable
88from cldk .models .java import JApplication
99from cldk .models .java .models import JCompilationUnit , JMethodDetail , JType , JField
@@ -157,7 +157,8 @@ def get_call_graph_json(self) -> str:
157157 raise NotImplementedError ("Producing a call graph over a single file is not implemented yet." )
158158 return self .backend .get_call_graph_json ()
159159
160- def get_callers (self , target_class_name : str , target_method_declaration : str ):
160+ def get_callers (self , target_class_name : str , target_method_declaration : str ,
161+ using_symbol_table : bool = False ) -> Dict :
161162 """
162163 Get all the caller details for a given java method.
163164
@@ -168,7 +169,7 @@ def get_callers(self, target_class_name: str, target_method_declaration: str):
168169 """
169170 if self .source_code :
170171 raise NotImplementedError ("Generating all callers over a single file is not implemented yet." )
171- return self .backend .get_all_callers (target_class_name , target_method_declaration )
172+ return self .backend .get_all_callers (target_class_name , target_method_declaration , using_symbol_table )
172173
173174 def get_callees (self , source_class_name : str , source_method_declaration : str ):
174175 """
@@ -437,25 +438,50 @@ def get_implemented_interfaces(self, qualified_class_name) -> List[str]:
437438 raise NotImplementedError (f"Support for this functionality has not been implemented yet." )
438439 return self .backend .get_implemented_interfaces (qualified_class_name )
439440
440- def get_class_call_graph (self , qualified_class_name : str , method_name : str | None = None ) -> (List )[Tuple [JMethodDetail , JMethodDetail ]]:
441+ def __get_class_call_graph_using_symbol_table (self , qualified_class_name : str , method_signature : str | None = None ) -> (List )[Tuple [JMethodDetail , JMethodDetail ]]:
442+ """
443+ A call graph using symbol table for a given class and a given method.
444+ Args:
445+ qualified_class_name:
446+ method_signature:
447+
448+ Returns:
449+ List[Tuple[JMethodDetail, JMethodDetail]]
450+ An edge list of the call graph for the given class and method.
451+ """
452+ if self .analysis_backend in [AnalysisEngine .CODEQL , AnalysisEngine .TREESITTER ]:
453+ raise NotImplementedError (f"Support for this functionality has not been implemented yet." )
454+ return self .backend .get_class_call_graph_using_symbol_table (qualified_class_name , method_signature )
455+
456+ def get_class_call_graph (self , qualified_class_name : str , method_signature : str | None = None ,
457+ using_symbol_table : bool = False ) -> List [Tuple [JMethodDetail , JMethodDetail ]]:
441458 """
442459 A call graph for a given class and (optionally) a given method.
443460
444461 Parameters
445462 ----------
463+ using_symbol_table: bool
464+ Generate call graph using symbol table
446465 qualified_class_name : str
447466 The qualified name of the class.
448467 method_name : str, optional
449- The name of the method in the class.
468+ The signature of the method in the class.
450469
451470 Returns
452471 -------
453472 List[Tuple[JMethodDetail, JMethodDetail]]
454473 An edge list of the call graph for the given class and method.
474+
475+ Args:
476+ using_symbol_table:
477+ using_symbol_table:
455478 """
479+ if using_symbol_table :
480+ return self .__get_class_call_graph_using_symbol_table (qualified_class_name = qualified_class_name ,
481+ method_signature = method_signature )
456482 if self .analysis_backend in [AnalysisEngine .CODEQL , AnalysisEngine .TREESITTER ]:
457483 raise NotImplementedError (f"Support for this functionality has not been implemented yet." )
458- return self .backend .get_class_call_graph (qualified_class_name , method_name )
484+ return self .backend .get_class_call_graph (qualified_class_name , method_signature )
459485
460486 def get_entry_point_classes (self ) -> Dict [str , JType ]:
461487 """
0 commit comments