Map the new interface

# Conflicts:
#	crates/project/src/lsp_store.rs

# Conflicts:
#	crates/project/src/lsp_store.rs

# Conflicts:
#	crates/editor/src/editor.rs
#	crates/project/src/lsp_store.rs
This commit is contained in:
Kirill Bulatov 2025-07-17 13:11:23 +03:00
parent 64b14ef848
commit ee3245c9a5
6 changed files with 127 additions and 42 deletions

View file

@ -0,0 +1,56 @@
use std::{collections::BTreeMap, ops::Range};
use clock::Global;
use collections::HashMap;
use futures::future::Shared;
use gpui::{Context, Entity, Task};
use language::BufferRow;
use lsp::LanguageServerId;
use text::BufferId;
use crate::{InlayHint, buffer_store::BufferStore};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InlayHintId(usize);
#[derive(Debug)]
pub struct InlayHintCache {
buffer_store: Entity<BufferStore>,
hints_for_version: Global,
hints: HashMap<LanguageServerId, Hints>,
cache_version: usize,
}
#[derive(Debug, Default)]
struct Hints {
hints: HashMap<InlayHintId, InlayHint>,
hints_by_chunks: BTreeMap<Range<BufferRow>, Option<Vec<InlayHintId>>>,
hint_updates: HashMap<Range<BufferRow>, Shared<Task<InlayHints>>>,
}
pub struct InlayHints {
pub cache_version: usize,
pub hints: Vec<InlayHint>,
}
impl InlayHintCache {
pub fn remove_server_data(&mut self, for_server: LanguageServerId) -> bool {
let removed = self.hints.remove(&for_server).is_some();
if removed {
self.cache_version += 1;
}
removed
}
pub fn hints(
&self,
buffer: BufferId,
range: Range<usize>,
known_cache_version: Option<usize>,
cx: &mut Context<Self>,
) -> Option<Shared<Task<InlayHints>>> {
todo!("TODO kb")
}
// we want to store the cache version outbound, so they can query with it: we can return nothing (`Option`) if the version matches
// we can get a new server up/down, so we want to re-query for them things, ignoring the cache version
}