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

Function macro_receiver_chain

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

receiverChain.

(e: &MExpr)

Source from the content-addressed store, hash-verified

1887
1888/// receiverChain.
1889fn macro_receiver_chain(e: &MExpr) -> Option<String> {
1890 let mut links: Vec<String> = Vec::new();
1891 let mut cur = e;
1892 while links.len() <= RECEIVER_CHAIN_MAX_LINKS {
1893 match cur {
1894 MExpr::SelfE | MExpr::Name(_) => {
1895 let root = match cur {
1896 MExpr::Name(n) => n.as_str(),
1897 _ => "self",
1898 };
1899 if links.is_empty() || !is_rust_ident(root) {
1900 return None;
1901 }
1902 links.reverse();
1903 let mut s = root.to_string();
1904 for l in links {
1905 s.push('.');
1906 s.push_str(&l);
1907 }
1908 return Some(s);
1909 }
1910 MExpr::Method(b, n) => {
1911 if !is_rust_ident(n) {
1912 return None;
1913 }
1914 links.push(format!("{n}()"));
1915 cur = &**b;
1916 }
1917 MExpr::Field(b, n) => {
1918 if !is_field_text(n) {
1919 return None;
1920 }
1921 links.push(n.clone());
1922 cur = &**b;
1923 }
1924 _ => return None,
1925 }
1926 }
1927 None
1928}
1929
1930/// methodCallName.
1931fn 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