extractDecoratorsFor — Java annotations live inside `modifiers`.
(&mut self, decl: Node<'t>, decorated_row: u32)
| 1014 | |
| 1015 | /// extractDecoratorsFor — Java annotations live inside `modifiers`. |
| 1016 | fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 1017 | for i in 0..decl.named_child_count() { |
| 1018 | let Some(child) = decl.named_child(i) else { continue }; |
| 1019 | self.consider_decorator(child, decorated_row); |
| 1020 | if child.kind() == "modifiers" { |
| 1021 | for j in 0..child.named_child_count() { |
| 1022 | if let Some(m) = child.named_child(j) { |
| 1023 | self.consider_decorator(m, decorated_row); |
| 1024 | } |
| 1025 | } |
| 1026 | } |
| 1027 | } |
| 1028 | // Preceding-sibling scan (TS-style class decorators) — Java annotations |
| 1029 | // are inside modifiers, so this is inert here; kept for parity of shape. |
| 1030 | let Some(parent) = decl.parent() else { return }; |
| 1031 | let decl_start = decl.start_byte(); |
| 1032 | let mut decl_idx: isize = -1; |
| 1033 | for i in 0..parent.named_child_count() { |
| 1034 | if let Some(sib) = parent.named_child(i) { |
| 1035 | if sib.start_byte() == decl_start { |
| 1036 | decl_idx = i as isize; |
| 1037 | break; |
| 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | if decl_idx > 0 { |
| 1042 | let mut j = decl_idx - 1; |
| 1043 | while j >= 0 { |
| 1044 | let Some(sib) = parent.named_child(j as usize) else { |
| 1045 | j -= 1; |
| 1046 | continue; |
| 1047 | }; |
| 1048 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 1049 | break; |
| 1050 | } |
| 1051 | self.consider_decorator(sib, decorated_row); |
| 1052 | j -= 1; |
| 1053 | } |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1058 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected