mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Support completion for macros
This commit is contained in:
parent
e2ebb467bd
commit
7de9537ccc
4 changed files with 295 additions and 2 deletions
|
@ -7,7 +7,7 @@ mod structure;
|
|||
mod short_label;
|
||||
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, TypeParamsOwner},
|
||||
ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner},
|
||||
SyntaxKind::{ATTR, COMMENT},
|
||||
};
|
||||
|
||||
|
@ -61,6 +61,12 @@ pub(crate) fn where_predicates<N: TypeParamsOwner>(node: &N) -> Vec<String> {
|
|||
res
|
||||
}
|
||||
|
||||
pub(crate) fn macro_label(node: &ast::MacroCall) -> 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)
|
||||
}
|
||||
|
||||
pub(crate) fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String {
|
||||
rust_code_markup_with_doc::<_, &str>(val, None)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue