mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:23 +00:00
[ty] Add LSP debug information command (#20379)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
12086dfa69
commit
eb354608d2
10 changed files with 458 additions and 1 deletions
|
@ -463,7 +463,7 @@ impl From<&'static LintMetadata> for LintEntry {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, get_size2::GetSize)]
|
||||
#[derive(Clone, Default, PartialEq, Eq, get_size2::GetSize)]
|
||||
pub struct RuleSelection {
|
||||
/// Map with the severity for each enabled lint rule.
|
||||
///
|
||||
|
@ -541,6 +541,35 @@ impl RuleSelection {
|
|||
}
|
||||
}
|
||||
|
||||
// The default `LintId` debug implementation prints the entire lint metadata.
|
||||
// This is way too verbose.
|
||||
impl fmt::Debug for RuleSelection {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
let lints = self.lints.iter().sorted_by_key(|(lint, _)| lint.name);
|
||||
|
||||
if f.alternate() {
|
||||
let mut f = f.debug_map();
|
||||
|
||||
for (lint, (severity, source)) in lints {
|
||||
f.entry(
|
||||
&lint.name().as_str(),
|
||||
&format_args!("{severity:?} ({source:?})"),
|
||||
);
|
||||
}
|
||||
|
||||
f.finish()
|
||||
} else {
|
||||
let mut f = f.debug_set();
|
||||
|
||||
for (lint, _) in lints {
|
||||
f.entry(&lint.name());
|
||||
}
|
||||
|
||||
f.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq, get_size2::GetSize)]
|
||||
pub enum LintSource {
|
||||
/// The user didn't enable the rule explicitly, instead it's enabled by default.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue