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

Method declarator_bound_function

codegraph-kernel/src/tsjs/mod.rs:896–912  ·  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

894 /// `variable_declarator` with a plain identifier name —
895 /// `const NAME = () => {…}` / `= function () {…}`.
896 fn declarator_bound_function(&self, node: Node<'t>) -> bool {
897 if !matches!(node.kind(), "arrow_function" | "function_expression") {
898 return false;
899 }
900 let Some(declarator) = node.parent() else { return false };
901 if declarator.kind() != "variable_declarator" {
902 return false;
903 }
904 let Some(value) = declarator.child_by_field_name("value") else { return false };
905 if value.start_byte() != node.start_byte() || value.end_byte() != node.end_byte() {
906 return false;
907 }
908 declarator
909 .child_by_field_name("name")
910 .map(|n| n.kind() == "identifier")
911 .unwrap_or(false)
912 }
913
914 /// The declarator name a React handler hook binds an anonymous function
915 /// to — `const NAME = useCallback(<node>, [...])` (also `React.useCallback`,

Callers 1

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected