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

Method extract_decorators_for

codegraph-kernel/src/kotlin.rs:1561–1581  ·  view source on GitHub ↗

extractDecoratorsFor — kotlin annotations inside `modifiers`: `@Marker` (user_type child) → decorates ref; `@Anno(args)` (constructor_invocation) → NOTHING. Runs for functions/methods/classes only (hook properties never call it).

(&mut self, decl: Node<'t>, decorated_row: u32)

Source from the content-addressed store, hash-verified

1559 /// (constructor_invocation) → NOTHING. Runs for functions/methods/classes
1560 /// only (hook properties never call it).
1561 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {
1562 for child in decl.named_children(&mut decl.walk()) {
1563 self.consider_decorator(child, decorated_row);
1564 if child.kind() == "modifiers" {
1565 for m in child.named_children(&mut child.walk()) {
1566 self.consider_decorator(m, decorated_row);
1567 }
1568 }
1569 }
1570 // Walked back from the declaration itself. Finding its place first, by counting the
1571 // parent's children from the start, cost each declaration as much as it has
1572 // siblings before it: a file of twenty thousand took minutes.
1573 let mut sibling = decl.prev_named_sibling();
1574 while let Some(sib) = sibling {
1575 if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") {
1576 break;
1577 }
1578 self.consider_decorator(sib, decorated_row);
1579 sibling = sib.prev_named_sibling();
1580 }
1581 }
1582
1583 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1584 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {

Callers 3

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45

Calls 2

walkMethod · 0.45
consider_decoratorMethod · 0.45

Tested by

no test coverage detected