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

Method extract_decorators_for

codegraph-kernel/src/swift.rs:1278–1317  ·  view source on GitHub ↗

extractDecoratorsFor — swift `attribute` nodes inside `modifiers`. Coverage: functions/methods/classes/dedicated-branch properties only.

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

Source from the content-addressed store, hash-verified

1276 /// extractDecoratorsFor — swift `attribute` nodes inside `modifiers`.
1277 /// Coverage: functions/methods/classes/dedicated-branch properties only.
1278 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {
1279 for i in 0..decl.named_child_count() {
1280 let Some(child) = decl.named_child(i) else { continue };
1281 self.consider_decorator(child, decorated_row);
1282 if child.kind() == "modifiers" {
1283 for j in 0..child.named_child_count() {
1284 if let Some(m) = child.named_child(j) {
1285 self.consider_decorator(m, decorated_row);
1286 }
1287 }
1288 }
1289 }
1290 // Preceding-sibling scan — swift attributes are never siblings; the
1291 // scan stops at the first non-decorator sibling immediately.
1292 let Some(parent) = decl.parent() else { return };
1293 let decl_start = decl.start_byte();
1294 let mut decl_idx: isize = -1;
1295 for i in 0..parent.named_child_count() {
1296 if let Some(sib) = parent.named_child(i) {
1297 if sib.start_byte() == decl_start {
1298 decl_idx = i as isize;
1299 break;
1300 }
1301 }
1302 }
1303 if decl_idx > 0 {
1304 let mut j = decl_idx - 1;
1305 while j >= 0 {
1306 let Some(sib) = parent.named_child(j as usize) else {
1307 j -= 1;
1308 continue;
1309 };
1310 if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") {
1311 break;
1312 }
1313 self.consider_decorator(sib, decorated_row);
1314 j -= 1;
1315 }
1316 }
1317 }
1318
1319 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1320 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {

Callers 4

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45

Calls 1

consider_decoratorMethod · 0.45

Tested by

no test coverage detected