Spaces:
Running
Running
Update parser.py
Browse files
parser.py
CHANGED
@@ -130,23 +130,25 @@ def parse_node(node, lines, prev_end, level=0, total_lines=None, parent_path=Non
|
|
130 |
processed_lines.add(start_line)
|
131 |
|
132 |
# Handle variables in function definitions (input variables)
|
133 |
-
if isinstance(
|
134 |
-
|
135 |
-
|
136 |
-
if
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
'
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
150 |
|
151 |
# Process nested bodies
|
152 |
nested_prev_end = start_line
|
|
|
130 |
processed_lines.add(start_line)
|
131 |
|
132 |
# Handle variables in function definitions (input variables)
|
133 |
+
if isinstance(child, ast.Assign) or isinstance(child, ast.AnnAssign) or isinstance(child, ast.AugAssign):
|
134 |
+
targets = child.targets if isinstance(child, ast.Assign) else [child.target]
|
135 |
+
for target in targets:
|
136 |
+
if isinstance(target, ast.Name):
|
137 |
+
var_start = child.lineno
|
138 |
+
if var_start not in processed_lines and not is_blank_or_comment(lines[var_start - 1]):
|
139 |
+
counters['assigned_variable'] += 1
|
140 |
+
var_node_id = f"AssignedVariable[{counters['assigned_variable']}]"
|
141 |
+
var_info = {'role': 'assigned_variable', 'name': target.id}
|
142 |
+
parts.append({
|
143 |
+
'category': 'assigned_variable',
|
144 |
+
'source': lines[var_start - 1],
|
145 |
+
'location': (var_start, var_start),
|
146 |
+
'level': level + 1,
|
147 |
+
'vector': create_vector('assigned_variable', level + 1, (var_start, var_start), total_lines, current_path, var_info),
|
148 |
+
'parent_path': f"{current_path[0]} -> {var_node_id}",
|
149 |
+
'node_id': var_node_id
|
150 |
+
})
|
151 |
+
processed_lines.add(var_start)
|
152 |
|
153 |
# Process nested bodies
|
154 |
nested_prev_end = start_line
|