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

Function keeps_bare_receiver

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

2690/// collapse to the bare method name; a subscript anywhere in the chain does
2691/// not (mirrors keepsBareTsJsReceiver).
2692fn keeps_bare_receiver(node: Node<'_>, src: &str) -> bool {
2693 let mut cur = node;
2694 while matches!(cur.kind(), "member_expression" | "subscript_expression") {
2695 if cur.kind() == "subscript_expression" {
2696 return false;
2697 }
2698 match cur.child_by_field_name("object") {
2699 Some(object) => cur = peel_receiver(object),
2700 None => return false,
2701 }
2702 }
2703 match cur.kind() {
2704 "this" | "super" => true,
2705 "identifier" => &src[cur.byte_range()] == "window",
2706 _ => false,
2707 }
2708}

Callers 1

extract_callMethod · 0.85

Calls 1

peel_receiverFunction · 0.85

Tested by

no test coverage detected