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

Method extract_decorators_for

codegraph-kernel/src/kotlin.rs:1515–1552  ·  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

1513 /// (constructor_invocation) → NOTHING. Runs for functions/methods/classes
1514 /// only (hook properties never call it).
1515 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {
1516 for i in 0..decl.named_child_count() {
1517 let Some(child) = decl.named_child(i) else { continue };
1518 self.consider_decorator(child, decorated_row);
1519 if child.kind() == "modifiers" {
1520 for j in 0..child.named_child_count() {
1521 if let Some(m) = child.named_child(j) {
1522 self.consider_decorator(m, decorated_row);
1523 }
1524 }
1525 }
1526 }
1527 let Some(parent) = decl.parent() else { return };
1528 let decl_start = decl.start_byte();
1529 let mut decl_idx: isize = -1;
1530 for i in 0..parent.named_child_count() {
1531 if let Some(sib) = parent.named_child(i) {
1532 if sib.start_byte() == decl_start {
1533 decl_idx = i as isize;
1534 break;
1535 }
1536 }
1537 }
1538 if decl_idx > 0 {
1539 let mut j = decl_idx - 1;
1540 while j >= 0 {
1541 let Some(sib) = parent.named_child(j as usize) else {
1542 j -= 1;
1543 continue;
1544 };
1545 if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") {
1546 break;
1547 }
1548 self.consider_decorator(sib, decorated_row);
1549 j -= 1;
1550 }
1551 }
1552 }
1553
1554 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1555 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {

Callers 3

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45

Calls 1

consider_decoratorMethod · 0.45

Tested by

no test coverage detected