mulle-roam-code 0.0.1__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 (257) hide show
  1. mulle_roam_code-0.0.1.dist-info/METADATA +1590 -0
  2. mulle_roam_code-0.0.1.dist-info/RECORD +257 -0
  3. mulle_roam_code-0.0.1.dist-info/WHEEL +5 -0
  4. mulle_roam_code-0.0.1.dist-info/entry_points.txt +3 -0
  5. mulle_roam_code-0.0.1.dist-info/licenses/LICENSE +21 -0
  6. mulle_roam_code-0.0.1.dist-info/top_level.txt +1 -0
  7. roam/__init__.py +8 -0
  8. roam/__main__.py +5 -0
  9. roam/analysis/__init__.py +1 -0
  10. roam/analysis/effects.py +639 -0
  11. roam/analysis/taint.py +689 -0
  12. roam/api.py +238 -0
  13. roam/bridges/__init__.py +3 -0
  14. roam/bridges/base.py +49 -0
  15. roam/bridges/bridge_config.py +218 -0
  16. roam/bridges/bridge_protobuf.py +352 -0
  17. roam/bridges/bridge_rest_api.py +242 -0
  18. roam/bridges/bridge_salesforce.py +198 -0
  19. roam/bridges/bridge_template.py +247 -0
  20. roam/bridges/registry.py +51 -0
  21. roam/catalog/__init__.py +0 -0
  22. roam/catalog/detectors.py +2242 -0
  23. roam/catalog/fixes.py +86 -0
  24. roam/catalog/smells.py +599 -0
  25. roam/catalog/tasks.py +1260 -0
  26. roam/cli.py +548 -0
  27. roam/commands/__init__.py +0 -0
  28. roam/commands/changed_files.py +139 -0
  29. roam/commands/cmd_adversarial.py +699 -0
  30. roam/commands/cmd_affected.py +432 -0
  31. roam/commands/cmd_affected_tests.py +375 -0
  32. roam/commands/cmd_agent_context.py +168 -0
  33. roam/commands/cmd_agent_export.py +890 -0
  34. roam/commands/cmd_agent_plan.py +315 -0
  35. roam/commands/cmd_ai_ratio.py +765 -0
  36. roam/commands/cmd_ai_readiness.py +775 -0
  37. roam/commands/cmd_alerts.py +409 -0
  38. roam/commands/cmd_annotate.py +210 -0
  39. roam/commands/cmd_api_changes.py +796 -0
  40. roam/commands/cmd_api_drift.py +781 -0
  41. roam/commands/cmd_attest.py +913 -0
  42. roam/commands/cmd_auth_gaps.py +799 -0
  43. roam/commands/cmd_bisect.py +216 -0
  44. roam/commands/cmd_breaking.py +464 -0
  45. roam/commands/cmd_budget.py +413 -0
  46. roam/commands/cmd_bus_factor.py +403 -0
  47. roam/commands/cmd_capsule.py +275 -0
  48. roam/commands/cmd_check_rules.py +574 -0
  49. roam/commands/cmd_clean.py +147 -0
  50. roam/commands/cmd_closure.py +294 -0
  51. roam/commands/cmd_clusters.py +457 -0
  52. roam/commands/cmd_codeowners.py +600 -0
  53. roam/commands/cmd_complexity.py +364 -0
  54. roam/commands/cmd_config.py +310 -0
  55. roam/commands/cmd_context.py +1151 -0
  56. roam/commands/cmd_conventions.py +697 -0
  57. roam/commands/cmd_coupling.py +462 -0
  58. roam/commands/cmd_coverage_gaps.py +638 -0
  59. roam/commands/cmd_cut.py +235 -0
  60. roam/commands/cmd_dark_matter.py +127 -0
  61. roam/commands/cmd_dashboard.py +365 -0
  62. roam/commands/cmd_dead.py +1585 -0
  63. roam/commands/cmd_debt.py +731 -0
  64. roam/commands/cmd_deps.py +121 -0
  65. roam/commands/cmd_describe.py +959 -0
  66. roam/commands/cmd_dev_profile.py +580 -0
  67. roam/commands/cmd_diagnose.py +377 -0
  68. roam/commands/cmd_diff.py +633 -0
  69. roam/commands/cmd_digest.py +214 -0
  70. roam/commands/cmd_doc_staleness.py +334 -0
  71. roam/commands/cmd_docs_coverage.py +193 -0
  72. roam/commands/cmd_doctor.py +319 -0
  73. roam/commands/cmd_drift.py +377 -0
  74. roam/commands/cmd_duplicates.py +559 -0
  75. roam/commands/cmd_effects.py +362 -0
  76. roam/commands/cmd_endpoints.py +768 -0
  77. roam/commands/cmd_entry_points.py +358 -0
  78. roam/commands/cmd_fan.py +311 -0
  79. roam/commands/cmd_file.py +334 -0
  80. roam/commands/cmd_fingerprint.py +172 -0
  81. roam/commands/cmd_fitness.py +723 -0
  82. roam/commands/cmd_fn_coupling.py +295 -0
  83. roam/commands/cmd_forecast.py +366 -0
  84. roam/commands/cmd_grep.py +282 -0
  85. roam/commands/cmd_guard.py +434 -0
  86. roam/commands/cmd_health.py +922 -0
  87. roam/commands/cmd_hooks.py +458 -0
  88. roam/commands/cmd_hotspots.py +606 -0
  89. roam/commands/cmd_impact.py +228 -0
  90. roam/commands/cmd_index.py +102 -0
  91. roam/commands/cmd_ingest_trace.py +143 -0
  92. roam/commands/cmd_init.py +166 -0
  93. roam/commands/cmd_intent.py +459 -0
  94. roam/commands/cmd_invariants.py +301 -0
  95. roam/commands/cmd_layers.py +387 -0
  96. roam/commands/cmd_map.py +275 -0
  97. roam/commands/cmd_math.py +213 -0
  98. roam/commands/cmd_mcp_setup.py +135 -0
  99. roam/commands/cmd_metrics.py +663 -0
  100. roam/commands/cmd_migration_safety.py +712 -0
  101. roam/commands/cmd_minimap.py +519 -0
  102. roam/commands/cmd_missing_index.py +885 -0
  103. roam/commands/cmd_module.py +204 -0
  104. roam/commands/cmd_mutate.py +400 -0
  105. roam/commands/cmd_n1.py +967 -0
  106. roam/commands/cmd_onboard.py +740 -0
  107. roam/commands/cmd_orchestrate.py +180 -0
  108. roam/commands/cmd_orphan_routes.py +754 -0
  109. roam/commands/cmd_over_fetch.py +633 -0
  110. roam/commands/cmd_owner.py +299 -0
  111. roam/commands/cmd_partition.py +714 -0
  112. roam/commands/cmd_path_coverage.py +564 -0
  113. roam/commands/cmd_patterns.py +689 -0
  114. roam/commands/cmd_plan.py +616 -0
  115. roam/commands/cmd_plan_refactor.py +432 -0
  116. roam/commands/cmd_pr_diff.py +292 -0
  117. roam/commands/cmd_pr_risk.py +677 -0
  118. roam/commands/cmd_preflight.py +706 -0
  119. roam/commands/cmd_relate.py +405 -0
  120. roam/commands/cmd_report.py +304 -0
  121. roam/commands/cmd_reset.py +117 -0
  122. roam/commands/cmd_risk.py +533 -0
  123. roam/commands/cmd_rules.py +319 -0
  124. roam/commands/cmd_safe_delete.py +224 -0
  125. roam/commands/cmd_safe_zones.py +295 -0
  126. roam/commands/cmd_schema.py +166 -0
  127. roam/commands/cmd_search.py +295 -0
  128. roam/commands/cmd_search_semantic.py +101 -0
  129. roam/commands/cmd_secrets.py +636 -0
  130. roam/commands/cmd_semantic_diff.py +538 -0
  131. roam/commands/cmd_simulate.py +296 -0
  132. roam/commands/cmd_simulate_departure.py +632 -0
  133. roam/commands/cmd_sketch.py +160 -0
  134. roam/commands/cmd_smells.py +179 -0
  135. roam/commands/cmd_snapshot.py +50 -0
  136. roam/commands/cmd_spectral.py +183 -0
  137. roam/commands/cmd_split.py +432 -0
  138. roam/commands/cmd_suggest_refactoring.py +486 -0
  139. roam/commands/cmd_suggest_reviewers.py +491 -0
  140. roam/commands/cmd_supply_chain.py +831 -0
  141. roam/commands/cmd_symbol.py +135 -0
  142. roam/commands/cmd_syntax_check.py +301 -0
  143. roam/commands/cmd_test_gaps.py +574 -0
  144. roam/commands/cmd_testmap.py +308 -0
  145. roam/commands/cmd_tour.py +377 -0
  146. roam/commands/cmd_trace.py +304 -0
  147. roam/commands/cmd_trend.py +461 -0
  148. roam/commands/cmd_trends.py +929 -0
  149. roam/commands/cmd_understand.py +763 -0
  150. roam/commands/cmd_uses.py +170 -0
  151. roam/commands/cmd_verify.py +812 -0
  152. roam/commands/cmd_verify_imports.py +435 -0
  153. roam/commands/cmd_vibe_check.py +932 -0
  154. roam/commands/cmd_visualize.py +361 -0
  155. roam/commands/cmd_vuln_map.py +139 -0
  156. roam/commands/cmd_vuln_reach.py +289 -0
  157. roam/commands/cmd_vulns.py +414 -0
  158. roam/commands/cmd_watch.py +759 -0
  159. roam/commands/cmd_weather.py +118 -0
  160. roam/commands/cmd_why.py +325 -0
  161. roam/commands/cmd_ws.py +755 -0
  162. roam/commands/cmd_xlang.py +170 -0
  163. roam/commands/context_helpers.py +1137 -0
  164. roam/commands/gate_presets.py +222 -0
  165. roam/commands/graph_helpers.py +93 -0
  166. roam/commands/metrics_history.py +298 -0
  167. roam/commands/next_steps.py +107 -0
  168. roam/commands/resolve.py +302 -0
  169. roam/competitor_site_data.py +2229 -0
  170. roam/coverage_reports.py +462 -0
  171. roam/db/__init__.py +0 -0
  172. roam/db/connection.py +359 -0
  173. roam/db/queries.py +151 -0
  174. roam/db/schema.py +335 -0
  175. roam/exit_codes.py +100 -0
  176. roam/graph/__init__.py +43 -0
  177. roam/graph/anomaly.py +493 -0
  178. roam/graph/builder.py +61 -0
  179. roam/graph/clusters.py +286 -0
  180. roam/graph/cycles.py +210 -0
  181. roam/graph/dark_matter.py +207 -0
  182. roam/graph/diff.py +467 -0
  183. roam/graph/fingerprint.py +297 -0
  184. roam/graph/layers.py +134 -0
  185. roam/graph/pagerank.py +171 -0
  186. roam/graph/partition.py +437 -0
  187. roam/graph/pathfinding.py +119 -0
  188. roam/graph/propagation.py +208 -0
  189. roam/graph/simulate.py +286 -0
  190. roam/graph/spectral.py +260 -0
  191. roam/index/__init__.py +5 -0
  192. roam/index/complexity.py +1108 -0
  193. roam/index/discovery.py +338 -0
  194. roam/index/file_roles.py +586 -0
  195. roam/index/git_stats.py +577 -0
  196. roam/index/incremental.py +75 -0
  197. roam/index/indexer.py +1191 -0
  198. roam/index/parser.py +461 -0
  199. roam/index/relations.py +537 -0
  200. roam/index/symbols.py +71 -0
  201. roam/index/test_conventions.py +508 -0
  202. roam/languages/__init__.py +21 -0
  203. roam/languages/apex_lang.py +241 -0
  204. roam/languages/aura_lang.py +228 -0
  205. roam/languages/base.py +111 -0
  206. roam/languages/c_lang.py +458 -0
  207. roam/languages/csharp_lang.py +1215 -0
  208. roam/languages/foxpro_lang.py +1554 -0
  209. roam/languages/generic_lang.py +702 -0
  210. roam/languages/go_lang.py +392 -0
  211. roam/languages/hcl_lang.py +398 -0
  212. roam/languages/java_lang.py +418 -0
  213. roam/languages/javascript_lang.py +799 -0
  214. roam/languages/kotlin_lang.py +147 -0
  215. roam/languages/objc_lang.py +401 -0
  216. roam/languages/php_lang.py +696 -0
  217. roam/languages/python_lang.py +850 -0
  218. roam/languages/registry.py +283 -0
  219. roam/languages/ruby_lang.py +429 -0
  220. roam/languages/rust_lang.py +545 -0
  221. roam/languages/sfxml_lang.py +276 -0
  222. roam/languages/swift_lang.py +173 -0
  223. roam/languages/typescript_lang.py +323 -0
  224. roam/languages/visualforce_lang.py +151 -0
  225. roam/languages/yaml_lang.py +566 -0
  226. roam/mcp_server.py +4794 -0
  227. roam/output/__init__.py +0 -0
  228. roam/output/formatter.py +557 -0
  229. roam/output/mermaid.py +62 -0
  230. roam/output/sarif.py +897 -0
  231. roam/output/schema_registry.py +57 -0
  232. roam/plugins.py +208 -0
  233. roam/refactor/__init__.py +0 -0
  234. roam/refactor/codegen.py +106 -0
  235. roam/refactor/transforms.py +711 -0
  236. roam/rules/__init__.py +0 -0
  237. roam/rules/ast_match.py +238 -0
  238. roam/rules/builtin.py +617 -0
  239. roam/rules/dataflow.py +515 -0
  240. roam/rules/engine.py +943 -0
  241. roam/runtime/__init__.py +3 -0
  242. roam/runtime/hotspots.py +138 -0
  243. roam/runtime/trace_ingest.py +535 -0
  244. roam/search/__init__.py +1 -0
  245. roam/search/framework_packs.py +673 -0
  246. roam/search/index_embeddings.py +732 -0
  247. roam/search/onnx_embeddings.py +233 -0
  248. roam/search/tfidf.py +355 -0
  249. roam/security/__init__.py +1 -0
  250. roam/security/vuln_reach.py +246 -0
  251. roam/security/vuln_store.py +334 -0
  252. roam/surface_counts.py +158 -0
  253. roam/workspace/__init__.py +3 -0
  254. roam/workspace/aggregator.py +426 -0
  255. roam/workspace/api_scanner.py +538 -0
  256. roam/workspace/config.py +95 -0
  257. roam/workspace/db.py +136 -0
@@ -0,0 +1,392 @@
1
+ from __future__ import annotations
2
+
3
+ from .base import LanguageExtractor
4
+
5
+
6
+ class GoExtractor(LanguageExtractor):
7
+ """Full Go symbol and reference extractor."""
8
+
9
+ @property
10
+ def language_name(self) -> str:
11
+ return "go"
12
+
13
+ @property
14
+ def file_extensions(self) -> list[str]:
15
+ return [".go"]
16
+
17
+ def extract_symbols(self, tree, source: bytes, file_path: str) -> list[dict]:
18
+ symbols = []
19
+ self._pending_inherits = []
20
+ self._walk_symbols(tree.root_node, source, file_path, symbols)
21
+ return symbols
22
+
23
+ def extract_references(self, tree, source: bytes, file_path: str) -> list[dict]:
24
+ refs = []
25
+ self._walk_refs(tree.root_node, source, refs, scope_name=None)
26
+ # Collect inheritance refs accumulated during extract_symbols
27
+ refs.extend(getattr(self, "_pending_inherits", []))
28
+ self._pending_inherits = []
29
+ return refs
30
+
31
+ def get_docstring(self, node, source: bytes) -> str | None:
32
+ """Go doc comments: look for consecutive comment lines before node."""
33
+ prev = node.prev_sibling
34
+ comments = []
35
+ while prev and prev.type == "comment":
36
+ text = self.node_text(prev, source).strip()
37
+ if text.startswith("//"):
38
+ text = text[2:].strip()
39
+ comments.insert(0, text)
40
+ prev = prev.prev_sibling
41
+ return "\n".join(comments) if comments else None
42
+
43
+ def _is_exported(self, name: str) -> bool:
44
+ """In Go, exported identifiers start with an uppercase letter."""
45
+ return bool(name) and name[0].isupper()
46
+
47
+ # ---- Symbol extraction ----
48
+
49
+ def _walk_symbols(self, node, source, file_path, symbols):
50
+ for child in node.children:
51
+ if child.type == "function_declaration":
52
+ self._extract_function(child, source, symbols)
53
+ elif child.type == "method_declaration":
54
+ self._extract_method(child, source, symbols)
55
+ elif child.type == "type_declaration":
56
+ self._extract_type_decl(child, source, symbols)
57
+ elif child.type == "package_clause":
58
+ self._extract_package(child, source, symbols)
59
+ elif child.type == "var_declaration":
60
+ self._extract_var_decl(child, source, symbols)
61
+ elif child.type == "const_declaration":
62
+ self._extract_const_decl(child, source, symbols)
63
+
64
+ def _extract_function(self, node, source, symbols):
65
+ name_node = node.child_by_field_name("name")
66
+ if name_node is None:
67
+ return
68
+ name = self.node_text(name_node, source)
69
+ params = node.child_by_field_name("parameters")
70
+ result = node.child_by_field_name("result")
71
+
72
+ sig = f"func {name}({self._params_text(params, source)})"
73
+ if result:
74
+ sig += f" {self.node_text(result, source)}"
75
+
76
+ # Type parameters (generics)
77
+ type_params = node.child_by_field_name("type_parameters")
78
+ if type_params:
79
+ sig = f"func {name}{self.node_text(type_params, source)}({self._params_text(params, source)})"
80
+ if result:
81
+ sig += f" {self.node_text(result, source)}"
82
+
83
+ symbols.append(
84
+ self._make_symbol(
85
+ name=name,
86
+ kind="function",
87
+ line_start=node.start_point[0] + 1,
88
+ line_end=node.end_point[0] + 1,
89
+ signature=sig,
90
+ docstring=self.get_docstring(node, source),
91
+ visibility="public" if self._is_exported(name) else "private",
92
+ is_exported=self._is_exported(name),
93
+ )
94
+ )
95
+
96
+ def _extract_method(self, node, source, symbols):
97
+ name_node = node.child_by_field_name("name")
98
+ if name_node is None:
99
+ return
100
+ name = self.node_text(name_node, source)
101
+
102
+ # Get receiver
103
+ receiver = node.child_by_field_name("receiver")
104
+ recv_text = self.node_text(receiver, source) if receiver else ""
105
+ recv_type = self._extract_receiver_type(receiver, source)
106
+
107
+ params = node.child_by_field_name("parameters")
108
+ result = node.child_by_field_name("result")
109
+
110
+ sig = f"func {recv_text} {name}({self._params_text(params, source)})"
111
+ if result:
112
+ sig += f" {self.node_text(result, source)}"
113
+
114
+ qualified = f"{recv_type}.{name}" if recv_type else name
115
+
116
+ symbols.append(
117
+ self._make_symbol(
118
+ name=name,
119
+ kind="method",
120
+ line_start=node.start_point[0] + 1,
121
+ line_end=node.end_point[0] + 1,
122
+ qualified_name=qualified,
123
+ signature=sig,
124
+ docstring=self.get_docstring(node, source),
125
+ visibility="public" if self._is_exported(name) else "private",
126
+ is_exported=self._is_exported(name),
127
+ parent_name=recv_type,
128
+ )
129
+ )
130
+
131
+ def _extract_receiver_type(self, receiver, source) -> str:
132
+ """Extract the type name from a method receiver like (s *Server)."""
133
+ if receiver is None:
134
+ return ""
135
+ for child in receiver.children:
136
+ if child.type == "parameter_declaration":
137
+ type_node = child.child_by_field_name("type")
138
+ if type_node:
139
+ text = self.node_text(type_node, source).lstrip("*")
140
+ return text
141
+ return ""
142
+
143
+ def _extract_type_decl(self, node, source, symbols):
144
+ """Extract type declarations (struct, interface, type alias)."""
145
+ for child in node.children:
146
+ if child.type == "type_spec":
147
+ self._extract_type_spec(child, source, symbols, node)
148
+
149
+ def _extract_type_spec(self, node, source, symbols, parent_node):
150
+ name_node = node.child_by_field_name("name")
151
+ if name_node is None:
152
+ return
153
+ name = self.node_text(name_node, source)
154
+ type_node = node.child_by_field_name("type")
155
+
156
+ if type_node is None:
157
+ return
158
+
159
+ kind = "type_alias"
160
+ sig = f"type {name}"
161
+ if type_node.type == "struct_type":
162
+ kind = "struct"
163
+ sig = f"type {name} struct"
164
+ # Extract struct fields
165
+ self._extract_struct_fields(type_node, source, symbols, name)
166
+ elif type_node.type == "interface_type":
167
+ kind = "interface"
168
+ sig = f"type {name} interface"
169
+ self._extract_interface_methods(type_node, source, symbols, name)
170
+ else:
171
+ sig += f" {self.node_text(type_node, source)[:60]}"
172
+
173
+ symbols.append(
174
+ self._make_symbol(
175
+ name=name,
176
+ kind=kind,
177
+ line_start=parent_node.start_point[0] + 1,
178
+ line_end=parent_node.end_point[0] + 1,
179
+ signature=sig,
180
+ docstring=self.get_docstring(parent_node, source),
181
+ visibility="public" if self._is_exported(name) else "private",
182
+ is_exported=self._is_exported(name),
183
+ )
184
+ )
185
+
186
+ def _extract_struct_fields(self, struct_node, source, symbols, struct_name):
187
+ for child in struct_node.children:
188
+ if child.type == "field_declaration_list":
189
+ for field in child.children:
190
+ if field.type == "field_declaration":
191
+ name_node = field.child_by_field_name("name")
192
+ type_node = field.child_by_field_name("type")
193
+ if name_node:
194
+ field_name = self.node_text(name_node, source)
195
+ sig = field_name
196
+ if type_node:
197
+ sig += f" {self.node_text(type_node, source)}"
198
+ symbols.append(
199
+ self._make_symbol(
200
+ name=field_name,
201
+ kind="field",
202
+ line_start=field.start_point[0] + 1,
203
+ line_end=field.end_point[0] + 1,
204
+ qualified_name=f"{struct_name}.{field_name}",
205
+ signature=sig,
206
+ visibility="public" if self._is_exported(field_name) else "private",
207
+ is_exported=self._is_exported(field_name),
208
+ parent_name=struct_name,
209
+ )
210
+ )
211
+ elif type_node:
212
+ # No name = embedded/anonymous field (struct embedding)
213
+ type_name = self.node_text(type_node, source).lstrip("*")
214
+ self._pending_inherits.append(
215
+ self._make_reference(
216
+ target_name=type_name,
217
+ kind="inherits",
218
+ line=field.start_point[0] + 1,
219
+ source_name=struct_name,
220
+ )
221
+ )
222
+
223
+ def _extract_interface_methods(self, iface_node, source, symbols, iface_name):
224
+ for child in iface_node.children:
225
+ if child.type in ("method_spec", "method_elem"):
226
+ name_node = child.child_by_field_name("name")
227
+ if name_node:
228
+ method_name = self.node_text(name_node, source)
229
+ params = child.child_by_field_name("parameters")
230
+ result = child.child_by_field_name("result")
231
+ sig = f"{method_name}({self._params_text(params, source)})"
232
+ if result:
233
+ sig += f" {self.node_text(result, source)}"
234
+ symbols.append(
235
+ self._make_symbol(
236
+ name=method_name,
237
+ kind="method",
238
+ line_start=child.start_point[0] + 1,
239
+ line_end=child.end_point[0] + 1,
240
+ qualified_name=f"{iface_name}.{method_name}",
241
+ signature=sig,
242
+ visibility="public" if self._is_exported(method_name) else "private",
243
+ is_exported=self._is_exported(method_name),
244
+ parent_name=iface_name,
245
+ )
246
+ )
247
+
248
+ def _extract_package(self, node, source, symbols):
249
+ for child in node.children:
250
+ if child.type == "package_identifier":
251
+ name = self.node_text(child, source)
252
+ symbols.append(
253
+ self._make_symbol(
254
+ name=name,
255
+ kind="module",
256
+ line_start=node.start_point[0] + 1,
257
+ line_end=node.end_point[0] + 1,
258
+ signature=f"package {name}",
259
+ is_exported=True,
260
+ )
261
+ )
262
+
263
+ def _extract_var_decl(self, node, source, symbols):
264
+ for child in node.children:
265
+ if child.type == "var_spec":
266
+ name_node = child.child_by_field_name("name")
267
+ if name_node:
268
+ name = self.node_text(name_node, source)
269
+ type_n = child.child_by_field_name("type")
270
+ sig = f"var {name}"
271
+ if type_n:
272
+ sig += f" {self.node_text(type_n, source)}"
273
+ symbols.append(
274
+ self._make_symbol(
275
+ name=name,
276
+ kind="variable",
277
+ line_start=child.start_point[0] + 1,
278
+ line_end=child.end_point[0] + 1,
279
+ signature=sig,
280
+ visibility="public" if self._is_exported(name) else "private",
281
+ is_exported=self._is_exported(name),
282
+ )
283
+ )
284
+
285
+ def _extract_const_decl(self, node, source, symbols):
286
+ for child in node.children:
287
+ if child.type == "const_spec":
288
+ name_node = child.child_by_field_name("name")
289
+ if name_node:
290
+ name = self.node_text(name_node, source)
291
+ type_n = child.child_by_field_name("type")
292
+ sig = f"const {name}"
293
+ if type_n:
294
+ sig += f" {self.node_text(type_n, source)}"
295
+ symbols.append(
296
+ self._make_symbol(
297
+ name=name,
298
+ kind="constant",
299
+ line_start=child.start_point[0] + 1,
300
+ line_end=child.end_point[0] + 1,
301
+ signature=sig,
302
+ visibility="public" if self._is_exported(name) else "private",
303
+ is_exported=self._is_exported(name),
304
+ )
305
+ )
306
+
307
+ # ---- Reference extraction ----
308
+
309
+ def _walk_refs(self, node, source, refs, scope_name):
310
+ for child in node.children:
311
+ if child.type == "import_declaration":
312
+ self._extract_imports(child, source, refs, scope_name)
313
+ elif child.type == "call_expression":
314
+ self._extract_call(child, source, refs, scope_name)
315
+ else:
316
+ new_scope = scope_name
317
+ if child.type == "function_declaration":
318
+ n = child.child_by_field_name("name")
319
+ if n:
320
+ new_scope = self.node_text(n, source)
321
+ elif child.type == "method_declaration":
322
+ n = child.child_by_field_name("name")
323
+ if n:
324
+ recv = self._extract_receiver_type(child.child_by_field_name("receiver"), source)
325
+ fname = self.node_text(n, source)
326
+ new_scope = f"{recv}.{fname}" if recv else fname
327
+ self._walk_refs(child, source, refs, new_scope)
328
+
329
+ def _extract_imports(self, node, source, refs, scope_name):
330
+ for child in node.children:
331
+ if child.type == "import_spec":
332
+ path_node = child.child_by_field_name("path")
333
+ if path_node:
334
+ path = self.node_text(path_node, source).strip('"')
335
+ # Use last component as target name
336
+ target = path.rsplit("/", 1)[-1] if "/" in path else path
337
+ # Check for alias
338
+ name_node = child.child_by_field_name("name")
339
+ if name_node:
340
+ target = self.node_text(name_node, source)
341
+ refs.append(
342
+ self._make_reference(
343
+ target_name=target,
344
+ kind="import",
345
+ line=child.start_point[0] + 1,
346
+ source_name=scope_name,
347
+ import_path=path,
348
+ )
349
+ )
350
+ elif child.type == "import_spec_list":
351
+ self._extract_imports(child, source, refs, scope_name)
352
+ elif child.type == "interpreted_string_literal":
353
+ # Single import without parens
354
+ path = self.node_text(child, source).strip('"')
355
+ target = path.rsplit("/", 1)[-1] if "/" in path else path
356
+ refs.append(
357
+ self._make_reference(
358
+ target_name=target,
359
+ kind="import",
360
+ line=child.start_point[0] + 1,
361
+ source_name=scope_name,
362
+ import_path=path,
363
+ )
364
+ )
365
+
366
+ def _extract_call(self, node, source, refs, scope_name):
367
+ func_node = node.child_by_field_name("function")
368
+ if func_node is None:
369
+ return
370
+
371
+ # Handle method calls: obj.Method() -> extract "Method"
372
+ if func_node.type == "selector_expression":
373
+ field = func_node.child_by_field_name("field")
374
+ if field:
375
+ name = self.node_text(field, source)
376
+ else:
377
+ name = self.node_text(func_node, source)
378
+ else:
379
+ name = self.node_text(func_node, source)
380
+
381
+ refs.append(
382
+ self._make_reference(
383
+ target_name=name,
384
+ kind="call",
385
+ line=func_node.start_point[0] + 1,
386
+ source_name=scope_name,
387
+ )
388
+ )
389
+ # Recurse into arguments
390
+ args = node.child_by_field_name("arguments")
391
+ if args:
392
+ self._walk_refs(args, source, refs, scope_name)