aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/test_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/completion/src/test_utils.rs')
-rw-r--r--crates/completion/src/test_utils.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/crates/completion/src/test_utils.rs b/crates/completion/src/test_utils.rs
index b5e296777..6ea6da989 100644
--- a/crates/completion/src/test_utils.rs
+++ b/crates/completion/src/test_utils.rs
@@ -1,9 +1,12 @@
1//! Runs completion for testing purposes. 1//! Runs completion for testing purposes.
2 2
3use hir::Semantics; 3use hir::{PrefixKind, Semantics};
4use ide_db::{ 4use ide_db::{
5 base_db::{fixture::ChangeFixture, FileLoader, FilePosition}, 5 base_db::{fixture::ChangeFixture, FileLoader, FilePosition},
6 helpers::{insert_use::MergeBehavior, SnippetCap}, 6 helpers::{
7 insert_use::{InsertUseConfig, MergeBehavior},
8 SnippetCap,
9 },
7 RootDatabase, 10 RootDatabase,
8}; 11};
9use itertools::Itertools; 12use itertools::Itertools;
@@ -19,15 +22,18 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
19 add_call_parenthesis: true, 22 add_call_parenthesis: true,
20 add_call_argument_snippets: true, 23 add_call_argument_snippets: true,
21 snippet_cap: SnippetCap::new(true), 24 snippet_cap: SnippetCap::new(true),
22 merge: Some(MergeBehavior::Full), 25 insert_use: InsertUseConfig {
26 merge: Some(MergeBehavior::Full),
27 prefix_kind: PrefixKind::Plain,
28 },
23}; 29};
24 30
25/// Creates analysis from a multi-file fixture, returns positions marked with <|>. 31/// Creates analysis from a multi-file fixture, returns positions marked with $0.
26pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { 32pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
27 let change_fixture = ChangeFixture::parse(ra_fixture); 33 let change_fixture = ChangeFixture::parse(ra_fixture);
28 let mut database = RootDatabase::default(); 34 let mut database = RootDatabase::default();
29 database.apply_change(change_fixture.change); 35 database.apply_change(change_fixture.change);
30 let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); 36 let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
31 let offset = match range_or_offset { 37 let offset = match range_or_offset {
32 RangeOrOffset::Range(_) => panic!(), 38 RangeOrOffset::Range(_) => panic!(),
33 RangeOrOffset::Offset(it) => it, 39 RangeOrOffset::Offset(it) => it,
@@ -110,7 +116,7 @@ pub(crate) fn check_edit_with_config(
110 116
111 let mut combined_edit = completion.text_edit().to_owned(); 117 let mut combined_edit = completion.text_edit().to_owned();
112 if let Some(import_text_edit) = 118 if let Some(import_text_edit) =
113 completion.import_to_add().and_then(|edit| edit.to_text_edit(config.merge)) 119 completion.import_to_add().and_then(|edit| edit.to_text_edit(config.insert_use.merge))
114 { 120 {
115 combined_edit.union(import_text_edit).expect( 121 combined_edit.union(import_text_edit).expect(
116 "Failed to apply completion resolve changes: change ranges overlap, but should not", 122 "Failed to apply completion resolve changes: change ranges overlap, but should not",