MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extract_decorators_for

Method extract_decorators_for

codegraph-kernel/src/dart.rs:1934–1968  ·  view source on GitHub ↗
(&mut self, decl: Node<'t>, decorated_row: u32)

Source from the content-addressed store, hash-verified

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

Callers 3

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45

Calls 4

walkMethod · 0.45
collectMethod · 0.45
consider_decoratorMethod · 0.45
declaration_wrapperMethod · 0.45

Tested by

no test coverage detected