From 7de9537cccc7a6338bcd9c892a1fdb4a6008dc1a Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Tue, 10 Sep 2019 13:32:47 +0800 Subject: Support completion for macros --- crates/ra_ide_api/src/display.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src/display.rs') diff --git a/crates/ra_ide_api/src/display.rs b/crates/ra_ide_api/src/display.rs index cc59e99d8..a980c56bc 100644 --- a/crates/ra_ide_api/src/display.rs +++ b/crates/ra_ide_api/src/display.rs @@ -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(node: &N) -> Vec { 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>(val: CODE) -> String { rust_code_markup_with_doc::<_, &str>(val, None) } -- cgit v1.2.3