A property's node kind, or None when the declaration mints no node at all: destructuring, an unreadable name, or a local (inside a function body / `init` block / lambda / accessor). Kind by enclosing scope — a singleton `object` / `companion object` (and a top-level property) holds SHARED values (`val`→constant, `var`→variable, the Scala-object rule; a `const val` is just a val); a class/interface
(&self, node: Node<'t>)
| 756 | /// `const val` is just a val); a class/interface/enum instance `val`/`var` |
| 757 | /// is per-instance state → `field`. |
| 758 | fn property_kind(&self, node: Node<'t>) -> Option<&'static str> { |
| 759 | let var_decl = (0..node.named_child_count()) |
| 760 | .filter_map(|i| node.named_child(i)) |
| 761 | .find(|c| c.kind() == "variable_declaration")?; |
| 762 | let name_node = (0..var_decl.named_child_count()) |
| 763 | .filter_map(|i| var_decl.named_child(i)) |
| 764 | .find(|c| c.kind() == "simple_identifier")?; |
| 765 | if self.text(name_node).is_empty() { |
| 766 | return None; |
| 767 | } |
| 768 | let mut scope: &str = "const"; |
| 769 | let mut p = node.parent(); |
| 770 | while let Some(pn) = p { |
| 771 | match pn.kind() { |
| 772 | "function_body" | "function_declaration" | "lambda_literal" |
| 773 | | "anonymous_initializer" | "control_structure_body" | "getter" | "setter" => { |
| 774 | scope = "local"; |
| 775 | break; |
| 776 | } |
| 777 | "companion_object" | "object_declaration" => { |
| 778 | scope = "const"; |
| 779 | break; |
| 780 | } |
| 781 | "class_declaration" => { |
| 782 | scope = "instance"; |
| 783 | break; |
| 784 | } |
| 785 | _ => {} |
| 786 | } |
| 787 | p = pn.parent(); |
| 788 | } |
| 789 | if scope == "local" { |
| 790 | return None; |
| 791 | } |
| 792 | let binding = (0..node.named_child_count()) |
| 793 | .filter_map(|i| node.named_child(i)) |
| 794 | .find(|c| c.kind() == "binding_pattern_kind"); |
| 795 | let is_val = binding.map(|b| self.text(b) == "val").unwrap_or(false); |
| 796 | Some(if scope == "instance" { |
| 797 | "field" |
| 798 | } else if is_val { |
| 799 | "constant" |
| 800 | } else { |
| 801 | "variable" |
| 802 | }) |
| 803 | } |
| 804 | |
| 805 | /// The Kotlin visitNode hook: `Some` when it consumed the node, holding the |
| 806 | /// initializers it walked as such (`walkInitializer`), which the caller's |
no test coverage detected