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

Method extract_name

codegraph-kernel/src/scala.rs:519–530  ·  view source on GitHub ↗

extractName (tree-sitter.ts:98-192) — scala-reachable branches: the `name` field's raw text (operator glyphs and backticks kept), else the first identifier-ish child, else ` `.

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

Source from the content-addressed store, hash-verified

517 /// `name` field's raw text (operator glyphs and backticks kept), else the
518 /// first identifier-ish child, else `<anonymous>`.
519 fn extract_name(&self, node: Node<'t>) -> String {
520 if let Some(name_node) = node.child_by_field_name("name") {
521 return self.text(name_node).to_string();
522 }
523 let mut cursor = node.walk();
524 for c in node.named_children(&mut cursor) {
525 if matches!(c.kind(), "identifier" | "type_identifier" | "simple_identifier" | "constant") {
526 return self.text(c).to_string();
527 }
528 }
529 "<anonymous>".to_string()
530 }
531
532 // --- the main walk (visitNode, tree-sitter.ts:936-1303) ---------------
533

Callers 4

extract_classMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 2

walkMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected