Skip to content

Commit 5862d63

Browse files
committed
fix: parse function body node
1 parent f268b78 commit 5862d63

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

scubatrace/function.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ def create(node: Node, parent: File | BlockStatement):
8686
else:
8787
return Function(node, parent)
8888

89+
@cached_property
90+
def statements(self) -> list[Statement]:
91+
"""
92+
Statements in the function.
93+
"""
94+
if self.body_node is None:
95+
return []
96+
return BlockStatement.build_statements(self.body_node, self)
97+
8998
def __str__(self) -> str:
9099
return self.signature
91100

scubatrace/statement.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def variables(self) -> list[Identifier]:
124124
for identifier in self.identifiers:
125125
node = identifier.node
126126
if node.parent is not None and node.parent.type in [
127+
"ERROR",
127128
"call_expression",
128129
"function_declarator",
129130
"method_invocation",
@@ -724,7 +725,7 @@ def create(node: Node, parent: BlockStatement | Function | File):
724725
Args:
725726
node (Node): The tree-sitter node representing the block statement.
726727
parent (BlockStatement | Function | File): The parent block, function, or file this statement belongs to.
727-
728+
728729
Returns:
729730
BlockStatement: An instance of the appropriate BlockStatement subclass based on the language.
730731
"""

0 commit comments

Comments
 (0)