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

Method bare_call_name

codegraph-kernel/src/dart.rs:936–1021  ·  view source on GitHub ↗
(&self, node: Node<'t>)

Source from the content-addressed store, hash-verified

934 // --- extractBareCall (dart.ts:305-379) --------------------------------
935
936 fn bare_call_name(&self, node: Node<'t>) -> Option<String> {
937 if node.kind() == "selector" {
938 let mut cursor = node.walk();
939 let has_arg_part = node.named_children(&mut cursor).any(|c| c.kind() == "argument_part");
940 if !has_arg_part {
941 return None;
942 }
943 let prev = node.prev_named_sibling()?;
944 if prev.kind() == "identifier" {
945 return Some(self.text(prev).to_string());
946 }
947 if prev.kind() == "selector" {
948 let mut pc = prev.walk();
949 let accessor = prev.named_children(&mut pc).find(|c| {
950 matches!(
951 c.kind(),
952 "unconditional_assignable_selector" | "conditional_assignable_selector"
953 )
954 });
955 if let Some(accessor) = accessor {
956 let mut ac = accessor.walk();
957 let method_id = accessor.named_children(&mut ac).find(|c| c.kind() == "identifier");
958 if let Some(method_id) = method_id {
959 let accessor_prev = prev.prev_named_sibling();
960 if let Some(ap) = accessor_prev {
961 if ap.kind() == "identifier" {
962 return Some(format!("{}.{}", self.text(ap), self.text(method_id)));
963 }
964 // Chained static-factory: the receiver is itself
965 // a call — re-encode `<inner>().<method>` when
966 // the chain starts capitalized (#750).
967 if ap.kind() == "selector" {
968 let mut apc = ap.walk();
969 if ap.named_children(&mut apc).any(|c| c.kind() == "argument_part") {
970 if let Some(inner) = self.callee_of_arg_part(ap) {
971 if starts_upper_re().is_match(&inner) {
972 return Some(format!("{}().{}", inner, self.text(method_id)));
973 }
974 }
975 }
976 }
977 }
978 return Some(self.text(method_id).to_string());
979 }
980 }
981 }
982 // super.method() / this.method(): prev is a bare accessor.
983 if matches!(
984 prev.kind(),
985 "unconditional_assignable_selector" | "conditional_assignable_selector"
986 ) {
987 let mut pc = prev.walk();
988 let id = prev.named_children(&mut pc).find(|c| c.kind() == "identifier");
989 if let Some(id) = id {
990 return Some(self.text(id).to_string());
991 }
992 }
993 return None;

Callers 1

visit_bodyMethod · 0.45

Calls 3

callee_of_arg_partMethod · 0.80
starts_upper_reFunction · 0.70
textMethod · 0.45

Tested by

no test coverage detected