workspacer_syntax/
generate_macro_call_signature.rs

1// ---------------- [ File: workspacer-syntax/src/generate_macro_call_signature.rs ]
2crate::ix!();
3
4#[derive(Debug, Clone)]
5pub struct MacroCallSignatureGenerator(ast::MacroCall);
6
7impl GenerateSignature for ast::MacroCall {
8    fn generate_signature_with_opts(&self, opts: &SignatureOptions) -> String {
9        trace!("Generating signature for ast::MacroCall with opts: {:?}", opts);
10
11        let doc_text = if *opts.include_docs() {
12            extract_docs(&self.syntax())
13                .map(|d| format!("{}\n", d))
14                .unwrap_or_default()
15        } else {
16            "".to_string()
17        };
18
19        let path_str = self
20            .path()
21            .map(|p| p.syntax().text().to_string())
22            .unwrap_or_else(|| {
23                warn!("Macro path not found for MacroCall");
24                "<unknown_macro>".to_string()
25            });
26        debug!("MacroCall path: {}", path_str);
27
28        let call_body = if *opts.fully_expand() {
29            trace!("Fully expanding macro call body");
30            if let Some(tt) = self.token_tree() {
31                let body_str = tt.syntax().text().to_string();
32                debug!("MacroCall token_tree: {}", body_str);
33                body_str
34            } else {
35                warn!("No token_tree found for MacroCall");
36                "{ /* empty */ }".to_string()
37            }
38        } else {
39            "{ /* ... */ }".to_string()
40        };
41
42        let core = format!("{path_str}!{call_body}");
43        let final_sig = format!("{doc_text}{core}");
44        post_process_spacing(&final_sig)
45    }
46}