aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/display.rs
diff options
context:
space:
mode:
authoruHOOCCOOHu <[email protected]>2019-09-10 06:32:47 +0100
committeruHOOCCOOHu <[email protected]>2019-09-10 06:32:47 +0100
commit7de9537cccc7a6338bcd9c892a1fdb4a6008dc1a (patch)
tree8c6a25f27708815935511897071c749ecd6111e3 /crates/ra_ide_api/src/display.rs
parente2ebb467bdf3ebb7d29260adb95c56594c6db282 (diff)
Support completion for macros
Diffstat (limited to 'crates/ra_ide_api/src/display.rs')
-rw-r--r--crates/ra_ide_api/src/display.rs8
1 files changed, 7 insertions, 1 deletions
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;
7mod short_label; 7mod short_label;
8 8
9use ra_syntax::{ 9use ra_syntax::{
10 ast::{self, AstNode, TypeParamsOwner}, 10 ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner},
11 SyntaxKind::{ATTR, COMMENT}, 11 SyntaxKind::{ATTR, COMMENT},
12}; 12};
13 13
@@ -61,6 +61,12 @@ pub(crate) fn where_predicates<N: TypeParamsOwner>(node: &N) -> Vec<String> {
61 res 61 res
62} 62}
63 63
64pub(crate) fn macro_label(node: &ast::MacroCall) -> String {
65 let name = node.name().map(|name| name.syntax().text().to_string()).unwrap_or_default();
66 let vis = if node.has_atom_attr("macro_export") { "#[macro_export]\n" } else { "" };
67 format!("{}macro_rules! {}", vis, name)
68}
69
64pub(crate) fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String { 70pub(crate) fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String {
65 rust_code_markup_with_doc::<_, &str>(val, None) 71 rust_code_markup_with_doc::<_, &str>(val, None)
66} 72}