(&mut self, decl: Node<'t>, decorated_row: u32)
| 2036 | // --- extractDecoratorsFor -------------------------------------------------------------- |
| 2037 | |
| 2038 | pub(super) fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 2039 | // 1. Direct children (method/property style). |
| 2040 | for i in 0..decl.named_child_count() { |
| 2041 | let Some(child) = decl.named_child(i) else { continue }; |
| 2042 | self.consider_decorator(child, decorated_row); |
| 2043 | if child.kind() == "modifiers" { |
| 2044 | for j in 0..child.named_child_count() { |
| 2045 | if let Some(m) = child.named_child(j) { |
| 2046 | self.consider_decorator(m, decorated_row); |
| 2047 | } |
| 2048 | } |
| 2049 | } |
| 2050 | } |
| 2051 | // 2. Preceding siblings (TypeScript class style), stopping at the |
| 2052 | // first non-decorator so an earlier declaration's decorators never |
| 2053 | // leak in. Matching by startIndex, not object identity. |
| 2054 | let Some(parent) = decl.parent() else { return }; |
| 2055 | let decl_start = decl.start_byte(); |
| 2056 | let mut decl_idx: isize = -1; |
| 2057 | for i in 0..parent.named_child_count() { |
| 2058 | if let Some(sib) = parent.named_child(i) { |
| 2059 | if sib.start_byte() == decl_start { |
| 2060 | decl_idx = i as isize; |
| 2061 | break; |
| 2062 | } |
| 2063 | } |
| 2064 | } |
| 2065 | if decl_idx > 0 { |
| 2066 | let mut j = decl_idx - 1; |
| 2067 | while j >= 0 { |
| 2068 | let Some(sib) = parent.named_child(j as usize) else { |
| 2069 | j -= 1; |
| 2070 | continue; |
| 2071 | }; |
| 2072 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 2073 | break; |
| 2074 | } |
| 2075 | self.consider_decorator(sib, decorated_row); |
| 2076 | j -= 1; |
| 2077 | } |
| 2078 | } |
| 2079 | } |
| 2080 | |
| 2081 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 2082 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected