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

Method declarator_bound_function

codegraph-kernel/src/tsjs/mod.rs:1010–1026  ·  view source on GitHub ↗

Whether an anonymous function is the whole value of a `variable_declarator` with a plain identifier name — `const NAME = () => {…}` / `= function () {…}`.

(&self, node: Node<'t>)

Source from the content-addressed store, hash-verified

1008 /// `variable_declarator` with a plain identifier name —
1009 /// `const NAME = () => {…}` / `= function () {…}`.
1010 fn declarator_bound_function(&self, node: Node<'t>) -> bool {
1011 if !matches!(node.kind(), "arrow_function" | "function_expression") {
1012 return false;
1013 }
1014 let Some(declarator) = node.parent() else { return false };
1015 if declarator.kind() != "variable_declarator" {
1016 return false;
1017 }
1018 let Some(value) = declarator.child_by_field_name("value") else { return false };
1019 if value.start_byte() != node.start_byte() || value.end_byte() != node.end_byte() {
1020 return false;
1021 }
1022 declarator
1023 .child_by_field_name("name")
1024 .map(|n| n.kind() == "identifier")
1025 .unwrap_or(false)
1026 }
1027
1028 /// The declarator name a React handler hook binds an anonymous function
1029 /// to — `const NAME = useCallback(<node>, [...])` (also `React.useCallback`,

Callers 1

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected