Returns the identifier of the function being called (the `call` head).
(state: &ExtractionState, node: TsNode<'_>)
| 396 | |
| 397 | /// Returns the identifier of the function being called (the `call` head). |
| 398 | fn call_head(state: &ExtractionState, node: TsNode<'_>) -> Option<String> { |
| 399 | // In tree-sitter-elixir, call has a `target` field or first named child is the callee. |
| 400 | if let Some(target) = node.child_by_field_name("target") { |
| 401 | return Some(state.node_text(target)); |
| 402 | } |
| 403 | // Fall back: first identifier child. |
| 404 | let mut cursor = node.walk(); |
| 405 | if cursor.goto_first_child() { |
| 406 | loop { |
| 407 | let child = cursor.node(); |
| 408 | if child.kind() == "identifier" { |
| 409 | return Some(state.node_text(child)); |
| 410 | } |
| 411 | if !cursor.goto_next_sibling() { |
| 412 | break; |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | None |
| 417 | } |
| 418 | |
| 419 | /// Returns the name from the first argument of a call (e.g. module name in defmodule). |
| 420 | fn call_arg_name(state: &ExtractionState, node: TsNode<'_>) -> Option<String> { |