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

Method extract_member_read

codegraph-kernel/src/dart.rs:2205–2244  ·  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

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

Callers 1

visit_bodyMethod · 0.80

Calls 7

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

Tested by

no test coverage detected