diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-03 23:02:09 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-03 23:02:09 +0100 |
commit | fe16e1da695589d55f13b36644b7a56be7d09a48 (patch) | |
tree | c71705b63e971b5ddf05d1077c09f2f54e46093a /crates/ra_ide/src/completion/complete_keyword.rs | |
parent | f6bff05f2adfabae41ce9d2c5dabc2fb35ad21de (diff) | |
parent | cda1a6c63860013ff43f34c68532db41abc30516 (diff) |
Merge #5215
5215: Cleanup more completion tests r=matklad a=matklad
bors r+
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/completion/complete_keyword.rs')
-rw-r--r-- | crates/ra_ide/src/completion/complete_keyword.rs | 31 |
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 | ||
3 | use ra_syntax::{ast, SyntaxKind}; | 3 | use ra_syntax::{ast, SyntaxKind}; |
4 | use test_utils::mark; | ||
4 | 5 | ||
5 | use crate::completion::{ | 6 | use 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 | ||
39 | pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { | 40 | pub(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#" | ||
471 | fn test() { | ||
472 | let x = 2; // A comment<|> | ||
473 | } | ||
474 | "#, | ||
475 | expect![[""]], | ||
476 | ); | ||
477 | check( | ||
478 | r#" | ||
479 | /* | ||
480 | Some 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 | } |