20
20
21
21
from pathlib import Path
22
22
from typing import Dict , List , Optional
23
+ import networkx as nx
23
24
24
- from networkx import DiGraph
25
25
26
26
from cldk .analysis .c .clang import ClangAnalyzer
27
27
from cldk .models .c import CApplication , CFunction , CTranslationUnit , CMacro , CTypedef , CStruct , CEnum , CVariable
@@ -56,7 +56,7 @@ def _init_application(self, project_dir: Path) -> CApplication:
56
56
return CApplication (translation_units = translation_units )
57
57
58
58
def get_c_application (self ) -> CApplication :
59
- """Returns the C application object.
59
+ """returns the C application object.
60
60
61
61
Returns:
62
62
CApplication: C application object.
@@ -89,16 +89,16 @@ def is_parsable(self, source_code: str) -> bool:
89
89
"""
90
90
raise NotImplementedError ("Support for this functionality has not been implemented yet." )
91
91
92
- def get_call_graph (self ) -> DiGraph :
93
- """Returns the call graph of the C code.
92
+ def get_call_graph (self ) -> nx . DiGraph :
93
+ """returns the call graph of the C code.
94
94
95
95
Returns:
96
- DiGraph: The call graph of the C code.
96
+ nx. DiGraph: The call graph of the C code.
97
97
"""
98
98
raise NotImplementedError ("Support for this functionality has not been implemented yet." )
99
99
100
100
def get_call_graph_json (self ) -> str :
101
- """Returns a serialized call graph in json.
101
+ """returns a serialized call graph in json.
102
102
103
103
Raises:
104
104
NotImplementedError: Raised when this functionality is not suported.
@@ -110,7 +110,7 @@ def get_call_graph_json(self) -> str:
110
110
raise NotImplementedError ("Producing a call graph over a single file is not implemented yet." )
111
111
112
112
def get_callers (self , function : CFunction ) -> Dict :
113
- """Returns a dictionary of callers of the target method.
113
+ """returns a dictionary of callers of the target method.
114
114
115
115
Args:
116
116
function (CFunction): A CFunction object.
@@ -125,7 +125,7 @@ def get_callers(self, function: CFunction) -> Dict:
125
125
raise NotImplementedError ("Generating all callers over a single file is not implemented yet." )
126
126
127
127
def get_callees (self , function : CFunction ) -> Dict :
128
- """Returns a dictionary of callees in a fuction.
128
+ """returns a dictionary of callees in a fuction.
129
129
130
130
Args:
131
131
function (CFunction): A CFunction object.
@@ -139,7 +139,7 @@ def get_callees(self, function: CFunction) -> Dict:
139
139
raise NotImplementedError ("Generating all callees over a single file is not implemented yet." )
140
140
141
141
def get_functions (self ) -> Dict [str , CFunction ]:
142
- """Returns all functions in the project.
142
+ """returns all functions in the project.
143
143
144
144
Raises:
145
145
NotImplementedError: Raised when current AnalysisEngine does not support this function.
@@ -151,7 +151,7 @@ def get_functions(self) -> Dict[str, CFunction]:
151
151
return translation_unit .functions
152
152
153
153
def get_function (self , function_name : str , file_name : Optional [str ]) -> CFunction | List [CFunction ]:
154
- """Returns a function object given the function name.
154
+ """returns a function object given the function name.
155
155
156
156
Args:
157
157
function_name (str): The name of the function.
@@ -163,7 +163,7 @@ def get_function(self, function_name: str, file_name: Optional[str]) -> CFunctio
163
163
raise NotImplementedError ("Support for this functionality has not been implemented yet." )
164
164
165
165
def get_C_file (self , file_name : str ) -> str :
166
- """Returns a class given qualified class name.
166
+ """returns a class given qualified class name.
167
167
168
168
Args:
169
169
file_name (str): The name of the file.
@@ -191,7 +191,7 @@ def get_C_compilation_unit(self, file_path: str) -> CTranslationUnit:
191
191
return self .c_application .translation_units .get (file_path )
192
192
193
193
def get_functions_in_file (self , file_name : str ) -> List [CFunction ]:
194
- """Returns a dictionary of all methods of the given class.
194
+ """returns a dictionary of all methods of the given class.
195
195
196
196
Args:
197
197
file_name (str): The name of the file.
@@ -205,7 +205,7 @@ def get_functions_in_file(self, file_name: str) -> List[CFunction]:
205
205
raise NotImplementedError ("Support for this functionality has not been implemented yet." )
206
206
207
207
def get_macros (self ) -> List [CMacro ]:
208
- """Returns a list of all macros in the C code.
208
+ """returns a list of all macros in the C code.
209
209
210
210
Raises:
211
211
NotImplementedError: Raised when current AnalysisEngine does not support this function.
@@ -216,7 +216,7 @@ def get_macros(self) -> List[CMacro]:
216
216
raise NotImplementedError ("Support for this functionality has not been implemented yet." )
217
217
218
218
def get_macros_in_file (self , file_name : str ) -> List [CMacro ] | None :
219
- """Returns a list of all macros in the given file.
219
+ """returns a list of all macros in the given file.
220
220
221
221
Args:
222
222
file_name (str): The name of the file.
@@ -231,7 +231,7 @@ def get_macros_in_file(self, file_name: str) -> List[CMacro] | None:
231
231
232
232
233
233
def get_includes (self ) -> List [str ]:
234
- """Returns a list of all include statements across all files in the C code.
234
+ """returns a list of all include statements across all files in the C code.
235
235
236
236
Returns:
237
237
List[str]: A list of all include statements. Returns empty list if none found.
@@ -243,7 +243,7 @@ def get_includes(self) -> List[str]:
243
243
244
244
245
245
def get_includes_in_file (self , file_name : str ) -> List [str ] | None :
246
- """Returns a list of all include statements in the given file.
246
+ """returns a list of all include statements in the given file.
247
247
248
248
Args:
249
249
file_name (str): The name of the file to search in.
@@ -257,7 +257,7 @@ def get_includes_in_file(self, file_name: str) -> List[str] | None:
257
257
258
258
259
259
def get_macros (self ) -> List [CMacro ]:
260
- """Returns a list of all macro definitions across all files in the C code.
260
+ """returns a list of all macro definitions across all files in the C code.
261
261
262
262
Returns:
263
263
List[CMacro]: A list of all macro definitions. Returns empty list if none found.
@@ -269,7 +269,7 @@ def get_macros(self) -> List[CMacro]:
269
269
270
270
271
271
def get_macros_in_file (self , file_name : str ) -> List [CMacro ] | None :
272
- """Returns a list of all macro definitions in the given file.
272
+ """returns a list of all macro definitions in the given file.
273
273
274
274
Args:
275
275
file_name (str): The name of the file to search in.
@@ -283,7 +283,7 @@ def get_macros_in_file(self, file_name: str) -> List[CMacro] | None:
283
283
284
284
285
285
def get_typedefs (self ) -> List [CTypedef ]:
286
- """Returns a list of all typedef declarations across all files in the C code.
286
+ """returns a list of all typedef declarations across all files in the C code.
287
287
288
288
Returns:
289
289
List[CTypedef]: A list of all typedef declarations. Returns empty list if none found.
@@ -295,7 +295,7 @@ def get_typedefs(self) -> List[CTypedef]:
295
295
296
296
297
297
def get_typedefs_in_file (self , file_name : str ) -> List [CTypedef ] | None :
298
- """Returns a list of all typedef declarations in the given file.
298
+ """returns a list of all typedef declarations in the given file.
299
299
300
300
Args:
301
301
file_name (str): The name of the file to search in.
@@ -309,7 +309,7 @@ def get_typedefs_in_file(self, file_name: str) -> List[CTypedef] | None:
309
309
310
310
311
311
def get_structs (self ) -> List [CStruct ]:
312
- """Returns a list of all struct/union declarations across all files in the C code.
312
+ """returns a list of all struct/union declarations across all files in the C code.
313
313
314
314
Returns:
315
315
List[CStruct]: A list of all struct/union declarations. Returns empty list if none found.
@@ -321,7 +321,7 @@ def get_structs(self) -> List[CStruct]:
321
321
322
322
323
323
def get_structs_in_file (self , file_name : str ) -> List [CStruct ] | None :
324
- """Returns a list of all struct/union declarations in the given file.
324
+ """returns a list of all struct/union declarations in the given file.
325
325
326
326
Args:
327
327
file_name (str): The name of the file to search in.
@@ -335,7 +335,7 @@ def get_structs_in_file(self, file_name: str) -> List[CStruct] | None:
335
335
336
336
337
337
def get_enums (self ) -> List [CEnum ]:
338
- """Returns a list of all enum declarations across all files in the C code.
338
+ """returns a list of all enum declarations across all files in the C code.
339
339
340
340
Returns:
341
341
List[CEnum]: A list of all enum declarations. Returns empty list if none found.
@@ -347,7 +347,7 @@ def get_enums(self) -> List[CEnum]:
347
347
348
348
349
349
def get_enums_in_file (self , file_name : str ) -> List [CEnum ] | None :
350
- """Returns a list of all enum declarations in the given file.
350
+ """returns a list of all enum declarations in the given file.
351
351
352
352
Args:
353
353
file_name (str): The name of the file to search in.
@@ -361,7 +361,7 @@ def get_enums_in_file(self, file_name: str) -> List[CEnum] | None:
361
361
362
362
363
363
def get_globals (self , file_name : str ) -> List [CVariable ] | None :
364
- """Returns a list of all global variable declarations in the given file.
364
+ """returns a list of all global variable declarations in the given file.
365
365
366
366
Args:
367
367
file_name (str): The name of the file to search in.
0 commit comments