[ty] Add LSP debug information command (#20379)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
GF 2025-09-20 11:15:13 +00:00 committed by GitHub
parent 12086dfa69
commit eb354608d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 458 additions and 1 deletions

View file

@ -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.