mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Don't parse source files to generate macro completion details
This commit is contained in:
parent
b1ab5770c9
commit
6c8c02f625
15 changed files with 157 additions and 204 deletions
|
@ -1,6 +1,6 @@
|
|||
//! This module contains utilities for rendering syntax nodes into a string representing their signature.
|
||||
|
||||
use crate::ast::{self, HasAttrs, HasGenericParams, HasName};
|
||||
use crate::ast::{self, HasGenericParams, HasName};
|
||||
|
||||
use ast::HasVisibility;
|
||||
use stdx::format_to;
|
||||
|
@ -49,37 +49,3 @@ pub fn function_declaration(node: &ast::Fn) -> String {
|
|||
}
|
||||
buf
|
||||
}
|
||||
|
||||
pub fn macro_label(node: &ast::Macro) -> String {
|
||||
let name = node.name();
|
||||
let mut s = String::new();
|
||||
match node {
|
||||
ast::Macro::MacroRules(node) => {
|
||||
let vis = if node.has_atom_attr("macro_export") { "#[macro_export] " } else { "" };
|
||||
format_to!(s, "{}macro_rules!", vis);
|
||||
}
|
||||
ast::Macro::MacroDef(node) => {
|
||||
if let Some(vis) = node.visibility() {
|
||||
format_to!(s, "{} ", vis);
|
||||
}
|
||||
format_to!(s, "macro");
|
||||
}
|
||||
}
|
||||
if let Some(name) = name {
|
||||
format_to!(s, " {}", name);
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
pub fn fn_as_proc_macro_label(node: &ast::Fn) -> String {
|
||||
let name = node.name();
|
||||
let mut s = String::new();
|
||||
if let Some(vis) = node.visibility() {
|
||||
format_to!(s, "{} ", vis);
|
||||
}
|
||||
format_to!(s, "macro");
|
||||
if let Some(name) = name {
|
||||
format_to!(s, " {}", name);
|
||||
}
|
||||
s
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue