Done! Finish transition to async, very close to merging

This commit is contained in:
Isaac Clayton 2022-07-06 20:36:38 +02:00
parent 39fdbc593b
commit 895747476f
7 changed files with 2948 additions and 19 deletions

View file

@ -1675,7 +1675,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
},
Some(tree_sitter_rust::language()),
);
let mut fake_language_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let mut fake_language_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
capabilities: lsp::ServerCapabilities {
completion_provider: Some(lsp::CompletionOptions {
trigger_characters: Some(vec![".".to_string()]),
@ -2867,7 +2867,7 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
},
Some(tree_sitter_rust::language()),
);
let mut fake_language_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let mut fake_language_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
capabilities: lsp::ServerCapabilities {
rename_provider: Some(lsp::OneOf::Right(lsp::RenameOptions {
prepare_provider: Some(true),
@ -3051,7 +3051,7 @@ async fn test_language_server_statuses(
},
Some(tree_sitter_rust::language()),
);
let mut fake_language_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let mut fake_language_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
name: "the-language-server",
..Default::default()
}));
@ -4577,7 +4577,7 @@ async fn test_random_collaboration(
},
None,
);
let _fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let _fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
name: "the-fake-language-server",
capabilities: lsp::LanguageServer::full_capabilities(),
initializer: Some(Box::new({

View file

@ -6233,7 +6233,7 @@ mod tests {
platform::{WindowBounds, WindowOptions},
};
use indoc::indoc;
use language::{FakeLspAdapterInner, LanguageConfig};
use language::{FakeLspAdapter, LanguageConfig};
use lsp::FakeLanguageServer;
use project::FakeFs;
use settings::LanguageSettings;
@ -9302,7 +9302,7 @@ mod tests {
},
Some(tree_sitter_rust::language()),
);
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
capabilities: lsp::ServerCapabilities {
document_formatting_provider: Some(lsp::OneOf::Left(true)),
..Default::default()
@ -9414,7 +9414,7 @@ mod tests {
},
Some(tree_sitter_rust::language()),
);
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
capabilities: lsp::ServerCapabilities {
document_range_formatting_provider: Some(lsp::OneOf::Left(true)),
..Default::default()
@ -9526,7 +9526,7 @@ mod tests {
},
Some(tree_sitter_rust::language()),
);
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
capabilities: lsp::ServerCapabilities {
completion_provider: Some(lsp::CompletionOptions {
trigger_characters: Some(vec![".".to_string(), ":".to_string()]),

View file

@ -9,7 +9,7 @@ use indoc::indoc;
use collections::BTreeMap;
use gpui::{json, keymap::Keystroke, AppContext, ModelHandle, ViewContext, ViewHandle};
use language::{point_to_lsp, FakeLspAdapterInner, Language, LanguageConfig, Selection};
use language::{point_to_lsp, FakeLspAdapter, Language, LanguageConfig, Selection};
use project::Project;
use settings::Settings;
use util::{
@ -457,7 +457,7 @@ impl<'a> EditorLspTestContext<'a> {
.unwrap_or(&"txt".to_string())
);
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapterInner {
let mut fake_servers = language.set_fake_lsp_adapter(Arc::new(FakeLspAdapter {
capabilities,
..Default::default()
}));

View file

@ -254,10 +254,11 @@ fn deserialize_regex<'de, D: Deserializer<'de>>(d: D) -> Result<Option<Regex>, D
}
}
#[cfg(any(test, feature = "test-support"))]
pub type FakeLspAdapter = Arc<FakeLspAdapterInner>;
// #[cfg(any(test, feature = "test-support"))]
// pub type FakeLspAdapter = Arc<FakeLspAdapterInner>;
pub struct FakeLspAdapterInner {
#[cfg(any(test, feature = "test-support"))]
pub struct FakeLspAdapter {
pub name: &'static str,
pub capabilities: lsp::ServerCapabilities,
pub initializer: Option<Box<dyn 'static + Send + Sync + Fn(&mut lsp::FakeLanguageServer)>>,
@ -281,7 +282,7 @@ pub struct Language {
#[cfg(any(test, feature = "test-support"))]
fake_adapter: Option<(
mpsc::UnboundedSender<lsp::FakeLanguageServer>,
FakeLspAdapter,
Arc<FakeLspAdapter>,
)>,
}
@ -609,7 +610,7 @@ impl Language {
#[cfg(any(test, feature = "test-support"))]
pub fn set_fake_lsp_adapter(
&mut self,
fake_lsp_adapter: FakeLspAdapter,
fake_lsp_adapter: Arc<FakeLspAdapter>,
) -> mpsc::UnboundedReceiver<lsp::FakeLanguageServer> {
let (servers_tx, servers_rx) = mpsc::unbounded();
self.fake_adapter = Some((servers_tx, fake_lsp_adapter.clone()));
@ -763,7 +764,7 @@ impl CodeLabel {
}
#[cfg(any(test, feature = "test-support"))]
impl Default for FakeLspAdapterInner {
impl Default for FakeLspAdapter {
fn default() -> Self {
Self {
name: "the-fake-language-server",
@ -777,7 +778,7 @@ impl Default for FakeLspAdapterInner {
#[cfg(any(test, feature = "test-support"))]
#[async_trait]
impl LspAdapterTrait for FakeLspAdapter {
impl LspAdapterTrait for Arc<FakeLspAdapter> {
async fn name(&self) -> LanguageServerName {
LanguageServerName(self.name.into())
}

View file

@ -68,7 +68,7 @@ impl PluginBuilder {
pub fn new(wasi_ctx: WasiCtx) -> Result<Self, Error> {
let mut config = Config::default();
config.async_support(true);
config.epoch_interruption(true);
// config.epoch_interruption(true);
let engine = Engine::new(&config)?;
let linker = Linker::new(&engine);

File diff suppressed because it is too large Load diff

View file

@ -290,7 +290,7 @@ mod tests {
},
None,
);
let mut fake_servers = language.set_fake_lsp_adapter(FakeLspAdapter::default());
let mut fake_servers = language.set_fake_lsp_adapter(Arc::<FakeLspAdapter>::default());
let fs = FakeFs::new(cx.background());
fs.insert_tree("/dir", json!({ "test.rs": "" })).await;