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

Method extract_name

codegraph-kernel/src/dart.rs:560–594  ·  view source on GitHub ↗

extractName (tree-sitter.ts:90-192) — resolveName (ctor names) → name field → the method_signature inner unwrap → identifier-ish child → ` ` (operators land here).

(&self, node: Node<'t>)

Source from the content-addressed store, hash-verified

558 /// name field → the method_signature inner unwrap → identifier-ish
559 /// child → `<anonymous>` (operators land here).
560 fn extract_name(&self, node: Node<'t>) -> String {
561 // resolveName hook (dart.ts:244-260): named ctor/factory → ctor name.
562 if let Some((class_name, ctor_name)) = self.ctor_info(node) {
563 if ctor_name != class_name {
564 return ctor_name;
565 }
566 }
567 if let Some(name_node) = node.child_by_field_name("name") {
568 return self.text(name_node).to_string();
569 }
570 if node.kind() == "method_signature" {
571 let mut cursor = node.walk();
572 let inner = node.named_children(&mut cursor).find(|c| {
573 matches!(
574 c.kind(),
575 "function_signature" | "getter_signature" | "setter_signature"
576 | "constructor_signature" | "factory_constructor_signature"
577 )
578 });
579 if let Some(inner) = inner {
580 let mut ic = inner.walk();
581 let id = inner.named_children(&mut ic).find(|c| c.kind() == "identifier");
582 if let Some(id) = id {
583 return self.text(id).to_string();
584 }
585 }
586 }
587 let mut cursor = node.walk();
588 for c in node.named_children(&mut cursor) {
589 if matches!(c.kind(), "identifier" | "type_identifier" | "simple_identifier" | "constant") {
590 return self.text(c).to_string();
591 }
592 }
593 "<anonymous>".to_string()
594 }
595
596 // --- the main walk (visitNode, tree-sitter.ts:936-1303) ---------------
597

Callers 5

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 2

ctor_infoMethod · 0.80
textMethod · 0.45

Tested by

no test coverage detected