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

Function keeps_bare_receiver

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

2311/// collapse to the bare method name; a subscript anywhere in the chain does
2312/// not (mirrors keepsBareTsJsReceiver).
2313fn keeps_bare_receiver(node: Node<'_>, src: &str) -> bool {
2314 let mut cur = node;
2315 while matches!(cur.kind(), "member_expression" | "subscript_expression") {
2316 if cur.kind() == "subscript_expression" {
2317 return false;
2318 }
2319 match cur.child_by_field_name("object") {
2320 Some(object) => cur = peel_receiver(object),
2321 None => return false,
2322 }
2323 }
2324 match cur.kind() {
2325 "this" | "super" => true,
2326 "identifier" => &src[cur.byte_range()] == "window",
2327 _ => false,
2328 }
2329}

Callers 1

extract_callMethod · 0.85

Calls 1

peel_receiverFunction · 0.85

Tested by

no test coverage detected