Get a basic end-to-end test for rust-analyzer integration working
Co-Authored-By: Nathan Sobo <nathan@zed.dev> Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
9759f9e947
commit
580bad2042
9 changed files with 194 additions and 74 deletions
|
@ -7,8 +7,7 @@ use buffer::LanguageRegistry;
|
|||
use client::Client;
|
||||
use futures::Future;
|
||||
use fuzzy::{PathMatch, PathMatchCandidate, PathMatchCandidateSet};
|
||||
use gpui::{executor, AppContext, Entity, ModelContext, ModelHandle, Task};
|
||||
use lsp::LanguageServer;
|
||||
use gpui::{AppContext, Entity, ModelContext, ModelHandle, Task};
|
||||
use std::{
|
||||
path::Path,
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
|
@ -24,7 +23,6 @@ pub struct Project {
|
|||
languages: Arc<LanguageRegistry>,
|
||||
client: Arc<client::Client>,
|
||||
fs: Arc<dyn Fs>,
|
||||
language_server: Arc<LanguageServer>,
|
||||
}
|
||||
|
||||
pub enum Event {
|
||||
|
@ -45,19 +43,13 @@ pub struct ProjectEntry {
|
|||
}
|
||||
|
||||
impl Project {
|
||||
pub fn new(
|
||||
languages: Arc<LanguageRegistry>,
|
||||
rpc: Arc<Client>,
|
||||
fs: Arc<dyn Fs>,
|
||||
cx: &AppContext,
|
||||
) -> Self {
|
||||
pub fn new(languages: Arc<LanguageRegistry>, rpc: Arc<Client>, fs: Arc<dyn Fs>) -> Self {
|
||||
Self {
|
||||
worktrees: Default::default(),
|
||||
active_entry: None,
|
||||
languages,
|
||||
client: rpc,
|
||||
fs,
|
||||
language_server: LanguageServer::rust(cx).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,6 +408,6 @@ mod tests {
|
|||
let languages = Arc::new(LanguageRegistry::new());
|
||||
let fs = Arc::new(RealFs);
|
||||
let rpc = client::Client::new();
|
||||
cx.add_model(|cx| Project::new(languages, rpc, fs, cx))
|
||||
cx.add_model(|_| Project::new(languages, rpc, fs))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use gpui::{
|
|||
Task, UpgradeModelHandle, WeakModelHandle,
|
||||
};
|
||||
use lazy_static::lazy_static;
|
||||
use lsp::LanguageServer;
|
||||
use parking_lot::Mutex;
|
||||
use postage::{
|
||||
prelude::{Sink as _, Stream as _},
|
||||
|
@ -684,6 +685,7 @@ pub struct LocalWorktree {
|
|||
queued_operations: Vec<(u64, Operation)>,
|
||||
rpc: Arc<Client>,
|
||||
fs: Arc<dyn Fs>,
|
||||
language_server: Arc<LanguageServer>,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
|
@ -721,6 +723,7 @@ impl LocalWorktree {
|
|||
let (scan_states_tx, scan_states_rx) = smol::channel::unbounded();
|
||||
let (mut last_scan_state_tx, last_scan_state_rx) = watch::channel_with(ScanState::Scanning);
|
||||
let tree = cx.add_model(move |cx: &mut ModelContext<Worktree>| {
|
||||
let language_server = LanguageServer::rust(&abs_path, cx).unwrap();
|
||||
let mut snapshot = Snapshot {
|
||||
id: cx.model_id(),
|
||||
scan_id: 0,
|
||||
|
@ -796,6 +799,7 @@ impl LocalWorktree {
|
|||
languages,
|
||||
rpc,
|
||||
fs,
|
||||
language_server,
|
||||
};
|
||||
|
||||
cx.spawn_weak(|this, mut cx| async move {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue