diff options
author | Igor Aleksanov <[email protected]> | 2020-10-12 08:59:15 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-10-17 08:27:59 +0100 |
commit | 70157f07d9a33e4b8ed71e162218a793f44a7691 (patch) | |
tree | 26f9d4c06ac0428c0a35450dd305d9076b89e2fe /crates/ide/src/completion/patterns.rs | |
parent | 59483c217662fc5d89ef9da1cb93760e14a48418 (diff) |
Remove redundant completions
Diffstat (limited to 'crates/ide/src/completion/patterns.rs')
-rw-r--r-- | crates/ide/src/completion/patterns.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/ide/src/completion/patterns.rs b/crates/ide/src/completion/patterns.rs index b17ddf133..76fcad631 100644 --- a/crates/ide/src/completion/patterns.rs +++ b/crates/ide/src/completion/patterns.rs | |||
@@ -116,6 +116,25 @@ pub(crate) fn if_is_prev(element: SyntaxElement) -> bool { | |||
116 | .is_some() | 116 | .is_some() |
117 | } | 117 | } |
118 | 118 | ||
119 | pub(crate) fn fn_is_prev(element: SyntaxElement) -> bool { | ||
120 | element | ||
121 | .into_token() | ||
122 | .and_then(|it| previous_non_trivia_token(it)) | ||
123 | .filter(|it| it.kind() == FN_KW) | ||
124 | .is_some() | ||
125 | } | ||
126 | |||
127 | /// Check if the token previous to the previous one is `for`. | ||
128 | /// For example, `for _ i<|>` => true. | ||
129 | pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool { | ||
130 | element | ||
131 | .into_token() | ||
132 | .and_then(|it| previous_non_trivia_token(it)) | ||
133 | .and_then(|it| previous_non_trivia_token(it)) | ||
134 | .filter(|it| it.kind() == FOR_KW) | ||
135 | .is_some() | ||
136 | } | ||
137 | |||
119 | #[test] | 138 | #[test] |
120 | fn test_if_is_prev() { | 139 | fn test_if_is_prev() { |
121 | check_pattern_is_applicable(r"if l<|>", if_is_prev); | 140 | check_pattern_is_applicable(r"if l<|>", if_is_prev); |