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

Method extract_name

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

extractName incl. the resolveName hook: a multi-segment extension name (`extension KF.Builder`) takes the LAST type_identifier's text.

(&self, node: Node)

Source from the content-addressed store, hash-verified

430 /// extractName incl. the resolveName hook: a multi-segment extension name
431 /// (`extension KF.Builder`) takes the LAST type_identifier's text.
432 fn extract_name(&self, node: Node) -> String {
433 if node.kind() == "class_declaration" {
434 if let Some(name_node) = node.child_by_field_name("name") {
435 if name_node.kind() == "user_type" {
436 let ids: Vec<Node> = (0..name_node.named_child_count())
437 .filter_map(|i| name_node.named_child(i))
438 .filter(|c| c.kind() == "type_identifier")
439 .collect();
440 if ids.len() > 1 {
441 return self.text(ids[ids.len() - 1]).to_string();
442 }
443 }
444 }
445 }
446 if let Some(name_node) = node.child_by_field_name("name") {
447 return self.text(name_node).to_string();
448 }
449 for i in 0..node.named_child_count() {
450 if let Some(c) = node.named_child(i) {
451 if matches!(c.kind(), "identifier" | "type_identifier" | "simple_identifier" | "constant") {
452 return self.text(c).to_string();
453 }
454 }
455 }
456 "<anonymous>".to_string()
457 }
458
459 /// getVisibility: whole-text substring matching over `modifiers` children;
460 /// default INTERNAL. `open` → internal, `fileprivate` → private (via the

Callers 8

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45
extract_interfaceMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 3

lenMethod · 0.80
textMethod · 0.65
collectMethod · 0.45

Tested by

no test coverage detected