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