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

Method bare_call_name

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

Source from the content-addressed store, hash-verified

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

Callers 1

visit_bodyMethod · 0.45

Calls 3

callee_of_arg_partMethod · 0.80
starts_upper_reFunction · 0.70
textMethod · 0.65

Tested by

no test coverage detected