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

Method extract_local_object_owner

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

1441 /// or an IIFE gets the node a module-scope declaration would, with its
1442 /// members under it. False when the declarator holds no owned literal.
1443 pub(super) fn extract_local_object_owner(&mut self, declarator: Node<'t>) -> bool {
1444 let Some(name_node) = declarator.child_by_field_name("name") else { return false };
1445 if name_node.kind() != "identifier" {
1446 return false;
1447 }
1448 let Some(obj) = self.owned_object_value(declarator.child_by_field_name("value")) else {
1449 return false;
1450 };
1451 let is_const = declarator.parent().map(|d| self.is_const_decl(d)).unwrap_or(false);
1452 let kind: &'static str = if is_const { "constant" } else { "variable" };
1453 let name = self.text(name_node).to_string();
1454 // A local: never the target of another scope's value read.
1455 let extra = Extra {
1456 docstring: crate::docstring::preceding_docstring(declarator, self.src),
1457 signature: Some(util::init_signature(self.text(obj))),
1458 is_exported: Some(false),
1459 not_value_target: true,
1460 ..Extra::default()
1461 };
1462 let Some(row) = self.create_node(kind, &name, declarator, extra) else { return false };
1463 self.extract_variable_type_annotation(declarator, row);
1464 self.extract_object_data_members(Some(obj), row, kind, &name, INIT_SIGNATURE_CHARS);
1465 self.extract_owned_object_members(obj, row, kind, &name, false, false, false);
1466 true
1467 }
1468
1469 /// extractAssignedObjectOwner: `window.App = {…}` / `App.utils = {…}` /
1470 /// `dw_page = {…}`. A plain identifier target is qualified like a

Callers 1

Calls 10

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