Show diagnostic codes (#29296)
Closes #28135 Closes #4388 Closes #28136 Release Notes: - diagnostics: Show the diagnostic code if available --------- Co-authored-by: Neo Nie <nihgwu@live.com> Co-authored-by: Zed AI <ai+claude-3.7@zed.dev>
This commit is contained in:
parent
8836c6fb42
commit
9d10489607
13 changed files with 517 additions and 327 deletions
|
@ -208,6 +208,7 @@ pub struct Diagnostic {
|
|||
pub source: Option<String>,
|
||||
/// A machine-readable code that identifies this diagnostic.
|
||||
pub code: Option<NumberOrString>,
|
||||
pub code_description: Option<lsp::Url>,
|
||||
/// Whether this diagnostic is a hint, warning, or error.
|
||||
pub severity: DiagnosticSeverity,
|
||||
/// The human-readable message associated with this diagnostic.
|
||||
|
@ -4612,6 +4613,7 @@ impl Default for Diagnostic {
|
|||
Self {
|
||||
source: Default::default(),
|
||||
code: None,
|
||||
code_description: None,
|
||||
severity: DiagnosticSeverity::ERROR,
|
||||
message: Default::default(),
|
||||
group_id: 0,
|
||||
|
|
|
@ -213,6 +213,11 @@ pub fn serialize_diagnostics<'a>(
|
|||
group_id: entry.diagnostic.group_id as u64,
|
||||
is_primary: entry.diagnostic.is_primary,
|
||||
code: entry.diagnostic.code.as_ref().map(|s| s.to_string()),
|
||||
code_description: entry
|
||||
.diagnostic
|
||||
.code_description
|
||||
.as_ref()
|
||||
.map(|s| s.to_string()),
|
||||
is_disk_based: entry.diagnostic.is_disk_based,
|
||||
is_unnecessary: entry.diagnostic.is_unnecessary,
|
||||
data: entry.diagnostic.data.as_ref().map(|data| data.to_string()),
|
||||
|
@ -419,6 +424,9 @@ pub fn deserialize_diagnostics(
|
|||
message: diagnostic.message,
|
||||
group_id: diagnostic.group_id as usize,
|
||||
code: diagnostic.code.map(lsp::NumberOrString::from_string),
|
||||
code_description: diagnostic
|
||||
.code_description
|
||||
.and_then(|s| lsp::Url::parse(&s).ok()),
|
||||
is_primary: diagnostic.is_primary,
|
||||
is_disk_based: diagnostic.is_disk_based,
|
||||
is_unnecessary: diagnostic.is_unnecessary,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue