diff --git a/api/analyzers/c/analyzer.py b/api/analyzers/c/analyzer.py index 149915c..09a5e26 100644 --- a/api/analyzers/c/analyzer.py +++ b/api/analyzers/c/analyzer.py @@ -369,21 +369,24 @@ def first_pass(self, path: Path, f: io.TextIOWrapper, graph:Graph) -> None: # ] # } - functions = captures['function'] - for node in functions: - self.process_function_definition(file, node, path, graph, source_code) + if 'function' in captures: + functions = captures['function'] + for node in functions: + self.process_function_definition(file, node, path, graph, source_code) # Process struct definitions query = C_LANGUAGE.query("(struct_specifier) @struct") captures = query.captures(tree.root_node) - structs = captures['struct'] - # captures: {'struct': - # [ - # - # ] - # } - for node in structs: - self.process_struct_specifier(file, node, path, graph) + + if 'struct' in captures: + structs = captures['struct'] + # captures: {'struct': + # [ + # + # ] + # } + for node in structs: + self.process_struct_specifier(file, node, path, graph) def second_pass(self, path: Path, f: io.TextIOWrapper, graph: Graph) -> None: """