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

Function rust_macro_arg_refs

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

rustMacroArgRefs: none unless `mac` is one of RUST_EXPRESSION_MACROS, or one of `declared`, the file's own, written bare or through `crate::` or `self::`.

(mac: Node<'t>, src: &'t str, declared: &HashSet<String>)

Source from the content-addressed store, hash-verified

1985/// one of `declared`, the file's own, written bare or through `crate::` or
1986/// `self::`.
1987fn rust_macro_arg_refs<'t>(mac: Node<'t>, src: &'t str, declared: &HashSet<String>) -> Vec<MacroRef<'t>> {
1988 let mut out = Vec::new();
1989 let name_node = mac.named_child(0);
1990 let tree = (0..mac.named_child_count()).filter_map(|i| mac.named_child(i)).find(|c| c.kind() == "token_tree");
1991 let (Some(name_node), Some(tree)) = (name_node, tree) else { return out };
1992 let segments: Vec<&str> = macro_tok_text(name_node, src).split("::").map(|s| s.trim()).collect();
1993 let name = segments[segments.len() - 1];
1994 if RUST_EXPRESSION_MACROS.contains(&name) || (declared.contains(name) && macro_is_own_path(&segments)) {
1995 macro_scan_macro(tree, name, src, declared, &mut out);
1996 }
1997 out
1998}
1999
2000/// isOwnMacroPath: `wrap`, `crate::wrap`, `self::wrap`.
2001fn macro_is_own_path(segments: &[&str]) -> bool {

Callers 1

Calls 6

macro_tok_textFunction · 0.85
macro_is_own_pathFunction · 0.85
macro_scan_macroFunction · 0.85
mapMethod · 0.80
lenMethod · 0.80
collectMethod · 0.45

Tested by

no test coverage detected