(&mut self, decl: Node<'t>, decorated_row: u32)
| 1939 | // --- extractDecoratorsFor (:4897-5024) — the sibling scan ------------- |
| 1940 | |
| 1941 | fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) { |
| 1942 | // Scan 1: direct children (+ modifiers descent) — inert for dart |
| 1943 | // (annotations are preceding siblings), ported for fidelity. |
| 1944 | let mut cursor = decl.walk(); |
| 1945 | let kids: Vec<Node<'t>> = decl.named_children(&mut cursor).collect(); |
| 1946 | for child in kids { |
| 1947 | self.consider_decorator(child, decorated_row); |
| 1948 | if child.kind() == "modifiers" { |
| 1949 | let mut mc = child.walk(); |
| 1950 | let inner: Vec<Node<'t>> = child.named_children(&mut mc).collect(); |
| 1951 | for m in inner { |
| 1952 | self.consider_decorator(m, decorated_row); |
| 1953 | } |
| 1954 | } |
| 1955 | } |
| 1956 | // Scan 2: preceding siblings, backward, stop at the first |
| 1957 | // non-annotation — stacked annotations emit in REVERSE source order. |
| 1958 | // A `declaration`-wrapped member's annotations precede the wrapper, |
| 1959 | // and the comments between annotations and declaration are stepped over. |
| 1960 | let anchor = self.declaration_wrapper(decl).unwrap_or(decl); |
| 1961 | // Walked back from the declaration itself. Finding its place first, by counting the |
| 1962 | // parent's children from the start, cost each declaration as much as it has |
| 1963 | // siblings before it: a file of twenty thousand took minutes. |
| 1964 | let mut sibling = anchor.prev_named_sibling(); |
| 1965 | while let Some(sib) = sibling { |
| 1966 | sibling = sib.prev_named_sibling(); |
| 1967 | if DECORATOR_STEP_OVER.contains(&sib.kind()) { |
| 1968 | continue; |
| 1969 | } |
| 1970 | if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") { |
| 1971 | break; |
| 1972 | } |
| 1973 | self.consider_decorator(sib, decorated_row); |
| 1974 | } |
| 1975 | } |
| 1976 | |
| 1977 | fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) { |
| 1978 | if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") { |
no test coverage detected