Skip to content

Commit f54f0ed

Browse files
committed
adjust c analyzer
1 parent 09b57ec commit f54f0ed

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

api/analyzers/c/analyzer.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,26 @@ def first_pass(self, path: Path, f: io.TextIOWrapper, graph:Graph) -> None:
363363
# Process function definitions
364364
query = C_LANGUAGE.query("(function_definition) @function")
365365
captures = query.captures(tree.root_node)
366-
for capture in captures:
367-
node = capture[0]
366+
# captures: {'function':
367+
# [<Node type=function_definition, start_point=(0, 0), end_point=(7, 1)>,
368+
# <Node type=function_definition, start_point=(15, 0), end_point=(18, 1)>
369+
# ]
370+
# }
371+
372+
functions = captures['function']
373+
for node in functions:
368374
self.process_function_definition(file, node, path, graph, source_code)
369375

370376
# Process struct definitions
371377
query = C_LANGUAGE.query("(struct_specifier) @struct")
372378
captures = query.captures(tree.root_node)
373-
for capture in captures:
374-
node = capture[0]
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:
375386
self.process_struct_specifier(file, node, path, graph)
376387

377388
def second_pass(self, path: Path, f: io.TextIOWrapper, graph: Graph) -> None:

0 commit comments

Comments
 (0)