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

Method extract_local_object_owner

codegraph-kernel/src/tsjs/extractors.rs:932–955  ·  view source on GitHub ↗

extractLocalObjectOwner: `const api = { load() {…} }` in a function body or an IIFE gets the node a module-scope declaration would, with its members under it. False when the declarator holds no owned literal.

(&mut self, declarator: Node<'t>)

Source from the content-addressed store, hash-verified

930 /// or an IIFE gets the node a module-scope declaration would, with its
931 /// members under it. False when the declarator holds no owned literal.
932 pub(super) fn extract_local_object_owner(&mut self, declarator: Node<'t>) -> bool {
933 let Some(name_node) = declarator.child_by_field_name("name") else { return false };
934 if name_node.kind() != "identifier" {
935 return false;
936 }
937 let Some(obj) = self.owned_object_value(declarator.child_by_field_name("value")) else {
938 return false;
939 };
940 let is_const = declarator.parent().map(|d| self.is_const_decl(d)).unwrap_or(false);
941 let kind: &'static str = if is_const { "constant" } else { "variable" };
942 let name = self.text(name_node).to_string();
943 // A local: never the target of another scope's value read.
944 let extra = Extra {
945 docstring: crate::docstring::preceding_docstring(declarator, self.src),
946 signature: Some(util::init_signature(self.text(obj))),
947 is_exported: Some(false),
948 not_value_target: true,
949 ..Extra::default()
950 };
951 let Some(row) = self.create_node(kind, &name, declarator, extra) else { return false };
952 self.extract_variable_type_annotation(declarator, row);
953 self.extract_owned_object_members(obj, row, kind, &name, false, false);
954 true
955 }
956
957 /// extractAssignedObjectOwner: `window.App = {…}` / `App.utils = {…}` /
958 /// `dw_page = {…}`. A plain identifier target is qualified like a

Callers 1

Calls 9

preceding_docstringFunction · 0.85
init_signatureFunction · 0.85
owned_object_valueMethod · 0.80
mapMethod · 0.80
is_const_declMethod · 0.80
textMethod · 0.65
create_nodeMethod · 0.45

Tested by

no test coverage detected