From d08e81cdd818dd3378c292767e15a38e6bbc6f6c Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sat, 19 Jan 2019 22:02:50 +0800 Subject: [PATCH 1/6] refactor completions to use TextEdit instead of InsertText --- crates/ra_ide_api/src/completion.rs | 14 +- .../ra_ide_api/src/completion/complete_dot.rs | 27 +-- .../src/completion/complete_fn_param.rs | 13 +- .../src/completion/complete_keyword.rs | 164 ++++---------- .../src/completion/complete_path.rs | 21 +- .../src/completion/complete_scope.rs | 46 ++-- .../src/completion/complete_snippet.rs | 37 ++- .../src/completion/completion_context.rs | 6 +- .../src/completion/completion_item.rs | 210 ++++++++++-------- .../completion_item__bindings_from_for.snap | 35 +++ ...completion_item__bindings_from_if_let.snap | 47 ++++ .../completion_item__bindings_from_let.snap | 47 ++++ ...ompletes_break_and_continue_in_loops1.snap | 125 +++++++++++ ...ompletes_break_and_continue_in_loops2.snap | 91 ++++++++ .../completion_item__completion_postfix.snap | 102 +++++++++ ...mpletion_item__deeply_nested_use_tree.snap | 18 ++ ..._semi_after_return_if_not_a_statement.snap | 91 ++++++++ ...ender_function_parens_if_already_call.snap | 30 +++ ...nt_render_function_parens_in_use_item.snap | 18 ++ ...t_show_both_completions_for_shadowing.snap | 35 +++ ...m__inserts_parens_for_function_calls1.snap | 40 ++++ ...m__inserts_parens_for_function_calls2.snap | 40 ++++ ...ompletion_item__keywords_in_function1.snap | 91 ++++++++ ...ompletion_item__keywords_in_function2.snap | 125 +++++++++++ ...ompletion_item__keywords_in_function3.snap | 91 ++++++++ ...ompletion_item__keywords_in_function4.snap | 91 ++++++++ ...ompletion_item__keywords_in_use_stmt1.snap | 52 +++++ ...ompletion_item__keywords_in_use_stmt2.snap | 35 +++ ...ompletion_item__keywords_in_use_stmt3.snap | 35 +++ ..._item__last_return_in_block_has_semi1.snap | 91 ++++++++ ..._item__last_return_in_block_has_semi2.snap | 91 ++++++++ .../completion_item__method_completion.snap | 23 ++ .../completion_item__module_items.snap | 47 ++++ ..._item__module_items_in_nested_modules.snap | 35 +++ .../completion_item__nested_use_tree.snap | 30 +++ .../completion_item__no_non_self_method.snap | 5 + ..._no_semi_after_break_continue_in_expr.snap | 125 +++++++++++ ...ruct_field_completion_for_method_call.snap | 5 + ...ion_item__param_completion_last_param.snap | 18 ++ ...tion_item__param_completion_nth_param.snap | 18 ++ ...on_item__param_completion_trait_param.snap | 18 ++ ...completion_item__reference_completion.snap | 30 +++ .../completion_item__return_type.snap | 35 +++ .../completion_item__self_in_methods.snap | 18 ++ ...pletion_item__snippets_in_expressions.snap | 40 ++++ .../completion_item__snippets_in_items.snap | 42 ++++ ...pletion_item__struct_field_completion.snap | 20 ++ ...em__struct_field_completion_autoderef.snap | 37 +++ ...on_item__struct_field_completion_self.snap | 37 +++ ...on_item__use_item_starting_with_crate.snap | 30 +++ ...ion_item__use_item_starting_with_self.snap | 18 ++ crates/ra_ide_api/src/lib.rs | 2 +- crates/ra_lsp_server/src/conv.rs | 35 +-- .../ra_lsp_server/src/main_loop/handlers.rs | 6 +- 54 files changed, 2320 insertions(+), 313 deletions(-) create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__completion_postfix.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__deeply_nested_use_tree.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_in_use_item.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls2.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt2.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__method_completion.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__nested_use_tree.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__no_non_self_method.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__no_struct_field_completion_for_method_call.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_crate.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_self.snap diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index b03ddd74c0..855f5d9640 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs @@ -19,7 +19,7 @@ use crate::{ }, }; -pub use crate::completion::completion_item::{CompletionItem, InsertText, CompletionItemKind}; +pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind, InsertTextFormat}; /// Main entry point for completion. We run completion as a two-phase process. /// @@ -60,15 +60,3 @@ pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Opti Some(acc) } - -#[cfg(test)] -fn check_completion(code: &str, expected_completions: &str, kind: CompletionKind) { - use crate::mock_analysis::{single_file_with_position, analysis_and_position}; - let (analysis, position) = if code.contains("//-") { - analysis_and_position(code) - } else { - single_file_with_position(code) - }; - let completions = completions(&analysis.db, position).unwrap(); - completions.assert_match(expected_completions, kind); -} diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 473edc50ea..aaf739500a 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -1,6 +1,7 @@ use hir::{Ty, Def}; -use crate::completion::{CompletionContext, Completions, CompletionKind, CompletionItem, CompletionItemKind}; +use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; +use crate::completion::completion_item::CompletionKind; /// Complete dot accesses, i.e. fields or methods (currently only fields). pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { @@ -30,6 +31,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) for field in s.fields(ctx.db) { CompletionItem::new( CompletionKind::Reference, + ctx, field.name().to_string(), ) .kind(CompletionItemKind::Field) @@ -43,7 +45,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) } Ty::Tuple(fields) => { for (i, _ty) in fields.iter().enumerate() { - CompletionItem::new(CompletionKind::Reference, i.to_string()) + CompletionItem::new(CompletionKind::Reference, ctx, i.to_string()) .kind(CompletionItemKind::Field) .add_to(acc); } @@ -57,7 +59,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty receiver.iterate_methods(ctx.db, |func| { let sig = func.signature(ctx.db); if sig.has_self_param() { - CompletionItem::new(CompletionKind::Reference, sig.name().to_string()) + CompletionItem::new(CompletionKind::Reference, ctx, sig.name().to_string()) .from_function(ctx, func) .kind(CompletionItemKind::Method) .add_to(acc); @@ -69,27 +71,29 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty #[cfg(test)] mod tests { use crate::completion::*; + use crate::completion::completion_item::check_completion; - fn check_ref_completion(code: &str, expected_completions: &str) { - check_completion(code, expected_completions, CompletionKind::Reference); + fn check_ref_completion(name: &str, code: &str) { + check_completion(name, code, CompletionKind::Reference); } #[test] fn test_struct_field_completion() { check_ref_completion( + "struct_field_completion", r" struct A { the_field: u32 } fn foo(a: A) { a.<|> } ", - r#"the_field "u32""#, ); } #[test] fn test_struct_field_completion_self() { check_ref_completion( + "struct_field_completion_self", r" struct A { the_field: (u32,) } impl A { @@ -98,14 +102,13 @@ mod tests { } } ", - r#"the_field "(u32,)" - foo "foo($0)""#, ); } #[test] fn test_struct_field_completion_autoderef() { check_ref_completion( + "struct_field_completion_autoderef", r" struct A { the_field: (u32, i32) } impl A { @@ -114,27 +117,26 @@ mod tests { } } ", - r#"the_field "(u32, i32)" - foo "foo($0)""#, ); } #[test] fn test_no_struct_field_completion_for_method_call() { check_ref_completion( + "no_struct_field_completion_for_method_call", r" struct A { the_field: u32 } fn foo(a: A) { a.<|>() } ", - r#""#, ); } #[test] fn test_method_completion() { check_ref_completion( + "method_completion", r" struct A {} impl A { @@ -144,13 +146,13 @@ mod tests { a.<|> } ", - r#"the_method "the_method($0)""#, ); } #[test] fn test_no_non_self_method() { check_ref_completion( + "no_non_self_method", r" struct A {} impl A { @@ -160,7 +162,6 @@ mod tests { a.<|> } ", - r#""#, ); } } diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs index c1739e47ea..e3d1470c2b 100644 --- a/crates/ra_ide_api/src/completion/complete_fn_param.rs +++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs @@ -34,7 +34,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) } }) .for_each(|(label, lookup)| { - CompletionItem::new(CompletionKind::Magic, label) + CompletionItem::new(CompletionKind::Magic, ctx, label) .lookup_by(lookup) .add_to(acc) }); @@ -56,38 +56,40 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) #[cfg(test)] mod tests { use crate::completion::*; + use crate::completion::completion_item::check_completion; - fn check_magic_completion(code: &str, expected_completions: &str) { - check_completion(code, expected_completions, CompletionKind::Magic); + fn check_magic_completion(name: &str, code: &str) { + check_completion(name, code, CompletionKind::Magic); } #[test] fn test_param_completion_last_param() { check_magic_completion( + "param_completion_last_param", r" fn foo(file_id: FileId) {} fn bar(file_id: FileId) {} fn baz(file<|>) {} ", - r#"file_id "file_id: FileId""#, ); } #[test] fn test_param_completion_nth_param() { check_magic_completion( + "param_completion_nth_param", r" fn foo(file_id: FileId) {} fn bar(file_id: FileId) {} fn baz(file<|>, x: i32) {} ", - r#"file_id "file_id: FileId""#, ); } #[test] fn test_param_completion_trait_param() { check_magic_completion( + "param_completion_trait_param", r" pub(crate) trait SourceRoot { pub fn contains(&self, file_id: FileId) -> bool; @@ -96,7 +98,6 @@ mod tests { pub fn syntax(&self, file<|>) } ", - r#"file_id "file_id: FileId""#, ); } } diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs index d350f06ceb..3fbf363131 100644 --- a/crates/ra_ide_api/src/completion/complete_keyword.rs +++ b/crates/ra_ide_api/src/completion/complete_keyword.rs @@ -11,36 +11,33 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC // complete keyword "crate" in use stmt match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) { (Some(_), None) => { - CompletionItem::new(CompletionKind::Keyword, "crate") + CompletionItem::new(CompletionKind::Keyword, ctx, "crate") .kind(CompletionItemKind::Keyword) - .lookup_by("crate") - .snippet("crate::") + .insert_text("crate::") .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, "self") + CompletionItem::new(CompletionKind::Keyword, ctx, "self") .kind(CompletionItemKind::Keyword) - .lookup_by("self") .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, "super") + CompletionItem::new(CompletionKind::Keyword, ctx, "super") .kind(CompletionItemKind::Keyword) - .lookup_by("super") + .insert_text("super::") .add_to(acc); } (Some(_), Some(_)) => { - CompletionItem::new(CompletionKind::Keyword, "self") + CompletionItem::new(CompletionKind::Keyword, ctx, "self") .kind(CompletionItemKind::Keyword) - .lookup_by("self") .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, "super") + CompletionItem::new(CompletionKind::Keyword, ctx, "super") .kind(CompletionItemKind::Keyword) - .lookup_by("super") + .insert_text("super::") .add_to(acc); } _ => {} } } -fn keyword(kw: &str, snippet: &str) -> CompletionItem { - CompletionItem::new(CompletionKind::Keyword, kw) +fn keyword(ctx: &CompletionContext, kw: &str, snippet: &str) -> CompletionItem { + CompletionItem::new(CompletionKind::Keyword, ctx, kw) .kind(CompletionItemKind::Keyword) .snippet(snippet) .build() @@ -55,25 +52,25 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte Some(it) => it, None => return, }; - acc.add(keyword("if", "if $0 {}")); - acc.add(keyword("match", "match $0 {}")); - acc.add(keyword("while", "while $0 {}")); - acc.add(keyword("loop", "loop {$0}")); + acc.add(keyword(ctx, "if", "if $0 {}")); + acc.add(keyword(ctx, "match", "match $0 {}")); + acc.add(keyword(ctx, "while", "while $0 {}")); + acc.add(keyword(ctx, "loop", "loop {$0}")); if ctx.after_if { - acc.add(keyword("else", "else {$0}")); - acc.add(keyword("else if", "else if $0 {}")); + acc.add(keyword(ctx, "else", "else {$0}")); + acc.add(keyword(ctx, "else if", "else if $0 {}")); } if is_in_loop_body(ctx.leaf) { if ctx.can_be_stmt { - acc.add(keyword("continue", "continue;")); - acc.add(keyword("break", "break;")); + acc.add(keyword(ctx, "continue", "continue;")); + acc.add(keyword(ctx, "break", "break;")); } else { - acc.add(keyword("continue", "continue")); - acc.add(keyword("break", "break")); + acc.add(keyword(ctx, "continue", "continue")); + acc.add(keyword(ctx, "break", "break")); } } - acc.add_all(complete_return(fn_def, ctx.can_be_stmt)); + acc.add_all(complete_return(ctx, fn_def, ctx.can_be_stmt)); } fn is_in_loop_body(leaf: &SyntaxNode) -> bool { @@ -95,78 +92,69 @@ fn is_in_loop_body(leaf: &SyntaxNode) -> bool { false } -fn complete_return(fn_def: &ast::FnDef, can_be_stmt: bool) -> Option { +fn complete_return( + ctx: &CompletionContext, + fn_def: &ast::FnDef, + can_be_stmt: bool, +) -> Option { let snip = match (can_be_stmt, fn_def.ret_type().is_some()) { (true, true) => "return $0;", (true, false) => "return;", (false, true) => "return $0", (false, false) => "return", }; - Some(keyword("return", snip)) + Some(keyword(ctx, "return", snip)) } #[cfg(test)] mod tests { - use crate::completion::{CompletionKind, check_completion}; - fn check_keyword_completion(code: &str, expected_completions: &str) { - check_completion(code, expected_completions, CompletionKind::Keyword); + use crate::completion::CompletionKind; + use crate::completion::completion_item::check_completion; + + fn check_keyword_completion(name: &str, code: &str) { + check_completion(name, code, CompletionKind::Keyword); } #[test] fn completes_keywords_in_use_stmt() { check_keyword_completion( + "keywords_in_use_stmt1", r" use <|> ", - r#" - crate "crate" "crate::" - self "self" - super "super" - "#, ); check_keyword_completion( + "keywords_in_use_stmt2", r" use a::<|> ", - r#" - self "self" - super "super" - "#, ); check_keyword_completion( + "keywords_in_use_stmt3", r" use a::{b, <|>} ", - r#" - self "self" - super "super" - "#, ); } #[test] fn completes_various_keywords_in_function() { check_keyword_completion( + "keywords_in_function1", r" fn quux() { <|> } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - return "return;" - "#, ); } #[test] fn completes_else_after_if() { check_keyword_completion( + "keywords_in_function2", r" fn quux() { if true { @@ -174,55 +162,35 @@ mod tests { } <|> } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - else "else {$0}" - else if "else if $0 {}" - return "return;" - "#, ); } #[test] fn test_completion_return_value() { check_keyword_completion( + "keywords_in_function3", r" fn quux() -> i32 { <|> 92 } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - return "return $0;" - "#, ); check_keyword_completion( + "keywords_in_function4", r" fn quux() { <|> 92 } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - return "return;" - "#, ); } #[test] fn dont_add_semi_after_return_if_not_a_statement() { check_keyword_completion( + "dont_add_semi_after_return_if_not_a_statement", r" fn quux() -> i32 { match () { @@ -230,19 +198,13 @@ mod tests { } } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - return "return $0" - "#, ); } #[test] fn last_return_in_block_has_semi() { check_keyword_completion( + "last_return_in_block_has_semi1", r" fn quux() -> i32 { if condition { @@ -250,15 +212,9 @@ mod tests { } } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - return "return $0;" - "#, ); check_keyword_completion( + "last_return_in_block_has_semi2", r" fn quux() -> i32 { if condition { @@ -268,54 +224,35 @@ mod tests { x } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - return "return $0;" - "#, ); } #[test] fn completes_break_and_continue_in_loops() { check_keyword_completion( + "completes_break_and_continue_in_loops1", r" fn quux() -> i32 { loop { <|> } } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - continue "continue;" - break "break;" - return "return $0;" - "#, ); + // No completion: lambda isolates control flow check_keyword_completion( + "completes_break_and_continue_in_loops2", r" fn quux() -> i32 { loop { || { <|> } } } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - return "return $0;" - "#, ); } #[test] fn no_semi_after_break_continue_in_expr() { check_keyword_completion( + "no_semi_after_break_continue_in_expr", r" fn f() { loop { @@ -325,15 +262,6 @@ mod tests { } } ", - r#" - if "if $0 {}" - match "match $0 {}" - while "while $0 {}" - loop "loop {$0}" - continue "continue" - break "break" - return "return" - "#, ) } } diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 1eded7658e..7413c71e80 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -15,7 +15,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { hir::Def::Module(module) => { let module_scope = module.scope(ctx.db); for (name, res) in module_scope.entries() { - CompletionItem::new(CompletionKind::Reference, name.to_string()) + CompletionItem::new(CompletionKind::Reference, ctx, name.to_string()) .from_resolution(ctx, res) .add_to(acc); } @@ -24,7 +24,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { e.variants(ctx.db) .into_iter() .for_each(|(variant_name, _variant)| { - CompletionItem::new(CompletionKind::Reference, variant_name.to_string()) + CompletionItem::new(CompletionKind::Reference, ctx, variant_name.to_string()) .kind(CompletionItemKind::EnumVariant) .add_to(acc) }); @@ -35,7 +35,8 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { #[cfg(test)] mod tests { - use crate::completion::{CompletionKind, check_completion}; + use crate::completion::CompletionKind; + use crate::completion::completion_item::check_completion; fn check_reference_completion(code: &str, expected_completions: &str) { check_completion(code, expected_completions, CompletionKind::Reference); @@ -44,6 +45,7 @@ mod tests { #[test] fn completes_use_item_starting_with_self() { check_reference_completion( + "use_item_starting_with_self", r" use self::m::<|>; @@ -51,13 +53,13 @@ mod tests { struct Bar; } ", - "Bar", ); } #[test] fn completes_use_item_starting_with_crate() { check_reference_completion( + "use_item_starting_with_crate", " //- /lib.rs mod foo; @@ -65,13 +67,13 @@ mod tests { //- /foo.rs use crate::Sp<|> ", - "Spam;foo", ); } #[test] fn completes_nested_use_tree() { check_reference_completion( + "nested_use_tree", " //- /lib.rs mod foo; @@ -79,13 +81,13 @@ mod tests { //- /foo.rs use crate::{Sp<|>}; ", - "Spam;foo", ); } #[test] fn completes_deeply_nested_use_tree() { check_reference_completion( + "deeply_nested_use_tree", " //- /lib.rs mod foo; @@ -97,37 +99,37 @@ mod tests { //- /foo.rs use crate::{bar::{baz::Sp<|>}}; ", - "Spam", ); } #[test] fn completes_enum_variant() { check_reference_completion( + "reference_completion", " //- /lib.rs enum E { Foo, Bar(i32) } fn foo() { let _ = E::<|> } ", - "Foo;Bar", ); } #[test] fn dont_render_function_parens_in_use_item() { check_reference_completion( + "dont_render_function_parens_in_use_item", " //- /lib.rs mod m { pub fn foo() {} } use crate::m::f<|>; ", - "foo", ) } #[test] fn dont_render_function_parens_if_already_call() { check_reference_completion( + "dont_render_function_parens_if_already_call", " //- /lib.rs fn frobnicate() {} @@ -135,7 +137,6 @@ mod tests { frob<|>(); } ", - "main;frobnicate", ) } } diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 4276e47e89..bb080a341f 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -1,6 +1,5 @@ use rustc_hash::FxHashSet; -use ra_syntax::{AstNode, TextUnit}; - +use ra_syntax::ast::AstNode; use crate::completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}; pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { @@ -13,7 +12,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { }; if let Some(function) = &ctx.function { let scopes = function.scopes(ctx.db); - complete_fn(acc, &scopes, ctx.offset); + complete_fn(acc, &scopes, ctx); } let module_scope = module.scope(ctx.db); @@ -30,20 +29,24 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { } }) .for_each(|(name, res)| { - CompletionItem::new(CompletionKind::Reference, name.to_string()) + CompletionItem::new(CompletionKind::Reference, ctx, name.to_string()) .from_resolution(ctx, res) .add_to(acc) }); } -fn complete_fn(acc: &mut Completions, scopes: &hir::ScopesWithSyntaxMapping, offset: TextUnit) { +fn complete_fn( + acc: &mut Completions, + scopes: &hir::ScopesWithSyntaxMapping, + ctx: &CompletionContext, +) { let mut shadowed = FxHashSet::default(); scopes - .scope_chain_for_offset(offset) + .scope_chain_for_offset(ctx.offset) .flat_map(|scope| scopes.scopes.entries(scope).iter()) .filter(|entry| shadowed.insert(entry.name())) .for_each(|entry| { - CompletionItem::new(CompletionKind::Reference, entry.name().to_string()) + CompletionItem::new(CompletionKind::Reference, ctx, entry.name().to_string()) .kind(CompletionItemKind::Binding) .add_to(acc) }); @@ -51,15 +54,17 @@ fn complete_fn(acc: &mut Completions, scopes: &hir::ScopesWithSyntaxMapping, off #[cfg(test)] mod tests { - use crate::completion::{CompletionKind, check_completion}; + use crate::completion::CompletionKind; + use crate::completion::completion_item::check_completion; - fn check_reference_completion(code: &str, expected_completions: &str) { - check_completion(code, expected_completions, CompletionKind::Reference); + fn check_reference_completion(name: &str, code: &str) { + check_completion(name, code, CompletionKind::Reference); } #[test] fn completes_bindings_from_let() { check_reference_completion( + "bindings_from_let", r" fn quux(x: i32) { let y = 92; @@ -67,13 +72,13 @@ mod tests { let z = (); } ", - r#"y;x;quux "quux($0)""#, ); } #[test] fn completes_bindings_from_if_let() { check_reference_completion( + "bindings_from_if_let", r" fn quux() { if let Some(x) = foo() { @@ -85,13 +90,13 @@ mod tests { } } ", - r#"b;a;quux "quux()$0""#, ); } #[test] fn completes_bindings_from_for() { check_reference_completion( + "bindings_from_for", r" fn quux() { for x in &[1, 2, 3] { @@ -99,13 +104,13 @@ mod tests { } } ", - r#"x;quux "quux()$0""#, ); } #[test] fn completes_module_items() { check_reference_completion( + "module_items", r" struct Foo; enum Baz {} @@ -113,13 +118,13 @@ mod tests { <|> } ", - r#"quux "quux()$0";Foo;Baz"#, ); } #[test] fn completes_module_items_in_nested_modules() { check_reference_completion( + "module_items_in_nested_modules", r" struct Foo; mod m { @@ -127,24 +132,24 @@ mod tests { fn quux() { <|> } } ", - r#"quux "quux()$0";Bar"#, ); } #[test] fn completes_return_type() { check_reference_completion( + "return_type", r" struct Foo; fn x() -> <|> ", - r#"Foo;x "x()$0""#, ) } #[test] fn dont_show_both_completions_for_shadowing() { check_reference_completion( + "dont_show_both_completions_for_shadowing", r" fn foo() -> { let bar = 92; @@ -154,32 +159,29 @@ mod tests { } } ", - r#"bar;foo "foo()$0""#, ) } #[test] fn completes_self_in_methods() { - check_reference_completion(r"impl S { fn foo(&self) { <|> } }", "self") + check_reference_completion("self_in_methods", r"impl S { fn foo(&self) { <|> } }") } #[test] fn inserts_parens_for_function_calls() { check_reference_completion( + "inserts_parens_for_function_calls1", r" fn no_args() {} fn main() { no_<|> } ", - r#"no_args "no_args()$0" - main "main()$0""#, ); check_reference_completion( + "inserts_parens_for_function_calls2", r" fn with_args(x: i32, y: String) {} fn main() { with_<|> } ", - r#"main "main()$0" - with_args "with_args($0)""#, ); } } diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index a495751dda..fb94e3674a 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs @@ -1,7 +1,7 @@ use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; -fn snippet(label: &str, snippet: &str) -> Builder { - CompletionItem::new(CompletionKind::Snippet, label) +fn snippet<'a>(ctx: &'a CompletionContext<'a>, label: &str, snippet: &str) -> Builder<'a> { + CompletionItem::new(CompletionKind::Snippet, ctx, label) .snippet(snippet) .kind(CompletionItemKind::Snippet) } @@ -10,8 +10,8 @@ pub(super) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte if !(ctx.is_trivial_path && ctx.function_syntax.is_some()) { return; } - snippet("pd", "eprintln!(\"$0 = {:?}\", $0);").add_to(acc); - snippet("ppd", "eprintln!(\"$0 = {:#?}\", $0);").add_to(acc); + snippet(ctx, "pd", "eprintln!(\"$0 = {:?}\", $0);").add_to(acc); + snippet(ctx, "ppd", "eprintln!(\"$0 = {:#?}\", $0);").add_to(acc); } pub(super) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) { @@ -19,6 +19,7 @@ pub(super) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionConte return; } snippet( + ctx, "Test function", "\ #[test] @@ -29,45 +30,33 @@ fn ${1:feature}() { .lookup_by("tfn") .add_to(acc); - snippet("pub(crate)", "pub(crate) $0").add_to(acc); + snippet(ctx, "pub(crate)", "pub(crate) $0").add_to(acc); } #[cfg(test)] mod tests { - use crate::completion::{CompletionKind, check_completion}; - fn check_snippet_completion(code: &str, expected_completions: &str) { - check_completion(code, expected_completions, CompletionKind::Snippet); + use crate::completion::CompletionKind; + use crate::completion::completion_item::check_completion; + + fn check_snippet_completion(name: &str, code: &str) { + check_completion(name, code, CompletionKind::Snippet); } #[test] fn completes_snippets_in_expressions() { - check_snippet_completion( - r"fn foo(x: i32) { <|> }", - r##" - pd "eprintln!(\"$0 = {:?}\", $0);" - ppd "eprintln!(\"$0 = {:#?}\", $0);" - "##, - ); + check_snippet_completion("snippets_in_expressions", r"fn foo(x: i32) { <|> }"); } #[test] fn completes_snippets_in_items() { - // check_snippet_completion(r" - // <|> - // ", - // r##"[CompletionItem { label: "Test function", lookup: None, snippet: Some("#[test]\nfn test_${1:feature}() {\n$0\n}"##, - // ); check_snippet_completion( + "snippets_in_items", r" #[cfg(test)] mod tests { <|> } ", - r##" - tfn "Test function" "#[test]\nfn ${1:feature}() {\n $0\n}" - pub(crate) "pub(crate) $0" - "##, ); } } diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index e537e0082d..de9b95c81f 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -12,7 +12,7 @@ use crate::{db, FilePosition}; /// `CompletionContext` is created early during completion to figure out, where /// exactly is the cursor, syntax-wise. #[derive(Debug)] -pub(super) struct CompletionContext<'a> { +pub(crate) struct CompletionContext<'a> { pub(super) db: &'a db::RootDatabase, pub(super) offset: TextUnit, pub(super) leaf: &'a SyntaxNode, @@ -65,6 +65,10 @@ impl<'a> CompletionContext<'a> { Some(ctx) } + pub(crate) fn leaf_range(&self) -> TextRange { + self.leaf.range() + } + fn fill(&mut self, original_file: &'a SourceFile, offset: TextUnit) { // Insert a fake ident to get a valid parse tree. We will use this file // to determine context, though the original_file will be used for diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 11d00f78cd..7bd6344985 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -1,6 +1,10 @@ use hir::PerNs; +use ra_text_edit::{ + AtomTextEdit, + TextEdit, +}; -use crate::completion::CompletionContext; +use crate::completion::completion_context::CompletionContext; /// `CompletionItem` describes a single completion variant in the editor pop-up. /// It is basically a POD with various properties. To construct a @@ -11,15 +15,29 @@ pub struct CompletionItem { /// completion. completion_kind: CompletionKind, label: String, + kind: Option, detail: Option, lookup: Option, - snippet: Option, - kind: Option, -} - -pub enum InsertText { - PlainText { text: String }, - Snippet { text: String }, + /// The format of the insert text. The format applies to both the `insert_text` property + /// and the `insert` property of a provided `text_edit`. + insert_text_format: InsertTextFormat, + /// An edit which is applied to a document when selecting this completion. When an edit is + /// provided the value of `insert_text` is ignored. + /// + /// *Note:* The range of the edit must be a single line range and it must contain the position + /// at which completion has been requested. + /// + /// *Note:* If sending a range that overlaps a string, the string should match the relevant + /// part of the replacement text, or be filtered out. + text_edit: Option, + /// An optional array of additional text edits that are applied when + /// selecting this completion. Edits must not overlap (including the same insert position) + /// with the main edit nor with themselves. + /// + /// Additional text edits should be used to change text unrelated to the current cursor position + /// (for example adding an import statement at the top of the file if the completion item will + /// insert an unqualified type). + additional_text_edits: Option, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -40,7 +58,7 @@ pub enum CompletionItemKind { Method, } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Copy, Clone)] pub(crate) enum CompletionKind { /// Parser-based keyword completion. Keyword, @@ -51,16 +69,30 @@ pub(crate) enum CompletionKind { Snippet, } +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub enum InsertTextFormat { + PlainText, + Snippet, +} + impl CompletionItem { - pub(crate) fn new(completion_kind: CompletionKind, label: impl Into) -> Builder { + pub(crate) fn new<'a>( + completion_kind: CompletionKind, + ctx: &'a CompletionContext, + label: impl Into, + ) -> Builder<'a> { let label = label.into(); Builder { + ctx, completion_kind, label, + insert_text: None, + insert_text_format: InsertTextFormat::PlainText, detail: None, lookup: None, - snippet: None, kind: None, + text_edit: None, + additional_text_edits: None, } } /// What user sees in pop-up in the UI. @@ -78,64 +110,100 @@ impl CompletionItem { .map(|it| it.as_str()) .unwrap_or(self.label()) } - /// What is inserted. - pub fn insert_text(&self) -> InsertText { - match &self.snippet { - None => InsertText::PlainText { - text: self.label.clone(), - }, - Some(it) => InsertText::Snippet { text: it.clone() }, - } + + pub fn insert_text_format(&self) -> InsertTextFormat { + self.insert_text_format.clone() } pub fn kind(&self) -> Option { self.kind } + pub fn text_edit(&mut self) -> Option<&AtomTextEdit> { + self.text_edit.as_ref() + } + pub fn take_additional_text_edits(&mut self) -> Option { + self.additional_text_edits.take() + } } /// A helper to make `CompletionItem`s. #[must_use] -pub(crate) struct Builder { +pub(crate) struct Builder<'a> { + ctx: &'a CompletionContext<'a>, completion_kind: CompletionKind, label: String, + insert_text: Option, + insert_text_format: InsertTextFormat, detail: Option, lookup: Option, - snippet: Option, kind: Option, + text_edit: Option, + additional_text_edits: Option, } -impl Builder { +impl<'a> Builder<'a> { pub(crate) fn add_to(self, acc: &mut Completions) { acc.add(self.build()) } pub(crate) fn build(self) -> CompletionItem { + let self_text_edit = self.text_edit; + let self_insert_text = self.insert_text; + let text_edit = match (self_text_edit, self_insert_text) { + (Some(text_edit), ..) => Some(text_edit), + (None, Some(insert_text)) => { + Some(AtomTextEdit::replace(self.ctx.leaf_range(), insert_text)) + } + _ => None, + }; + CompletionItem { label: self.label, detail: self.detail, + insert_text_format: self.insert_text_format, lookup: self.lookup, - snippet: self.snippet, kind: self.kind, completion_kind: self.completion_kind, + text_edit, + additional_text_edits: self.additional_text_edits, } } - pub(crate) fn lookup_by(mut self, lookup: impl Into) -> Builder { + pub(crate) fn lookup_by(mut self, lookup: impl Into) -> Builder<'a> { self.lookup = Some(lookup.into()); self } - pub(crate) fn snippet(mut self, snippet: impl Into) -> Builder { - self.snippet = Some(snippet.into()); + pub(crate) fn insert_text(mut self, insert_text: impl Into) -> Builder<'a> { + self.insert_text = Some(insert_text.into()); self } - pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder { + pub(crate) fn insert_text_format( + mut self, + insert_text_format: InsertTextFormat, + ) -> Builder<'a> { + self.insert_text_format = insert_text_format; + self + } + pub(crate) fn snippet(mut self, snippet: impl Into) -> Builder<'a> { + self.insert_text_format = InsertTextFormat::Snippet; + self.insert_text(snippet) + } + pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder<'a> { self.kind = Some(kind); self } + pub(crate) fn text_edit(mut self, text_edit: AtomTextEdit) -> Builder<'a> { + self.text_edit = Some(text_edit); + self + } + pub(crate) fn additional_text_edits(mut self, additional_text_edits: TextEdit) -> Builder<'a> { + self.additional_text_edits = Some(additional_text_edits); + self + } #[allow(unused)] - pub(crate) fn detail(self, detail: impl Into) -> Builder { + pub(crate) fn detail(self, detail: impl Into) -> Builder<'a> { self.set_detail(Some(detail)) } - pub(crate) fn set_detail(mut self, detail: Option>) -> Builder { + pub(crate) fn set_detail(mut self, detail: Option>) -> Builder<'a> { self.detail = detail.map(Into::into); self } @@ -143,7 +211,7 @@ impl Builder { mut self, ctx: &CompletionContext, resolution: &hir::Resolution, - ) -> Builder { + ) -> Builder<'a> { let resolved = resolution.def_id.map(|d| d.resolve(ctx.db)); let kind = match resolved { PerNs { @@ -188,21 +256,22 @@ impl Builder { mut self, ctx: &CompletionContext, function: hir::Function, - ) -> Builder { + ) -> Builder<'a> { // If not an import, add parenthesis automatically. if ctx.use_item_syntax.is_none() && !ctx.is_call { if function.signature(ctx.db).params().is_empty() { - self.snippet = Some(format!("{}()$0", self.label)); + self.insert_text = Some(format!("{}()$0", self.label)); } else { - self.snippet = Some(format!("{}($0)", self.label)); + self.insert_text = Some(format!("{}($0)", self.label)); } + self.insert_text_format = InsertTextFormat::Snippet; } self.kind = Some(CompletionItemKind::Function); self } } -impl Into for Builder { +impl<'a> Into for Builder<'a> { fn into(self) -> CompletionItem { self.build() } @@ -225,60 +294,6 @@ impl Completions { { items.into_iter().for_each(|item| self.add(item.into())) } - - #[cfg(test)] - pub(crate) fn assert_match(&self, expected: &str, kind: CompletionKind) { - let expected = normalize(expected); - let actual = self.debug_render(kind); - test_utils::assert_eq_text!(expected.as_str(), actual.as_str(),); - - /// Normalize the textual representation of `Completions`: - /// replace `;` with newlines, normalize whitespace - fn normalize(expected: &str) -> String { - use ra_syntax::{tokenize, TextUnit, TextRange, SyntaxKind::SEMI}; - let mut res = String::new(); - for line in expected.trim().lines() { - let line = line.trim(); - let mut start_offset: TextUnit = 0.into(); - // Yep, we use rust tokenize in completion tests :-) - for token in tokenize(line) { - let range = TextRange::offset_len(start_offset, token.len); - start_offset += token.len; - if token.kind == SEMI { - res.push('\n'); - } else { - res.push_str(&line[range]); - } - } - - res.push('\n'); - } - res - } - } - - #[cfg(test)] - fn debug_render(&self, kind: CompletionKind) -> String { - let mut res = String::new(); - for c in self.buf.iter() { - if c.completion_kind == kind { - if let Some(lookup) = &c.lookup { - res.push_str(lookup); - res.push_str(&format!(" {:?}", c.label)); - } else { - res.push_str(&c.label); - } - if let Some(detail) = &c.detail { - res.push_str(&format!(" {:?}", detail)); - } - if let Some(snippet) = &c.snippet { - res.push_str(&format!(" {:?}", snippet)); - } - res.push('\n'); - } - } - res - } } impl Into> for Completions { @@ -286,3 +301,22 @@ impl Into> for Completions { self.buf } } + +#[cfg(test)] +pub(crate) fn check_completion(test_name: &str, code: &str, kind: CompletionKind) { + use crate::mock_analysis::{single_file_with_position, analysis_and_position}; + use crate::completion::completions; + use insta::assert_debug_snapshot_matches; + let (analysis, position) = if code.contains("//-") { + analysis_and_position(code) + } else { + single_file_with_position(code) + }; + let completions = completions(&analysis.db, position).unwrap(); + let completion_items: Vec = completions.into(); + let kind_completions: Vec = completion_items + .into_iter() + .filter(|c| c.completion_kind == kind) + .collect(); + assert_debug_snapshot_matches!(test_name, kind_completions); +} 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 new file mode 100644 index 0000000000..40a5fd90fa --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap @@ -0,0 +1,35 @@ +Created: 2019-01-19T13:42:17.835266+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "x", + kind: Some( + Binding + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "quux", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "quux()$0" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..f6c0d75013 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap @@ -0,0 +1,47 @@ +Created: 2019-01-19T13:42:17.835796+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "b", + kind: Some( + Binding + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "a", + kind: Some( + Binding + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "quux", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [213; 231), + insert: "quux()$0" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..a6fda0cf2d --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap @@ -0,0 +1,47 @@ +Created: 2019-01-19T13:42:17.835351+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "y", + kind: Some( + Binding + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "x", + kind: Some( + Binding + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "quux", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [78; 79), + insert: "quux($0)" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..b27674da42 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap @@ -0,0 +1,125 @@ +Created: 2019-01-19T13:42:17.819543+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [54; 56), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [54; 56), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [54; 56), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [54; 56), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "continue", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [54; 56), + insert: "continue;" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "break", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [54; 56), + insert: "break;" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [54; 56), + insert: "return $0;" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..4ebc168228 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap @@ -0,0 +1,91 @@ +Created: 2019-01-19T13:42:17.830288+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [59; 61), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [59; 61), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [59; 61), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [59; 61), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [59; 61), + insert: "return $0;" + } + ), + additional_text_edits: None + } +] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completion_postfix.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completion_postfix.snap new file mode 100644 index 0000000000..60b5a7424b --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completion_postfix.snap @@ -0,0 +1,102 @@ +Created: 2019-01-19T13:50:41.824939+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Postfix, + label: "not", + kind: None, + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [78; 78), + insert: "!not" + } + ), + additional_text_edits: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, + CompletionItem { + completion_kind: Postfix, + label: "if", + kind: None, + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [78; 78), + insert: "if bar {$0}" + } + ), + additional_text_edits: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, + CompletionItem { + completion_kind: Postfix, + label: "match", + kind: None, + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [78; 78), + insert: "match bar {\n${1:_} => {$0\\},\n}" + } + ), + additional_text_edits: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + }, + CompletionItem { + completion_kind: Postfix, + label: "while", + kind: None, + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [78; 78), + insert: "while bar {\n$0\n}" + } + ), + additional_text_edits: Some( + TextEdit { + atoms: [ + AtomTextEdit { + delete: [72; 78), + insert: "" + } + ] + } + ) + } +] 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 new file mode 100644 index 0000000000..b33bc3e047 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__deeply_nested_use_tree.snap @@ -0,0 +1,18 @@ +Created: 2019-01-19T11:53:16.799862+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "Spam", + kind: Some( + Struct + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..0a96291ab6 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap @@ -0,0 +1,91 @@ +Created: 2019-01-19T13:42:17.821375+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [84; 102), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [84; 102), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [84; 102), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [84; 102), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [84; 102), + insert: "return $0" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..5126c2bdc4 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap @@ -0,0 +1,30 @@ +Created: 2019-01-19T11:53:16.799845+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "main", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "frobnicate", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..dd91e337a4 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_in_use_item.snap @@ -0,0 +1,18 @@ +Created: 2019-01-19T11:53:16.799820+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "foo", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..9c1c3fe6a6 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap @@ -0,0 +1,35 @@ +Created: 2019-01-19T13:42:17.841643+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "bar", + kind: Some( + Binding + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "foo", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [108; 146), + insert: "foo()$0" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..7d693be771 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap @@ -0,0 +1,40 @@ +Created: 2019-01-19T13:42:17.844671+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "no_args", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [53; 56), + insert: "no_args()$0" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "main", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [53; 56), + insert: "main()$0" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..1d2946c499 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls2.snap @@ -0,0 +1,40 @@ +Created: 2019-01-19T13:42:17.849139+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "main", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [72; 77), + insert: "main()$0" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "with_args", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [72; 77), + insert: "with_args($0)" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..2059d63e83 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap @@ -0,0 +1,91 @@ +Created: 2019-01-19T13:42:17.819926+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 54), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 54), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 54), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 54), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 54), + insert: "return;" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..2cc81582c0 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap @@ -0,0 +1,125 @@ +Created: 2019-01-19T13:42:17.819839+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [91; 105), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [91; 105), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [91; 105), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [91; 105), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "else", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [91; 105), + insert: "else {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "else if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [91; 105), + insert: "else if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [91; 105), + insert: "return;" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..26dec82c7b --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap @@ -0,0 +1,91 @@ +Created: 2019-01-19T13:42:17.822255+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [31; 65), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [31; 65), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [31; 65), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [31; 65), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [31; 65), + insert: "return $0;" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..4167165ec2 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap @@ -0,0 +1,91 @@ +Created: 2019-01-19T13:42:17.830680+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 58), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 58), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 58), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 58), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [24; 58), + insert: "return;" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..db137d896f --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap @@ -0,0 +1,52 @@ +Created: 2019-01-19T13:42:17.819227+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "crate", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: Some( + AtomTextEdit { + delete: [16; 30), + insert: "crate::" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "self", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "super", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: Some( + AtomTextEdit { + delete: [16; 30), + insert: "super::" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..1ff0f49393 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt2.snap @@ -0,0 +1,35 @@ +Created: 2019-01-19T13:42:17.822990+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "self", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "super", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: Some( + AtomTextEdit { + delete: [18; 20), + insert: "super::" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..e14bd209ce --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap @@ -0,0 +1,35 @@ +Created: 2019-01-19T13:42:17.826915+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "self", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "super", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: Some( + AtomTextEdit { + delete: [23; 24), + insert: "super::" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..a728283554 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap @@ -0,0 +1,91 @@ +Created: 2019-01-19T13:42:17.821139+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "return $0;" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..c5d5e74cbd --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap @@ -0,0 +1,91 @@ +Created: 2019-01-19T13:42:17.829078+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [62; 100), + insert: "return $0;" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..c18b44d590 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__method_completion.snap @@ -0,0 +1,23 @@ +Created: 2019-01-19T13:42:17.817204+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "the_method", + kind: Some( + Method + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [143; 144), + insert: "the_method($0)" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..8d262a91de --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap @@ -0,0 +1,47 @@ +Created: 2019-01-19T13:42:17.835687+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "quux", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [72; 102), + insert: "quux()$0" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "Foo", + kind: Some( + Struct + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "Baz", + kind: Some( + Enum + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..0973445215 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap @@ -0,0 +1,35 @@ +Created: 2019-01-19T13:42:17.836102+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "quux", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [100; 102), + insert: "quux()$0" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "Bar", + kind: Some( + Struct + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..dbe1e04452 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__nested_use_tree.snap @@ -0,0 +1,30 @@ +Created: 2019-01-19T11:53:16.799743+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "Spam", + kind: Some( + Struct + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "foo", + kind: Some( + Module + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__no_non_self_method.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_non_self_method.snap new file mode 100644 index 0000000000..417b692dca --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_non_self_method.snap @@ -0,0 +1,5 @@ +Created: 2019-01-19T11:34:11.702251+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[] 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 new file mode 100644 index 0000000000..26c54018ea --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap @@ -0,0 +1,125 @@ +Created: 2019-01-19T13:42:17.821881+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Keyword, + label: "if", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [106; 108), + insert: "if $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "match", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [106; 108), + insert: "match $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "while", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [106; 108), + insert: "while $0 {}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "loop", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [106; 108), + insert: "loop {$0}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "continue", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [106; 108), + insert: "continue" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "break", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [106; 108), + insert: "break" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Keyword, + label: "return", + kind: Some( + Keyword + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [106; 108), + insert: "return" + } + ), + additional_text_edits: None + } +] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__no_struct_field_completion_for_method_call.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_struct_field_completion_for_method_call.snap new file mode 100644 index 0000000000..0948c9fe60 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_struct_field_completion_for_method_call.snap @@ -0,0 +1,5 @@ +Created: 2019-01-19T11:34:11.702201+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[] 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 new file mode 100644 index 0000000000..160da9e316 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap @@ -0,0 +1,18 @@ +Created: 2019-01-19T11:27:14.070727+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Magic, + label: "file_id: FileId", + kind: None, + detail: None, + lookup: Some( + "file_id" + ), + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..baeb01ed9a --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap @@ -0,0 +1,18 @@ +Created: 2019-01-19T11:29:09.355053+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Magic, + label: "file_id: FileId", + kind: None, + detail: None, + lookup: Some( + "file_id" + ), + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..8193c4f170 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap @@ -0,0 +1,18 @@ +Created: 2019-01-19T11:29:09.355066+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Magic, + label: "file_id: FileId", + kind: None, + detail: None, + lookup: Some( + "file_id" + ), + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap new file mode 100644 index 0000000000..abd17dcec1 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap @@ -0,0 +1,30 @@ +Created: 2019-01-19T11:53:16.799765+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "Foo", + kind: Some( + EnumVariant + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "Bar", + kind: Some( + EnumVariant + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..c00a5ea5d3 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap @@ -0,0 +1,35 @@ +Created: 2019-01-19T13:42:17.837692+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "Foo", + kind: Some( + Struct + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "x", + kind: Some( + Function + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [46; 60), + insert: "x()$0" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..263b151564 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap @@ -0,0 +1,18 @@ +Created: 2019-01-19T11:59:18.394156+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "self", + kind: Some( + Binding + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..82f0a6d8d7 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap @@ -0,0 +1,40 @@ +Created: 2019-01-19T13:42:17.844708+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Snippet, + label: "pd", + kind: Some( + Snippet + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [16; 18), + insert: "eprintln!(\"$0 = {:?}\", $0);" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Snippet, + label: "ppd", + kind: Some( + Snippet + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [16; 18), + insert: "eprintln!(\"$0 = {:#?}\", $0);" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..e7cc5c410c --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap @@ -0,0 +1,42 @@ +Created: 2019-01-19T13:42:17.845616+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Snippet, + label: "Test function", + kind: Some( + Snippet + ), + detail: None, + lookup: Some( + "tfn" + ), + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [49; 79), + insert: "#[test]\nfn ${1:feature}() {\n $0\n}" + } + ), + additional_text_edits: None + }, + CompletionItem { + completion_kind: Snippet, + label: "pub(crate)", + kind: Some( + Snippet + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [49; 79), + insert: "pub(crate) $0" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..d27ca5f8f8 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion.snap @@ -0,0 +1,20 @@ +Created: 2019-01-19T11:34:11.702218+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "the_field", + kind: Some( + Field + ), + detail: Some( + "u32" + ), + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..8e547ad376 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap @@ -0,0 +1,37 @@ +Created: 2019-01-19T13:42:17.817216+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "the_field", + kind: Some( + Field + ), + detail: Some( + "(u32, i32)" + ), + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "foo", + kind: Some( + Method + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [125; 126), + insert: "foo($0)" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..4536cee171 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap @@ -0,0 +1,37 @@ +Created: 2019-01-19T13:42:17.817207+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "the_field", + kind: Some( + Field + ), + detail: Some( + "(u32,)" + ), + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "foo", + kind: Some( + Method + ), + detail: None, + lookup: None, + insert_text_format: Snippet, + text_edit: Some( + AtomTextEdit { + delete: [120; 121), + insert: "foo($0)" + } + ), + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..4c35be33ad --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_crate.snap @@ -0,0 +1,30 @@ +Created: 2019-01-19T11:53:16.799683+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "Spam", + kind: Some( + Struct + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + }, + CompletionItem { + completion_kind: Reference, + label: "foo", + kind: Some( + Module + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] 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 new file mode 100644 index 0000000000..9780d652a7 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__use_item_starting_with_self.snap @@ -0,0 +1,18 @@ +Created: 2019-01-19T11:53:16.799788+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[ + CompletionItem { + completion_kind: Reference, + label: "Bar", + kind: Some( + Struct + ), + detail: None, + lookup: None, + insert_text_format: PlainText, + text_edit: None, + additional_text_edits: None + } +] diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 33bef178a9..fb0821ff63 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -43,7 +43,7 @@ use crate::{ }; pub use crate::{ - completion::{CompletionItem, CompletionItemKind, InsertText}, + completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, runnables::{Runnable, RunnableKind}, navigation_target::NavigationTarget, }; diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 6e187d49e2..76215a9751 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -1,13 +1,13 @@ use lsp_types::{ - self, CreateFile, DocumentChangeOperation, DocumentChanges, InsertTextFormat, Location, LocationLink, + self, CreateFile, DocumentChangeOperation, DocumentChanges, Location, LocationLink, Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit, }; use ra_ide_api::{ CompletionItem, CompletionItemKind, FileId, FilePosition, FileRange, FileSystemEdit, - InsertText, NavigationTarget, SourceChange, SourceFileEdit, RangeInfo, - LineCol, LineIndex, translate_offset_with_edit + NavigationTarget, SourceChange, SourceFileEdit, RangeInfo, + LineCol, LineIndex, translate_offset_with_edit, InsertTextFormat }; use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use ra_text_edit::{AtomTextEdit, TextEdit}; @@ -74,27 +74,30 @@ impl Conv for CompletionItemKind { } } -impl Conv for CompletionItem { +impl ConvWith for CompletionItem { + type Ctx = LineIndex; type Output = ::lsp_types::CompletionItem; - fn conv(self) -> ::Output { - let mut res = ::lsp_types::CompletionItem { + fn conv_with(mut self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { + let text_edit = self.text_edit().map(|t| t.conv_with(ctx)); + let additonal_text_edit = self + .take_additional_text_edits() + .map(|it| it.conv_with(ctx)); + + let mut res = lsp_types::CompletionItem { label: self.label().to_string(), detail: self.detail().map(|it| it.to_string()), filter_text: Some(self.lookup().to_string()), kind: self.kind().map(|it| it.conv()), + text_edit, + additional_text_edits: additonal_text_edit, ..Default::default() }; - match self.insert_text() { - InsertText::PlainText { text } => { - res.insert_text = Some(text); - res.insert_text_format = Some(InsertTextFormat::PlainText); - } - InsertText::Snippet { text } => { - res.insert_text = Some(text); - res.insert_text_format = Some(InsertTextFormat::Snippet); - } - } + res.insert_text_format = Some(match self.insert_text_format() { + InsertTextFormat::Snippet => lsp_types::InsertTextFormat::Snippet, + InsertTextFormat::PlainText => lsp_types::InsertTextFormat::PlainText, + }); + res } } diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 8f9db68a2f..d1e8c57747 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -337,7 +337,11 @@ pub fn handle_completion( None => return Ok(None), Some(items) => items, }; - let items = items.into_iter().map(|item| item.conv()).collect(); + let line_index = world.analysis().file_line_index(position.file_id); + let items = items + .into_iter() + .map(|item| item.conv_with(&line_index)) + .collect(); Ok(Some(req::CompletionResponse::Array(items))) } From 64342599ca43fb72d0db8e79802a1018f480b5f5 Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sat, 19 Jan 2019 22:11:38 +0800 Subject: [PATCH 2/6] ignore unused methods --- crates/ra_ide_api/src/completion/completion_item.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 7bd6344985..f9a2665249 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -176,6 +176,7 @@ impl<'a> Builder<'a> { self.insert_text = Some(insert_text.into()); self } + #[allow(unused)] pub(crate) fn insert_text_format( mut self, insert_text_format: InsertTextFormat, @@ -191,10 +192,12 @@ impl<'a> Builder<'a> { self.kind = Some(kind); self } + #[allow(unused)] pub(crate) fn text_edit(mut self, text_edit: AtomTextEdit) -> Builder<'a> { self.text_edit = Some(text_edit); self } + #[allow(unused)] pub(crate) fn additional_text_edits(mut self, additional_text_edits: TextEdit) -> Builder<'a> { self.additional_text_edits = Some(additional_text_edits); self From 94d96b60f334e662f516bd0f04cc4191d7a804e6 Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sun, 20 Jan 2019 00:38:34 +0800 Subject: [PATCH 3/6] refactor to use `remove_range` and `replace_range` instead of TextEdit --- .../ra_ide_api/src/completion/complete_dot.rs | 16 ++- .../src/completion/complete_fn_param.rs | 2 +- .../src/completion/complete_keyword.rs | 13 ++- .../src/completion/complete_path.rs | 20 +++- .../src/completion/complete_scope.rs | 20 +++- .../src/completion/complete_snippet.rs | 4 +- .../src/completion/completion_item.rs | 110 ++++++------------ .../completion_item__bindings_from_for.snap | 19 ++- ...completion_item__bindings_from_if_let.snap | 24 ++-- .../completion_item__bindings_from_let.snap | 24 ++-- ...ompletes_break_and_continue_in_loops1.snap | 86 ++++++-------- ...ompletes_break_and_continue_in_loops2.snap | 62 +++++----- ...mpletion_item__deeply_nested_use_tree.snap | 7 +- ..._semi_after_return_if_not_a_statement.snap | 62 +++++----- ...ender_function_parens_if_already_call.snap | 12 +- ...nt_render_function_parens_in_use_item.snap | 7 +- ...t_show_both_completions_for_shadowing.snap | 19 ++- ...m__inserts_parens_for_function_calls1.snap | 26 ++--- ...m__inserts_parens_for_function_calls2.snap | 26 ++--- ...ompletion_item__keywords_in_function1.snap | 62 +++++----- ...ompletion_item__keywords_in_function2.snap | 86 ++++++-------- ...ompletion_item__keywords_in_function3.snap | 62 +++++----- ...ompletion_item__keywords_in_function4.snap | 62 +++++----- ...ompletion_item__keywords_in_use_stmt1.snap | 31 +++-- ...ompletion_item__keywords_in_use_stmt2.snap | 19 ++- ...ompletion_item__keywords_in_use_stmt3.snap | 19 ++- ..._item__last_return_in_block_has_semi1.snap | 62 +++++----- ..._item__last_return_in_block_has_semi2.snap | 62 +++++----- .../completion_item__method_completion.snap | 14 +-- .../completion_item__module_items.snap | 24 ++-- ..._item__module_items_in_nested_modules.snap | 19 ++- .../completion_item__nested_use_tree.snap | 12 +- ..._no_semi_after_break_continue_in_expr.snap | 86 ++++++-------- ...ion_item__param_completion_last_param.snap | 7 +- ...tion_item__param_completion_nth_param.snap | 7 +- ...on_item__param_completion_trait_param.snap | 7 +- ...completion_item__reference_completion.snap | 12 +- .../completion_item__return_type.snap | 19 ++- .../completion_item__self_in_methods.snap | 7 +- ...pletion_item__snippets_in_expressions.snap | 26 ++--- .../completion_item__snippets_in_items.snap | 26 ++--- ...pletion_item__struct_field_completion.snap | 7 +- ...em__struct_field_completion_autoderef.snap | 19 ++- ...on_item__struct_field_completion_self.snap | 19 ++- ...on_item__use_item_starting_with_crate.snap | 12 +- ...ion_item__use_item_starting_with_self.snap | 7 +- crates/ra_lsp_server/src/conv.rs | 20 ++-- 47 files changed, 619 insertions(+), 755 deletions(-) diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index aaf739500a..e1c0d26c7d 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -31,7 +31,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) for field in s.fields(ctx.db) { CompletionItem::new( CompletionKind::Reference, - ctx, + ctx.leaf_range(), field.name().to_string(), ) .kind(CompletionItemKind::Field) @@ -45,7 +45,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) } Ty::Tuple(fields) => { for (i, _ty) in fields.iter().enumerate() { - CompletionItem::new(CompletionKind::Reference, ctx, i.to_string()) + CompletionItem::new(CompletionKind::Reference, ctx.leaf_range(), i.to_string()) .kind(CompletionItemKind::Field) .add_to(acc); } @@ -59,10 +59,14 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty receiver.iterate_methods(ctx.db, |func| { let sig = func.signature(ctx.db); if sig.has_self_param() { - CompletionItem::new(CompletionKind::Reference, ctx, sig.name().to_string()) - .from_function(ctx, func) - .kind(CompletionItemKind::Method) - .add_to(acc); + CompletionItem::new( + CompletionKind::Reference, + ctx.leaf_range(), + sig.name().to_string(), + ) + .from_function(ctx, func) + .kind(CompletionItemKind::Method) + .add_to(acc); } None::<()> }); diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs index e3d1470c2b..c3e3ea9310 100644 --- a/crates/ra_ide_api/src/completion/complete_fn_param.rs +++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs @@ -34,7 +34,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) } }) .for_each(|(label, lookup)| { - CompletionItem::new(CompletionKind::Magic, ctx, label) + CompletionItem::new(CompletionKind::Magic, ctx.leaf_range(), label) .lookup_by(lookup) .add_to(acc) }); diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs index 3fbf363131..006b200765 100644 --- a/crates/ra_ide_api/src/completion/complete_keyword.rs +++ b/crates/ra_ide_api/src/completion/complete_keyword.rs @@ -9,25 +9,26 @@ use crate::completion::{CompletionContext, CompletionItem, Completions, Completi pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { // complete keyword "crate" in use stmt + let leaf_range = ctx.leaf_range(); match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) { (Some(_), None) => { - CompletionItem::new(CompletionKind::Keyword, ctx, "crate") + CompletionItem::new(CompletionKind::Keyword, leaf_range, "crate") .kind(CompletionItemKind::Keyword) .insert_text("crate::") .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, ctx, "self") + CompletionItem::new(CompletionKind::Keyword, leaf_range, "self") .kind(CompletionItemKind::Keyword) .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, ctx, "super") + CompletionItem::new(CompletionKind::Keyword, leaf_range, "super") .kind(CompletionItemKind::Keyword) .insert_text("super::") .add_to(acc); } (Some(_), Some(_)) => { - CompletionItem::new(CompletionKind::Keyword, ctx, "self") + CompletionItem::new(CompletionKind::Keyword, leaf_range, "self") .kind(CompletionItemKind::Keyword) .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, ctx, "super") + CompletionItem::new(CompletionKind::Keyword, leaf_range, "super") .kind(CompletionItemKind::Keyword) .insert_text("super::") .add_to(acc); @@ -37,7 +38,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC } fn keyword(ctx: &CompletionContext, kw: &str, snippet: &str) -> CompletionItem { - CompletionItem::new(CompletionKind::Keyword, ctx, kw) + CompletionItem::new(CompletionKind::Keyword, ctx.leaf_range(), kw) .kind(CompletionItemKind::Keyword) .snippet(snippet) .build() diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 7413c71e80..513a2ee89c 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -15,18 +15,26 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { hir::Def::Module(module) => { let module_scope = module.scope(ctx.db); for (name, res) in module_scope.entries() { - CompletionItem::new(CompletionKind::Reference, ctx, name.to_string()) - .from_resolution(ctx, res) - .add_to(acc); + CompletionItem::new( + CompletionKind::Reference, + ctx.leaf_range(), + name.to_string(), + ) + .from_resolution(ctx, res) + .add_to(acc); } } hir::Def::Enum(e) => { e.variants(ctx.db) .into_iter() .for_each(|(variant_name, _variant)| { - CompletionItem::new(CompletionKind::Reference, ctx, variant_name.to_string()) - .kind(CompletionItemKind::EnumVariant) - .add_to(acc) + CompletionItem::new( + CompletionKind::Reference, + ctx.leaf_range(), + variant_name.to_string(), + ) + .kind(CompletionItemKind::EnumVariant) + .add_to(acc) }); } _ => return, diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index bb080a341f..958a12f226 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -29,9 +29,13 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { } }) .for_each(|(name, res)| { - CompletionItem::new(CompletionKind::Reference, ctx, name.to_string()) - .from_resolution(ctx, res) - .add_to(acc) + CompletionItem::new( + CompletionKind::Reference, + ctx.leaf_range(), + name.to_string(), + ) + .from_resolution(ctx, res) + .add_to(acc) }); } @@ -46,9 +50,13 @@ fn complete_fn( .flat_map(|scope| scopes.scopes.entries(scope).iter()) .filter(|entry| shadowed.insert(entry.name())) .for_each(|entry| { - CompletionItem::new(CompletionKind::Reference, ctx, entry.name().to_string()) - .kind(CompletionItemKind::Binding) - .add_to(acc) + CompletionItem::new( + CompletionKind::Reference, + ctx.leaf_range(), + entry.name().to_string(), + ) + .kind(CompletionItemKind::Binding) + .add_to(acc) }); } diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index fb94e3674a..4fa23bbf6f 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs @@ -1,7 +1,7 @@ use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; -fn snippet<'a>(ctx: &'a CompletionContext<'a>, label: &str, snippet: &str) -> Builder<'a> { - CompletionItem::new(CompletionKind::Snippet, ctx, label) +fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder { + CompletionItem::new(CompletionKind::Snippet, ctx.leaf_range(), label) .snippet(snippet) .kind(CompletionItemKind::Snippet) } diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index f9a2665249..da8da94d1e 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -1,10 +1,7 @@ use hir::PerNs; -use ra_text_edit::{ - AtomTextEdit, - TextEdit, -}; use crate::completion::completion_context::CompletionContext; +use ra_syntax::TextRange; /// `CompletionItem` describes a single completion variant in the editor pop-up. /// It is basically a POD with various properties. To construct a @@ -18,26 +15,10 @@ pub struct CompletionItem { kind: Option, detail: Option, lookup: Option, - /// The format of the insert text. The format applies to both the `insert_text` property - /// and the `insert` property of a provided `text_edit`. + insert_text: Option, insert_text_format: InsertTextFormat, - /// An edit which is applied to a document when selecting this completion. When an edit is - /// provided the value of `insert_text` is ignored. - /// - /// *Note:* The range of the edit must be a single line range and it must contain the position - /// at which completion has been requested. - /// - /// *Note:* If sending a range that overlaps a string, the string should match the relevant - /// part of the replacement text, or be filtered out. - text_edit: Option, - /// An optional array of additional text edits that are applied when - /// selecting this completion. Edits must not overlap (including the same insert position) - /// with the main edit nor with themselves. - /// - /// Additional text edits should be used to change text unrelated to the current cursor position - /// (for example adding an import statement at the top of the file if the completion item will - /// insert an unqualified type). - additional_text_edits: Option, + replace_range: TextRange, + delete_range: Option, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -76,14 +57,14 @@ pub enum InsertTextFormat { } impl CompletionItem { - pub(crate) fn new<'a>( + pub(crate) fn new( completion_kind: CompletionKind, - ctx: &'a CompletionContext, + replace_range: TextRange, label: impl Into, - ) -> Builder<'a> { + ) -> Builder { let label = label.into(); Builder { - ctx, + replace_range, completion_kind, label, insert_text: None, @@ -91,8 +72,7 @@ impl CompletionItem { detail: None, lookup: None, kind: None, - text_edit: None, - additional_text_edits: None, + delete_range: None, } } /// What user sees in pop-up in the UI. @@ -114,22 +94,27 @@ impl CompletionItem { pub fn insert_text_format(&self) -> InsertTextFormat { self.insert_text_format.clone() } - + 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 text_edit(&mut self) -> Option<&AtomTextEdit> { - self.text_edit.as_ref() + pub fn delete_range(&self) -> Option { + self.delete_range } - pub fn take_additional_text_edits(&mut self) -> Option { - self.additional_text_edits.take() + pub fn replace_range(&self) -> TextRange { + self.replace_range } } /// A helper to make `CompletionItem`s. #[must_use] -pub(crate) struct Builder<'a> { - ctx: &'a CompletionContext<'a>, +pub(crate) struct Builder { + replace_range: TextRange, completion_kind: CompletionKind, label: String, insert_text: Option, @@ -137,76 +122,53 @@ pub(crate) struct Builder<'a> { detail: Option, lookup: Option, kind: Option, - text_edit: Option, - additional_text_edits: Option, + delete_range: Option, } -impl<'a> Builder<'a> { +impl Builder { pub(crate) fn add_to(self, acc: &mut Completions) { acc.add(self.build()) } pub(crate) fn build(self) -> CompletionItem { - let self_text_edit = self.text_edit; - let self_insert_text = self.insert_text; - let text_edit = match (self_text_edit, self_insert_text) { - (Some(text_edit), ..) => Some(text_edit), - (None, Some(insert_text)) => { - Some(AtomTextEdit::replace(self.ctx.leaf_range(), insert_text)) - } - _ => None, - }; - CompletionItem { + replace_range: self.replace_range, label: self.label, detail: self.detail, insert_text_format: self.insert_text_format, lookup: self.lookup, kind: self.kind, completion_kind: self.completion_kind, - text_edit, - additional_text_edits: self.additional_text_edits, + delete_range: self.delete_range, + insert_text: self.insert_text, } } - pub(crate) fn lookup_by(mut self, lookup: impl Into) -> Builder<'a> { + pub(crate) fn lookup_by(mut self, lookup: impl Into) -> Builder { self.lookup = Some(lookup.into()); self } - pub(crate) fn insert_text(mut self, insert_text: impl Into) -> Builder<'a> { + pub(crate) fn insert_text(mut self, insert_text: impl Into) -> Builder { self.insert_text = Some(insert_text.into()); self } #[allow(unused)] - pub(crate) fn insert_text_format( - mut self, - insert_text_format: InsertTextFormat, - ) -> Builder<'a> { + pub(crate) fn insert_text_format(mut self, insert_text_format: InsertTextFormat) -> Builder { self.insert_text_format = insert_text_format; self } - pub(crate) fn snippet(mut self, snippet: impl Into) -> Builder<'a> { + pub(crate) fn snippet(mut self, snippet: impl Into) -> Builder { self.insert_text_format = InsertTextFormat::Snippet; self.insert_text(snippet) } - pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder<'a> { + pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder { self.kind = Some(kind); self } #[allow(unused)] - pub(crate) fn text_edit(mut self, text_edit: AtomTextEdit) -> Builder<'a> { - self.text_edit = Some(text_edit); - self - } - #[allow(unused)] - pub(crate) fn additional_text_edits(mut self, additional_text_edits: TextEdit) -> Builder<'a> { - self.additional_text_edits = Some(additional_text_edits); - self - } - #[allow(unused)] - pub(crate) fn detail(self, detail: impl Into) -> Builder<'a> { + pub(crate) fn detail(self, detail: impl Into) -> Builder { self.set_detail(Some(detail)) } - pub(crate) fn set_detail(mut self, detail: Option>) -> Builder<'a> { + pub(crate) fn set_detail(mut self, detail: Option>) -> Builder { self.detail = detail.map(Into::into); self } @@ -214,7 +176,7 @@ impl<'a> Builder<'a> { mut self, ctx: &CompletionContext, resolution: &hir::Resolution, - ) -> Builder<'a> { + ) -> Builder { let resolved = resolution.def_id.map(|d| d.resolve(ctx.db)); let kind = match resolved { PerNs { @@ -259,7 +221,7 @@ impl<'a> Builder<'a> { mut self, ctx: &CompletionContext, function: hir::Function, - ) -> Builder<'a> { + ) -> Builder { // If not an import, add parenthesis automatically. if ctx.use_item_syntax.is_none() && !ctx.is_call { if function.signature(ctx.db).params().is_empty() { @@ -274,7 +236,7 @@ impl<'a> Builder<'a> { } } -impl<'a> Into for Builder<'a> { +impl<'a> Into for Builder { fn into(self) -> CompletionItem { self.build() } 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 40a5fd90fa..ff8646ab20 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.835266+00:00 +Created: 2019-01-19T16:37:23.674785+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,13 +24,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "quux()$0" - } + insert_text: Some( + "quux()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None } ] 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 f6c0d75013..2176af32d8 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.835796+00:00 +Created: 2019-01-19T16:37:23.676585+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [213; 231), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,9 +24,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [213; 231), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -35,13 +37,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [213; 231), - insert: "quux()$0" - } + insert_text: Some( + "quux()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [213; 231), + delete_range: None } ] 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 a6fda0cf2d..49745745dc 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.835351+00:00 +Created: 2019-01-19T16:37:23.676674+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [78; 79), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,9 +24,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [78; 79), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -35,13 +37,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [78; 79), - insert: "quux($0)" - } + insert_text: Some( + "quux($0)" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [78; 79), + delete_range: None } ] 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 b27674da42..c8a0a78aab 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.819543+00:00 +Created: 2019-01-19T16:37:23.630898+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [54; 56), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [54; 56), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [54; 56), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [54; 56), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [54; 56), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [54; 56), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [54; 56), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [54; 56), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,14 +71,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [54; 56), - insert: "continue;" - } + insert_text: Some( + "continue;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [54; 56), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -96,14 +86,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [54; 56), - insert: "break;" - } + insert_text: Some( + "break;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [54; 56), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -113,13 +101,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [54; 56), - insert: "return $0;" - } + insert_text: Some( + "return $0;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [54; 56), + delete_range: None } ] 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 4ebc168228..707021e212 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.830288+00:00 +Created: 2019-01-19T16:37:23.647435+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [59; 61), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [59; 61), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [59; 61), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [59; 61), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [59; 61), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [59; 61), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [59; 61), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [59; 61), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,13 +71,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [59; 61), - insert: "return $0;" - } + insert_text: Some( + "return $0;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [59; 61), + delete_range: None } ] 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 b33bc3e047..a65ab3cc00 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,4 +1,4 @@ -Created: 2019-01-19T11:53:16.799862+00:00 +Created: 2019-01-19T16:37:23.649286+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,8 +11,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [23; 25), + delete_range: None } ] 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 0a96291ab6..a935b06f4e 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.821375+00:00 +Created: 2019-01-19T16:37:23.640573+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [84; 102), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [84; 102), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [84; 102), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [84; 102), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [84; 102), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [84; 102), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [84; 102), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [84; 102), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,13 +71,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [84; 102), - insert: "return $0" - } + insert_text: Some( + "return $0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [84; 102), + delete_range: None } ] 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 5126c2bdc4..abc01d4d61 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,4 +1,4 @@ -Created: 2019-01-19T11:53:16.799845+00:00 +Created: 2019-01-19T16:37:23.670539+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [35; 39), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,8 +24,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [35; 39), + delete_range: None } ] 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 dd91e337a4..2d3234b2c2 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,4 +1,4 @@ -Created: 2019-01-19T11:53:16.799820+00:00 +Created: 2019-01-19T16:37:23.671764+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,8 +11,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [40; 41), + delete_range: None } ] 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 9c1c3fe6a6..6e4817d1a6 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.841643+00:00 +Created: 2019-01-19T16:37:23.680378+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [108; 146), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,13 +24,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [108; 146), - insert: "foo()$0" - } + insert_text: Some( + "foo()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [108; 146), + delete_range: None } ] 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 7d693be771..4ec75e2ca4 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.844671+00:00 +Created: 2019-01-19T16:37:23.681170+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [53; 56), - insert: "no_args()$0" - } + insert_text: Some( + "no_args()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [53; 56), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -28,13 +26,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [53; 56), - insert: "main()$0" - } + insert_text: Some( + "main()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [53; 56), + delete_range: None } ] 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 1d2946c499..11a8f17572 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.849139+00:00 +Created: 2019-01-19T16:37:23.686781+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [72; 77), - insert: "main()$0" - } + insert_text: Some( + "main()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [72; 77), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -28,13 +26,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [72; 77), - insert: "with_args($0)" - } + insert_text: Some( + "with_args($0)" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [72; 77), + delete_range: None } ] 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 2059d63e83..02e88a96e0 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.819926+00:00 +Created: 2019-01-19T16:37:23.640068+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 54), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 54), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 54), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 54), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 54), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 54), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 54), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 54), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,13 +71,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 54), - insert: "return;" - } + insert_text: Some( + "return;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 54), + delete_range: None } ] 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 2cc81582c0..41dc288f6c 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.819839+00:00 +Created: 2019-01-19T16:37:23.640134+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [91; 105), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [91; 105), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [91; 105), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [91; 105), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [91; 105), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [91; 105), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [91; 105), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [91; 105), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,14 +71,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [91; 105), - insert: "else {$0}" - } + insert_text: Some( + "else {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [91; 105), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -96,14 +86,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [91; 105), - insert: "else if $0 {}" - } + insert_text: Some( + "else if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [91; 105), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -113,13 +101,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [91; 105), - insert: "return;" - } + insert_text: Some( + "return;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [91; 105), + delete_range: None } ] 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 26dec82c7b..6cbed012f8 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.822255+00:00 +Created: 2019-01-19T16:37:23.640767+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [31; 65), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [31; 65), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [31; 65), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [31; 65), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [31; 65), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [31; 65), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [31; 65), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [31; 65), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,13 +71,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [31; 65), - insert: "return $0;" - } + insert_text: Some( + "return $0;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [31; 65), + delete_range: None } ] 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 4167165ec2..b95cb72c11 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.830680+00:00 +Created: 2019-01-19T16:37:23.664707+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 58), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 58), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 58), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 58), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 58), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 58), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 58), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 58), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,13 +71,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [24; 58), - insert: "return;" - } + insert_text: Some( + "return;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [24; 58), + delete_range: None } ] 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 db137d896f..d53c9e72f2 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.819227+00:00 +Created: 2019-01-19T16:37:23.639067+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: PlainText, - text_edit: Some( - AtomTextEdit { - delete: [16; 30), - insert: "crate::" - } + insert_text: Some( + "crate::" ), - additional_text_edits: None + insert_text_format: PlainText, + replace_range: [16; 30), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,9 +26,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [16; 30), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -40,13 +39,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: PlainText, - text_edit: Some( - AtomTextEdit { - delete: [16; 30), - insert: "super::" - } + insert_text: Some( + "super::" ), - additional_text_edits: None + insert_text_format: PlainText, + replace_range: [16; 30), + delete_range: None } ] 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 1ff0f49393..fee3b6e3b0 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.822990+00:00 +Created: 2019-01-19T16:37:23.643595+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [18; 20), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -23,13 +24,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: PlainText, - text_edit: Some( - AtomTextEdit { - delete: [18; 20), - insert: "super::" - } + insert_text: Some( + "super::" ), - additional_text_edits: None + insert_text_format: PlainText, + replace_range: [18; 20), + delete_range: None } ] 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 e14bd209ce..2181d6c8b2 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.826915+00:00 +Created: 2019-01-19T16:37:23.648502+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [23; 24), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -23,13 +24,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: PlainText, - text_edit: Some( - AtomTextEdit { - delete: [23; 24), - insert: "super::" - } + insert_text: Some( + "super::" ), - additional_text_edits: None + insert_text_format: PlainText, + replace_range: [23; 24), + delete_range: None } ] 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 a728283554..6da2c0ea98 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.821139+00:00 +Created: 2019-01-19T16:37:23.640449+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,13 +71,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "return $0;" - } + insert_text: Some( + "return $0;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None } ] 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 c5d5e74cbd..33bc4bb518 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.829078+00:00 +Created: 2019-01-19T16:37:23.649440+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,13 +71,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [62; 100), - insert: "return $0;" - } + insert_text: Some( + "return $0;" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [62; 100), + delete_range: None } ] 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 c18b44d590..9081bd50db 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.817204+00:00 +Created: 2019-01-19T16:37:23.629020+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,13 +11,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [143; 144), - insert: "the_method($0)" - } + insert_text: Some( + "the_method($0)" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [143; 144), + delete_range: None } ] 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 8d262a91de..be75ec0b55 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.835687+00:00 +Created: 2019-01-19T16:37:23.676740+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [72; 102), - insert: "quux()$0" - } + insert_text: Some( + "quux()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [72; 102), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -28,9 +26,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [72; 102), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -40,8 +39,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [72; 102), + delete_range: None } ] 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 0973445215..8277a6191f 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.836102+00:00 +Created: 2019-01-19T16:37:23.677905+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [100; 102), - insert: "quux()$0" - } + insert_text: Some( + "quux()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [100; 102), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -28,8 +26,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [100; 102), + delete_range: None } ] 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 dbe1e04452..bb2830737c 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,4 +1,4 @@ -Created: 2019-01-19T11:53:16.799743+00:00 +Created: 2019-01-19T16:37:23.666350+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [12; 14), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,8 +24,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [12; 14), + delete_range: None } ] 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 26c54018ea..8bcf60fa8b 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.821881+00:00 +Created: 2019-01-19T16:37:23.640842+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [106; 108), - insert: "if $0 {}" - } + insert_text: Some( + "if $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [106; 108), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -28,14 +26,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [106; 108), - insert: "match $0 {}" - } + insert_text: Some( + "match $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [106; 108), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -45,14 +41,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [106; 108), - insert: "while $0 {}" - } + insert_text: Some( + "while $0 {}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [106; 108), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -62,14 +56,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [106; 108), - insert: "loop {$0}" - } + insert_text: Some( + "loop {$0}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [106; 108), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -79,14 +71,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [106; 108), - insert: "continue" - } + insert_text: Some( + "continue" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [106; 108), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -96,14 +86,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [106; 108), - insert: "break" - } + insert_text: Some( + "break" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [106; 108), + delete_range: None }, CompletionItem { completion_kind: Keyword, @@ -113,13 +101,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [106; 108), - insert: "return" - } + insert_text: Some( + "return" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [106; 108), + delete_range: None } ] 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 160da9e316..67a0751296 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,4 +1,4 @@ -Created: 2019-01-19T11:27:14.070727+00:00 +Created: 2019-01-19T16:37:23.629063+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,8 +11,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: Some( "file_id" ), + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [98; 102), + delete_range: None } ] 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 baeb01ed9a..7f349ea160 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,4 +1,4 @@ -Created: 2019-01-19T11:29:09.355053+00:00 +Created: 2019-01-19T16:37:23.629062+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,8 +11,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: Some( "file_id" ), + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [98; 102), + delete_range: None } ] 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 8193c4f170..8aa07e2bcc 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,4 +1,4 @@ -Created: 2019-01-19T11:29:09.355066+00:00 +Created: 2019-01-19T16:37:23.630980+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,8 +11,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: Some( "file_id" ), + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [269; 273), + delete_range: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap index abd17dcec1..1e69b865fd 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap @@ -1,4 +1,4 @@ -Created: 2019-01-19T11:53:16.799765+00:00 +Created: 2019-01-19T16:37:23.664242+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [45; 47), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,8 +24,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [45; 47), + delete_range: None } ] 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 c00a5ea5d3..5d2d018721 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.837692+00:00 +Created: 2019-01-19T16:37:23.678426+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [46; 60), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,13 +24,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [46; 60), - insert: "x()$0" - } + insert_text: Some( + "x()$0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [46; 60), + delete_range: None } ] 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 263b151564..61ed4d0f2b 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,4 +1,4 @@ -Created: 2019-01-19T11:59:18.394156+00:00 +Created: 2019-01-19T16:37:23.679470+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,8 +11,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [24; 26), + delete_range: None } ] 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 82f0a6d8d7..10ced4f288 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.844708+00:00 +Created: 2019-01-19T16:37:23.681192+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,14 +11,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [16; 18), - insert: "eprintln!(\"$0 = {:?}\", $0);" - } + insert_text: Some( + "eprintln!(\"$0 = {:?}\", $0);" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [16; 18), + delete_range: None }, CompletionItem { completion_kind: Snippet, @@ -28,13 +26,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [16; 18), - insert: "eprintln!(\"$0 = {:#?}\", $0);" - } + insert_text: Some( + "eprintln!(\"$0 = {:#?}\", $0);" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [16; 18), + delete_range: None } ] 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 e7cc5c410c..5a87ae357d 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.845616+00:00 +Created: 2019-01-19T16:37:23.682017+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,14 +13,12 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: Some( "tfn" ), - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [49; 79), - insert: "#[test]\nfn ${1:feature}() {\n $0\n}" - } + insert_text: Some( + "#[test]\nfn ${1:feature}() {\n $0\n}" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [49; 79), + delete_range: None }, CompletionItem { completion_kind: Snippet, @@ -30,13 +28,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [49; 79), - insert: "pub(crate) $0" - } + insert_text: Some( + "pub(crate) $0" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [49; 79), + delete_range: None } ] 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 d27ca5f8f8..6208d04a48 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,4 +1,4 @@ -Created: 2019-01-19T11:34:11.702218+00:00 +Created: 2019-01-19T16:37:23.628928+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "u32" ), lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [84; 85), + delete_range: None } ] 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 8e547ad376..6de8ada5a4 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.817216+00:00 +Created: 2019-01-19T16:37:23.629043+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,9 +13,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "(u32, i32)" ), lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [125; 126), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -25,13 +26,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [125; 126), - insert: "foo($0)" - } + insert_text: Some( + "foo($0)" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [125; 126), + delete_range: None } ] 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 4536cee171..3e5c4fca90 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,4 +1,4 @@ -Created: 2019-01-19T13:42:17.817207+00:00 +Created: 2019-01-19T16:37:23.629041+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,9 +13,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "(u32,)" ), lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [120; 121), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -25,13 +26,11 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, - insert_text_format: Snippet, - text_edit: Some( - AtomTextEdit { - delete: [120; 121), - insert: "foo($0)" - } + insert_text: Some( + "foo($0)" ), - additional_text_edits: None + insert_text_format: Snippet, + replace_range: [120; 121), + delete_range: None } ] 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 4c35be33ad..bbec167d5d 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,4 +1,4 @@ -Created: 2019-01-19T11:53:16.799683+00:00 +Created: 2019-01-19T16:37:23.667522+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,9 +11,10 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [11; 13), + delete_range: None }, CompletionItem { completion_kind: Reference, @@ -23,8 +24,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [11; 13), + delete_range: None } ] 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 9780d652a7..ed571c605d 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,4 +1,4 @@ -Created: 2019-01-19T11:53:16.799788+00:00 +Created: 2019-01-19T16:37:23.669476+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -11,8 +11,9 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), detail: None, lookup: None, + insert_text: None, insert_text_format: PlainText, - text_edit: None, - additional_text_edits: None + replace_range: [24; 26), + delete_range: None } ] diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 76215a9751..54a977b7a2 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -13,6 +13,7 @@ use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use ra_text_edit::{AtomTextEdit, TextEdit}; use crate::{req, server_world::ServerWorld, Result}; +use ra_text_edit::TextEditBuilder; pub trait Conv { type Output; @@ -78,19 +79,24 @@ impl ConvWith for CompletionItem { type Ctx = LineIndex; type Output = ::lsp_types::CompletionItem; - fn conv_with(mut self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { - let text_edit = self.text_edit().map(|t| t.conv_with(ctx)); - let additonal_text_edit = self - .take_additional_text_edits() - .map(|it| it.conv_with(ctx)); + fn conv_with(self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { + let atom_text_edit = AtomTextEdit::replace(self.replace_range(), self.insert_text()); + let text_edit = (&atom_text_edit).conv_with(ctx); + let additional_text_edits = if let Some(delete_range) = self.delete_range() { + let mut builder = TextEditBuilder::default(); + builder.delete(delete_range); + Some(builder.finish().conv_with(ctx)) + } else { + None + }; let mut res = lsp_types::CompletionItem { label: self.label().to_string(), detail: self.detail().map(|it| it.to_string()), filter_text: Some(self.lookup().to_string()), kind: self.kind().map(|it| it.conv()), - text_edit, - additional_text_edits: additonal_text_edit, + text_edit: Some(text_edit), + additional_text_edits, ..Default::default() }; res.insert_text_format = Some(match self.insert_text_format() { From 2a43638052213d1faa690e6d68bd5702e44fa027 Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sun, 20 Jan 2019 12:02:00 +0800 Subject: [PATCH 4/6] use a combination of `source_change` and `text_edit` for `CompleteItem` --- .../ra_ide_api/src/completion/complete_dot.rs | 14 +++++---- .../src/completion/complete_fn_param.rs | 2 +- .../src/completion/complete_keyword.rs | 14 ++++----- .../src/completion/complete_path.rs | 4 +-- .../src/completion/complete_scope.rs | 4 +-- .../src/completion/complete_snippet.rs | 2 +- .../src/completion/completion_context.rs | 5 +++- .../src/completion/completion_item.rs | 30 +++++++++++-------- .../completion_item__bindings_from_for.snap | 10 +++---- ...completion_item__bindings_from_if_let.snap | 14 ++++----- .../completion_item__bindings_from_let.snap | 14 ++++----- ...ompletes_break_and_continue_in_loops1.snap | 30 +++++++++---------- ...ompletes_break_and_continue_in_loops2.snap | 22 +++++++------- ...mpletion_item__deeply_nested_use_tree.snap | 6 ++-- ..._semi_after_return_if_not_a_statement.snap | 22 +++++++------- ...ender_function_parens_if_already_call.snap | 10 +++---- ...nt_render_function_parens_in_use_item.snap | 6 ++-- ...t_show_both_completions_for_shadowing.snap | 10 +++---- ...m__inserts_parens_for_function_calls1.snap | 10 +++---- ...m__inserts_parens_for_function_calls2.snap | 10 +++---- ...ompletion_item__keywords_in_function1.snap | 22 +++++++------- ...ompletion_item__keywords_in_function2.snap | 30 +++++++++---------- ...ompletion_item__keywords_in_function3.snap | 22 +++++++------- ...ompletion_item__keywords_in_function4.snap | 22 +++++++------- ...ompletion_item__keywords_in_use_stmt1.snap | 14 ++++----- ...ompletion_item__keywords_in_use_stmt2.snap | 10 +++---- ...ompletion_item__keywords_in_use_stmt3.snap | 10 +++---- ..._item__last_return_in_block_has_semi1.snap | 22 +++++++------- ..._item__last_return_in_block_has_semi2.snap | 22 +++++++------- .../completion_item__method_completion.snap | 6 ++-- .../completion_item__module_items.snap | 14 ++++----- ..._item__module_items_in_nested_modules.snap | 10 +++---- .../completion_item__nested_use_tree.snap | 10 +++---- ..._no_semi_after_break_continue_in_expr.snap | 30 +++++++++---------- ...ion_item__param_completion_last_param.snap | 6 ++-- ...tion_item__param_completion_nth_param.snap | 6 ++-- ...on_item__param_completion_trait_param.snap | 6 ++-- ...completion_item__reference_completion.snap | 10 +++---- .../completion_item__return_type.snap | 10 +++---- .../completion_item__self_in_methods.snap | 6 ++-- ...pletion_item__snippets_in_expressions.snap | 10 +++---- .../completion_item__snippets_in_items.snap | 10 +++---- ...pletion_item__struct_field_completion.snap | 6 ++-- ...em__struct_field_completion_autoderef.snap | 10 +++---- ...on_item__struct_field_completion_self.snap | 10 +++---- ...on_item__use_item_starting_with_crate.snap | 10 +++---- ...ion_item__use_item_starting_with_self.snap | 6 ++-- crates/ra_lsp_server/src/conv.rs | 11 +++---- 48 files changed, 305 insertions(+), 295 deletions(-) diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index e1c0d26c7d..fb8b2fc88e 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -31,7 +31,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) for field in s.fields(ctx.db) { CompletionItem::new( CompletionKind::Reference, - ctx.leaf_range(), + ctx.source_range(), field.name().to_string(), ) .kind(CompletionItemKind::Field) @@ -45,9 +45,13 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) } Ty::Tuple(fields) => { for (i, _ty) in fields.iter().enumerate() { - CompletionItem::new(CompletionKind::Reference, ctx.leaf_range(), i.to_string()) - .kind(CompletionItemKind::Field) - .add_to(acc); + CompletionItem::new( + CompletionKind::Reference, + ctx.source_range(), + i.to_string(), + ) + .kind(CompletionItemKind::Field) + .add_to(acc); } } _ => {} @@ -61,7 +65,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty if sig.has_self_param() { CompletionItem::new( CompletionKind::Reference, - ctx.leaf_range(), + ctx.source_range(), sig.name().to_string(), ) .from_function(ctx, func) diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs index c3e3ea9310..8d4df4ea15 100644 --- a/crates/ra_ide_api/src/completion/complete_fn_param.rs +++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs @@ -34,7 +34,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) } }) .for_each(|(label, lookup)| { - CompletionItem::new(CompletionKind::Magic, ctx.leaf_range(), label) + CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label) .lookup_by(lookup) .add_to(acc) }); diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs index 006b200765..10ae01bc59 100644 --- a/crates/ra_ide_api/src/completion/complete_keyword.rs +++ b/crates/ra_ide_api/src/completion/complete_keyword.rs @@ -9,26 +9,26 @@ use crate::completion::{CompletionContext, CompletionItem, Completions, Completi pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { // complete keyword "crate" in use stmt - let leaf_range = ctx.leaf_range(); + let source_range = ctx.source_range(); match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) { (Some(_), None) => { - CompletionItem::new(CompletionKind::Keyword, leaf_range, "crate") + CompletionItem::new(CompletionKind::Keyword, source_range, "crate") .kind(CompletionItemKind::Keyword) .insert_text("crate::") .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, leaf_range, "self") + CompletionItem::new(CompletionKind::Keyword, source_range, "self") .kind(CompletionItemKind::Keyword) .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, leaf_range, "super") + CompletionItem::new(CompletionKind::Keyword, source_range, "super") .kind(CompletionItemKind::Keyword) .insert_text("super::") .add_to(acc); } (Some(_), Some(_)) => { - CompletionItem::new(CompletionKind::Keyword, leaf_range, "self") + CompletionItem::new(CompletionKind::Keyword, source_range, "self") .kind(CompletionItemKind::Keyword) .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, leaf_range, "super") + CompletionItem::new(CompletionKind::Keyword, source_range, "super") .kind(CompletionItemKind::Keyword) .insert_text("super::") .add_to(acc); @@ -38,7 +38,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC } fn keyword(ctx: &CompletionContext, kw: &str, snippet: &str) -> CompletionItem { - CompletionItem::new(CompletionKind::Keyword, ctx.leaf_range(), kw) + CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), kw) .kind(CompletionItemKind::Keyword) .snippet(snippet) .build() diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 513a2ee89c..804954ee16 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -17,7 +17,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { for (name, res) in module_scope.entries() { CompletionItem::new( CompletionKind::Reference, - ctx.leaf_range(), + ctx.source_range(), name.to_string(), ) .from_resolution(ctx, res) @@ -30,7 +30,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { .for_each(|(variant_name, _variant)| { CompletionItem::new( CompletionKind::Reference, - ctx.leaf_range(), + ctx.source_range(), variant_name.to_string(), ) .kind(CompletionItemKind::EnumVariant) diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 958a12f226..20fc77f06e 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -31,7 +31,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { .for_each(|(name, res)| { CompletionItem::new( CompletionKind::Reference, - ctx.leaf_range(), + ctx.source_range(), name.to_string(), ) .from_resolution(ctx, res) @@ -52,7 +52,7 @@ fn complete_fn( .for_each(|entry| { CompletionItem::new( CompletionKind::Reference, - ctx.leaf_range(), + ctx.source_range(), entry.name().to_string(), ) .kind(CompletionItemKind::Binding) diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index 4fa23bbf6f..d3344b865b 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs @@ -1,7 +1,7 @@ use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder { - CompletionItem::new(CompletionKind::Snippet, ctx.leaf_range(), label) + CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label) .snippet(snippet) .kind(CompletionItemKind::Snippet) } diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index de9b95c81f..fd4cfc9449 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -65,7 +65,10 @@ impl<'a> CompletionContext<'a> { Some(ctx) } - pub(crate) fn leaf_range(&self) -> TextRange { + // The range of the identifier that is being completed. + // This is purely advisory and can be used, for example, to highlight this range in the editor. + // Clients are expected to ignore this field. + pub(crate) fn source_range(&self) -> TextRange { self.leaf.range() } diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index da8da94d1e..f46d9e5812 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -2,6 +2,7 @@ use hir::PerNs; use crate::completion::completion_context::CompletionContext; use ra_syntax::TextRange; +use ra_text_edit::TextEdit; /// `CompletionItem` describes a single completion variant in the editor pop-up. /// It is basically a POD with various properties. To construct a @@ -17,8 +18,8 @@ pub struct CompletionItem { lookup: Option, insert_text: Option, insert_text_format: InsertTextFormat, - replace_range: TextRange, - delete_range: Option, + source_range: TextRange, + text_edit: Option, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -64,7 +65,7 @@ impl CompletionItem { ) -> Builder { let label = label.into(); Builder { - replace_range, + source_range: replace_range, completion_kind, label, insert_text: None, @@ -72,7 +73,7 @@ impl CompletionItem { detail: None, lookup: None, kind: None, - delete_range: None, + text_edit: None, } } /// What user sees in pop-up in the UI. @@ -103,18 +104,18 @@ impl CompletionItem { pub fn kind(&self) -> Option { self.kind } - pub fn delete_range(&self) -> Option { - self.delete_range + pub fn take_text_edit(&mut self) -> Option { + self.text_edit.take() } - pub fn replace_range(&self) -> TextRange { - self.replace_range + pub fn source_range(&self) -> TextRange { + self.source_range } } /// A helper to make `CompletionItem`s. #[must_use] pub(crate) struct Builder { - replace_range: TextRange, + source_range: TextRange, completion_kind: CompletionKind, label: String, insert_text: Option, @@ -122,7 +123,7 @@ pub(crate) struct Builder { detail: Option, lookup: Option, kind: Option, - delete_range: Option, + text_edit: Option, } impl Builder { @@ -132,14 +133,14 @@ impl Builder { pub(crate) fn build(self) -> CompletionItem { CompletionItem { - replace_range: self.replace_range, + source_range: self.source_range, label: self.label, detail: self.detail, insert_text_format: self.insert_text_format, lookup: self.lookup, kind: self.kind, completion_kind: self.completion_kind, - delete_range: self.delete_range, + text_edit: self.text_edit, insert_text: self.insert_text, } } @@ -165,6 +166,11 @@ impl Builder { self } #[allow(unused)] + pub(crate) fn text_edit(mut self, edit: TextEdit) -> Builder { + self.text_edit = Some(edit); + self + } + #[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 ff8646ab20..132048d9c4 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.674785+00:00 +Created: 2019-01-20T04:00:48.241096+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -28,7 +28,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "quux()$0" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None } ] 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 2176af32d8..e7b628f19f 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.676585+00:00 +Created: 2019-01-20T04:00:48.242456+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [213; 231), - delete_range: None + source_range: [213; 231), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -26,8 +26,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [213; 231), - delete_range: None + source_range: [213; 231), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -41,7 +41,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "quux()$0" ), insert_text_format: Snippet, - replace_range: [213; 231), - delete_range: None + source_range: [213; 231), + text_edit: None } ] 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 49745745dc..403fe0c4c8 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.676674+00:00 +Created: 2019-01-20T04:00:48.243016+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [78; 79), - delete_range: None + source_range: [78; 79), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -26,8 +26,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [78; 79), - delete_range: None + source_range: [78; 79), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -41,7 +41,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "quux($0)" ), insert_text_format: Snippet, - replace_range: [78; 79), - delete_range: None + source_range: [78; 79), + text_edit: None } ] 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 c8a0a78aab..413960191b 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.630898+00:00 +Created: 2019-01-20T04:00:48.206357+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [54; 56), - delete_range: None + source_range: [54; 56), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [54; 56), - delete_range: None + source_range: [54; 56), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [54; 56), - delete_range: None + source_range: [54; 56), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [54; 56), - delete_range: None + source_range: [54; 56), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,8 +75,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "continue;" ), insert_text_format: Snippet, - replace_range: [54; 56), - delete_range: None + source_range: [54; 56), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -90,8 +90,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "break;" ), insert_text_format: Snippet, - replace_range: [54; 56), - delete_range: None + source_range: [54; 56), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -105,7 +105,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return $0;" ), insert_text_format: Snippet, - replace_range: [54; 56), - delete_range: None + source_range: [54; 56), + text_edit: None } ] 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 707021e212..dc2fc95e32 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.647435+00:00 +Created: 2019-01-20T04:00:48.217822+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [59; 61), - delete_range: None + source_range: [59; 61), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [59; 61), - delete_range: None + source_range: [59; 61), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [59; 61), - delete_range: None + source_range: [59; 61), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [59; 61), - delete_range: None + source_range: [59; 61), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,7 +75,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return $0;" ), insert_text_format: Snippet, - replace_range: [59; 61), - delete_range: None + source_range: [59; 61), + text_edit: None } ] 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 a65ab3cc00..26ca189338 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.649286+00:00 +Created: 2019-01-20T04:00:48.217724+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [23; 25), - delete_range: None + source_range: [23; 25), + text_edit: None } ] 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 a935b06f4e..f5ae8c29f6 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.640573+00:00 +Created: 2019-01-20T04:00:48.208392+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [84; 102), - delete_range: None + source_range: [84; 102), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [84; 102), - delete_range: None + source_range: [84; 102), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [84; 102), - delete_range: None + source_range: [84; 102), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [84; 102), - delete_range: None + source_range: [84; 102), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,7 +75,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return $0" ), insert_text_format: Snippet, - replace_range: [84; 102), - delete_range: None + source_range: [84; 102), + text_edit: None } ] 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 abc01d4d61..88c9287fd1 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.670539+00:00 +Created: 2019-01-20T04:00:48.239872+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [35; 39), - delete_range: None + source_range: [35; 39), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -26,7 +26,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [35; 39), - delete_range: None + source_range: [35; 39), + text_edit: None } ] 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 2d3234b2c2..33286e68ba 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.671764+00:00 +Created: 2019-01-20T04:00:48.239894+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [40; 41), - delete_range: None + source_range: [40; 41), + text_edit: None } ] 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 6e4817d1a6..2db0eb7558 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.680378+00:00 +Created: 2019-01-20T04:00:48.248606+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [108; 146), - delete_range: None + source_range: [108; 146), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -28,7 +28,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "foo()$0" ), insert_text_format: Snippet, - replace_range: [108; 146), - delete_range: None + source_range: [108; 146), + text_edit: None } ] 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 4ec75e2ca4..7ae216cd26 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.681170+00:00 +Created: 2019-01-20T04:00:48.249349+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "no_args()$0" ), insert_text_format: Snippet, - replace_range: [53; 56), - delete_range: None + source_range: [53; 56), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -30,7 +30,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "main()$0" ), insert_text_format: Snippet, - replace_range: [53; 56), - delete_range: None + source_range: [53; 56), + text_edit: None } ] 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 11a8f17572..231d75d7a4 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.686781+00:00 +Created: 2019-01-20T04:00:48.255317+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "main()$0" ), insert_text_format: Snippet, - replace_range: [72; 77), - delete_range: None + source_range: [72; 77), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -30,7 +30,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "with_args($0)" ), insert_text_format: Snippet, - replace_range: [72; 77), - delete_range: None + source_range: [72; 77), + text_edit: None } ] 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 02e88a96e0..4d309b20e3 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.640068+00:00 +Created: 2019-01-20T04:00:48.207728+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [24; 54), - delete_range: None + source_range: [24; 54), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [24; 54), - delete_range: None + source_range: [24; 54), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [24; 54), - delete_range: None + source_range: [24; 54), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [24; 54), - delete_range: None + source_range: [24; 54), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,7 +75,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return;" ), insert_text_format: Snippet, - replace_range: [24; 54), - delete_range: None + source_range: [24; 54), + text_edit: None } ] 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 41dc288f6c..0f1e66ac3c 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.640134+00:00 +Created: 2019-01-20T04:00:48.207381+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [91; 105), - delete_range: None + source_range: [91; 105), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [91; 105), - delete_range: None + source_range: [91; 105), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [91; 105), - delete_range: None + source_range: [91; 105), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [91; 105), - delete_range: None + source_range: [91; 105), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,8 +75,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "else {$0}" ), insert_text_format: Snippet, - replace_range: [91; 105), - delete_range: None + source_range: [91; 105), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -90,8 +90,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "else if $0 {}" ), insert_text_format: Snippet, - replace_range: [91; 105), - delete_range: None + source_range: [91; 105), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -105,7 +105,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return;" ), insert_text_format: Snippet, - replace_range: [91; 105), - delete_range: None + source_range: [91; 105), + text_edit: None } ] 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 6cbed012f8..25c29dc18c 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.640767+00:00 +Created: 2019-01-20T04:00:48.211090+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [31; 65), - delete_range: None + source_range: [31; 65), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [31; 65), - delete_range: None + source_range: [31; 65), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [31; 65), - delete_range: None + source_range: [31; 65), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [31; 65), - delete_range: None + source_range: [31; 65), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,7 +75,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return $0;" ), insert_text_format: Snippet, - replace_range: [31; 65), - delete_range: None + source_range: [31; 65), + text_edit: None } ] 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 b95cb72c11..7e43be4b0e 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.664707+00:00 +Created: 2019-01-20T04:00:48.218272+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [24; 58), - delete_range: None + source_range: [24; 58), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [24; 58), - delete_range: None + source_range: [24; 58), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [24; 58), - delete_range: None + source_range: [24; 58), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [24; 58), - delete_range: None + source_range: [24; 58), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,7 +75,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return;" ), insert_text_format: Snippet, - replace_range: [24; 58), - delete_range: None + source_range: [24; 58), + text_edit: None } ] 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 d53c9e72f2..7ed890b74a 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.639067+00:00 +Created: 2019-01-20T04:00:48.207433+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "crate::" ), insert_text_format: PlainText, - replace_range: [16; 30), - delete_range: None + source_range: [16; 30), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -28,8 +28,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [16; 30), - delete_range: None + source_range: [16; 30), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -43,7 +43,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "super::" ), insert_text_format: PlainText, - replace_range: [16; 30), - delete_range: None + source_range: [16; 30), + text_edit: None } ] 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 fee3b6e3b0..8d33629ed6 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.643595+00:00 +Created: 2019-01-20T04:00:48.214287+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [18; 20), - delete_range: None + source_range: [18; 20), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -28,7 +28,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "super::" ), insert_text_format: PlainText, - replace_range: [18; 20), - delete_range: None + source_range: [18; 20), + text_edit: None } ] 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 2181d6c8b2..66ab20f419 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.648502+00:00 +Created: 2019-01-20T04:00:48.217815+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [23; 24), - delete_range: None + source_range: [23; 24), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -28,7 +28,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "super::" ), insert_text_format: PlainText, - replace_range: [23; 24), - delete_range: None + source_range: [23; 24), + text_edit: None } ] 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 6da2c0ea98..2dc47e9b1f 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.640449+00:00 +Created: 2019-01-20T04:00:48.208669+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,7 +75,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return $0;" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None } ] 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 33bc4bb518..59e11c585e 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.649440+00:00 +Created: 2019-01-20T04:00:48.221138+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,7 +75,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return $0;" ), insert_text_format: Snippet, - replace_range: [62; 100), - delete_range: None + source_range: [62; 100), + text_edit: None } ] 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 9081bd50db..44624473e5 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.629020+00:00 +Created: 2019-01-20T04:00:48.203164+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,7 +15,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "the_method($0)" ), insert_text_format: Snippet, - replace_range: [143; 144), - delete_range: None + source_range: [143; 144), + text_edit: None } ] 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 be75ec0b55..9ebb8a3579 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.676740+00:00 +Created: 2019-01-20T04:00:48.243581+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "quux()$0" ), insert_text_format: Snippet, - replace_range: [72; 102), - delete_range: None + source_range: [72; 102), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -28,8 +28,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [72; 102), - delete_range: None + source_range: [72; 102), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -41,7 +41,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [72; 102), - delete_range: None + source_range: [72; 102), + text_edit: None } ] 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 8277a6191f..9b7aa05400 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.677905+00:00 +Created: 2019-01-20T04:00:48.244757+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "quux()$0" ), insert_text_format: Snippet, - replace_range: [100; 102), - delete_range: None + source_range: [100; 102), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -28,7 +28,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [100; 102), - delete_range: None + source_range: [100; 102), + text_edit: None } ] 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 bb2830737c..555f7acc67 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.666350+00:00 +Created: 2019-01-20T04:00:48.222109+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [12; 14), - delete_range: None + source_range: [12; 14), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -26,7 +26,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [12; 14), - delete_range: None + source_range: [12; 14), + text_edit: None } ] 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 8bcf60fa8b..fd56a6c8c0 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.640842+00:00 +Created: 2019-01-20T04:00:48.209867+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "if $0 {}" ), insert_text_format: Snippet, - replace_range: [106; 108), - delete_range: None + source_range: [106; 108), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -30,8 +30,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "match $0 {}" ), insert_text_format: Snippet, - replace_range: [106; 108), - delete_range: None + source_range: [106; 108), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -45,8 +45,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "while $0 {}" ), insert_text_format: Snippet, - replace_range: [106; 108), - delete_range: None + source_range: [106; 108), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -60,8 +60,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "loop {$0}" ), insert_text_format: Snippet, - replace_range: [106; 108), - delete_range: None + source_range: [106; 108), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -75,8 +75,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "continue" ), insert_text_format: Snippet, - replace_range: [106; 108), - delete_range: None + source_range: [106; 108), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -90,8 +90,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "break" ), insert_text_format: Snippet, - replace_range: [106; 108), - delete_range: None + source_range: [106; 108), + text_edit: None }, CompletionItem { completion_kind: Keyword, @@ -105,7 +105,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "return" ), insert_text_format: Snippet, - replace_range: [106; 108), - delete_range: None + source_range: [106; 108), + text_edit: None } ] 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 67a0751296..e0e5929ffb 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.629063+00:00 +Created: 2019-01-20T04:00:48.203211+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), insert_text: None, insert_text_format: PlainText, - replace_range: [98; 102), - delete_range: None + source_range: [98; 102), + text_edit: None } ] 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 7f349ea160..2899cf98e5 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.629062+00:00 +Created: 2019-01-20T04:00:48.203236+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), insert_text: None, insert_text_format: PlainText, - replace_range: [98; 102), - delete_range: None + source_range: [98; 102), + text_edit: None } ] 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 8aa07e2bcc..8a4d9ef635 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.630980+00:00 +Created: 2019-01-20T04:00:48.206552+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs ), insert_text: None, insert_text_format: PlainText, - replace_range: [269; 273), - delete_range: None + source_range: [269; 273), + text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap index 1e69b865fd..404c738bd9 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap @@ -1,4 +1,4 @@ -Created: 2019-01-19T16:37:23.664242+00:00 +Created: 2019-01-20T04:00:48.220278+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [45; 47), - delete_range: None + source_range: [45; 47), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -26,7 +26,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [45; 47), - delete_range: None + source_range: [45; 47), + text_edit: None } ] 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 5d2d018721..6bef3ed95c 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.678426+00:00 +Created: 2019-01-20T04:00:48.245820+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [46; 60), - delete_range: None + source_range: [46; 60), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -28,7 +28,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "x()$0" ), insert_text_format: Snippet, - replace_range: [46; 60), - delete_range: None + source_range: [46; 60), + text_edit: None } ] 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 61ed4d0f2b..56bfe1b0d6 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.679470+00:00 +Created: 2019-01-20T04:00:48.244260+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [24; 26), - delete_range: None + source_range: [24; 26), + text_edit: None } ] 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 10ced4f288..648d7f1899 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.681192+00:00 +Created: 2019-01-20T04:00:48.252281+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "eprintln!(\"$0 = {:?}\", $0);" ), insert_text_format: Snippet, - replace_range: [16; 18), - delete_range: None + source_range: [16; 18), + text_edit: None }, CompletionItem { completion_kind: Snippet, @@ -30,7 +30,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "eprintln!(\"$0 = {:#?}\", $0);" ), insert_text_format: Snippet, - replace_range: [16; 18), - delete_range: None + source_range: [16; 18), + text_edit: None } ] 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 5a87ae357d..f5d0140eaf 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.682017+00:00 +Created: 2019-01-20T04:00:48.253073+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -17,8 +17,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "#[test]\nfn ${1:feature}() {\n $0\n}" ), insert_text_format: Snippet, - replace_range: [49; 79), - delete_range: None + source_range: [49; 79), + text_edit: None }, CompletionItem { completion_kind: Snippet, @@ -32,7 +32,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "pub(crate) $0" ), insert_text_format: Snippet, - replace_range: [49; 79), - delete_range: None + source_range: [49; 79), + text_edit: None } ] 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 6208d04a48..530c76a02c 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.628928+00:00 +Created: 2019-01-20T04:00:48.203121+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,7 +15,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [84; 85), - delete_range: None + source_range: [84; 85), + text_edit: None } ] 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 6de8ada5a4..ec861bf7e0 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.629043+00:00 +Created: 2019-01-20T04:00:48.203230+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [125; 126), - delete_range: None + source_range: [125; 126), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -30,7 +30,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "foo($0)" ), insert_text_format: Snippet, - replace_range: [125; 126), - delete_range: None + source_range: [125; 126), + text_edit: None } ] 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 3e5c4fca90..ee69884c81 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.629041+00:00 +Created: 2019-01-20T04:00:48.203235+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,8 +15,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [120; 121), - delete_range: None + source_range: [120; 121), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -30,7 +30,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "foo($0)" ), insert_text_format: Snippet, - replace_range: [120; 121), - delete_range: None + source_range: [120; 121), + text_edit: None } ] 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 bbec167d5d..29f7f86f1e 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.667522+00:00 +Created: 2019-01-20T04:00:48.223130+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,8 +13,8 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [11; 13), - delete_range: None + source_range: [11; 13), + text_edit: None }, CompletionItem { completion_kind: Reference, @@ -26,7 +26,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [11; 13), - delete_range: None + source_range: [11; 13), + text_edit: None } ] 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 ed571c605d..8b6aca26e7 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,4 +1,4 @@ -Created: 2019-01-19T16:37:23.669476+00:00 +Created: 2019-01-20T04:00:48.225170+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - replace_range: [24; 26), - delete_range: None + source_range: [24; 26), + text_edit: None } ] diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 54a977b7a2..23b226fac7 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -13,7 +13,6 @@ use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use ra_text_edit::{AtomTextEdit, TextEdit}; use crate::{req, server_world::ServerWorld, Result}; -use ra_text_edit::TextEditBuilder; pub trait Conv { type Output; @@ -79,13 +78,11 @@ impl ConvWith for CompletionItem { type Ctx = LineIndex; type Output = ::lsp_types::CompletionItem; - fn conv_with(self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { - let atom_text_edit = AtomTextEdit::replace(self.replace_range(), self.insert_text()); + 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(delete_range) = self.delete_range() { - let mut builder = TextEditBuilder::default(); - builder.delete(delete_range); - Some(builder.finish().conv_with(ctx)) + let additional_text_edits = if let Some(edit) = self.take_text_edit() { + Some(edit.conv_with(ctx)) } else { None }; From ecc5a2e3df178194a25b85f90eb84e4386ed246d Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sun, 20 Jan 2019 13:34:16 +0800 Subject: [PATCH 5/6] workaround for trigger character --- crates/ra_ide_api/src/completion/completion_context.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index fd4cfc9449..7bc2def144 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -69,7 +69,11 @@ impl<'a> CompletionContext<'a> { // This is purely advisory and can be used, for example, to highlight this range in the editor. // Clients are expected to ignore this field. pub(crate) fn source_range(&self) -> TextRange { - self.leaf.range() + match self.leaf.kind() { + // workaroud when completion is triggered by trigger characters. + DOT | COLONCOLON => TextRange::from_to(self.offset, self.offset), + _ => self.leaf.range() + } } fn fill(&mut self, original_file: &'a SourceFile, offset: TextUnit) { From fd8db14c2fcec7801edbdbb8e7f4d4c982a3da09 Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sun, 20 Jan 2019 17:28:10 +0800 Subject: [PATCH 6/6] fix tests --- crates/ra_ide_api/src/completion/completion_context.rs | 2 +- .../snapshots/completion_item__keywords_in_use_stmt2.snap | 6 +++--- .../snapshots/completion_item__method_completion.snap | 4 ++-- .../snapshots/completion_item__reference_completion.snap | 6 +++--- .../snapshots/completion_item__struct_field_completion.snap | 4 ++-- .../completion_item__struct_field_completion_autoderef.snap | 6 +++--- .../completion_item__struct_field_completion_self.snap | 6 +++--- .../completion_item__use_item_starting_with_self.snap | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 7bc2def144..b09c66c18d 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -72,7 +72,7 @@ impl<'a> CompletionContext<'a> { match self.leaf.kind() { // workaroud when completion is triggered by trigger characters. DOT | COLONCOLON => TextRange::from_to(self.offset, self.offset), - _ => self.leaf.range() + _ => self.leaf.range(), } } 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 8d33629ed6..4d4c7af500 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,4 +1,4 @@ -Created: 2019-01-20T04:00:48.214287+00:00 +Created: 2019-01-20T09:26:20.872623+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [18; 20), + source_range: [20; 20), text_edit: None }, CompletionItem { @@ -28,7 +28,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "super::" ), insert_text_format: PlainText, - source_range: [18; 20), + source_range: [20; 20), text_edit: None } ] 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 44624473e5..966148a362 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,4 +1,4 @@ -Created: 2019-01-20T04:00:48.203164+00:00 +Created: 2019-01-20T09:26:20.868112+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,7 +15,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "the_method($0)" ), insert_text_format: Snippet, - source_range: [143; 144), + source_range: [144; 144), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap index 404c738bd9..632d9bbc72 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap @@ -1,4 +1,4 @@ -Created: 2019-01-20T04:00:48.220278+00:00 +Created: 2019-01-20T09:26:20.899262+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [45; 47), + source_range: [47; 47), text_edit: None }, CompletionItem { @@ -26,7 +26,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [45; 47), + source_range: [47; 47), text_edit: None } ] 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 530c76a02c..c88ddbc671 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,4 +1,4 @@ -Created: 2019-01-20T04:00:48.203121+00:00 +Created: 2019-01-20T09:26:20.868146+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,7 +15,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [84; 85), + source_range: [85; 85), text_edit: None } ] 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 ec861bf7e0..f310f523df 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,4 +1,4 @@ -Created: 2019-01-20T04:00:48.203230+00:00 +Created: 2019-01-20T09:26:20.868561+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,7 +15,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [125; 126), + source_range: [126; 126), text_edit: None }, CompletionItem { @@ -30,7 +30,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "foo($0)" ), insert_text_format: Snippet, - source_range: [125; 126), + source_range: [126; 126), text_edit: None } ] 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 ee69884c81..4eae65128d 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,4 +1,4 @@ -Created: 2019-01-20T04:00:48.203235+00:00 +Created: 2019-01-20T09:26:20.868333+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -15,7 +15,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [120; 121), + source_range: [121; 121), text_edit: None }, CompletionItem { @@ -30,7 +30,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs "foo($0)" ), insert_text_format: Snippet, - source_range: [120; 121), + source_range: [121; 121), text_edit: None } ] 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 8b6aca26e7..1a3bd80341 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,4 +1,4 @@ -Created: 2019-01-20T04:00:48.225170+00:00 +Created: 2019-01-20T09:26:20.899584+00:00 Creator: insta@0.1.4 Source: crates/ra_ide_api/src/completion/completion_item.rs @@ -13,7 +13,7 @@ Source: crates/ra_ide_api/src/completion/completion_item.rs lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [24; 26), + source_range: [26; 26), text_edit: None } ]