From 434f1520df2965240809e37ea144c61f564c1c39 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 Feb 2019 20:13:39 +0300 Subject: add ref postfix template --- .../ra_ide_api/src/completion/complete_postfix.rs | 1 + ...mpletion_works_for_trivial_path_expression.snap | 29 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs index 10a3c8db7..b7dc50c34 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs @@ -30,6 +30,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { if let Some(dot_receiver) = ctx.dot_receiver { let receiver_text = dot_receiver.syntax().text().to_string(); postfix_snippet(ctx, "not", &format!("!{}", receiver_text)).add_to(acc); + postfix_snippet(ctx, "ref", &format!("&{}", receiver_text)).add_to(acc); postfix_snippet(ctx, "if", &format!("if {} {{$0}}", receiver_text)).add_to(acc); postfix_snippet( ctx, diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap index bc886ef0b..3e16c8e79 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap @@ -1,8 +1,8 @@ --- -created: "2019-02-03T11:38:42.897384636+00:00" -creator: insta@0.5.3 -expression: kind_completions +created: "2019-02-14T17:12:57.412523988Z" +creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs +expression: kind_completions --- [ CompletionItem { @@ -97,6 +97,29 @@ source: crates/ra_ide_api/src/completion/completion_item.rs } ) }, + CompletionItem { + completion_kind: Postfix, + label: "ref", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "&bar" + ), + insert_text_format: Snippet, + source_range: [76; 76), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 76), + insert: "" + } + ] + } + ) + }, CompletionItem { completion_kind: Postfix, label: "while", -- cgit v1.2.3