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

Function keeps_bare_receiver

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

`this` / `super`, or a member chain rooted at either or at `window`, still collapse to the bare method name; a subscript anywhere in the chain does not (mirrors keepsBareTsJsReceiver).

(node: Node<'_>, src: &str)

Source from the content-addressed store, hash-verified

2173/// collapse to the bare method name; a subscript anywhere in the chain does
2174/// not (mirrors keepsBareTsJsReceiver).
2175fn keeps_bare_receiver(node: Node<'_>, src: &str) -> bool {
2176 let mut cur = node;
2177 while matches!(cur.kind(), "member_expression" | "subscript_expression") {
2178 if cur.kind() == "subscript_expression" {
2179 return false;
2180 }
2181 match cur.child_by_field_name("object") {
2182 Some(object) => cur = peel_receiver(object),
2183 None => return false,
2184 }
2185 }
2186 match cur.kind() {
2187 "this" | "super" => true,
2188 "identifier" => &src[cur.byte_range()] == "window",
2189 _ => false,
2190 }
2191}

Callers 1

extract_callMethod · 0.85

Calls 1

peel_receiverFunction · 0.85

Tested by

no test coverage detected