agentcrew-ai 0.8.12__py3-none-any.whl → 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. AgentCrew/__init__.py +1 -1
  2. AgentCrew/app.py +34 -633
  3. AgentCrew/main.py +55 -3
  4. AgentCrew/main_docker.py +1 -30
  5. AgentCrew/modules/agents/local_agent.py +26 -1
  6. AgentCrew/modules/chat/message/command_processor.py +33 -8
  7. AgentCrew/modules/chat/message/handler.py +5 -1
  8. AgentCrew/modules/code_analysis/__init__.py +8 -0
  9. AgentCrew/modules/code_analysis/parsers/__init__.py +67 -0
  10. AgentCrew/modules/code_analysis/parsers/base.py +93 -0
  11. AgentCrew/modules/code_analysis/parsers/cpp_parser.py +127 -0
  12. AgentCrew/modules/code_analysis/parsers/csharp_parser.py +162 -0
  13. AgentCrew/modules/code_analysis/parsers/generic_parser.py +63 -0
  14. AgentCrew/modules/code_analysis/parsers/go_parser.py +154 -0
  15. AgentCrew/modules/code_analysis/parsers/java_parser.py +103 -0
  16. AgentCrew/modules/code_analysis/parsers/javascript_parser.py +268 -0
  17. AgentCrew/modules/code_analysis/parsers/kotlin_parser.py +84 -0
  18. AgentCrew/modules/code_analysis/parsers/php_parser.py +107 -0
  19. AgentCrew/modules/code_analysis/parsers/python_parser.py +60 -0
  20. AgentCrew/modules/code_analysis/parsers/ruby_parser.py +46 -0
  21. AgentCrew/modules/code_analysis/parsers/rust_parser.py +72 -0
  22. AgentCrew/modules/code_analysis/service.py +231 -897
  23. AgentCrew/modules/command_execution/constants.py +2 -2
  24. AgentCrew/modules/console/completers.py +1 -1
  25. AgentCrew/modules/console/confirmation_handler.py +4 -4
  26. AgentCrew/modules/console/console_ui.py +17 -3
  27. AgentCrew/modules/console/conversation_browser/__init__.py +9 -0
  28. AgentCrew/modules/console/conversation_browser/browser.py +84 -0
  29. AgentCrew/modules/console/conversation_browser/browser_input_handler.py +279 -0
  30. AgentCrew/modules/console/conversation_browser/browser_ui.py +643 -0
  31. AgentCrew/modules/console/conversation_handler.py +34 -1
  32. AgentCrew/modules/console/diff_display.py +22 -51
  33. AgentCrew/modules/console/display_handlers.py +142 -26
  34. AgentCrew/modules/console/tool_display.py +4 -6
  35. AgentCrew/modules/file_editing/service.py +8 -8
  36. AgentCrew/modules/file_editing/tool.py +65 -67
  37. AgentCrew/modules/gui/components/command_handler.py +137 -29
  38. AgentCrew/modules/gui/components/tool_handlers.py +0 -2
  39. AgentCrew/modules/gui/themes/README.md +30 -14
  40. AgentCrew/modules/gui/themes/__init__.py +2 -1
  41. AgentCrew/modules/gui/themes/atom_light.yaml +1287 -0
  42. AgentCrew/modules/gui/themes/catppuccin.yaml +1276 -0
  43. AgentCrew/modules/gui/themes/dracula.yaml +1262 -0
  44. AgentCrew/modules/gui/themes/nord.yaml +1267 -0
  45. AgentCrew/modules/gui/themes/saigontech.yaml +1268 -0
  46. AgentCrew/modules/gui/themes/style_provider.py +76 -264
  47. AgentCrew/modules/gui/themes/theme_loader.py +379 -0
  48. AgentCrew/modules/gui/themes/unicorn.yaml +1276 -0
  49. AgentCrew/modules/gui/widgets/configs/global_settings.py +3 -4
  50. AgentCrew/modules/gui/widgets/diff_widget.py +30 -61
  51. AgentCrew/modules/llm/constants.py +18 -9
  52. AgentCrew/modules/memory/context_persistent.py +1 -0
  53. AgentCrew/modules/memory/tool.py +1 -1
  54. AgentCrew/setup.py +470 -0
  55. {agentcrew_ai-0.8.12.dist-info → agentcrew_ai-0.9.0.dist-info}/METADATA +1 -1
  56. {agentcrew_ai-0.8.12.dist-info → agentcrew_ai-0.9.0.dist-info}/RECORD +60 -41
  57. {agentcrew_ai-0.8.12.dist-info → agentcrew_ai-0.9.0.dist-info}/WHEEL +1 -1
  58. AgentCrew/modules/gui/themes/atom_light.py +0 -1365
  59. AgentCrew/modules/gui/themes/catppuccin.py +0 -1404
  60. AgentCrew/modules/gui/themes/dracula.py +0 -1372
  61. AgentCrew/modules/gui/themes/nord.py +0 -1365
  62. AgentCrew/modules/gui/themes/saigontech.py +0 -1359
  63. AgentCrew/modules/gui/themes/unicorn.py +0 -1372
  64. {agentcrew_ai-0.8.12.dist-info → agentcrew_ai-0.9.0.dist-info}/entry_points.txt +0 -0
  65. {agentcrew_ai-0.8.12.dist-info → agentcrew_ai-0.9.0.dist-info}/licenses/LICENSE +0 -0
  66. {agentcrew_ai-0.8.12.dist-info → agentcrew_ai-0.9.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,268 @@
1
+ """
2
+ JavaScript/TypeScript language parser for code analysis.
3
+ """
4
+
5
+ from typing import Any, Dict, Optional
6
+
7
+ from .base import BaseLanguageParser
8
+
9
+
10
+ class JavaScriptParser(BaseLanguageParser):
11
+ """Parser for JavaScript and TypeScript source code."""
12
+
13
+ @property
14
+ def language_name(self) -> str:
15
+ return "javascript"
16
+
17
+ def process_node(
18
+ self, node, source_code: bytes, process_children_callback
19
+ ) -> Optional[Dict[str, Any]]:
20
+ result = self._create_base_result(node)
21
+
22
+ if node.type in [
23
+ "class_declaration",
24
+ "method_definition",
25
+ "class",
26
+ "method_declaration",
27
+ "function_declaration",
28
+ "interface_declaration",
29
+ "export_statement",
30
+ "arrow_function",
31
+ "lexical_declaration",
32
+ ]:
33
+ if node.type == "export_statement":
34
+ return self._handle_export_statement(
35
+ node, source_code, process_children_callback
36
+ )
37
+ elif node.type == "arrow_function":
38
+ return self._handle_arrow_function(
39
+ node, source_code, result, process_children_callback
40
+ )
41
+ elif node.type == "lexical_declaration":
42
+ return self._handle_lexical_declaration(
43
+ node, source_code, result, process_children_callback
44
+ )
45
+ else:
46
+ self._handle_regular_declaration(node, source_code, result)
47
+
48
+ elif node.type in ["property_declaration", "public_field_definition"]:
49
+ return self._handle_property_declaration(node, source_code, result)
50
+
51
+ elif node.type in ["variable_statement", "variable_declaration"]:
52
+ return self._handle_variable_statement(
53
+ node, source_code, result, process_children_callback
54
+ )
55
+
56
+ children = []
57
+ for child in node.children:
58
+ child_result = process_children_callback(child)
59
+ if child_result and self._is_significant_node(child_result):
60
+ children.append(child_result)
61
+
62
+ if children:
63
+ result["children"] = children
64
+
65
+ return result
66
+
67
+ def _handle_export_statement(
68
+ self, node, source_code: bytes, process_children_callback
69
+ ) -> Optional[Dict[str, Any]]:
70
+ for child in node.children:
71
+ if child.type in [
72
+ "class_declaration",
73
+ "function_declaration",
74
+ "interface_declaration",
75
+ "variable_statement",
76
+ "lexical_declaration",
77
+ "method_definition",
78
+ ]:
79
+ exported_result = process_children_callback(child)
80
+ if exported_result:
81
+ exported_result["exported"] = True
82
+ return exported_result
83
+ return None
84
+
85
+ def _handle_arrow_function(
86
+ self,
87
+ node,
88
+ source_code: bytes,
89
+ result: Dict[str, Any],
90
+ process_children_callback,
91
+ ) -> Dict[str, Any]:
92
+ parent = node.parent
93
+ if parent and parent.type == "variable_declarator":
94
+ for sibling in parent.children:
95
+ if sibling.type == "identifier":
96
+ result["type"] = "arrow_function"
97
+ result["name"] = self.extract_node_text(sibling, source_code)
98
+
99
+ for child in node.children:
100
+ if child.type == "formal_parameters":
101
+ params = self._extract_parameters(child, source_code)
102
+ if params:
103
+ result["parameters"] = params
104
+
105
+ return result
106
+
107
+ def _handle_lexical_declaration(
108
+ self,
109
+ node,
110
+ source_code: bytes,
111
+ result: Dict[str, Any],
112
+ process_children_callback,
113
+ ) -> Dict[str, Any]:
114
+ for child in node.children:
115
+ if child.type == "variable_declarator":
116
+ var_name = None
117
+ has_arrow_function = False
118
+
119
+ for declarator_child in child.children:
120
+ if declarator_child.type == "identifier":
121
+ var_name = self.extract_node_text(declarator_child, source_code)
122
+ elif declarator_child.type == "arrow_function":
123
+ has_arrow_function = True
124
+
125
+ if var_name and has_arrow_function:
126
+ result["type"] = "arrow_function"
127
+ result["name"] = var_name
128
+ for declarator_child in child.children:
129
+ if declarator_child.type == "arrow_function":
130
+ arrow_result = process_children_callback(declarator_child)
131
+ if arrow_result and "parameters" in arrow_result:
132
+ result["parameters"] = arrow_result["parameters"]
133
+ else:
134
+ result["type"] = "variable_declaration"
135
+ result["name"] = var_name
136
+ result["first_line"] = (
137
+ self.extract_node_text(node, source_code)
138
+ .split("\n")[0]
139
+ .strip("{")
140
+ )
141
+
142
+ return result
143
+
144
+ def _handle_regular_declaration(
145
+ self, node, source_code: bytes, result: Dict[str, Any]
146
+ ) -> None:
147
+ for child in node.children:
148
+ if child.type in ["identifier", "type_identifier", "property_identifier"]:
149
+ result["name"] = self.extract_node_text(child, source_code)
150
+ elif child.type == "formal_parameters" and node.type in [
151
+ "function_declaration",
152
+ "method_declaration",
153
+ "method_definition",
154
+ ]:
155
+ params = self._extract_parameters_with_types(child, source_code)
156
+ if params:
157
+ result["parameters"] = params
158
+
159
+ def _handle_variable_statement(
160
+ self,
161
+ node,
162
+ source_code: bytes,
163
+ result: Dict[str, Any],
164
+ process_children_callback,
165
+ ) -> Dict[str, Any]:
166
+ for child in node.children:
167
+ if child.type == "variable_declaration_list":
168
+ for declarator in child.children:
169
+ if declarator.type == "variable_declarator":
170
+ var_name = None
171
+ has_arrow_function = False
172
+
173
+ for declarator_child in declarator.children:
174
+ if declarator_child.type == "identifier":
175
+ var_name = self.extract_node_text(
176
+ declarator_child, source_code
177
+ )
178
+ elif declarator_child.type == "arrow_function":
179
+ has_arrow_function = True
180
+
181
+ if var_name:
182
+ if has_arrow_function:
183
+ result["type"] = "arrow_function"
184
+ result["name"] = var_name
185
+ for declarator_child in declarator.children:
186
+ if declarator_child.type == "arrow_function":
187
+ arrow_result = process_children_callback(
188
+ declarator_child
189
+ )
190
+ if (
191
+ arrow_result
192
+ and "parameters" in arrow_result
193
+ ):
194
+ result["parameters"] = arrow_result[
195
+ "parameters"
196
+ ]
197
+ else:
198
+ result["type"] = "variable_declaration"
199
+ result["name"] = var_name
200
+ return result
201
+
202
+ elif child.type == "identifier":
203
+ result["type"] = "variable_declaration"
204
+ result["name"] = self.extract_node_text(child, source_code)
205
+ return result
206
+
207
+ return result
208
+
209
+ def _handle_property_declaration(
210
+ self, node, source_code: bytes, result: Dict[str, Any]
211
+ ) -> Dict[str, Any]:
212
+ prop_name = None
213
+ prop_type = None
214
+
215
+ for child in node.children:
216
+ if child.type in ["property_identifier", "identifier"]:
217
+ prop_name = self.extract_node_text(child, source_code)
218
+ elif child.type == "type_annotation":
219
+ for type_child in child.children:
220
+ if type_child.type != ":":
221
+ prop_type = self.extract_node_text(type_child, source_code)
222
+
223
+ if prop_name:
224
+ result["type"] = "property_declaration"
225
+ if prop_type:
226
+ result["name"] = f"{prop_name}: {prop_type}"
227
+ else:
228
+ result["name"] = prop_name
229
+
230
+ return result
231
+
232
+ def _extract_parameters(self, params_node, source_code: bytes) -> list:
233
+ params = []
234
+ for param in params_node.children:
235
+ if param.type in ["required_parameter", "optional_parameter", "identifier"]:
236
+ param_text = self.extract_node_text(param, source_code)
237
+ params.append(param_text)
238
+ return params
239
+
240
+ def _extract_parameters_with_types(self, params_node, source_code: bytes) -> list:
241
+ params = []
242
+ for param in params_node.children:
243
+ if param.type in ["required_parameter", "optional_parameter", "identifier"]:
244
+ param_name = None
245
+ param_type = None
246
+
247
+ if param.type == "identifier":
248
+ param_name = self.extract_node_text(param, source_code)
249
+ params.append(param_name)
250
+ continue
251
+
252
+ for param_child in param.children:
253
+ if param_child.type in ["identifier", "object_pattern"]:
254
+ param_name = self.extract_node_text(param_child, source_code)
255
+ elif param_child.type == "type_annotation":
256
+ for type_child in param_child.children:
257
+ if type_child.type != ":":
258
+ param_type = self.extract_node_text(
259
+ type_child, source_code
260
+ )
261
+
262
+ if param_name:
263
+ if param_type:
264
+ params.append(f"{param_name}: {param_type}")
265
+ else:
266
+ params.append(param_name)
267
+
268
+ return params
@@ -0,0 +1,84 @@
1
+ """
2
+ Kotlin language parser for code analysis.
3
+ """
4
+
5
+ from typing import Any, Dict, Optional
6
+
7
+ from .base import BaseLanguageParser
8
+
9
+
10
+ class KotlinParser(BaseLanguageParser):
11
+ """Parser for Kotlin source code."""
12
+
13
+ @property
14
+ def language_name(self) -> str:
15
+ return "kotlin"
16
+
17
+ def process_node(
18
+ self, node, source_code: bytes, process_children_callback
19
+ ) -> Optional[Dict[str, Any]]:
20
+ result = self._create_base_result(node)
21
+
22
+ if node.type == "class_declaration":
23
+ for child in node.children:
24
+ if child.type in ["simple_identifier", "type_identifier"]:
25
+ result["name"] = self.extract_node_text(child, source_code)
26
+ elif child.type == "class_body":
27
+ children = []
28
+ for body_child in child.children:
29
+ child_result = process_children_callback(body_child)
30
+ if child_result and self._is_significant_node(child_result):
31
+ children.append(child_result)
32
+ if children:
33
+ result["children"] = children
34
+ return result
35
+
36
+ elif node.type == "function_declaration":
37
+ for child in node.children:
38
+ if child.type == "simple_identifier":
39
+ result["name"] = self.extract_node_text(child, source_code)
40
+ return result
41
+ return result
42
+
43
+ elif node.type in ["property_declaration", "variable_declaration"]:
44
+ return self._handle_property_declaration(node, source_code, result)
45
+
46
+ children = []
47
+ for child in node.children:
48
+ child_result = process_children_callback(child)
49
+ if child_result and self._is_significant_node(child_result):
50
+ children.append(child_result)
51
+
52
+ if children:
53
+ result["children"] = children
54
+
55
+ return result
56
+
57
+ def _handle_property_declaration(
58
+ self, node, source_code: bytes, result: Dict[str, Any]
59
+ ) -> Dict[str, Any]:
60
+ prop_name = None
61
+ prop_type = None
62
+
63
+ for child in node.children:
64
+ if child.type == "variable_declaration":
65
+ for subchild in child.children:
66
+ if subchild.type == "simple_identifier" and prop_name is None:
67
+ prop_name = self.extract_node_text(subchild, source_code)
68
+ elif subchild.type == "user_type":
69
+ prop_type = self.extract_node_text(subchild, source_code)
70
+ elif subchild.type in ["nullable_type", "type_identifier"]:
71
+ prop_type = self.extract_node_text(subchild, source_code)
72
+ elif child.type == "simple_identifier" and prop_name is None:
73
+ prop_name = self.extract_node_text(child, source_code)
74
+ elif child.type == "user_type":
75
+ prop_type = self.extract_node_text(child, source_code)
76
+
77
+ if prop_name:
78
+ result["type"] = "property_declaration"
79
+ if prop_type:
80
+ result["name"] = f"{prop_name}: {prop_type}"
81
+ else:
82
+ result["name"] = prop_name
83
+
84
+ return result
@@ -0,0 +1,107 @@
1
+ """
2
+ PHP language parser for code analysis.
3
+ """
4
+
5
+ from typing import Any, Dict, Optional
6
+
7
+ from .base import BaseLanguageParser
8
+
9
+
10
+ class PhpParser(BaseLanguageParser):
11
+ """Parser for PHP source code."""
12
+
13
+ @property
14
+ def language_name(self) -> str:
15
+ return "php"
16
+
17
+ def process_node(
18
+ self, node, source_code: bytes, process_children_callback
19
+ ) -> Optional[Dict[str, Any]]:
20
+ result = self._create_base_result(node)
21
+
22
+ if node.type in [
23
+ "class_declaration",
24
+ "interface_declaration",
25
+ "trait_declaration",
26
+ ]:
27
+ for child in node.children:
28
+ if child.type == "name":
29
+ result["name"] = self.extract_node_text(child, source_code)
30
+ elif child.type == "declaration_list":
31
+ children = []
32
+ for body_child in child.children:
33
+ child_result = process_children_callback(body_child)
34
+ if child_result and self._is_significant_node(child_result):
35
+ children.append(child_result)
36
+ if children:
37
+ result["children"] = children
38
+ return result
39
+
40
+ elif node.type in ["method_declaration", "function_definition"]:
41
+ for child in node.children:
42
+ if child.type == "name":
43
+ result["name"] = self.extract_node_text(child, source_code)
44
+ return result
45
+ return result
46
+
47
+ elif node.type == "property_declaration":
48
+ return self._handle_property_declaration(node, source_code, result)
49
+
50
+ elif node.type == "const_declaration":
51
+ return self._handle_const_declaration(node, source_code, result)
52
+
53
+ children = []
54
+ for child in node.children:
55
+ child_result = process_children_callback(child)
56
+ if child_result and self._is_significant_node(child_result):
57
+ children.append(child_result)
58
+
59
+ if children:
60
+ result["children"] = children
61
+
62
+ return result
63
+
64
+ def _handle_property_declaration(
65
+ self, node, source_code: bytes, result: Dict[str, Any]
66
+ ) -> Dict[str, Any]:
67
+ prop_name = None
68
+ prop_type = None
69
+
70
+ for child in node.children:
71
+ if child.type in [
72
+ "primitive_type",
73
+ "named_type",
74
+ "optional_type",
75
+ "union_type",
76
+ ]:
77
+ prop_type = self.extract_node_text(child, source_code)
78
+ elif child.type == "property_element":
79
+ for subchild in child.children:
80
+ if subchild.type == "variable_name":
81
+ prop_name = self.extract_node_text(subchild, source_code)
82
+
83
+ if prop_name:
84
+ result["type"] = "property_declaration"
85
+ if prop_type:
86
+ result["name"] = f"{prop_type} {prop_name}"
87
+ else:
88
+ result["name"] = prop_name
89
+
90
+ return result
91
+
92
+ def _handle_const_declaration(
93
+ self, node, source_code: bytes, result: Dict[str, Any]
94
+ ) -> Dict[str, Any]:
95
+ const_name = None
96
+
97
+ for child in node.children:
98
+ if child.type == "const_element":
99
+ for subchild in child.children:
100
+ if subchild.type == "name":
101
+ const_name = self.extract_node_text(subchild, source_code)
102
+
103
+ if const_name:
104
+ result["type"] = "const_declaration"
105
+ result["name"] = const_name
106
+
107
+ return result
@@ -0,0 +1,60 @@
1
+ """
2
+ Python language parser for code analysis.
3
+ """
4
+
5
+ from typing import Any, Dict, Optional
6
+
7
+ from .base import BaseLanguageParser
8
+
9
+
10
+ class PythonParser(BaseLanguageParser):
11
+ """Parser for Python source code."""
12
+
13
+ @property
14
+ def language_name(self) -> str:
15
+ return "python"
16
+
17
+ def process_node(
18
+ self, node, source_code: bytes, process_children_callback
19
+ ) -> Optional[Dict[str, Any]]:
20
+ result = self._create_base_result(node)
21
+
22
+ if node.type in ["class_definition", "function_definition"]:
23
+ for child in node.children:
24
+ if child.type == "identifier":
25
+ result["name"] = self.extract_node_text(child, source_code)
26
+ elif child.type == "parameters":
27
+ params = []
28
+ for param in child.children:
29
+ if "parameter" in param.type or param.type == "identifier":
30
+ params.append(self.extract_node_text(param, source_code))
31
+ if params:
32
+ result["parameters"] = params
33
+
34
+ elif node.type == "assignment":
35
+ var_name = None
36
+ var_type = None
37
+ for child in node.children:
38
+ if child.type == "identifier" and var_name is None:
39
+ var_name = self.extract_node_text(child, source_code)
40
+ elif child.type == "type":
41
+ var_type = self.extract_node_text(child, source_code)
42
+
43
+ if var_name:
44
+ result["type"] = "variable_declaration"
45
+ if var_type:
46
+ result["name"] = f"{var_name}: {var_type}"
47
+ else:
48
+ result["name"] = var_name
49
+ return result
50
+
51
+ children = []
52
+ for child in node.children:
53
+ child_result = process_children_callback(child)
54
+ if child_result and self._is_significant_node(child_result):
55
+ children.append(child_result)
56
+
57
+ if children:
58
+ result["children"] = children
59
+
60
+ return result
@@ -0,0 +1,46 @@
1
+ """
2
+ Ruby language parser for code analysis.
3
+ """
4
+
5
+ from typing import Any, Dict, Optional
6
+
7
+ from .base import BaseLanguageParser
8
+
9
+
10
+ class RubyParser(BaseLanguageParser):
11
+ """Parser for Ruby source code."""
12
+
13
+ @property
14
+ def language_name(self) -> str:
15
+ return "ruby"
16
+
17
+ def process_node(
18
+ self, node, source_code: bytes, process_children_callback
19
+ ) -> Optional[Dict[str, Any]]:
20
+ result = self._create_base_result(node)
21
+
22
+ if node.type in ["class", "method", "singleton_method", "module"]:
23
+ for child in node.children:
24
+ if child.type == "identifier":
25
+ result["name"] = self.extract_node_text(child, source_code)
26
+ return result
27
+ return result
28
+
29
+ elif node.type in ["assignment", "global_variable"]:
30
+ for child in node.children:
31
+ if child.type in ["identifier", "global_variable"]:
32
+ result["type"] = "variable_declaration"
33
+ result["name"] = self.extract_node_text(child, source_code)
34
+ return result
35
+ return result
36
+
37
+ children = []
38
+ for child in node.children:
39
+ child_result = process_children_callback(child)
40
+ if child_result and self._is_significant_node(child_result):
41
+ children.append(child_result)
42
+
43
+ if children:
44
+ result["children"] = children
45
+
46
+ return result
@@ -0,0 +1,72 @@
1
+ """
2
+ Rust language parser for code analysis.
3
+ """
4
+
5
+ from typing import Any, Dict, Optional
6
+
7
+ from .base import BaseLanguageParser
8
+
9
+
10
+ class RustParser(BaseLanguageParser):
11
+ """Parser for Rust source code."""
12
+
13
+ @property
14
+ def language_name(self) -> str:
15
+ return "rust"
16
+
17
+ def process_node(
18
+ self, node, source_code: bytes, process_children_callback
19
+ ) -> Optional[Dict[str, Any]]:
20
+ result = self._create_base_result(node)
21
+
22
+ if node.type in ["struct_item", "impl_item", "fn_item", "trait_item"]:
23
+ for child in node.children:
24
+ if child.type == "identifier":
25
+ result["name"] = self.extract_node_text(child, source_code)
26
+ return result
27
+ return result
28
+
29
+ elif node.type in ["static_item", "const_item", "let_declaration"]:
30
+ return self._handle_variable_declaration(node, source_code, result)
31
+
32
+ children = []
33
+ for child in node.children:
34
+ child_result = process_children_callback(child)
35
+ if child_result and self._is_significant_node(child_result):
36
+ children.append(child_result)
37
+
38
+ if children:
39
+ result["children"] = children
40
+
41
+ return result
42
+
43
+ def _handle_variable_declaration(
44
+ self, node, source_code: bytes, result: Dict[str, Any]
45
+ ) -> Dict[str, Any]:
46
+ var_name = None
47
+ var_type = None
48
+
49
+ for child in node.children:
50
+ if child.type == "identifier" and var_name is None:
51
+ var_name = self.extract_node_text(child, source_code)
52
+ elif child.type == "pattern":
53
+ if child.children:
54
+ var_name = self.extract_node_text(child.children[0], source_code)
55
+ elif child.type in [
56
+ "type_identifier",
57
+ "generic_type",
58
+ "reference_type",
59
+ "pointer_type",
60
+ "array_type",
61
+ "primitive_type",
62
+ ]:
63
+ var_type = self.extract_node_text(child, source_code)
64
+
65
+ if var_name:
66
+ result["type"] = "variable_declaration"
67
+ if var_type:
68
+ result["name"] = f"{var_name}: {var_type}"
69
+ else:
70
+ result["name"] = var_name
71
+
72
+ return result