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

Method callee_name_of

codegraph-kernel/src/tsjs/extractors.rs:1765–1779  ·  view source on GitHub ↗

The name a non-member callee writes, past `(fn)`, `fn!`, `(fn as F)`, `await` and a tag's type arguments (`css `), or None for one that names nothing: a call, a function, a subscript, `(0, fn)`. A dotted chain keeps its text, `(a.b)()` → `a.b`. The node is where the name starts, which is where the reference sits. Mirrors tsJsCalleeName.

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

Source from the content-addressed store, hash-verified

1763 /// chain keeps its text, `(a.b)()` → `a.b`. The node is where the name
1764 /// starts, which is where the reference sits. Mirrors tsJsCalleeName.
1765 fn callee_name_of(&self, func: Node<'t>) -> Option<(String, Node<'t>)> {
1766 let mut cur = peel_receiver(func);
1767 while cur.kind() == "instantiation_expression" {
1768 let inner = cur.child_by_field_name("function").or_else(|| cur.named_child(0))?;
1769 cur = peel_receiver(inner);
1770 }
1771 match cur.kind() {
1772 "identifier" | "super" | "import" => Some((self.text(cur).to_string(), cur)),
1773 "member_expression" => {
1774 let chain: String = self.text(cur).chars().filter(|c| !c.is_whitespace()).collect();
1775 util::dotted_chain().is_match(&chain).then_some((chain, cur))
1776 }
1777 _ => None,
1778 }
1779 }
1780
1781 // --- extractInstantiation -----------------------------------------------------------
1782

Callers 1

extract_callMethod · 0.80

Calls 3

peel_receiverFunction · 0.85
textMethod · 0.65
collectMethod · 0.45

Tested by

no test coverage detected