mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 23:25:03 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
22c8c9c401
commit
8231fee466
111 changed files with 5796 additions and 5130 deletions
|
@ -50,6 +50,7 @@ mod handlers {
|
|||
pub(crate) mod field_shorthand;
|
||||
pub(crate) mod useless_braces;
|
||||
pub(crate) mod unlinked_file;
|
||||
pub(crate) mod json_is_not_rust;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -59,6 +60,7 @@ use hir::{diagnostics::AnyDiagnostic, InFile, Semantics};
|
|||
use ide_db::{
|
||||
assists::{Assist, AssistId, AssistKind, AssistResolveStrategy},
|
||||
base_db::{FileId, FileRange, SourceDatabase},
|
||||
imports::insert_use::InsertUseConfig,
|
||||
label::Label,
|
||||
source_change::SourceChange,
|
||||
FxHashSet, RootDatabase,
|
||||
|
@ -139,13 +141,37 @@ impl Default for ExprFillDefaultMode {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DiagnosticsConfig {
|
||||
pub proc_macros_enabled: bool,
|
||||
pub proc_attr_macros_enabled: bool,
|
||||
pub disable_experimental: bool,
|
||||
pub disabled: FxHashSet<String>,
|
||||
pub expr_fill_default: ExprFillDefaultMode,
|
||||
// FIXME: We may want to include a whole `AssistConfig` here
|
||||
pub insert_use: InsertUseConfig,
|
||||
}
|
||||
|
||||
impl DiagnosticsConfig {
|
||||
pub fn test_sample() -> Self {
|
||||
use hir::PrefixKind;
|
||||
use ide_db::imports::insert_use::ImportGranularity;
|
||||
|
||||
Self {
|
||||
proc_macros_enabled: Default::default(),
|
||||
proc_attr_macros_enabled: Default::default(),
|
||||
disable_experimental: Default::default(),
|
||||
disabled: Default::default(),
|
||||
expr_fill_default: Default::default(),
|
||||
insert_use: InsertUseConfig {
|
||||
granularity: ImportGranularity::Preserve,
|
||||
enforce_granularity: false,
|
||||
prefix_kind: PrefixKind::Plain,
|
||||
group: false,
|
||||
skip_glob_imports: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DiagnosticsContext<'a> {
|
||||
|
@ -172,9 +198,12 @@ pub fn diagnostics(
|
|||
}),
|
||||
);
|
||||
|
||||
for node in parse.tree().syntax().descendants() {
|
||||
let parse = sema.parse(file_id);
|
||||
|
||||
for node in parse.syntax().descendants() {
|
||||
handlers::useless_braces::useless_braces(&mut res, file_id, &node);
|
||||
handlers::field_shorthand::field_shorthand(&mut res, file_id, &node);
|
||||
handlers::json_is_not_rust::json_in_items(&sema, &mut res, file_id, &node, &config);
|
||||
}
|
||||
|
||||
let module = sema.to_module_def(file_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue