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

Function keeps_bare_receiver

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

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

Callers 1

extract_callMethod · 0.85

Calls 1

peel_receiverFunction · 0.85

Tested by

no test coverage detected