Skip to content

Commit 722489e

Browse files
committed
Remove filtered completion list usage in completion tests
1 parent 142b6dc commit 722489e

File tree

14 files changed

+1746
-1346
lines changed

14 files changed

+1746
-1346
lines changed

crates/ide_completion/src/completions/dot.rs

Lines changed: 359 additions & 12 deletions
Large diffs are not rendered by default.

crates/ide_completion/src/completions/flyimport.rs

Lines changed: 0 additions & 1015 deletions
Large diffs are not rendered by default.

crates/ide_completion/src/completions/keyword.rs

Lines changed: 29 additions & 266 deletions
Original file line numberDiff line numberDiff line change
@@ -181,115 +181,15 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet
181181
mod tests {
182182
use expect_test::{expect, Expect};
183183

184-
use crate::{
185-
tests::{check_edit, filtered_completion_list},
186-
CompletionKind,
187-
};
184+
use crate::tests::{check_edit, completion_list};
188185

189186
fn check(ra_fixture: &str, expect: Expect) {
190-
let actual = filtered_completion_list(ra_fixture, CompletionKind::Keyword);
187+
let actual = completion_list(ra_fixture);
191188
expect.assert_eq(&actual)
192189
}
193190

194191
#[test]
195-
fn test_keywords_in_function() {
196-
check(
197-
r"fn quux() { $0 }",
198-
expect![[r#"
199-
kw unsafe
200-
kw fn
201-
kw const
202-
kw type
203-
kw impl
204-
kw extern
205-
kw use
206-
kw trait
207-
kw static
208-
kw mod
209-
kw match
210-
kw while
211-
kw while let
212-
kw loop
213-
kw if
214-
kw if let
215-
kw for
216-
kw true
217-
kw false
218-
kw let
219-
kw return
220-
kw self
221-
kw super
222-
kw crate
223-
"#]],
224-
);
225-
}
226-
227-
#[test]
228-
fn test_keywords_inside_block() {
229-
check(
230-
r"fn quux() { if true { $0 } }",
231-
expect![[r#"
232-
kw unsafe
233-
kw fn
234-
kw const
235-
kw type
236-
kw impl
237-
kw extern
238-
kw use
239-
kw trait
240-
kw static
241-
kw mod
242-
kw match
243-
kw while
244-
kw while let
245-
kw loop
246-
kw if
247-
kw if let
248-
kw for
249-
kw true
250-
kw false
251-
kw let
252-
kw return
253-
kw self
254-
kw super
255-
kw crate
256-
"#]],
257-
);
258-
}
259-
260-
#[test]
261-
fn test_keywords_after_if() {
262-
check(
263-
r#"fn quux() { if true { () } $0 }"#,
264-
expect![[r#"
265-
kw unsafe
266-
kw fn
267-
kw const
268-
kw type
269-
kw impl
270-
kw extern
271-
kw use
272-
kw trait
273-
kw static
274-
kw mod
275-
kw match
276-
kw while
277-
kw while let
278-
kw loop
279-
kw if
280-
kw if let
281-
kw for
282-
kw true
283-
kw false
284-
kw let
285-
kw else
286-
kw else if
287-
kw return
288-
kw self
289-
kw super
290-
kw crate
291-
"#]],
292-
);
192+
fn test_else_edit_after_if() {
293193
check_edit(
294194
"else",
295195
r#"fn quux() { if true { () } $0 }"#,
@@ -299,68 +199,6 @@ mod tests {
299199
);
300200
}
301201

302-
#[test]
303-
fn test_keywords_in_match_arm() {
304-
check(
305-
r#"
306-
fn quux() -> i32 {
307-
match () { () => $0 }
308-
}
309-
"#,
310-
expect![[r#"
311-
kw unsafe
312-
kw match
313-
kw while
314-
kw while let
315-
kw loop
316-
kw if
317-
kw if let
318-
kw for
319-
kw true
320-
kw false
321-
kw return
322-
kw self
323-
kw super
324-
kw crate
325-
"#]],
326-
);
327-
}
328-
329-
#[test]
330-
fn test_keywords_in_loop() {
331-
check(
332-
r"fn my() { loop { $0 } }",
333-
expect![[r#"
334-
kw unsafe
335-
kw fn
336-
kw const
337-
kw type
338-
kw impl
339-
kw extern
340-
kw use
341-
kw trait
342-
kw static
343-
kw mod
344-
kw match
345-
kw while
346-
kw while let
347-
kw loop
348-
kw if
349-
kw if let
350-
kw for
351-
kw true
352-
kw false
353-
kw let
354-
kw continue
355-
kw break
356-
kw return
357-
kw self
358-
kw super
359-
kw crate
360-
"#]],
361-
);
362-
}
363-
364202
#[test]
365203
fn test_keywords_after_unsafe_in_block_expr() {
366204
check(
@@ -369,38 +207,12 @@ fn quux() -> i32 {
369207
kw fn
370208
kw trait
371209
kw impl
210+
sn pd
211+
sn ppd
372212
"#]],
373213
);
374214
}
375215

376-
#[test]
377-
fn no_keyword_completion_in_comments() {
378-
cov_mark::check!(no_keyword_completion_in_comments);
379-
check(
380-
r#"
381-
fn test() {
382-
let x = 2; // A comment$0
383-
}
384-
"#,
385-
expect![[""]],
386-
);
387-
check(
388-
r#"
389-
/*
390-
Some multi-line comment$0
391-
*/
392-
"#,
393-
expect![[""]],
394-
);
395-
check(
396-
r#"
397-
/// Some doc comment
398-
/// let test$0 = 1
399-
"#,
400-
expect![[""]],
401-
);
402-
}
403-
404216
#[test]
405217
fn test_completion_await_impls_future() {
406218
check(
@@ -413,6 +225,18 @@ fn foo(a: A) { a.$0 }
413225
"#,
414226
expect![[r#"
415227
kw await expr.await
228+
sn ref &expr
229+
sn refm &mut expr
230+
sn match match expr {}
231+
sn box Box::new(expr)
232+
sn ok Ok(expr)
233+
sn err Err(expr)
234+
sn some Some(expr)
235+
sn dbg dbg!(expr)
236+
sn dbgr dbg!(&expr)
237+
sn call function(expr)
238+
sn let let
239+
sn letm let mut
416240
"#]],
417241
);
418242

@@ -427,83 +251,22 @@ fn foo() {
427251
"#,
428252
expect![[r#"
429253
kw await expr.await
254+
sn ref &expr
255+
sn refm &mut expr
256+
sn match match expr {}
257+
sn box Box::new(expr)
258+
sn ok Ok(expr)
259+
sn err Err(expr)
260+
sn some Some(expr)
261+
sn dbg dbg!(expr)
262+
sn dbgr dbg!(&expr)
263+
sn call function(expr)
264+
sn let let
265+
sn letm let mut
430266
"#]],
431267
)
432268
}
433269

434-
#[test]
435-
fn after_let() {
436-
check(
437-
r#"fn main() { let _ = $0 }"#,
438-
expect![[r#"
439-
kw unsafe
440-
kw match
441-
kw while
442-
kw while let
443-
kw loop
444-
kw if
445-
kw if let
446-
kw for
447-
kw true
448-
kw false
449-
kw return
450-
kw self
451-
kw super
452-
kw crate
453-
"#]],
454-
)
455-
}
456-
457-
#[test]
458-
fn skip_struct_initializer() {
459-
cov_mark::check!(no_keyword_completion_in_record_lit);
460-
check(
461-
r#"
462-
struct Foo {
463-
pub f: i32,
464-
}
465-
fn foo() {
466-
Foo {
467-
$0
468-
}
469-
}
470-
"#,
471-
expect![[r#""#]],
472-
);
473-
}
474-
475-
#[test]
476-
fn struct_initializer_field_expr() {
477-
check(
478-
r#"
479-
struct Foo {
480-
pub f: i32,
481-
}
482-
fn foo() {
483-
Foo {
484-
f: $0
485-
}
486-
}
487-
"#,
488-
expect![[r#"
489-
kw unsafe
490-
kw match
491-
kw while
492-
kw while let
493-
kw loop
494-
kw if
495-
kw if let
496-
kw for
497-
kw true
498-
kw false
499-
kw return
500-
kw self
501-
kw super
502-
kw crate
503-
"#]],
504-
);
505-
}
506-
507270
#[test]
508271
fn let_semi() {
509272
cov_mark::check!(let_semi);

crates/ide_completion/src/completions/mod_.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ fn module_chain_to_containing_module_file(
141141

142142
#[cfg(test)]
143143
mod tests {
144-
use crate::tests::completion_list;
145144
use expect_test::{expect, Expect};
146145

146+
use crate::tests::completion_list;
147+
147148
fn check(ra_fixture: &str, expect: Expect) {
148149
let actual = completion_list(ra_fixture);
149150
expect.assert_eq(&actual);

crates/ide_completion/src/completions/postfix.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ mod tests {
270270
use expect_test::{expect, Expect};
271271

272272
use crate::{
273-
tests::{check_edit, check_edit_with_config, filtered_completion_list, TEST_CONFIG},
274-
CompletionConfig, CompletionKind, Snippet,
273+
tests::{check_edit, check_edit_with_config, completion_list, TEST_CONFIG},
274+
CompletionConfig, Snippet,
275275
};
276276

277277
fn check(ra_fixture: &str, expect: Expect) {
278-
let actual = filtered_completion_list(ra_fixture, CompletionKind::Postfix);
278+
let actual = completion_list(ra_fixture);
279279
expect.assert_eq(&actual)
280280
}
281281

crates/ide_completion/src/completions/qualified_path.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,10 @@ fn add_enum_variants(acc: &mut Completions, ctx: &CompletionContext, e: hir::Enu
250250
mod tests {
251251
use expect_test::{expect, Expect};
252252

253-
use crate::{
254-
tests::{check_edit, filtered_completion_list},
255-
CompletionKind,
256-
};
253+
use crate::tests::{check_edit, completion_list_no_kw};
257254

258255
fn check(ra_fixture: &str, expect: Expect) {
259-
let actual = filtered_completion_list(ra_fixture, CompletionKind::Reference);
256+
let actual = completion_list_no_kw(ra_fixture);
260257
expect.assert_eq(&actual);
261258
}
262259

0 commit comments

Comments
 (0)