zeta: Send up diagnostics with prediction requests (#24384)

This PR makes it so we send up the diagnostic groups as additional data
with the edit prediction request.

We're not yet making use of them, but we are recording them so we can
use them later (e.g., to train the model).

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Marshall Bowers 2025-02-06 13:07:26 -05:00 committed by GitHub
parent 13089d7ec6
commit 09967ac3d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 145 additions and 31 deletions

View file

@ -2,6 +2,7 @@ use crate::{range_to_lsp, Diagnostic};
use anyhow::Result;
use collections::HashMap;
use lsp::LanguageServerId;
use serde::Serialize;
use std::{
cmp::{Ordering, Reverse},
iter,
@ -25,7 +26,7 @@ pub struct DiagnosticSet {
/// the diagnostics are stored internally as [`Anchor`]s, but can be
/// resolved to different coordinates types like [`usize`] byte offsets or
/// [`Point`](gpui::Point)s.
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct DiagnosticEntry<T> {
/// The range of the buffer where the diagnostic applies.
pub range: Range<T>,
@ -35,7 +36,7 @@ pub struct DiagnosticEntry<T> {
/// A group of related diagnostics, ordered by their start position
/// in the buffer.
#[derive(Debug)]
#[derive(Debug, Serialize)]
pub struct DiagnosticGroup<T> {
/// The diagnostics.
pub entries: Vec<DiagnosticEntry<T>>,
@ -43,6 +44,20 @@ pub struct DiagnosticGroup<T> {
pub primary_ix: usize,
}
impl DiagnosticGroup<Anchor> {
/// Converts the entries in this [`DiagnosticGroup`] to a different buffer coordinate type.
pub fn resolve<O: FromAnchor>(&self, buffer: &text::BufferSnapshot) -> DiagnosticGroup<O> {
DiagnosticGroup {
entries: self
.entries
.iter()
.map(|entry| entry.resolve(buffer))
.collect(),
primary_ix: self.primary_ix,
}
}
}
#[derive(Clone, Debug)]
pub struct Summary {
start: Anchor,