Skip to content

Commit 938169e

Browse files
committed
fix error when no function or struct in code
1 parent 46d4693 commit 938169e

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

api/analyzers/c/analyzer.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -369,21 +369,24 @@ def first_pass(self, path: Path, f: io.TextIOWrapper, graph:Graph) -> None:
369369
# ]
370370
# }
371371

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)
375376

376377
# Process struct definitions
377378
query = C_LANGUAGE.query("(struct_specifier) @struct")
378379
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)
387390

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

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ validators = "^0.34.0"
1313
falkordb = "^1.0.5"
1414
tree-sitter-c = "^0.23.2"
1515
tree-sitter-python = "^0.23.6"
16-
flask = "^3.0.3"
16+
flask = "^3.1.0"
1717
python-dotenv = "^1.0.1"
1818

1919
[tool.poetry.group.test.dependencies]

0 commit comments

Comments
 (0)