From 1852b272334b436865cb36089a91b5dba3148c7f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 12 Sep 2019 00:24:39 +0300 Subject: Add `!` to the macro completion label --- .../completion/complete_macro_in_item_position.rs | 2 +- crates/ra_ide_api/src/completion/complete_path.rs | 2 +- crates/ra_ide_api/src/completion/complete_scope.rs | 24 +++++++++++----------- crates/ra_ide_api/src/completion/presentation.rs | 16 +++++++++------ 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs index dfba97f17..a08fb3b5c 100644 --- a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs +++ b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs @@ -37,7 +37,7 @@ mod tests { ), @r##"[ CompletionItem { - label: "foo", + label: "foo!", source_range: [46; 46), delete: [46; 46), insert: "foo!($0)", diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 465edf6dd..457a3d10c 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -605,7 +605,7 @@ mod tests { ), @r###"[ CompletionItem { - label: "foo", + label: "foo!", source_range: [179; 179), delete: [179; 179), insert: "foo!($0)", diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 7380d8508..2ea22876f 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -568,7 +568,7 @@ mod tests { ), @r##"[ CompletionItem { - label: "bar", + label: "bar!", source_range: [252; 252), delete: [252; 252), insert: "bar!($0)", @@ -576,7 +576,7 @@ mod tests { detail: "macro_rules! bar", }, CompletionItem { - label: "baz", + label: "baz!", source_range: [252; 252), delete: [252; 252), insert: "baz!($0)", @@ -584,7 +584,7 @@ mod tests { detail: "#[macro_export]\nmacro_rules! baz", }, CompletionItem { - label: "foo", + label: "foo!", source_range: [252; 252), delete: [252; 252), insert: "foo!($0)", @@ -637,17 +637,17 @@ mod tests { label: "foo", source_range: [49; 49), delete: [49; 49), - insert: "foo!($0)", - kind: Macro, - detail: "macro_rules! foo", + insert: "foo()$0", + kind: Function, + detail: "fn foo()", }, CompletionItem { - label: "foo", + label: "foo!", source_range: [49; 49), delete: [49; 49), - insert: "foo()$0", - kind: Function, - detail: "fn foo()", + insert: "foo!($0)", + kind: Macro, + detail: "macro_rules! foo", }, ]"## ); @@ -670,7 +670,7 @@ mod tests { ), @r##"[ CompletionItem { - label: "foo", + label: "foo!", source_range: [57; 57), delete: [57; 57), insert: "foo!($0)", @@ -706,7 +706,7 @@ mod tests { ), @r##"[ CompletionItem { - label: "foo", + label: "foo!", source_range: [50; 50), delete: [50; 50), insert: "foo!($0)", diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 1995e8971..301c878b1 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -108,13 +108,17 @@ impl Completions { let ast_node = macro_.source(ctx.db).ast; if let Some(name) = name { let detail = macro_label(&ast_node); + let code_declaration = name + "!"; - let builder = - CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.clone()) - .kind(CompletionItemKind::Macro) - .set_documentation(macro_.docs(ctx.db)) - .detail(detail) - .insert_snippet(format!("{}!($0)", name)); + let builder = CompletionItem::new( + CompletionKind::Reference, + ctx.source_range(), + &code_declaration, + ) + .kind(CompletionItemKind::Macro) + .set_documentation(macro_.docs(ctx.db)) + .detail(detail) + .insert_snippet(format!("{}($0)", &code_declaration)); self.add(builder); } -- cgit v1.2.3