11035: Include clippy lint groups in autocomplete r=Veykril a=k-nasa

## Why

close: https://github.com/rust-analyzer/rust-analyzer/issues/11027

## Proof

I confirmed that complement candidates are coming out.

https://user-images.githubusercontent.com/23740172/146465758-bc7d5cdd-e2fb-48d6-abf7-804ba859c9b1.mov


Co-authored-by: k-nasa <htilcs1115@gmail.com>
This commit is contained in:
bors[bot] 2021-12-18 17:59:29 +00:00 committed by GitHub
commit 81d0096000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 194 additions and 994 deletions

View File

@ -6,7 +6,9 @@
use ide_db::{
helpers::{
generated_lints::{CLIPPY_LINTS, DEFAULT_LINTS, FEATURES, RUSTDOC_LINTS},
generated_lints::{
Lint, CLIPPY_LINTS, CLIPPY_LINT_GROUPS, DEFAULT_LINTS, FEATURES, RUSTDOC_LINTS,
},
parse_tt_as_comma_sep_paths,
},
SymbolKind,
@ -36,9 +38,17 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
"feature" => lint::complete_lint(acc, ctx, &parse_tt_as_comma_sep_paths(tt)?, FEATURES),
"allow" | "warn" | "deny" | "forbid" => {
let existing_lints = parse_tt_as_comma_sep_paths(tt)?;
lint::complete_lint(acc, ctx, &existing_lints, DEFAULT_LINTS);
lint::complete_lint(acc, ctx, &existing_lints, CLIPPY_LINTS);
lint::complete_lint(acc, ctx, &existing_lints, RUSTDOC_LINTS);
let lints: Vec<Lint> = CLIPPY_LINT_GROUPS
.iter()
.map(|g| &g.lint)
.chain(DEFAULT_LINTS.iter())
.chain(CLIPPY_LINTS.iter())
.chain(RUSTDOC_LINTS)
.cloned()
.collect();
lint::complete_lint(acc, ctx, &existing_lints, &lints);
}
"cfg" => {
cfg::complete_cfg(acc, ctx);

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@ fn sourcegen_lint_completions() {
let mut contents = String::from(
r"
#[derive(Clone)]
pub struct Lint {
pub label: &'static str,
pub description: &'static str,