@@ -369,21 +369,24 @@ def first_pass(self, path: Path, f: io.TextIOWrapper, graph:Graph) -> None:
369
369
# ]
370
370
# }
371
371
372
- functions = captures ['function' ]
373
- for node in functions :
374
- self .process_function_definition (file , node , path , graph , source_code )
372
+ if 'function' in captures :
373
+ functions = captures ['function' ]
374
+ for node in functions :
375
+ self .process_function_definition (file , node , path , graph , source_code )
375
376
376
377
# Process struct definitions
377
378
query = C_LANGUAGE .query ("(struct_specifier) @struct" )
378
379
captures = query .captures (tree .root_node )
379
- structs = captures ['struct' ]
380
- # captures: {'struct':
381
- # [
382
- # <Node type=struct_specifier, start_point=(9, 0), end_point=(13, 1)>
383
- # ]
384
- # }
385
- for node in structs :
386
- self .process_struct_specifier (file , node , path , graph )
380
+
381
+ if 'struct' in captures :
382
+ structs = captures ['struct' ]
383
+ # captures: {'struct':
384
+ # [
385
+ # <Node type=struct_specifier, start_point=(9, 0), end_point=(13, 1)>
386
+ # ]
387
+ # }
388
+ for node in structs :
389
+ self .process_struct_specifier (file , node , path , graph )
387
390
388
391
def second_pass (self , path : Path , f : io .TextIOWrapper , graph : Graph ) -> None :
389
392
"""
0 commit comments