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

Method callee_name_of

codegraph-kernel/src/tsjs/extractors.rs:1903–1917  ·  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

1901 /// chain keeps its text, `(a.b)()` → `a.b`. The node is where the name
1902 /// starts, which is where the reference sits. Mirrors tsJsCalleeName.
1903 fn callee_name_of(&self, func: Node<'t>) -> Option<(String, Node<'t>)> {
1904 let mut cur = peel_receiver(func);
1905 while cur.kind() == "instantiation_expression" {
1906 let inner = cur.child_by_field_name("function").or_else(|| cur.named_child(0))?;
1907 cur = peel_receiver(inner);
1908 }
1909 match cur.kind() {
1910 "identifier" | "super" | "import" => Some((self.text(cur).to_string(), cur)),
1911 "member_expression" => {
1912 let chain: String = self.text(cur).chars().filter(|c| !c.is_whitespace()).collect();
1913 util::dotted_chain().is_match(&chain).then_some((chain, cur))
1914 }
1915 _ => None,
1916 }
1917 }
1918
1919 // --- extractInstantiation -----------------------------------------------------------
1920

Callers 1

extract_callMethod · 0.80

Calls 3

peel_receiverFunction · 0.85
textMethod · 0.65
collectMethod · 0.45

Tested by

no test coverage detected