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

Method extract_decorators_for

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

Source from the content-addressed store, hash-verified

1546 // --- extractDecoratorsFor (:4897-5024) — the sibling scan -------------
1547
1548 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {
1549 // Scan 1: direct children (+ modifiers descent) — inert for dart
1550 // (annotations are preceding siblings), ported for fidelity.
1551 let mut cursor = decl.walk();
1552 let kids: Vec<Node<'t>> = decl.named_children(&mut cursor).collect();
1553 for child in kids {
1554 self.consider_decorator(child, decorated_row);
1555 if child.kind() == "modifiers" {
1556 let mut mc = child.walk();
1557 let inner: Vec<Node<'t>> = child.named_children(&mut mc).collect();
1558 for m in inner {
1559 self.consider_decorator(m, decorated_row);
1560 }
1561 }
1562 }
1563 // Scan 2: preceding siblings, backward, stop at the first
1564 // non-annotation — stacked annotations emit in REVERSE source order.
1565 // A `declaration`-wrapped member's annotations precede the wrapper,
1566 // and the comments between annotations and declaration are stepped over.
1567 let anchor = self.declaration_wrapper(decl).unwrap_or(decl);
1568 if let Some(parent) = anchor.parent() {
1569 let decl_start = anchor.start_byte();
1570 let mut decl_idx: Option<usize> = None;
1571 for i in 0..parent.named_child_count() {
1572 if let Some(sib) = parent.named_child(i) {
1573 if sib.start_byte() == decl_start {
1574 decl_idx = Some(i);
1575 break;
1576 }
1577 }
1578 }
1579 if let Some(di) = decl_idx {
1580 for j in (0..di).rev() {
1581 let Some(sib) = parent.named_child(j) else { continue };
1582 if DECORATOR_STEP_OVER.contains(&sib.kind()) {
1583 continue;
1584 }
1585 if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") {
1586 break;
1587 }
1588 self.consider_decorator(sib, decorated_row);
1589 }
1590 }
1591 }
1592 }
1593
1594 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1595 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.80
collectMethod · 0.45
consider_decoratorMethod · 0.45
declaration_wrapperMethod · 0.45

Tested by

no test coverage detected