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

Method extract_decorators_for

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

1023
1024 /// extractDecoratorsFor — Java annotations live inside `modifiers`.
1025 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {
1026 for i in 0..decl.named_child_count() {
1027 let Some(child) = decl.named_child(i) else { continue };
1028 self.consider_decorator(child, decorated_row);
1029 if child.kind() == "modifiers" {
1030 for j in 0..child.named_child_count() {
1031 if let Some(m) = child.named_child(j) {
1032 self.consider_decorator(m, decorated_row);
1033 }
1034 }
1035 }
1036 }
1037 // Preceding-sibling scan (TS-style class decorators) — Java annotations
1038 // are inside modifiers, so this is inert here; kept for parity of shape.
1039 let Some(parent) = decl.parent() else { return };
1040 let decl_start = decl.start_byte();
1041 let mut decl_idx: isize = -1;
1042 for i in 0..parent.named_child_count() {
1043 if let Some(sib) = parent.named_child(i) {
1044 if sib.start_byte() == decl_start {
1045 decl_idx = i as isize;
1046 break;
1047 }
1048 }
1049 }
1050 if decl_idx > 0 {
1051 let mut j = decl_idx - 1;
1052 while j >= 0 {
1053 let Some(sib) = parent.named_child(j as usize) else {
1054 j -= 1;
1055 continue;
1056 };
1057 if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") {
1058 break;
1059 }
1060 self.consider_decorator(sib, decorated_row);
1061 j -= 1;
1062 }
1063 }
1064 }
1065
1066 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1067 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