From 3c7c5a7354760a12b38c7186193232d68056a76e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Feb 2019 19:37:22 +0300 Subject: move presentaion completion to presentation --- .../ra_ide_api/src/completion/completion_item.rs | 80 ---------------------- crates/ra_ide_api/src/completion/presentation.rs | 80 ++++++++++++++++++++++ 2 files changed, 80 insertions(+), 80 deletions(-) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 95bdd59b4..91e32b3c8 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -411,83 +411,3 @@ pub(crate) fn check_completion(test_name: &str, code: &str, kind: CompletionKind let kind_completions = do_completion(code, kind); assert_debug_snapshot_matches!(test_name, kind_completions); } - -#[cfg(test)] -mod tests { - use test_utils::covers; - - use super::*; - - fn check_reference_completion(code: &str, expected_completions: &str) { - check_completion(code, expected_completions, CompletionKind::Reference); - } - - #[test] - fn inserts_parens_for_function_calls() { - covers!(inserts_parens_for_function_calls); - check_reference_completion( - "inserts_parens_for_function_calls1", - r" - fn no_args() {} - fn main() { no_<|> } - ", - ); - check_reference_completion( - "inserts_parens_for_function_calls2", - r" - fn with_args(x: i32, y: String) {} - fn main() { with_<|> } - ", - ); - check_reference_completion( - "inserts_parens_for_function_calls3", - r" - struct S {} - impl S { - fn foo(&self) {} - } - fn bar(s: &S) { - s.f<|> - } - ", - ) - } - - #[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<|>; - ", - ) - } - - #[test] - fn dont_render_function_parens_if_already_call() { - check_reference_completion( - "dont_render_function_parens_if_already_call", - " - //- /lib.rs - fn frobnicate() {} - fn main() { - frob<|>(); - } - ", - ); - check_reference_completion( - "dont_render_function_parens_if_already_call_assoc_fn", - " - //- /lib.rs - struct Foo {} - impl Foo { fn new() -> Foo {} } - fn main() { - Foo::ne<|>(); - } - ", - ) - } - -} diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 9c31a3801..057dbc21a 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -70,3 +70,83 @@ fn function_item_label(ctx: &CompletionContext, function: hir::Function) -> Opti let node = function.source(ctx.db).1; function_label(&node) } + +#[cfg(test)] +mod tests { + use test_utils::covers; + + use crate::completion::{CompletionKind, completion_item::check_completion}; + + fn check_reference_completion(code: &str, expected_completions: &str) { + check_completion(code, expected_completions, CompletionKind::Reference); + } + + #[test] + fn inserts_parens_for_function_calls() { + covers!(inserts_parens_for_function_calls); + check_reference_completion( + "inserts_parens_for_function_calls1", + r" + fn no_args() {} + fn main() { no_<|> } + ", + ); + check_reference_completion( + "inserts_parens_for_function_calls2", + r" + fn with_args(x: i32, y: String) {} + fn main() { with_<|> } + ", + ); + check_reference_completion( + "inserts_parens_for_function_calls3", + r" + struct S {} + impl S { + fn foo(&self) {} + } + fn bar(s: &S) { + s.f<|> + } + ", + ) + } + + #[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<|>; + ", + ) + } + + #[test] + fn dont_render_function_parens_if_already_call() { + check_reference_completion( + "dont_render_function_parens_if_already_call", + " + //- /lib.rs + fn frobnicate() {} + fn main() { + frob<|>(); + } + ", + ); + check_reference_completion( + "dont_render_function_parens_if_already_call_assoc_fn", + " + //- /lib.rs + struct Foo {} + impl Foo { fn new() -> Foo {} } + fn main() { + Foo::ne<|>(); + } + ", + ) + } + +} -- cgit v1.2.3