From 6d253b58da955cee73b0715b91d728df5009937d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 7 Nov 2018 21:38:41 +0300 Subject: Complete paths in use trees --- crates/ra_analysis/tests/tests.rs | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'crates/ra_analysis/tests/tests.rs') diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs index c605d34f0..719c166b5 100644 --- a/crates/ra_analysis/tests/tests.rs +++ b/crates/ra_analysis/tests/tests.rs @@ -452,3 +452,44 @@ fn test_complete_crate_path() { &completions, ); } + +#[test] +fn test_complete_crate_path_with_braces() { + let (analysis, position) = analysis_and_position( + " + //- /lib.rs + mod foo; + struct Spam; + //- /foo.rs + use crate::{Sp<|>}; + ", + ); + let completions = analysis.completions(position).unwrap().unwrap(); + assert_eq_dbg( + r#"[CompletionItem { label: "foo", lookup: None, snippet: None }, + CompletionItem { label: "Spam", lookup: None, snippet: None }]"#, + &completions, + ); +} + +#[test] +fn test_complete_crate_path_in_nested_tree() { + let (analysis, position) = analysis_and_position( + " + //- /lib.rs + mod foo; + pub mod bar { + pub mod baz { + pub struct Spam; + } + } + //- /foo.rs + use crate::{bar::{baz::Sp<|>}}; + ", + ); + let completions = analysis.completions(position).unwrap().unwrap(); + assert_eq_dbg( + r#"[CompletionItem { label: "Spam", lookup: None, snippet: None }]"#, + &completions, + ); +} -- cgit v1.2.3