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

Method member_literals_of

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

memberLiteralsOf: the object literals whose members a value gives its owner. The value itself, through `as const`, `satisfies` and parentheses, or the literals handed directly to the call or the `new` it is (`defineConfig({…})`, `new Vuex.Store({…})`).

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

Source from the content-addressed store, hash-verified

1112 /// parentheses, or the literals handed directly to the call or the `new`
1113 /// it is (`defineConfig({…})`, `new Vuex.Store({…})`).
1114 fn member_literals_of(&self, value: Node<'t>) -> Vec<Node<'t>> {
1115 let mut node = value;
1116 while matches!(node.kind(), "as_expression" | "satisfies_expression" | "parenthesized_expression") {
1117 let mut cursor = node.walk();
1118 let inner = node.named_children(&mut cursor).find(|child| child.kind() != "comment");
1119 let Some(inner) = inner else { return Vec::new() };
1120 node = inner;
1121 }
1122 if matches!(node.kind(), "object" | "object_expression") {
1123 return vec![node];
1124 }
1125 if !matches!(node.kind(), "call_expression" | "new_expression") {
1126 return Vec::new();
1127 }
1128 let Some(arguments) = node.child_by_field_name("arguments") else { return Vec::new() };
1129 let mut cursor = arguments.walk();
1130 arguments.named_children(&mut cursor).filter_map(|argument| self.object_literal_of(Some(argument))).collect()
1131 }
1132
1133 /// extractModuleValueMembers: the members of what a module exports or
1134 /// assigns with no declaration to hold them (`export default {…}`,

Callers 1

Calls 3

object_literal_ofMethod · 0.80
walkMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected