Pass an AsyncAppContext to fake language server request handlers

This commit is contained in:
Antonio Scandurra
2022-02-23 16:14:36 +01:00
parent 73fcebb8b2
commit 9e173564e9
6 changed files with 122 additions and 106 deletions
+3 -3
View File
@@ -13,7 +13,7 @@ use futures::{
future::{BoxFuture, Shared},
FutureExt, TryFutureExt,
};
use gpui::{AppContext, Task};
use gpui::{MutableAppContext, Task};
use highlight_map::HighlightMap;
use lazy_static::lazy_static;
use parking_lot::{Mutex, RwLock};
@@ -225,7 +225,7 @@ impl LanguageRegistry {
language: &Arc<Language>,
root_path: Arc<Path>,
http_client: Arc<dyn HttpClient>,
cx: &AppContext,
cx: &mut MutableAppContext,
) -> Option<Task<Result<Arc<lsp::LanguageServer>>>> {
#[cfg(any(test, feature = "test-support"))]
if let Some(config) = &language.config.language_server {
@@ -234,7 +234,7 @@ impl LanguageRegistry {
let (server, mut fake_server) = lsp::LanguageServer::fake_with_capabilities(
fake_config.capabilities.clone(),
cx.background().clone(),
cx,
);
if let Some(initalizer) = &fake_config.initializer {
+2 -2
View File
@@ -554,7 +554,7 @@ fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut MutableAppConte
#[gpui::test]
async fn test_diagnostics(mut cx: gpui::TestAppContext) {
let (language_server, mut fake) = lsp::LanguageServer::fake(cx.background());
let (language_server, mut fake) = cx.update(lsp::LanguageServer::fake);
let mut rust_lang = rust_lang();
rust_lang.config.language_server = Some(LanguageServerConfig {
disk_based_diagnostic_sources: HashSet::from_iter(["disk".to_string()]),
@@ -837,7 +837,7 @@ async fn test_diagnostics(mut cx: gpui::TestAppContext) {
#[gpui::test]
async fn test_edits_from_lsp_with_past_version(mut cx: gpui::TestAppContext) {
let (language_server, mut fake) = lsp::LanguageServer::fake(cx.background());
let (language_server, mut fake) = cx.update(lsp::LanguageServer::fake);
let text = "
fn a() {