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:
parent
13089d7ec6
commit
09967ac3d0
16 changed files with 145 additions and 31 deletions
|
@ -197,7 +197,7 @@ struct SelectionSet {
|
|||
}
|
||||
|
||||
/// A diagnostic associated with a certain range of a buffer.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Diagnostic {
|
||||
/// The name of the service that produced this diagnostic.
|
||||
pub source: Option<String>,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -32,10 +32,7 @@ use gpui::{App, AsyncApp, Entity, SharedString, Task};
|
|||
pub use highlight_map::HighlightMap;
|
||||
use http_client::HttpClient;
|
||||
pub use language_registry::{LanguageName, LoadedLanguage};
|
||||
use lsp::{
|
||||
CodeActionKind, InitializeParams, LanguageServerBinary, LanguageServerBinaryOptions,
|
||||
LanguageServerName,
|
||||
};
|
||||
use lsp::{CodeActionKind, InitializeParams, LanguageServerBinary, LanguageServerBinaryOptions};
|
||||
use parking_lot::Mutex;
|
||||
use regex::Regex;
|
||||
use schemars::{
|
||||
|
@ -73,12 +70,12 @@ use util::serde::default_true;
|
|||
|
||||
pub use buffer::Operation;
|
||||
pub use buffer::*;
|
||||
pub use diagnostic_set::DiagnosticEntry;
|
||||
pub use diagnostic_set::{DiagnosticEntry, DiagnosticGroup};
|
||||
pub use language_registry::{
|
||||
AvailableLanguage, LanguageNotFound, LanguageQueries, LanguageRegistry,
|
||||
LanguageServerBinaryStatus, QUERY_FILENAME_PREFIXES,
|
||||
};
|
||||
pub use lsp::LanguageServerId;
|
||||
pub use lsp::{LanguageServerId, LanguageServerName};
|
||||
pub use outline::*;
|
||||
pub use syntax_map::{OwnedSyntaxLayer, SyntaxLayer, ToTreeSitterPoint, TreeSitterOptions};
|
||||
pub use text::{AnchorRangeExt, LineEnding};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue