mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Basic support for decl macros 2.0
This commit is contained in:
parent
bd4c352831
commit
c31c3246a8
15 changed files with 195 additions and 28 deletions
|
@ -76,8 +76,20 @@ pub fn type_label(node: &ast::TypeAlias) -> String {
|
|||
label.trim().to_owned()
|
||||
}
|
||||
|
||||
pub fn macro_label(node: &ast::MacroRules) -> String {
|
||||
pub fn macro_label(node: &ast::Macro) -> String {
|
||||
let name = node.name().map(|name| name.syntax().text().to_string()).unwrap_or_default();
|
||||
let vis = if node.has_atom_attr("macro_export") { "#[macro_export]\n" } else { "" };
|
||||
format!("{}macro_rules! {}", vis, name)
|
||||
match node {
|
||||
ast::Macro::MacroRules(node) => {
|
||||
let vis = if node.has_atom_attr("macro_export") { "#[macro_export]\n" } else { "" };
|
||||
format!("{}macro_rules! {}", vis, name)
|
||||
}
|
||||
ast::Macro::MacroDef(node) => {
|
||||
let mut s = String::new();
|
||||
if let Some(vis) = node.visibility() {
|
||||
format_to!(s, "{} ", vis);
|
||||
}
|
||||
format_to!(s, "macro {}", name);
|
||||
s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue