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

Function macro_receiver_chain

codegraph-kernel/src/rustlang.rs:1916–1955  ·  view source on GitHub ↗

receiverChain.

(e: &MExpr)

Source from the content-addressed store, hash-verified

1914
1915/// receiverChain.
1916fn macro_receiver_chain(e: &MExpr) -> Option<String> {
1917 let mut links: Vec<String> = Vec::new();
1918 let mut cur = e;
1919 while links.len() <= RECEIVER_CHAIN_MAX_LINKS {
1920 match cur {
1921 MExpr::SelfE | MExpr::Name(_) => {
1922 let root = match cur {
1923 MExpr::Name(n) => n.as_str(),
1924 _ => "self",
1925 };
1926 if links.is_empty() || !is_rust_ident(root) {
1927 return None;
1928 }
1929 links.reverse();
1930 let mut s = root.to_string();
1931 for l in links {
1932 s.push('.');
1933 s.push_str(&l);
1934 }
1935 return Some(s);
1936 }
1937 MExpr::Method(b, n) => {
1938 if !is_rust_ident(n) {
1939 return None;
1940 }
1941 links.push(format!("{n}()"));
1942 cur = &**b;
1943 }
1944 MExpr::Field(b, n) => {
1945 if !is_field_text(n) {
1946 return None;
1947 }
1948 links.push(n.clone());
1949 cur = &**b;
1950 }
1951 _ => return None,
1952 }
1953 }
1954 None
1955}
1956
1957/// methodCallName.
1958fn macro_method_call_name(base: &MExpr, method: &str) -> Option<String> {

Callers 1

macro_method_call_nameFunction · 0.85

Calls 4

is_rust_identFunction · 0.85
is_field_textFunction · 0.85
lenMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected