Remove NodeRuntime static & add fake implementation for tests

This commit is contained in:
Julia 2023-08-09 21:32:41 -04:00
parent 9272e9354a
commit 8d672f5d4c
17 changed files with 179 additions and 131 deletions

View file

@ -22,11 +22,11 @@ fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
}
pub struct CssLspAdapter {
node: Arc<NodeRuntime>,
node: Arc<dyn NodeRuntime>,
}
impl CssLspAdapter {
pub fn new(node: Arc<NodeRuntime>) -> Self {
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
CssLspAdapter { node }
}
}
@ -65,7 +65,7 @@ impl LspAdapter for CssLspAdapter {
self.node
.npm_install_packages(
&container_dir,
[("vscode-langservers-extracted", version.as_str())],
&[("vscode-langservers-extracted", version.as_str())],
)
.await?;
}
@ -81,14 +81,14 @@ impl LspAdapter for CssLspAdapter {
container_dir: PathBuf,
_: &dyn LspAdapterDelegate,
) -> Option<LanguageServerBinary> {
get_cached_server_binary(container_dir, &self.node).await
get_cached_server_binary(container_dir, &*self.node).await
}
async fn installation_test_binary(
&self,
container_dir: PathBuf,
) -> Option<LanguageServerBinary> {
get_cached_server_binary(container_dir, &self.node).await
get_cached_server_binary(container_dir, &*self.node).await
}
async fn initialization_options(&self) -> Option<serde_json::Value> {
@ -100,7 +100,7 @@ impl LspAdapter for CssLspAdapter {
async fn get_cached_server_binary(
container_dir: PathBuf,
node: &NodeRuntime,
node: &dyn NodeRuntime,
) -> Option<LanguageServerBinary> {
(|| async move {
let mut last_version_dir = None;