From 1c5a63e3dbb53654dbc2fd10492d46f373192ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20=C4=90=E1=BB=A9c=20Hi=E1=BA=BFu?= Date: Sat, 2 Feb 2019 22:10:18 +0700 Subject: add postfix completion for `dbg!()` with `.dbg` --- .../ra_ide_api/src/completion/complete_postfix.rs | 14 +++ ...ompletion_item__filter_postfix_completion1.snap | 27 ++++- ...ompletion_item__filter_postfix_completion2.snap | 27 ++++- ...ompletion_item__filter_postfix_completion3.snap | 27 ++++- ...ompletion_item__filter_postfix_completion4.snap | 123 +++++++++++++++++++++ 5 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion4.snap (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 b5c4d2ebd..af25452b8 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs @@ -42,6 +42,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { ) .add_to(acc); postfix_snippet(ctx, "while", &format!("while {} {{\n$0\n}}", receiver_text)).add_to(acc); + postfix_snippet(ctx, "dbg", &format!("dbg!({})", receiver_text)).add_to(acc); } } @@ -92,4 +93,17 @@ mod tests { "#, ); } + + #[test] + fn test_filter_postfix_completion4() { + check_snippet_completion( + "filter_postfix_completion4", + r#" + fn main() { + let bar = "a"; + bar.dbg<|> + } + "#, + ); + } } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap index 6b2287951..840ec4881 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap @@ -1,10 +1,33 @@ --- -created: "2019-01-27T19:56:59.944118550+00:00" -creator: insta@0.5.2 +created: "2019-02-02T15:08:34.016389802+00:00" +creator: insta@0.5.3 expression: kind_completions source: crates/ra_ide_api/src/completion/completion_item.rs --- [ + CompletionItem { + completion_kind: Postfix, + label: "dbg", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "dbg!(bar)" + ), + insert_text_format: Snippet, + source_range: [76; 76), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 76), + insert: "" + } + ] + } + ) + }, CompletionItem { completion_kind: Postfix, label: "if", diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap index 6925fd102..b46366d88 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap @@ -1,10 +1,33 @@ --- -created: "2019-01-27T19:56:59.942831213+00:00" -creator: insta@0.5.2 +created: "2019-02-02T15:08:34.016388824+00:00" +creator: insta@0.5.3 expression: kind_completions source: crates/ra_ide_api/src/completion/completion_item.rs --- [ + CompletionItem { + completion_kind: Postfix, + label: "dbg", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "dbg!(bar)" + ), + insert_text_format: Snippet, + source_range: [76; 77), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 76), + insert: "" + } + ] + } + ) + }, CompletionItem { completion_kind: Postfix, label: "if", diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap index 22eaf2b4f..3f865cf93 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap @@ -1,10 +1,33 @@ --- -created: "2019-01-27T19:56:59.944615925+00:00" -creator: insta@0.5.2 +created: "2019-02-02T15:08:34.060136941+00:00" +creator: insta@0.5.3 expression: kind_completions source: crates/ra_ide_api/src/completion/completion_item.rs --- [ + CompletionItem { + completion_kind: Postfix, + label: "dbg", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "dbg!(bar)" + ), + insert_text_format: Snippet, + source_range: [78; 78), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, CompletionItem { completion_kind: Postfix, label: "if", diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion4.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion4.snap new file mode 100644 index 000000000..da1033e7c --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion4.snap @@ -0,0 +1,123 @@ +--- +created: "2019-02-02T15:08:34.069147268+00:00" +creator: insta@0.5.3 +expression: kind_completions +source: crates/ra_ide_api/src/completion/completion_item.rs +--- +[ + CompletionItem { + completion_kind: Postfix, + label: "dbg", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "dbg!(bar)" + ), + insert_text_format: Snippet, + source_range: [78; 78), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, + CompletionItem { + completion_kind: Postfix, + label: "if", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "if bar {$0}" + ), + insert_text_format: Snippet, + source_range: [78; 78), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, + CompletionItem { + completion_kind: Postfix, + label: "match", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "match bar {\n${1:_} => {$0\\},\n}" + ), + insert_text_format: Snippet, + source_range: [78; 78), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, + CompletionItem { + completion_kind: Postfix, + label: "not", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "!bar" + ), + insert_text_format: Snippet, + source_range: [78; 78), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, + CompletionItem { + completion_kind: Postfix, + label: "while", + kind: None, + detail: None, + documentation: None, + lookup: None, + insert_text: Some( + "while bar {\n$0\n}" + ), + insert_text_format: Snippet, + source_range: [78; 78), + text_edit: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + } +] -- cgit v1.2.3