diff options
Diffstat (limited to 'crates/ide/src/completion/complete_attribute.rs')
-rw-r--r-- | crates/ide/src/completion/complete_attribute.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/crates/ide/src/completion/complete_attribute.rs b/crates/ide/src/completion/complete_attribute.rs index 603d935de..b193c6387 100644 --- a/crates/ide/src/completion/complete_attribute.rs +++ b/crates/ide/src/completion/complete_attribute.rs | |||
@@ -9,6 +9,7 @@ use syntax::{ast, AstNode, SyntaxKind}; | |||
9 | use crate::completion::{ | 9 | use crate::completion::{ |
10 | completion_context::CompletionContext, | 10 | completion_context::CompletionContext, |
11 | completion_item::{CompletionItem, CompletionItemKind, CompletionKind, Completions}, | 11 | completion_item::{CompletionItem, CompletionItemKind, CompletionKind, Completions}, |
12 | UNSTABLE_FEATURE_DESCRIPTOR, | ||
12 | }; | 13 | }; |
13 | 14 | ||
14 | pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { | 15 | pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { |
@@ -17,12 +18,15 @@ pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) | |||
17 | (Some(path), Some(token_tree)) if path.to_string() == "derive" => { | 18 | (Some(path), Some(token_tree)) if path.to_string() == "derive" => { |
18 | complete_derive(acc, ctx, token_tree) | 19 | complete_derive(acc, ctx, token_tree) |
19 | } | 20 | } |
21 | (Some(path), Some(token_tree)) if path.to_string() == "feature" => { | ||
22 | complete_lint(acc, ctx, token_tree, UNSTABLE_FEATURE_DESCRIPTOR) | ||
23 | } | ||
20 | (Some(path), Some(token_tree)) | 24 | (Some(path), Some(token_tree)) |
21 | if ["allow", "warn", "deny", "forbid"] | 25 | if ["allow", "warn", "deny", "forbid"] |
22 | .iter() | 26 | .iter() |
23 | .any(|lint_level| lint_level == &path.to_string()) => | 27 | .any(|lint_level| lint_level == &path.to_string()) => |
24 | { | 28 | { |
25 | complete_lint(acc, ctx, token_tree) | 29 | complete_lint(acc, ctx, token_tree, DEFAULT_LINT_COMPLETIONS) |
26 | } | 30 | } |
27 | (_, Some(_token_tree)) => {} | 31 | (_, Some(_token_tree)) => {} |
28 | _ => complete_attribute_start(acc, ctx, attribute), | 32 | _ => complete_attribute_start(acc, ctx, attribute), |
@@ -162,9 +166,14 @@ fn complete_derive(acc: &mut Completions, ctx: &CompletionContext, derive_input: | |||
162 | } | 166 | } |
163 | } | 167 | } |
164 | 168 | ||
165 | fn complete_lint(acc: &mut Completions, ctx: &CompletionContext, derive_input: ast::TokenTree) { | 169 | fn complete_lint( |
170 | acc: &mut Completions, | ||
171 | ctx: &CompletionContext, | ||
172 | derive_input: ast::TokenTree, | ||
173 | lints_completions: &[LintCompletion], | ||
174 | ) { | ||
166 | if let Ok(existing_lints) = parse_comma_sep_input(derive_input) { | 175 | if let Ok(existing_lints) = parse_comma_sep_input(derive_input) { |
167 | for lint_completion in DEFAULT_LINT_COMPLETIONS | 176 | for lint_completion in lints_completions |
168 | .into_iter() | 177 | .into_iter() |
169 | .filter(|completion| !existing_lints.contains(completion.label)) | 178 | .filter(|completion| !existing_lints.contains(completion.label)) |
170 | { | 179 | { |
@@ -228,7 +237,7 @@ fn get_derive_names_in_scope(ctx: &CompletionContext) -> FxHashSet<String> { | |||
228 | result | 237 | result |
229 | } | 238 | } |
230 | 239 | ||
231 | struct DeriveCompletion { | 240 | pub(crate) struct DeriveCompletion { |
232 | label: &'static str, | 241 | label: &'static str, |
233 | dependencies: &'static [&'static str], | 242 | dependencies: &'static [&'static str], |
234 | } | 243 | } |
@@ -248,9 +257,9 @@ const DEFAULT_DERIVE_COMPLETIONS: &[DeriveCompletion] = &[ | |||
248 | DeriveCompletion { label: "Ord", dependencies: &["PartialOrd", "Eq", "PartialEq"] }, | 257 | DeriveCompletion { label: "Ord", dependencies: &["PartialOrd", "Eq", "PartialEq"] }, |
249 | ]; | 258 | ]; |
250 | 259 | ||
251 | struct LintCompletion { | 260 | pub(crate) struct LintCompletion { |
252 | label: &'static str, | 261 | pub(crate) label: &'static str, |
253 | description: &'static str, | 262 | pub(crate) description: &'static str, |
254 | } | 263 | } |
255 | 264 | ||
256 | #[rustfmt::skip] | 265 | #[rustfmt::skip] |