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

Method extract_local_object_owner

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

1071 /// or an IIFE gets the node a module-scope declaration would, with its
1072 /// members under it. False when the declarator holds no owned literal.
1073 pub(super) fn extract_local_object_owner(&mut self, declarator: Node<'t>) -> bool {
1074 let Some(name_node) = declarator.child_by_field_name("name") else { return false };
1075 if name_node.kind() != "identifier" {
1076 return false;
1077 }
1078 let Some(obj) = self.owned_object_value(declarator.child_by_field_name("value")) else {
1079 return false;
1080 };
1081 let is_const = declarator.parent().map(|d| self.is_const_decl(d)).unwrap_or(false);
1082 let kind: &'static str = if is_const { "constant" } else { "variable" };
1083 let name = self.text(name_node).to_string();
1084 // A local: never the target of another scope's value read.
1085 let extra = Extra {
1086 docstring: crate::docstring::preceding_docstring(declarator, self.src),
1087 signature: Some(util::init_signature(self.text(obj))),
1088 is_exported: Some(false),
1089 not_value_target: true,
1090 ..Extra::default()
1091 };
1092 let Some(row) = self.create_node(kind, &name, declarator, extra) else { return false };
1093 self.extract_variable_type_annotation(declarator, row);
1094 self.extract_owned_object_members(obj, row, kind, &name, false, false, false);
1095 true
1096 }
1097
1098 /// extractAssignedObjectOwner: `window.App = {…}` / `App.utils = {…}` /
1099 /// `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