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

Method extract_name

codegraph-kernel/src/lua.rs:366–389  ·  view source on GitHub ↗

extractName (tree-sitter.ts:98-192) — the lua-reachable branches.

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

Source from the content-addressed store, hash-verified

364
365 /// extractName (tree-sitter.ts:98-192) — the lua-reachable branches.
366 fn extract_name(&self, node: Node<'t>) -> String {
367 if let Some(name_node) = node.child_by_field_name("name") {
368 // Lua: dot/method index → the trailing field/method segment.
369 if name_node.kind() == "dot_index_expression" {
370 if let Some(f) = name_node.child_by_field_name("field") {
371 return self.text(f).to_string();
372 }
373 }
374 if name_node.kind() == "method_index_expression" {
375 if let Some(m) = name_node.child_by_field_name("method") {
376 return self.text(m).to_string();
377 }
378 }
379 return self.text(name_node).to_string();
380 }
381 // Fallback: first identifier-ish named child.
382 let mut cursor = node.walk();
383 for c in node.named_children(&mut cursor) {
384 if matches!(c.kind(), "identifier" | "type_identifier" | "simple_identifier" | "constant") {
385 return self.text(c).to_string();
386 }
387 }
388 "<anonymous>".to_string()
389 }
390
391 /// getSignature — lua (lua.ts:83-86) / luau (luau.ts:26-35).
392 fn signature_of(&self, node: Node<'t>) -> Option<String> {

Callers 3

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 2

walkMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected