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:
Conrad Irwin 2025-04-23 20:51:01 -06:00 committed by GitHub
parent 8836c6fb42
commit 9d10489607
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 517 additions and 327 deletions

View file

@ -5950,6 +5950,29 @@ impl MultiBufferSnapshot {
.map(|(range, diagnostic, _)| DiagnosticEntry { diagnostic, range })
}
pub fn diagnostics_with_buffer_ids_in_range<'a, T>(
&'a self,
range: Range<T>,
) -> impl Iterator<Item = (BufferId, DiagnosticEntry<T>)> + 'a
where
T: 'a
+ text::ToOffset
+ text::FromAnchor
+ TextDimension
+ Ord
+ Sub<T, Output = T>
+ fmt::Debug,
{
self.lift_buffer_metadata(range, move |buffer, buffer_range| {
Some(
buffer
.diagnostics_in_range(buffer_range.start..buffer_range.end, false)
.map(|entry| (entry.range, entry.diagnostic)),
)
})
.map(|(range, diagnostic, b)| (b.buffer_id, DiagnosticEntry { diagnostic, range }))
}
pub fn syntax_ancestor<T: ToOffset>(
&self,
range: Range<T>,