(&mut self, decl: Node<'t>, decorated_row: u32)
| 1021 | // --- extractDecoratorsFor (:4897-5024) -------------------------------- |
| 1022 | |
| 1023 | fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 1024 | // consider(): scala annotations are `annotation` nodes; the name is |
| 1025 | // the first identifier-ish child (type_identifier for scala), with |
| 1026 | // call_expression unwrap for invoked decorators. |
| 1027 | // Scan 1: direct children (+ modifiers descent — inert for scala, |
| 1028 | // annotations aren't inside modifiers in this grammar, but ported). |
| 1029 | let mut cursor = decl.walk(); |
| 1030 | let kids: Vec<Node<'t>> = decl.named_children(&mut cursor).collect(); |
| 1031 | for child in kids { |
| 1032 | self.consider_decorator(child, decorated_row); |
| 1033 | if child.kind() == "modifiers" { |
| 1034 | let mut mc = child.walk(); |
| 1035 | let inner: Vec<Node<'t>> = child.named_children(&mut mc).collect(); |
| 1036 | for m in inner { |
| 1037 | self.consider_decorator(m, decorated_row); |
| 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | // Scan 2: preceding siblings (TS class style — inert for scala where |
| 1042 | // annotations are children, ported for fidelity). |
| 1043 | if let Some(parent) = decl.parent() { |
| 1044 | let decl_start = decl.start_byte(); |
| 1045 | let mut decl_idx: Option<usize> = None; |
| 1046 | for i in 0..parent.named_child_count() { |
| 1047 | if let Some(sib) = parent.named_child(i) { |
| 1048 | if sib.start_byte() == decl_start { |
| 1049 | decl_idx = Some(i); |
| 1050 | break; |
| 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | if let Some(di) = decl_idx { |
| 1055 | for j in (0..di).rev() { |
| 1056 | let Some(sib) = parent.named_child(j) else { continue }; |
| 1057 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 1058 | break; |
| 1059 | } |
| 1060 | self.consider_decorator(sib, decorated_row); |
| 1061 | } |
| 1062 | } |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1067 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected