aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/complete_keyword.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-03 22:46:36 +0100
committerAleksey Kladov <[email protected]>2020-07-03 23:01:45 +0100
commitcda1a6c63860013ff43f34c68532db41abc30516 (patch)
treec71705b63e971b5ddf05d1077c09f2f54e46093a /crates/ra_ide/src/completion/complete_keyword.rs
parent9f9b38bdb47f6301fc01287fbe8dc1256c44fe08 (diff)
Cleanup more completion tests
Diffstat (limited to 'crates/ra_ide/src/completion/complete_keyword.rs')
-rw-r--r--crates/ra_ide/src/completion/complete_keyword.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs
index 34d061f5a..086b917ce 100644
--- a/crates/ra_ide/src/completion/complete_keyword.rs
+++ b/crates/ra_ide/src/completion/complete_keyword.rs
@@ -1,6 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use ra_syntax::{ast, SyntaxKind}; 3use ra_syntax::{ast, SyntaxKind};
4use test_utils::mark;
4 5
5use crate::completion::{ 6use crate::completion::{
6 CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, 7 CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions,
@@ -38,6 +39,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
38 39
39pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { 40pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) {
40 if ctx.token.kind() == SyntaxKind::COMMENT { 41 if ctx.token.kind() == SyntaxKind::COMMENT {
42 mark::hit!(no_keyword_completion_in_comments);
41 return; 43 return;
42 } 44 }
43 45
@@ -180,6 +182,7 @@ mod tests {
180 test_utils::{check_edit, completion_list}, 182 test_utils::{check_edit, completion_list},
181 CompletionKind, 183 CompletionKind,
182 }; 184 };
185 use test_utils::mark;
183 186
184 fn check(ra_fixture: &str, expect: Expect) { 187 fn check(ra_fixture: &str, expect: Expect) {
185 let actual = completion_list(ra_fixture, CompletionKind::Keyword); 188 let actual = completion_list(ra_fixture, CompletionKind::Keyword);
@@ -459,4 +462,32 @@ fn quux() -> i32 {
459 "#]], 462 "#]],
460 ); 463 );
461 } 464 }
465
466 #[test]
467 fn no_keyword_completion_in_comments() {
468 mark::check!(no_keyword_completion_in_comments);
469 check(
470 r#"
471fn test() {
472 let x = 2; // A comment<|>
473}
474"#,
475 expect![[""]],
476 );
477 check(
478 r#"
479/*
480Some multi-line comment<|>
481*/
482"#,
483 expect![[""]],
484 );
485 check(
486 r#"
487/// Some doc comment
488/// let test<|> = 1
489"#,
490 expect![[""]],
491 );
492 }
462} 493}