From 92aa0f9c871a9308ea3db1b1c4b7e42d88348e30 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 18 Feb 2019 12:05:16 +0300 Subject: Don't use additional_text_edits API internally --- .../ra_ide_api/src/completion/complete_postfix.rs | 17 ++-- .../ra_ide_api/src/completion/completion_item.rs | 103 +++++++++++++-------- .../completion_item__bindings_from_for.snap | 22 ++++- .../completion_item__bindings_from_if_let.snap | 30 +++++- .../completion_item__bindings_from_let.snap | 30 +++++- ...em__completes_break_and_continue_in_loops1.snap | 86 ++++++++++++----- ...em__completes_break_and_continue_in_loops2.snap | 62 +++++++++---- .../completion_item__completes_prelude.snap | 30 +++++- ...on_item__completes_use_paths_across_crates.snap | 10 +- .../completion_item__deeply_nested_use_tree.snap | 10 +- ...t_add_semi_after_return_if_not_a_statement.snap | 62 +++++++++---- ...ont_render_function_parens_if_already_call.snap | 18 +++- ...r_function_parens_if_already_call_assoc_fn.snap | 10 +- ...m__dont_render_function_parens_in_use_item.snap | 10 +- ...__dont_show_both_completions_for_shadowing.snap | 22 ++++- .../snapshots/completion_item__enum_variant.snap | 18 +++- ...completion_item__enum_variant_with_details.snap | 26 +++++- .../snapshots/completion_item__extern_prelude.snap | 10 +- .../snapshots/completion_item__generic_params.snap | 22 ++++- .../completion_item__generic_params_in_struct.snap | 18 +++- ...n_item__inserts_parens_for_function_calls1.snap | 26 ++++-- ...n_item__inserts_parens_for_function_calls2.snap | 26 ++++-- ...n_item__inserts_parens_for_function_calls3.snap | 14 ++- .../completion_item__keywords_in_function1.snap | 62 +++++++++---- .../completion_item__keywords_in_function2.snap | 86 ++++++++++++----- .../completion_item__keywords_in_function3.snap | 62 +++++++++---- .../completion_item__keywords_in_function4.snap | 62 +++++++++---- .../completion_item__keywords_in_use_stmt1.snap | 34 +++++-- .../completion_item__keywords_in_use_stmt2.snap | 22 ++++- .../completion_item__keywords_in_use_stmt3.snap | 22 ++++- ...etion_item__last_return_in_block_has_semi1.snap | 62 +++++++++---- ...etion_item__last_return_in_block_has_semi2.snap | 62 +++++++++---- .../completion_item__method_attr_filtering.snap | 14 ++- .../completion_item__method_completion.snap | 14 ++- .../snapshots/completion_item__mod_with_docs.snap | 10 +- .../snapshots/completion_item__module_items.snap | 30 +++++- ...etion_item__module_items_in_nested_modules.snap | 22 ++++- .../completion_item__nested_use_tree.snap | 18 +++- ...item__no_semi_after_break_continue_in_expr.snap | 74 ++++++++++++--- ...mpletion_item__param_completion_last_param.snap | 10 +- ...ompletion_item__param_completion_nth_param.snap | 10 +- ...pletion_item__param_completion_trait_param.snap | 10 +- ...mpletion_works_for_trivial_path_expression.snap | 58 +++++------- .../snapshots/completion_item__return_type.snap | 22 ++++- .../completion_item__self_in_methods.snap | 18 +++- .../completion_item__snippets_in_expressions.snap | 26 ++++-- .../completion_item__snippets_in_items.snap | 26 ++++-- .../completion_item__struct_associated_const.snap | 10 +- .../completion_item__struct_associated_method.snap | 14 ++- .../completion_item__struct_associated_type.snap | 10 +- .../completion_item__struct_field_completion.snap | 10 +- ...on_item__struct_field_completion_autoderef.snap | 22 ++++- ...pletion_item__struct_field_completion_self.snap | 22 ++++- .../completion_item__tuple_field_completion.snap | 18 +++- ...pletion_item__use_item_starting_with_crate.snap | 18 +++- ...mpletion_item__use_item_starting_with_self.snap | 10 +- crates/ra_lsp_server/src/conv.rs | 32 +++++-- 57 files changed, 1300 insertions(+), 384 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 4ba181720..ce3d6ed3c 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs @@ -16,15 +16,16 @@ use ra_syntax::{ use ra_text_edit::TextEditBuilder; fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { - let replace_range = ctx.source_range(); - let receiver_range = ctx.dot_receiver.expect("no receiver available").syntax().range(); - let delete_range = TextRange::from_to(receiver_range.start(), replace_range.start()); - let mut builder = TextEditBuilder::default(); - builder.delete(delete_range); - CompletionItem::new(CompletionKind::Postfix, replace_range, label) - .insert_snippet(snippet) + let edit = { + let receiver_range = ctx.dot_receiver.expect("no receiver available").syntax().range(); + let delete_range = TextRange::from_to(receiver_range.start(), ctx.source_range().end()); + let mut builder = TextEditBuilder::default(); + builder.replace(delete_range, snippet.to_string()); + builder.finish() + }; + CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label) .detail(detail) - .text_edit(builder.finish()) + .snippet_edit(edit) } pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 1cdcde211..9aa9768d1 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -2,7 +2,7 @@ use std::fmt; use hir::{Docs, Documentation, PerNs, Resolution}; use ra_syntax::TextRange; -use ra_text_edit::TextEdit; +use ra_text_edit::{ TextEditBuilder, TextEdit}; use test_utils::tested_by; use crate::completion::{ @@ -17,29 +17,47 @@ use crate::completion::{ /// `CompletionItem`, use `new` method and the `Builder` struct. pub struct CompletionItem { /// Used only internally in tests, to check only specific kind of - /// completion. + /// completion (postfix, keyword, reference, etc). #[allow(unused)] completion_kind: CompletionKind, + /// Label in the completion pop up which identifies completion. label: String, + /// Range of identifier that is being completed. + /// + /// It should be used primarily for UI, but we also use this to convert + /// genetic TextEdit into LSP's completion edit (see conv.rs). + /// + /// `source_range` must contain the completion offset. `insert_text` should + /// start with what `source_range` points to, or VSCode will filter out the + /// completion silently. + source_range: TextRange, + /// What happens when user selects this item. + /// + /// Typically, replaces `source_range` with new identifier. + text_edit: TextEdit, + insert_text_format: InsertTextFormat, + + /// What item (struct, function, etc) are we completing. kind: Option, + + /// Lookup is used to check if completion item indeed can complete current + /// ident. + /// + /// That is, in `foo.bar<|>` lookup of `abracadabra` will be accepted (it + /// contains `bar` sub sequence), and `quux` will rejected. lookup: Option, + + /// Additional info to show in the UI pop up. detail: Option, documentation: Option, - insert_text: Option, - insert_text_format: InsertTextFormat, - /// Where completion occurs. `source_range` must contain the completion offset. - /// `insert_text` should start with what `source_range` points to, or VSCode - /// will filter out the completion silently. - source_range: TextRange, - /// Additional text edit, ranges in `text_edit` must never intersect with `source_range`. - /// Or VSCode will drop it silently. - text_edit: Option, } impl fmt::Debug for CompletionItem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut s = f.debug_struct("CompletionItem"); - s.field("label", &self.label()).field("source_range", &self.source_range()); + s.field("label", &self.label()) + .field("source_range", &self.source_range()) + .field("text_edit", &self.text_edit); if let Some(kind) = self.kind().as_ref() { s.field("kind", kind); } @@ -52,13 +70,6 @@ impl fmt::Debug for CompletionItem { if let Some(documentation) = self.documentation() { s.field("documentation", &documentation); } - if self.insert_text() != self.label() { - s.field("insert_text", &self.insert_text()) - .field("insert_text_format", &self.insert_text_format()); - } - if let Some(edit) = self.text_edit.as_ref() { - s.field("text_edit", edit); - } s.finish() } } @@ -103,12 +114,12 @@ pub enum InsertTextFormat { impl CompletionItem { pub(crate) fn new( completion_kind: CompletionKind, - replace_range: TextRange, + source_range: TextRange, label: impl Into, ) -> Builder { let label = label.into(); Builder { - source_range: replace_range, + source_range, completion_kind, label, insert_text: None, @@ -124,6 +135,18 @@ impl CompletionItem { pub fn label(&self) -> &str { &self.label } + pub fn source_range(&self) -> TextRange { + self.source_range + } + + pub fn insert_text_format(&self) -> InsertTextFormat { + self.insert_text_format + } + + pub fn text_edit(&self) -> &TextEdit { + &self.text_edit + } + /// Short one-line additional information, like a type pub fn detail(&self) -> Option<&str> { self.detail.as_ref().map(|it| it.as_str()) @@ -137,24 +160,9 @@ impl CompletionItem { self.lookup.as_ref().map(|it| it.as_str()).unwrap_or_else(|| self.label()) } - pub fn insert_text_format(&self) -> InsertTextFormat { - self.insert_text_format - } - pub fn insert_text(&self) -> String { - match &self.insert_text { - Some(t) => t.clone(), - None => self.label.clone(), - } - } pub fn kind(&self) -> Option { self.kind } - pub fn take_text_edit(&mut self) -> Option { - self.text_edit.take() - } - pub fn source_range(&self) -> TextRange { - self.source_range - } } /// A helper to make `CompletionItem`s. @@ -178,17 +186,27 @@ impl Builder { } pub(crate) fn build(self) -> CompletionItem { + let label = self.label; + let text_edit = match self.text_edit { + Some(it) => it, + None => { + let mut builder = TextEditBuilder::default(); + builder + .replace(self.source_range, self.insert_text.unwrap_or_else(|| label.clone())); + builder.finish() + } + }; + CompletionItem { source_range: self.source_range, - label: self.label, + label, + insert_text_format: self.insert_text_format, + text_edit, detail: self.detail, documentation: self.documentation, - insert_text_format: self.insert_text_format, lookup: self.lookup, kind: self.kind, completion_kind: self.completion_kind, - text_edit: self.text_edit, - insert_text: self.insert_text, } } pub(crate) fn lookup_by(mut self, lookup: impl Into) -> Builder { @@ -207,11 +225,14 @@ impl Builder { self.kind = Some(kind); self } - #[allow(unused)] pub(crate) fn text_edit(mut self, edit: TextEdit) -> Builder { self.text_edit = Some(edit); self } + pub(crate) fn snippet_edit(mut self, edit: TextEdit) -> Builder { + self.insert_text_format = InsertTextFormat::Snippet; + self.text_edit(edit) + } #[allow(unused)] pub(crate) fn detail(self, detail: impl Into) -> Builder { self.set_detail(Some(detail)) diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap index 799daa724..e6e389fbd 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.736783986Z" +created: "2019-02-18T09:10:52.089782502Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,14 +8,28 @@ expression: kind_completions CompletionItem { label: "quux", source_range: [83; 83), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "quux()$0" + } + ] + }, kind: Function, - detail: "fn quux()", - insert_text: "quux()$0", - insert_text_format: Snippet + detail: "fn quux()" }, CompletionItem { label: "x", source_range: [83; 83), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "x" + } + ] + }, kind: Binding } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap index e6c1a936a..badaed8fe 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.739513594Z" +created: "2019-02-18T09:10:52.092577354Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,19 +8,41 @@ expression: kind_completions CompletionItem { label: "a", source_range: [214; 214), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [214; 214), + insert: "a" + } + ] + }, kind: Binding }, CompletionItem { label: "b", source_range: [214; 214), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [214; 214), + insert: "b" + } + ] + }, kind: Binding }, CompletionItem { label: "quux", source_range: [214; 214), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [214; 214), + insert: "quux()$0" + } + ] + }, kind: Function, - detail: "fn quux()", - insert_text: "quux()$0", - insert_text_format: Snippet + detail: "fn quux()" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap index 2b0da7d73..1b4cbf91e 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.739513592Z" +created: "2019-02-18T09:10:52.090000719Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,19 +8,41 @@ expression: kind_completions CompletionItem { label: "quux", source_range: [79; 79), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [79; 79), + insert: "quux($0)" + } + ] + }, kind: Function, - detail: "fn quux(x: i32)", - insert_text: "quux($0)", - insert_text_format: Snippet + detail: "fn quux(x: i32)" }, CompletionItem { label: "x", source_range: [79; 79), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [79; 79), + insert: "x" + } + ] + }, kind: Binding }, CompletionItem { label: "y", source_range: [79; 79), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [79; 79), + insert: "y" + } + ] + }, kind: Binding } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap index 5d62a6cb0..74f6fcd77 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.630948152Z" +created: "2019-02-18T09:10:51.974241301Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,50 +8,92 @@ expression: kind_completions CompletionItem { label: "break", source_range: [55; 55), - kind: Keyword, - insert_text: "break;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [55; 55), + insert: "break;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "continue", source_range: [55; 55), - kind: Keyword, - insert_text: "continue;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [55; 55), + insert: "continue;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "if", source_range: [55; 55), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [55; 55), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [55; 55), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [55; 55), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [55; 55), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [55; 55), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [55; 55), - kind: Keyword, - insert_text: "return $0;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [55; 55), + insert: "return $0;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [55; 55), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [55; 55), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap index aeedd0e80..225ca4c7f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.662074625Z" +created: "2019-02-18T09:10:52.011157905Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,36 +8,66 @@ expression: kind_completions CompletionItem { label: "if", source_range: [60; 60), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [60; 60), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [60; 60), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [60; 60), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [60; 60), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [60; 60), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [60; 60), - kind: Keyword, - insert_text: "return $0;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [60; 60), + insert: "return $0;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [60; 60), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [60; 60), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_prelude.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_prelude.snap index a22205dad..58515b86f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_prelude.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_prelude.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.774580359Z" +created: "2019-02-18T09:10:52.125606390Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,19 +8,41 @@ expression: kind_completions CompletionItem { label: "Option", source_range: [18; 18), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [18; 18), + insert: "Option" + } + ] + }, kind: Struct }, CompletionItem { label: "foo", source_range: [18; 18), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [18; 18), + insert: "foo()$0" + } + ] + }, kind: Function, - detail: "fn foo()", - insert_text: "foo()$0", - insert_text_format: Snippet + detail: "fn foo()" }, CompletionItem { label: "std", source_range: [18; 18), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [18; 18), + insert: "std" + } + ] + }, kind: Module } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_use_paths_across_crates.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_use_paths_across_crates.snap index fcbb592e1..3b6ff57c1 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_use_paths_across_crates.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_use_paths_across_crates.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.729954589Z" +created: "2019-02-18T09:10:52.081693428Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "bar", source_range: [9; 9), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [9; 9), + insert: "bar" + } + ] + }, kind: Module } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__deeply_nested_use_tree.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__deeply_nested_use_tree.snap index 3c5460319..1fb15ee0d 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__deeply_nested_use_tree.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__deeply_nested_use_tree.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.663233766Z" +created: "2019-02-18T09:10:52.018717911Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "Spam", source_range: [23; 25), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [23; 25), + insert: "Spam" + } + ] + }, kind: Struct } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap index 493684e5b..34e75ef80 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.637726929Z" +created: "2019-02-18T09:10:51.979744970Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,36 +8,66 @@ expression: kind_completions CompletionItem { label: "if", source_range: [85; 85), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [85; 85), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [85; 85), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [85; 85), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [85; 85), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [85; 85), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [85; 85), - kind: Keyword, - insert_text: "return $0", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [85; 85), + insert: "return $0" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [85; 85), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [85; 85), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap index 4e37dbef1..89ae3d405 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.812347626Z" +created: "2019-02-18T09:10:52.163807552Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,12 +8,28 @@ expression: kind_completions CompletionItem { label: "frobnicate", source_range: [35; 39), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [35; 39), + insert: "frobnicate" + } + ] + }, kind: Function, detail: "fn frobnicate()" }, CompletionItem { label: "main", source_range: [35; 39), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [35; 39), + insert: "main" + } + ] + }, kind: Function, detail: "fn main()" } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call_assoc_fn.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call_assoc_fn.snap index 2ba9c82b0..ab4075c50 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call_assoc_fn.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call_assoc_fn.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.843178841Z" +created: "2019-02-18T09:10:52.194798097Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "new", source_range: [67; 69), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [67; 69), + insert: "new" + } + ] + }, kind: Method, detail: "fn new() -> Foo" } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_in_use_item.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_in_use_item.snap index c071ff198..259f9fc62 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_in_use_item.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_in_use_item.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.808400485Z" +created: "2019-02-18T09:10:52.156083575Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "foo", source_range: [40; 41), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [40; 41), + insert: "foo" + } + ] + }, kind: Function, detail: "pub fn foo()" } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap index 68bfbcdcd..7af2f3eb9 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.810202671Z" +created: "2019-02-18T09:10:52.134207539Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,14 +8,28 @@ expression: kind_completions CompletionItem { label: "bar", source_range: [129; 129), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [129; 129), + insert: "bar" + } + ] + }, kind: Binding }, CompletionItem { label: "foo", source_range: [129; 129), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [129; 129), + insert: "foo()$0" + } + ] + }, kind: Function, - detail: "fn foo() ->", - insert_text: "foo()$0", - insert_text_format: Snippet + detail: "fn foo() ->" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap index b4a8443a0..7f36a5ec5 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.672144115Z" +created: "2019-02-18T09:10:52.033853029Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "Bar", source_range: [116; 116), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [116; 116), + insert: "Bar" + } + ] + }, kind: EnumVariant, detail: "(i32)", documentation: Documentation( @@ -17,6 +25,14 @@ expression: kind_completions CompletionItem { label: "Foo", source_range: [116; 116), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [116; 116), + insert: "Foo" + } + ] + }, kind: EnumVariant, detail: "()", documentation: Documentation( diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap index 8f6defc4f..0d2390eb2 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.686329490Z" +created: "2019-02-18T09:10:52.039179076Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "Bar", source_range: [180; 180), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [180; 180), + insert: "Bar" + } + ] + }, kind: EnumVariant, detail: "(i32, u32)", documentation: Documentation( @@ -17,6 +25,14 @@ expression: kind_completions CompletionItem { label: "Foo", source_range: [180; 180), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [180; 180), + insert: "Foo" + } + ] + }, kind: EnumVariant, detail: "()", documentation: Documentation( @@ -26,6 +42,14 @@ expression: kind_completions CompletionItem { label: "S", source_range: [180; 180), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [180; 180), + insert: "S" + } + ] + }, kind: EnumVariant, detail: "(S)" } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap index 2a2959fd2..249b51311 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.763042807Z" +created: "2019-02-18T09:10:52.097703010Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "other_crate", source_range: [4; 4), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [4; 4), + insert: "other_crate" + } + ] + }, kind: Module } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params.snap index 5e1a876da..d73860e72 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.765665697Z" +created: "2019-02-18T09:10:52.113095718Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,14 +8,28 @@ expression: kind_completions CompletionItem { label: "T", source_range: [44; 44), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [44; 44), + insert: "T" + } + ] + }, kind: TypeParam }, CompletionItem { label: "quux", source_range: [44; 44), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [44; 44), + insert: "quux()$0" + } + ] + }, kind: Function, - detail: "fn quux()", - insert_text: "quux()$0", - insert_text_format: Snippet + detail: "fn quux()" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params_in_struct.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params_in_struct.snap index b0c9bff03..b75350f0e 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params_in_struct.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__generic_params_in_struct.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.768275744Z" +created: "2019-02-18T09:10:52.117910091Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,11 +8,27 @@ expression: kind_completions CompletionItem { label: "T", source_range: [46; 46), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [46; 46), + insert: "T" + } + ] + }, kind: TypeParam }, CompletionItem { label: "X", source_range: [46; 46), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [46; 46), + insert: "X" + } + ] + }, kind: Struct } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap index 8ef0a4b7a..9a42b6c12 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.808403924Z" +created: "2019-02-18T09:10:52.160884429Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,17 +8,29 @@ expression: kind_completions CompletionItem { label: "main", source_range: [53; 56), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [53; 56), + insert: "main()$0" + } + ] + }, kind: Function, - detail: "fn main()", - insert_text: "main()$0", - insert_text_format: Snippet + detail: "fn main()" }, CompletionItem { label: "no_args", source_range: [53; 56), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [53; 56), + insert: "no_args()$0" + } + ] + }, kind: Function, - detail: "fn no_args()", - insert_text: "no_args()$0", - insert_text_format: Snippet + detail: "fn no_args()" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls2.snap index 32730639e..5397a0bbe 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls2.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.843178843Z" +created: "2019-02-18T09:10:52.192876554Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,17 +8,29 @@ expression: kind_completions CompletionItem { label: "main", source_range: [72; 77), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 77), + insert: "main()$0" + } + ] + }, kind: Function, - detail: "fn main()", - insert_text: "main()$0", - insert_text_format: Snippet + detail: "fn main()" }, CompletionItem { label: "with_args", source_range: [72; 77), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 77), + insert: "with_args($0)" + } + ] + }, kind: Function, - detail: "fn with_args(x: i32, y: String)", - insert_text: "with_args($0)", - insert_text_format: Snippet + detail: "fn with_args(x: i32, y: String)" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls3.snap index 99f21b258..97c128dcb 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls3.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.877573951Z" +created: "2019-02-18T09:10:52.224275781Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,9 +8,15 @@ expression: kind_completions CompletionItem { label: "foo", source_range: [139; 140), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [139; 140), + insert: "foo()$0" + } + ] + }, kind: Method, - detail: "fn foo(&self)", - insert_text: "foo()$0", - insert_text_format: Snippet + detail: "fn foo(&self)" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap index 022e3f6e9..18f1aa846 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.639066512Z" +created: "2019-02-18T09:10:51.982940400Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,36 +8,66 @@ expression: kind_completions CompletionItem { label: "if", source_range: [41; 41), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [41; 41), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [41; 41), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [41; 41), - kind: Keyword, - insert_text: "return;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "return;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [41; 41), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap index fd63c1678..07e673852 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.630760038Z" +created: "2019-02-18T09:10:51.986894362Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,50 +8,92 @@ expression: kind_completions CompletionItem { label: "else", source_range: [92; 92), - kind: Keyword, - insert_text: "else {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [92; 92), + insert: "else {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "else if", source_range: [92; 92), - kind: Keyword, - insert_text: "else if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [92; 92), + insert: "else if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "if", source_range: [92; 92), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [92; 92), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [92; 92), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [92; 92), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [92; 92), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [92; 92), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [92; 92), - kind: Keyword, - insert_text: "return;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [92; 92), + insert: "return;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [92; 92), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [92; 92), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap index 90f769078..a31881175 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.659527166Z" +created: "2019-02-18T09:10:52.010821546Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,36 +8,66 @@ expression: kind_completions CompletionItem { label: "if", source_range: [48; 48), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [48; 48), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [48; 48), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [48; 48), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [48; 48), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [48; 48), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [48; 48), - kind: Keyword, - insert_text: "return $0;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [48; 48), + insert: "return $0;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [48; 48), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [48; 48), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap index 5e7ec108c..8e66260f6 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.696757543Z" +created: "2019-02-18T09:10:52.039207401Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,36 +8,66 @@ expression: kind_completions CompletionItem { label: "if", source_range: [41; 41), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [41; 41), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [41; 41), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [41; 41), - kind: Keyword, - insert_text: "return;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "return;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [41; 41), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [41; 41), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap index f969a843b..facd37bd9 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.633925638Z" +created: "2019-02-18T09:10:51.979744931Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,20 +8,40 @@ expression: kind_completions CompletionItem { label: "crate", source_range: [17; 17), - kind: Keyword, - insert_text: "crate::", - insert_text_format: PlainText + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [17; 17), + insert: "crate::" + } + ] + }, + kind: Keyword }, CompletionItem { label: "self", source_range: [17; 17), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [17; 17), + insert: "self" + } + ] + }, kind: Keyword }, CompletionItem { label: "super", source_range: [17; 17), - kind: Keyword, - insert_text: "super::", - insert_text_format: PlainText + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [17; 17), + insert: "super::" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt2.snap index bbbdeae8f..7a9792b0e 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt2.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.658885169Z" +created: "2019-02-18T09:10:52.008665355Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,13 +8,27 @@ expression: kind_completions CompletionItem { label: "self", source_range: [20; 20), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [20; 20), + insert: "self" + } + ] + }, kind: Keyword }, CompletionItem { label: "super", source_range: [20; 20), - kind: Keyword, - insert_text: "super::", - insert_text_format: PlainText + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [20; 20), + insert: "super::" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap index 84475e0d8..9f0731aa1 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.688856977Z" +created: "2019-02-18T09:10:52.032133616Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,13 +8,27 @@ expression: kind_completions CompletionItem { label: "self", source_range: [24; 24), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [24; 24), + insert: "self" + } + ] + }, kind: Keyword }, CompletionItem { label: "super", source_range: [24; 24), - kind: Keyword, - insert_text: "super::", - insert_text_format: PlainText + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [24; 24), + insert: "super::" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap index 5d12dd41b..7d90ef4f3 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.638715790Z" +created: "2019-02-18T09:10:51.985317165Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,36 +8,66 @@ expression: kind_completions CompletionItem { label: "if", source_range: [83; 83), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [83; 83), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [83; 83), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [83; 83), - kind: Keyword, - insert_text: "return $0;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "return $0;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [83; 83), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap index 5866369b6..94e3a2dcb 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.661936290Z" +created: "2019-02-18T09:10:52.013549824Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,36 +8,66 @@ expression: kind_completions CompletionItem { label: "if", source_range: [83; 83), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [83; 83), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [83; 83), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [83; 83), - kind: Keyword, - insert_text: "return $0;", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "return $0;" + } + ] + }, + kind: Keyword }, CompletionItem { label: "while", source_range: [83; 83), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [83; 83), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__method_attr_filtering.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__method_attr_filtering.snap index 4753eece7..9e4062641 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__method_attr_filtering.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__method_attr_filtering.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.598946710Z" +created: "2019-02-18T09:10:51.944926087Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,9 +8,15 @@ expression: kind_completions CompletionItem { label: "the_method", source_range: [249; 249), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [249; 249), + insert: "the_method()$0" + } + ] + }, kind: Method, - detail: "fn the_method(&self)", - insert_text: "the_method()$0", - insert_text_format: Snippet + detail: "fn the_method(&self)" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__method_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__method_completion.snap index 6cc8ab26c..f8b142b71 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__method_completion.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__method_completion.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.598948318Z" +created: "2019-02-18T09:10:51.944760801Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,9 +8,15 @@ expression: kind_completions CompletionItem { label: "the_method", source_range: [144; 144), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [144; 144), + insert: "the_method()$0" + } + ] + }, kind: Method, - detail: "fn the_method(&self)", - insert_text: "the_method()$0", - insert_text_format: Snippet + detail: "fn the_method(&self)" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__mod_with_docs.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__mod_with_docs.snap index 47579bde1..670803b6f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__mod_with_docs.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__mod_with_docs.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.682030298Z" +created: "2019-02-18T09:10:52.036530210Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "my", source_range: [23; 25), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [23; 25), + insert: "my" + } + ] + }, kind: Module, documentation: Documentation( "Some simple\ndocs describing `mod my`." diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap index 28efac43f..d082a9c2f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.770568686Z" +created: "2019-02-18T09:10:52.120932427Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,19 +8,41 @@ expression: kind_completions CompletionItem { label: "Baz", source_range: [89; 89), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [89; 89), + insert: "Baz" + } + ] + }, kind: Enum }, CompletionItem { label: "Foo", source_range: [89; 89), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [89; 89), + insert: "Foo" + } + ] + }, kind: Struct }, CompletionItem { label: "quux", source_range: [89; 89), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [89; 89), + insert: "quux()$0" + } + ] + }, kind: Function, - detail: "fn quux()", - insert_text: "quux()$0", - insert_text_format: Snippet + detail: "fn quux()" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap index 01b6b968c..daa3026fa 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.770992040Z" +created: "2019-02-18T09:10:52.120931050Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,14 +8,28 @@ expression: kind_completions CompletionItem { label: "Bar", source_range: [101; 101), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [101; 101), + insert: "Bar" + } + ] + }, kind: Struct }, CompletionItem { label: "quux", source_range: [101; 101), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [101; 101), + insert: "quux()$0" + } + ] + }, kind: Function, - detail: "fn quux()", - insert_text: "quux()$0", - insert_text_format: Snippet + detail: "fn quux()" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__nested_use_tree.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__nested_use_tree.snap index e95763580..0536d2cd5 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__nested_use_tree.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__nested_use_tree.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.689653720Z" +created: "2019-02-18T09:10:52.039178133Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,11 +8,27 @@ expression: kind_completions CompletionItem { label: "Spam", source_range: [12; 14), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [12; 14), + insert: "Spam" + } + ] + }, kind: Struct }, CompletionItem { label: "foo", source_range: [12; 14), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [12; 14), + insert: "foo" + } + ] + }, kind: Module } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap index 1295355a2..42f736d74 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.641375216Z" +created: "2019-02-18T09:10:51.988658363Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,44 +8,92 @@ expression: kind_completions CompletionItem { label: "break", source_range: [106; 108), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [106; 108), + insert: "break" + } + ] + }, kind: Keyword }, CompletionItem { label: "continue", source_range: [106; 108), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [106; 108), + insert: "continue" + } + ] + }, kind: Keyword }, CompletionItem { label: "if", source_range: [106; 108), - kind: Keyword, - insert_text: "if $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [106; 108), + insert: "if $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "loop", source_range: [106; 108), - kind: Keyword, - insert_text: "loop {$0}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [106; 108), + insert: "loop {$0}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "match", source_range: [106; 108), - kind: Keyword, - insert_text: "match $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [106; 108), + insert: "match $0 {}" + } + ] + }, + kind: Keyword }, CompletionItem { label: "return", source_range: [106; 108), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [106; 108), + insert: "return" + } + ] + }, kind: Keyword }, CompletionItem { label: "while", source_range: [106; 108), - kind: Keyword, - insert_text: "while $0 {}", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [106; 108), + insert: "while $0 {}" + } + ] + }, + kind: Keyword } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap index dba925f7c..0c651f26e 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.606265507Z" +created: "2019-02-18T09:10:51.951199574Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "file_id: FileId", source_range: [98; 102), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [98; 102), + insert: "file_id: FileId" + } + ] + }, lookup: "file_id" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap index c5873becb..1064e28c5 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.606265538Z" +created: "2019-02-18T09:10:51.951199556Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "file_id: FileId", source_range: [98; 102), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [98; 102), + insert: "file_id: FileId" + } + ] + }, lookup: "file_id" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap index 5231db54c..548c0c9ce 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.628419014Z" +created: "2019-02-18T09:10:51.973234775Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "file_id: FileId", source_range: [269; 273), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [269; 273), + insert: "file_id: FileId" + } + ] + }, lookup: "file_id" } ] 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 bd22d546a..fcca19b77 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,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.734401559Z" +created: "2019-02-18T09:10:52.087222569Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,106 +8,92 @@ expression: kind_completions CompletionItem { label: "dbg", source_range: [76; 76), - detail: "dbg!(expr)", - insert_text: "dbg!(bar)", - insert_text_format: Snippet, text_edit: TextEdit { atoms: [ AtomTextEdit { delete: [72; 76), - insert: "" + insert: "dbg!(bar)" } ] - } + }, + detail: "dbg!(expr)" }, CompletionItem { label: "if", source_range: [76; 76), - detail: "if expr {}", - insert_text: "if bar {$0}", - insert_text_format: Snippet, text_edit: TextEdit { atoms: [ AtomTextEdit { delete: [72; 76), - insert: "" + insert: "if bar {$0}" } ] - } + }, + detail: "if expr {}" }, CompletionItem { label: "match", source_range: [76; 76), - detail: "match expr {}", - insert_text: "match bar {\n${1:_} => {$0\\},\n}", - insert_text_format: Snippet, text_edit: TextEdit { atoms: [ AtomTextEdit { delete: [72; 76), - insert: "" + insert: "match bar {\n${1:_} => {$0\\},\n}" } ] - } + }, + detail: "match expr {}" }, CompletionItem { label: "not", source_range: [76; 76), - detail: "!expr", - insert_text: "!bar", - insert_text_format: Snippet, text_edit: TextEdit { atoms: [ AtomTextEdit { delete: [72; 76), - insert: "" + insert: "!bar" } ] - } + }, + detail: "!expr" }, CompletionItem { label: "ref", source_range: [76; 76), - detail: "&expr", - insert_text: "&bar", - insert_text_format: Snippet, text_edit: TextEdit { atoms: [ AtomTextEdit { delete: [72; 76), - insert: "" + insert: "&bar" } ] - } + }, + detail: "&expr" }, CompletionItem { label: "refm", source_range: [76; 76), - detail: "&mut expr", - insert_text: "&mut bar", - insert_text_format: Snippet, text_edit: TextEdit { atoms: [ AtomTextEdit { delete: [72; 76), - insert: "" + insert: "&mut bar" } ] - } + }, + detail: "&mut expr" }, CompletionItem { label: "while", source_range: [76; 76), - detail: "while expr {}", - insert_text: "while bar {\n$0\n}", - insert_text_format: Snippet, text_edit: TextEdit { atoms: [ AtomTextEdit { delete: [72; 76), - insert: "" + insert: "while bar {\n$0\n}" } ] - } + }, + detail: "while expr {}" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap index 25c5007e4..954d1b4bc 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.780512486Z" +created: "2019-02-18T09:10:52.125606324Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,14 +8,28 @@ expression: kind_completions CompletionItem { label: "Foo", source_range: [47; 47), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [47; 47), + insert: "Foo" + } + ] + }, kind: Struct }, CompletionItem { label: "x", source_range: [47; 47), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [47; 47), + insert: "x()$0" + } + ] + }, kind: Function, - detail: "fn x() ->", - insert_text: "x()$0", - insert_text_format: Snippet + detail: "fn x() ->" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap index d390be2dc..3a88b7fbc 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.774705610Z" +created: "2019-02-18T09:10:52.129525933Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,11 +8,27 @@ expression: kind_completions CompletionItem { label: "Self", source_range: [25; 25), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [25; 25), + insert: "Self" + } + ] + }, kind: TypeParam }, CompletionItem { label: "self", source_range: [25; 25), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [25; 25), + insert: "self" + } + ] + }, kind: Binding } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap index 6ad919849..9bd6fe91d 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.799497268Z" +created: "2019-02-18T09:10:52.156085697Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,15 +8,27 @@ expression: kind_completions CompletionItem { label: "pd", source_range: [17; 17), - kind: Snippet, - insert_text: "eprintln!(\"$0 = {:?}\", $0);", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [17; 17), + insert: "eprintln!(\"$0 = {:?}\", $0);" + } + ] + }, + kind: Snippet }, CompletionItem { label: "ppd", source_range: [17; 17), - kind: Snippet, - insert_text: "eprintln!(\"$0 = {:#?}\", $0);", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [17; 17), + insert: "eprintln!(\"$0 = {:#?}\", $0);" + } + ] + }, + kind: Snippet } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap index 43367010b..486b353ef 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.800831987Z" +created: "2019-02-18T09:10:52.152402422Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,16 +8,28 @@ expression: kind_completions CompletionItem { label: "Test function", source_range: [66; 66), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [66; 66), + insert: "#[test]\nfn ${1:feature}() {\n $0\n}" + } + ] + }, kind: Snippet, - lookup: "tfn", - insert_text: "#[test]\nfn ${1:feature}() {\n $0\n}", - insert_text_format: Snippet + lookup: "tfn" }, CompletionItem { label: "pub(crate)", source_range: [66; 66), - kind: Snippet, - insert_text: "pub(crate) $0", - insert_text_format: Snippet + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [66; 66), + insert: "pub(crate) $0" + } + ] + }, + kind: Snippet } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_const.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_const.snap index c78b06d3c..b34f6f26f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_const.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_const.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.704544613Z" +created: "2019-02-18T09:10:52.050659483Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "C", source_range: [107; 107), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [107; 107), + insert: "C" + } + ] + }, kind: Const, detail: "const C: i32 = 42;", documentation: Documentation( diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_method.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_method.snap index 67638b4d1..f6c95074a 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_method.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_method.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.704544615Z" +created: "2019-02-18T09:10:52.050659480Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,12 +8,18 @@ expression: kind_completions CompletionItem { label: "m", source_range: [100; 100), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [100; 100), + insert: "m()$0" + } + ] + }, kind: Method, detail: "fn m()", documentation: Documentation( "An associated method" - ), - insert_text: "m()$0", - insert_text_format: Snippet + ) } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_type.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_type.snap index c5f5b9f10..79168702c 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_type.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_associated_type.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.725668999Z" +created: "2019-02-18T09:10:52.066746177Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "T", source_range: [101; 101), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [101; 101), + insert: "T" + } + ] + }, kind: TypeAlias, detail: "type T = i32;", documentation: Documentation( diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion.snap index ffad98f7d..f22bbd987 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.599230647Z" +created: "2019-02-18T09:10:51.944776686Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "the_field", source_range: [85; 85), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [85; 85), + insert: "the_field" + } + ] + }, kind: Field, detail: "u32" } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap index 99aef933a..8b53d5e95 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.598966298Z" +created: "2019-02-18T09:10:51.944780241Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,14 +8,28 @@ expression: kind_completions CompletionItem { label: "foo", source_range: [126; 126), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [126; 126), + insert: "foo()$0" + } + ] + }, kind: Method, - detail: "fn foo(&self)", - insert_text: "foo()$0", - insert_text_format: Snippet + detail: "fn foo(&self)" }, CompletionItem { label: "the_field", source_range: [126; 126), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [126; 126), + insert: "the_field" + } + ] + }, kind: Field, detail: "(u32, i32)" } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap index 52991b9fb..f20e4dcab 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.598965593Z" +created: "2019-02-18T09:10:51.944941588Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,14 +8,28 @@ expression: kind_completions CompletionItem { label: "foo", source_range: [187; 187), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [187; 187), + insert: "foo()$0" + } + ] + }, kind: Method, - detail: "fn foo(self)", - insert_text: "foo()$0", - insert_text_format: Snippet + detail: "fn foo(self)" }, CompletionItem { label: "the_field", source_range: [187; 187), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [187; 187), + insert: "the_field" + } + ] + }, kind: Field, detail: "(u32,)", documentation: Documentation( diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap index 5b6ed9d77..b1ebac40b 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.598973382Z" +created: "2019-02-18T09:10:51.944941196Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,12 +8,28 @@ expression: kind_completions CompletionItem { label: "0", source_range: [75; 75), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [75; 75), + insert: "0" + } + ] + }, kind: Field, detail: "i32" }, CompletionItem { label: "1", source_range: [75; 75), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [75; 75), + insert: "1" + } + ] + }, kind: Field, detail: "f64" } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_crate.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_crate.snap index 3c670ad5b..30a67db61 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_crate.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_crate.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.726365989Z" +created: "2019-02-18T09:10:52.063155992Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,11 +8,27 @@ expression: kind_completions CompletionItem { label: "Spam", source_range: [11; 13), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [11; 13), + insert: "Spam" + } + ] + }, kind: Struct }, CompletionItem { label: "foo", source_range: [11; 13), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [11; 13), + insert: "foo" + } + ] + }, kind: Module } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_self.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_self.snap index bf314de84..a8257ef12 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_self.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_self.snap @@ -1,5 +1,5 @@ --- -created: "2019-02-18T07:29:59.731789946Z" +created: "2019-02-18T09:10:52.075119580Z" creator: insta@0.6.2 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions @@ -8,6 +8,14 @@ expression: kind_completions CompletionItem { label: "Bar", source_range: [26; 26), + text_edit: TextEdit { + atoms: [ + AtomTextEdit { + delete: [26; 26), + insert: "Bar" + } + ] + }, kind: Struct } ] diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index c3192a1e5..f0f67b663 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -79,11 +79,31 @@ impl ConvWith for CompletionItem { type Ctx = LineIndex; type Output = ::lsp_types::CompletionItem; - fn conv_with(mut self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { - let atom_text_edit = AtomTextEdit::replace(self.source_range(), self.insert_text()); - let text_edit = (&atom_text_edit).conv_with(ctx); - let additional_text_edits = - if let Some(edit) = self.take_text_edit() { Some(edit.conv_with(ctx)) } else { None }; + fn conv_with(self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { + let mut additional_text_edits = Vec::new(); + let mut text_edit = None; + // LSP does not allow arbitrary edits in completion, so we have to do a + // non-trivial mapping here. + for atom_edit in self.text_edit().as_atoms() { + if self.source_range().is_subrange(&atom_edit.delete) { + text_edit = Some(if atom_edit.delete == self.source_range() { + atom_edit.conv_with(ctx) + } else { + assert!(self.source_range().end() == atom_edit.delete.end()); + let range1 = + TextRange::from_to(atom_edit.delete.start(), self.source_range().start()); + let range2 = self.source_range(); + let edit1 = AtomTextEdit::replace(range1, String::new()); + let edit2 = AtomTextEdit::replace(range2, atom_edit.insert.clone()); + additional_text_edits.push(edit1.conv_with(ctx)); + edit2.conv_with(ctx) + }) + } else { + assert!(self.source_range().intersection(&atom_edit.delete).is_none()); + additional_text_edits.push(atom_edit.conv_with(ctx)); + } + } + let text_edit = text_edit.unwrap(); let mut res = lsp_types::CompletionItem { label: self.label().to_string(), @@ -91,7 +111,7 @@ impl ConvWith for CompletionItem { filter_text: Some(self.lookup().to_string()), kind: self.kind().map(|it| it.conv()), text_edit: Some(text_edit), - additional_text_edits, + additional_text_edits: Some(additional_text_edits), documentation: self.documentation().map(|it| it.conv()), ..Default::default() }; -- cgit v1.2.3