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

Method extract_decorators_for

codegraph-kernel/src/swift.rs:1251–1273  ·  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

1249 /// extractDecoratorsFor — swift `attribute` nodes inside `modifiers`.
1250 /// Coverage: functions/methods/classes/dedicated-branch properties only.
1251 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {
1252 for child in decl.named_children(&mut decl.walk()) {
1253 self.consider_decorator(child, decorated_row);
1254 if child.kind() == "modifiers" {
1255 for m in child.named_children(&mut child.walk()) {
1256 self.consider_decorator(m, decorated_row);
1257 }
1258 }
1259 }
1260 // Preceding-sibling scan — swift attributes are never siblings; the
1261 // scan stops at the first non-decorator sibling immediately.
1262 // Walked back from the declaration itself. Finding its place first, by counting the
1263 // parent's children from the start, cost each declaration as much as it has
1264 // siblings before it: a file of twenty thousand took minutes.
1265 let mut sibling = decl.prev_named_sibling();
1266 while let Some(sib) = sibling {
1267 if !matches!(sib.kind(), "decorator" | "annotation" | "marker_annotation") {
1268 break;
1269 }
1270 self.consider_decorator(sib, decorated_row);
1271 sibling = sib.prev_named_sibling();
1272 }
1273 }
1274
1275 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1276 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {

Callers 4

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45

Calls 2

walkMethod · 0.45
consider_decoratorMethod · 0.45

Tested by

no test coverage detected