(&mut self, decl: Node<'t>, decorated_row: u32)
| 2438 | // --- extractDecoratorsFor -------------------------------------------------------------- |
| 2439 | |
| 2440 | pub(super) fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 2441 | // 1. Direct children (method/property style). |
| 2442 | for child in decl.named_children(&mut decl.walk()) { |
| 2443 | self.consider_decorator(child, decorated_row); |
| 2444 | if child.kind() == "modifiers" { |
| 2445 | for m in child.named_children(&mut child.walk()) { |
| 2446 | self.consider_decorator(m, decorated_row); |
| 2447 | } |
| 2448 | } |
| 2449 | } |
| 2450 | // 2. Preceding siblings (TypeScript class style), stopping at the |
| 2451 | // first non-decorator so an earlier declaration's decorators never |
| 2452 | // leak in. Matching by startIndex, not object identity. |
| 2453 | // Walked back from the declaration itself. Finding its place first, by counting the |
| 2454 | // parent's children from the start, cost each declaration as much as it has |
| 2455 | // siblings before it: a file of twenty thousand took minutes. |
| 2456 | let mut sibling = decl.prev_named_sibling(); |
| 2457 | while let Some(sib) = sibling { |
| 2458 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 2459 | break; |
| 2460 | } |
| 2461 | self.consider_decorator(sib, decorated_row); |
| 2462 | sibling = sib.prev_named_sibling(); |
| 2463 | } |
| 2464 | } |
| 2465 | |
| 2466 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 2467 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected