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

Method extract_decorators_for

codegraph-kernel/src/java.rs:1102–1141  ·  view source on GitHub ↗

extractDecoratorsFor — Java annotations live inside `modifiers`.

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

Source from the content-addressed store, hash-verified

1100
1101 /// extractDecoratorsFor — Java annotations live inside `modifiers`.
1102 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {
1103 for i in 0..decl.named_child_count() {
1104 let Some(child) = decl.named_child(i) else { continue };
1105 self.consider_decorator(child, decorated_row);
1106 if child.kind() == "modifiers" {
1107 for j in 0..child.named_child_count() {
1108 if let Some(m) = child.named_child(j) {
1109 self.consider_decorator(m, decorated_row);
1110 }
1111 }
1112 }
1113 }
1114 // Preceding-sibling scan (TS-style class decorators) — Java annotations
1115 // are inside modifiers, so this is inert here; kept for parity of shape.
1116 let Some(parent) = decl.parent() else { return };
1117 let decl_start = decl.start_byte();
1118 let mut decl_idx: isize = -1;
1119 for i in 0..parent.named_child_count() {
1120 if let Some(sib) = parent.named_child(i) {
1121 if sib.start_byte() == decl_start {
1122 decl_idx = i as isize;
1123 break;
1124 }
1125 }
1126 }
1127 if decl_idx > 0 {
1128 let mut j = decl_idx - 1;
1129 while j >= 0 {
1130 let Some(sib) = parent.named_child(j as usize) else {
1131 j -= 1;
1132 continue;
1133 };
1134 if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") {
1135 break;
1136 }
1137 self.consider_decorator(sib, decorated_row);
1138 j -= 1;
1139 }
1140 }
1141 }
1142
1143 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1144 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {

Callers 4

extract_classMethod · 0.45
extract_methodMethod · 0.45
extract_functionMethod · 0.45
extract_fieldMethod · 0.45

Calls 1

consider_decoratorMethod · 0.45

Tested by

no test coverage detected