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

Method extract_decorators_for

codegraph-kernel/src/java.rs:1100–1139  ·  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

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