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

Method extract_member_read

codegraph-kernel/src/dart.rs:2219–2258  ·  view source on GitHub ↗

dartMemberRead (dart.ts) — `x.area` / `x?.area` not followed by a call's argument part, receiver a plain name: a `references` ref `x.area` on `area`, which the resolver links to a getter only (#2338).

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

Source from the content-addressed store, hash-verified

2217 /// argument part, receiver a plain name: a `references` ref `x.area` on
2218 /// `area`, which the resolver links to a getter only (#2338).
2219 fn extract_member_read(&mut self, node: Node<'t>) {
2220 if node.kind() != "selector" {
2221 return;
2222 }
2223 let mut cursor = node.walk();
2224 let accessor = node.named_children(&mut cursor).find(|c| {
2225 matches!(c.kind(), "unconditional_assignable_selector" | "conditional_assignable_selector")
2226 });
2227 let member = accessor.and_then(|a| {
2228 let mut ac = a.walk();
2229 let found = a.named_children(&mut ac).find(|c| c.kind() == "identifier");
2230 found
2231 });
2232 let Some(member) = member else { return };
2233 let Some(receiver) = prev_named(node) else { return };
2234 if receiver.kind() != "identifier" {
2235 return;
2236 }
2237 let next = next_named(node);
2238 if let Some(next) = next {
2239 if next.kind() == "selector" {
2240 let mut nc = next.walk();
2241 if next.named_children(&mut nc).any(|c| c.kind() == "argument_part") {
2242 return;
2243 }
2244 }
2245 // `p.Box` in `p.Box<int>.named(…)` is a type, after its import prefix.
2246 if self.type_arguments_type(next) == Some(member) {
2247 return;
2248 }
2249 }
2250 // The callee of a generic call the grammar read as comparisons
2251 // (`ref.read<Repo>(p)`) is called; a prefixed type argument names a type.
2252 if self.in_misparsed_generic_call(receiver, next, node.parent()) {
2253 return;
2254 }
2255 let name = format!("{}.{}", self.text(receiver), self.text(member));
2256 let reader = self.top_row();
2257 self.push_ref_at(reader, &name, "references", member);
2258 }
2259
2260 // --- visitFunctionBody (:5129-5286) — dart rows -----------------------
2261

Callers 1

visit_bodyMethod · 0.80

Calls 7

prev_namedFunction · 0.85
next_namedFunction · 0.85
walkMethod · 0.80
type_arguments_typeMethod · 0.80
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected