Determine if a declaration is exported (publicly visible). Walks the immediate children of the declaration node looking for access-level modifiers. Stops searching once it hits the main declaration keyword (`func`, `class`, etc.) to avoid scanning the body. Returns `true` by default (Swift `internal` = module-visible).
(&self, node: &Node, source: &str)
| 381 | /// |
| 382 | /// Returns `true` by default (Swift `internal` = module-visible). |
| 383 | fn is_exported(&self, node: &Node, source: &str) -> bool { |
| 384 | let mut cursor = node.walk(); |
| 385 | for child in node.children(&mut cursor) { |
| 386 | let kind = child.kind(); |
| 387 | |
| 388 | // Check a `modifiers` wrapper node (tree-sitter-swift groups |
| 389 | // attributes and access-level modifiers under one node). |
| 390 | if kind == "modifiers" { |
| 391 | let mut inner = child.walk(); |
| 392 | for modifier in child.children(&mut inner) { |
| 393 | let text = self.node_text(&modifier, source); |
| 394 | if text.starts_with("private") || text.starts_with("fileprivate") { |
| 395 | return false; |
| 396 | } |
| 397 | if text.starts_with("public") || text.starts_with("open") { |
| 398 | return true; |
| 399 | } |
| 400 | } |
| 401 | continue; |
| 402 | } |
| 403 | |
| 404 | // Direct access_level_modifier child (some grammar versions) |
| 405 | if kind == "access_level_modifier" || kind == "visibility_modifier" { |
| 406 | let text = self.node_text(&child, source); |
| 407 | if text.starts_with("private") || text.starts_with("fileprivate") { |
| 408 | return false; |
| 409 | } |
| 410 | if text.starts_with("public") || text.starts_with("open") { |
| 411 | return true; |
| 412 | } |
| 413 | continue; |
| 414 | } |
| 415 | |
| 416 | // Stop at the main declaration keyword so we don't scan the body |
| 417 | let text = self.node_text(&child, source); |
| 418 | match text.as_str() { |
| 419 | "func" | "class" | "struct" | "enum" | "protocol" | "import" | "typealias" |
| 420 | | "init" | "var" | "let" | "extension" | "actor" => break, |
| 421 | _ => {} |
| 422 | } |
| 423 | } |
| 424 | // Default: internal = module-visible = exported |
| 425 | true |
| 426 | } |
| 427 | |
| 428 | // ── Signature builders ────────────────────────────────────────── |
| 429 |
no test coverage detected