Bump tree-sitter to 0.27 and wasmtime to 48.0 (#63169)
Release Notes: - N/A
This commit is contained in:
1 parent
95eaa2c371
commit
8383e32479
14 files changed
+545
-515
No files matched your search
Generated
+370
-392
File diff suppressed because it is too large.
Load diff
+5
-4
@@ -834,7 +834,7 @@ toml_edit = { version = "0.22", default-features = false, features = [
|
||||
"serde",
|
||||
] }
|
||||
tower-http = "0.4.4"
|
||||
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "dff1fd868c750dbbae179fcd5c43ce987e4e0528" }
|
||||
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "43623ec9bf0eaaf7113285c46e8a09018f181b18" }
|
||||
tracing = "0.1.40"
|
||||
tree-sitter-bash = "0.25.1"
|
||||
tree-sitter-c = "0.24.1"
|
||||
@@ -874,7 +874,8 @@ vte = { version = "0.15.0", features = ["ansi"] }
|
||||
walkdir = "2.5"
|
||||
wasm-encoder = "0.252"
|
||||
wasmparser = "0.252"
|
||||
wasmtime = { version = "36", default-features = false, features = [
|
||||
wasmtime = { version = "48", default-features = false, features = [
|
||||
"anyhow",
|
||||
"async",
|
||||
"demangle",
|
||||
"runtime",
|
||||
@@ -885,7 +886,7 @@ wasmtime = { version = "36", default-features = false, features = [
|
||||
] }
|
||||
wasm-bindgen = "0.2.120"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
wasmtime-wasi = "36.0.14"
|
||||
wasmtime-wasi = "48"
|
||||
wax = "0.7"
|
||||
web-time = "1.1.0"
|
||||
webrtc-sys = "0.3.23"
|
||||
@@ -964,7 +965,7 @@ features = [
|
||||
# Unify `tree_sitter_language::LanguageFn` between crates.io grammar crates and
|
||||
# the git tree-sitter above; two instances of the crate would make grammar
|
||||
# constants type-incompatible with `tree_sitter::Language`.
|
||||
tree-sitter-language = { git = "https://github.com/tree-sitter/tree-sitter", rev = "dff1fd868c750dbbae179fcd5c43ce987e4e0528" }
|
||||
tree-sitter-language = { git = "https://github.com/tree-sitter/tree-sitter", rev = "43623ec9bf0eaaf7113285c46e8a09018f181b18" }
|
||||
async-process = { git = "https://github.com/zed-industries/async-process.git", rev = "0b6d6713570af61806e1e5cb40e0f757cb93fd9d" }
|
||||
async-task = { git = "https://github.com/smol-rs/async-task.git", rev = "b4486cd71e4e94fbda54ce6302444de14f4d190e" }
|
||||
windows-capture = { git = "https://github.com/zed-industries/windows-capture.git", rev = "f0d6c1b6691db75461b732f6d5ff56eed002eeb9" }
|
||||
|
||||
@@ -178,6 +178,7 @@ impl extension::Extension for WasmExtension {
|
||||
.boxed()
|
||||
})
|
||||
.await?
|
||||
.map_err(anyhow::Error::from)
|
||||
}
|
||||
|
||||
async fn language_server_workspace_configuration_schema(
|
||||
@@ -199,6 +200,7 @@ impl extension::Extension for WasmExtension {
|
||||
.boxed()
|
||||
})
|
||||
.await?
|
||||
.map_err(anyhow::Error::from)
|
||||
}
|
||||
|
||||
async fn language_server_additional_initialization_options(
|
||||
@@ -510,6 +512,7 @@ impl extension::Extension for WasmExtension {
|
||||
.boxed()
|
||||
})
|
||||
.await?
|
||||
.map_err(anyhow::Error::from)
|
||||
}
|
||||
async fn run_dap_locator(
|
||||
&self,
|
||||
@@ -549,7 +552,6 @@ fn wasm_engine(executor: &BackgroundExecutor) -> wasmtime::Engine {
|
||||
.get_or_init(|| {
|
||||
let mut config = wasmtime::Config::new();
|
||||
config.wasm_component_model(true);
|
||||
config.async_support(true);
|
||||
config
|
||||
.enable_incremental_compilation(cache_store())
|
||||
.unwrap();
|
||||
@@ -649,6 +651,7 @@ impl WasmHost {
|
||||
executor.spawn(async move {
|
||||
let zed_api_version = parse_wasm_extension_version(&manifest_id, &wasm_bytes)?;
|
||||
let component = Component::from_binary(&engine, &wasm_bytes)
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to compile wasm component")?;
|
||||
|
||||
anyhow::Ok((zed_api_version, component))
|
||||
@@ -686,6 +689,7 @@ impl WasmHost {
|
||||
extension
|
||||
.call_init_extension(&mut store)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to initialize wasm extension")?;
|
||||
|
||||
let (tx, mut rx) = mpsc::unbounded::<ExtensionCall>();
|
||||
@@ -733,8 +737,7 @@ impl WasmHost {
|
||||
.await
|
||||
.context("failed to create extension work dir")?;
|
||||
|
||||
let file_perms = wasmtime_wasi::FilePerms::all();
|
||||
let dir_perms = wasmtime_wasi::DirPerms::all();
|
||||
let permissions = wasmtime_wasi::FsPerms::ReadWrite;
|
||||
let path = SanitizedPath::new(&extension_work_dir).to_string();
|
||||
#[cfg(target_os = "windows")]
|
||||
let path = path.replace('\\', "/");
|
||||
@@ -744,8 +747,8 @@ impl WasmHost {
|
||||
.env("PWD", &path)
|
||||
.env("RUST_BACKTRACE", "full");
|
||||
|
||||
ctx.preopened_dir(&path, ".", dir_perms, file_perms)?;
|
||||
ctx.preopened_dir(&path, &path, dir_perms, file_perms)?;
|
||||
ctx.preopened_dir(&path, ".", permissions)?;
|
||||
ctx.preopened_dir(&path, &path, permissions)?;
|
||||
|
||||
Ok(ctx.build())
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use task::{DebugScenario, SpawnInTerminal, TaskTemplate, ZedDebugConfig};
|
||||
use latest::dap::StartDebuggingRequestArgumentsRequest;
|
||||
|
||||
use super::{WasmState, wasm_engine};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use anyhow::{Context as _, Result};
|
||||
use semver::Version;
|
||||
use since_v0_8_0 as latest;
|
||||
use std::{ops::RangeInclusive, path::PathBuf, sync::Arc};
|
||||
@@ -42,7 +42,7 @@ pub use since_v0_0_4::LanguageServerConfig;
|
||||
|
||||
pub fn new_linker(
|
||||
executor: &BackgroundExecutor,
|
||||
f: impl FnOnce(&mut Linker<WasmState>) -> Result<()>,
|
||||
f: impl FnOnce(&mut Linker<WasmState>) -> wasmtime::Result<()>,
|
||||
) -> Linker<WasmState> {
|
||||
let mut linker = Linker::new(&wasm_engine(executor));
|
||||
wasmtime_wasi::p2::add_to_linker_async(&mut linker).unwrap();
|
||||
@@ -121,6 +121,7 @@ impl Extension {
|
||||
let extension =
|
||||
latest::Extension::instantiate_async(store, component, latest::linker(executor))
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_8_0(extension))
|
||||
} else if version >= since_v0_6_0::MIN_VERSION {
|
||||
@@ -130,6 +131,7 @@ impl Extension {
|
||||
since_v0_6_0::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_6_0(extension))
|
||||
} else if version >= since_v0_5_0::MIN_VERSION {
|
||||
@@ -139,6 +141,7 @@ impl Extension {
|
||||
since_v0_5_0::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_5_0(extension))
|
||||
} else if version >= since_v0_4_0::MIN_VERSION {
|
||||
@@ -148,6 +151,7 @@ impl Extension {
|
||||
since_v0_4_0::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_4_0(extension))
|
||||
} else if version >= since_v0_3_0::MIN_VERSION {
|
||||
@@ -157,6 +161,7 @@ impl Extension {
|
||||
since_v0_3_0::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_3_0(extension))
|
||||
} else if version >= since_v0_2_0::MIN_VERSION {
|
||||
@@ -166,6 +171,7 @@ impl Extension {
|
||||
since_v0_2_0::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_2_0(extension))
|
||||
} else if version >= since_v0_1_0::MIN_VERSION {
|
||||
@@ -175,6 +181,7 @@ impl Extension {
|
||||
since_v0_1_0::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_1_0(extension))
|
||||
} else if version >= since_v0_0_6::MIN_VERSION {
|
||||
@@ -184,6 +191,7 @@ impl Extension {
|
||||
since_v0_0_6::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_0_6(extension))
|
||||
} else if version >= since_v0_0_4::MIN_VERSION {
|
||||
@@ -193,6 +201,7 @@ impl Extension {
|
||||
since_v0_0_4::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_0_4(extension))
|
||||
} else {
|
||||
@@ -202,12 +211,13 @@ impl Extension {
|
||||
since_v0_0_1::linker(executor),
|
||||
)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok(Self::V0_0_1(extension))
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn call_init_extension(&self, store: &mut Store<WasmState>) -> Result<()> {
|
||||
pub async fn call_init_extension(&self, store: &mut Store<WasmState>) -> wasmtime::Result<()> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => ext.call_init_extension(store).await,
|
||||
Extension::V0_6_0(ext) => ext.call_init_extension(store).await,
|
||||
@@ -228,7 +238,7 @@ impl Extension {
|
||||
language_server_id: &LanguageServerName,
|
||||
language_name: &LanguageName,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Result<Command, String>> {
|
||||
) -> wasmtime::Result<Result<Command, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_language_server_command(store, &language_server_id.0, resource)
|
||||
@@ -294,7 +304,7 @@ impl Extension {
|
||||
language_server_id: &LanguageServerName,
|
||||
language_name: &LanguageName,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Result<Option<String>, String>> {
|
||||
) -> wasmtime::Result<Result<Option<String>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_language_server_initialization_options(
|
||||
@@ -391,7 +401,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
language_server_id: &LanguageServerName,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Result<Option<String>, String>> {
|
||||
) -> wasmtime::Result<Result<Option<String>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_language_server_workspace_configuration(
|
||||
@@ -466,7 +476,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
language_server_id: &LanguageServerName,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Option<String>> {
|
||||
) -> wasmtime::Result<Option<String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_language_server_initialization_options_schema(
|
||||
@@ -493,7 +503,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
language_server_id: &LanguageServerName,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Option<String>> {
|
||||
) -> wasmtime::Result<Option<String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_language_server_workspace_configuration_schema(
|
||||
@@ -521,7 +531,7 @@ impl Extension {
|
||||
language_server_id: &LanguageServerName,
|
||||
target_language_server_id: &LanguageServerName,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Result<Option<String>, String>> {
|
||||
) -> wasmtime::Result<Result<Option<String>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_language_server_additional_initialization_options(
|
||||
@@ -574,7 +584,7 @@ impl Extension {
|
||||
language_server_id: &LanguageServerName,
|
||||
target_language_server_id: &LanguageServerName,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Result<Option<String>, String>> {
|
||||
) -> wasmtime::Result<Result<Option<String>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_language_server_additional_workspace_configuration(
|
||||
@@ -626,7 +636,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
language_server_id: &LanguageServerName,
|
||||
completions: Vec<latest::Completion>,
|
||||
) -> Result<Result<Vec<Option<CodeLabel>>, String>> {
|
||||
) -> wasmtime::Result<Result<Vec<Option<CodeLabel>>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_labels_for_completions(store, &language_server_id.0, &completions)
|
||||
@@ -732,7 +742,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
language_server_id: &LanguageServerName,
|
||||
symbols: Vec<latest::Symbol>,
|
||||
) -> Result<Result<Vec<Option<CodeLabel>>, String>> {
|
||||
) -> wasmtime::Result<Result<Vec<Option<CodeLabel>>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_labels_for_symbols(store, &language_server_id.0, &symbols)
|
||||
@@ -838,7 +848,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
command: &SlashCommand,
|
||||
arguments: &[String],
|
||||
) -> Result<Result<Vec<SlashCommandArgumentCompletion>, String>> {
|
||||
) -> wasmtime::Result<Result<Vec<SlashCommandArgumentCompletion>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_complete_slash_command_argument(store, command, arguments)
|
||||
@@ -880,7 +890,7 @@ impl Extension {
|
||||
command: &SlashCommand,
|
||||
arguments: &[String],
|
||||
resource: Option<Resource<Arc<dyn WorktreeDelegate>>>,
|
||||
) -> Result<Result<SlashCommandOutput, String>> {
|
||||
) -> wasmtime::Result<Result<SlashCommandOutput, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_run_slash_command(store, command, arguments, resource)
|
||||
@@ -910,9 +920,9 @@ impl Extension {
|
||||
ext.call_run_slash_command(store, command, arguments, resource)
|
||||
.await
|
||||
}
|
||||
Extension::V0_0_1(_) | Extension::V0_0_4(_) | Extension::V0_0_6(_) => {
|
||||
anyhow::bail!("`run_slash_command` not available prior to v0.1.0");
|
||||
}
|
||||
Extension::V0_0_1(_) | Extension::V0_0_4(_) | Extension::V0_0_6(_) => Err(
|
||||
wasmtime::Error::msg("`run_slash_command` not available prior to v0.1.0"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -921,7 +931,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
context_server_id: Arc<str>,
|
||||
project: Resource<ExtensionProject>,
|
||||
) -> Result<Result<Command, String>> {
|
||||
) -> wasmtime::Result<Result<Command, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_context_server_command(store, &context_server_id, project)
|
||||
@@ -950,9 +960,9 @@ impl Extension {
|
||||
Extension::V0_0_1(_)
|
||||
| Extension::V0_0_4(_)
|
||||
| Extension::V0_0_6(_)
|
||||
| Extension::V0_1_0(_) => {
|
||||
anyhow::bail!("`context_server_command` not available prior to v0.2.0");
|
||||
}
|
||||
| Extension::V0_1_0(_) => Err(wasmtime::Error::msg(
|
||||
"`context_server_command` not available prior to v0.2.0",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -961,7 +971,7 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
context_server_id: Arc<str>,
|
||||
project: Resource<ExtensionProject>,
|
||||
) -> Result<Result<Option<ContextServerConfiguration>, String>> {
|
||||
) -> wasmtime::Result<Result<Option<ContextServerConfiguration>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_context_server_configuration(store, &context_server_id, project)
|
||||
@@ -981,9 +991,9 @@ impl Extension {
|
||||
| Extension::V0_1_0(_)
|
||||
| Extension::V0_2_0(_)
|
||||
| Extension::V0_3_0(_)
|
||||
| Extension::V0_4_0(_) => {
|
||||
anyhow::bail!("`context_server_configuration` not available prior to v0.5.0");
|
||||
}
|
||||
| Extension::V0_4_0(_) => Err(wasmtime::Error::msg(
|
||||
"`context_server_configuration` not available prior to v0.5.0",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -991,7 +1001,7 @@ impl Extension {
|
||||
&self,
|
||||
store: &mut Store<WasmState>,
|
||||
provider: &str,
|
||||
) -> Result<Result<Vec<String>, String>> {
|
||||
) -> wasmtime::Result<Result<Vec<String>, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => ext.call_suggest_docs_packages(store, provider).await,
|
||||
Extension::V0_6_0(ext) => ext.call_suggest_docs_packages(store, provider).await,
|
||||
@@ -1000,9 +1010,9 @@ impl Extension {
|
||||
Extension::V0_3_0(ext) => ext.call_suggest_docs_packages(store, provider).await,
|
||||
Extension::V0_2_0(ext) => ext.call_suggest_docs_packages(store, provider).await,
|
||||
Extension::V0_1_0(ext) => ext.call_suggest_docs_packages(store, provider).await,
|
||||
Extension::V0_0_1(_) | Extension::V0_0_4(_) | Extension::V0_0_6(_) => {
|
||||
anyhow::bail!("`suggest_docs_packages` not available prior to v0.1.0");
|
||||
}
|
||||
Extension::V0_0_1(_) | Extension::V0_0_4(_) | Extension::V0_0_6(_) => Err(
|
||||
wasmtime::Error::msg("`suggest_docs_packages` not available prior to v0.1.0"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,7 +1022,7 @@ impl Extension {
|
||||
provider: &str,
|
||||
package_name: &str,
|
||||
kv_store: Resource<Arc<dyn KeyValueStoreDelegate>>,
|
||||
) -> Result<Result<(), String>> {
|
||||
) -> wasmtime::Result<Result<(), String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
ext.call_index_docs(store, provider, package_name, kv_store)
|
||||
@@ -1042,9 +1052,9 @@ impl Extension {
|
||||
ext.call_index_docs(store, provider, package_name, kv_store)
|
||||
.await
|
||||
}
|
||||
Extension::V0_0_1(_) | Extension::V0_0_4(_) | Extension::V0_0_6(_) => {
|
||||
anyhow::bail!("`index_docs` not available prior to v0.1.0");
|
||||
}
|
||||
Extension::V0_0_1(_) | Extension::V0_0_4(_) | Extension::V0_0_6(_) => Err(
|
||||
wasmtime::Error::msg("`index_docs` not available prior to v0.1.0"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1055,24 +1065,24 @@ impl Extension {
|
||||
task: DebugTaskDefinition,
|
||||
user_installed_path: Option<PathBuf>,
|
||||
resource: Resource<Arc<dyn WorktreeDelegate>>,
|
||||
) -> Result<Result<DebugAdapterBinary, String>> {
|
||||
) -> wasmtime::Result<Result<DebugAdapterBinary, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
let dap_binary = ext
|
||||
.call_get_dap_binary(
|
||||
store,
|
||||
&adapter_name,
|
||||
&task.try_into()?,
|
||||
&task.try_into().into_wasmtime_result()?,
|
||||
user_installed_path.as_ref().and_then(|p| p.to_str()),
|
||||
resource,
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
Ok(Ok(dap_binary))
|
||||
}
|
||||
Extension::V0_6_0(ext) => {
|
||||
let task: latest::DebugTaskDefinition = task.try_into()?;
|
||||
let task: latest::DebugTaskDefinition = task.try_into().into_wasmtime_result()?;
|
||||
let dap_binary = ext
|
||||
.call_get_dap_binary(
|
||||
store,
|
||||
@@ -1082,7 +1092,7 @@ impl Extension {
|
||||
resource,
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
Ok(Ok(dap_binary.into()))
|
||||
}
|
||||
@@ -1093,9 +1103,9 @@ impl Extension {
|
||||
| Extension::V0_1_0(_)
|
||||
| Extension::V0_0_6(_)
|
||||
| Extension::V0_0_4(_)
|
||||
| Extension::V0_0_1(_) => {
|
||||
anyhow::bail!("`get_dap_binary` not available prior to v0.6.0");
|
||||
}
|
||||
| Extension::V0_0_1(_) => Err(wasmtime::Error::msg(
|
||||
"`get_dap_binary` not available prior to v0.6.0",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1104,25 +1114,27 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
adapter_name: Arc<str>,
|
||||
config: serde_json::Value,
|
||||
) -> Result<Result<StartDebuggingRequestArgumentsRequest, String>> {
|
||||
) -> wasmtime::Result<Result<StartDebuggingRequestArgumentsRequest, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
let config =
|
||||
serde_json::to_string(&config).context("Adapter config is not a valid JSON")?;
|
||||
let config = serde_json::to_string(&config)
|
||||
.context("Adapter config is not a valid JSON")
|
||||
.into_wasmtime_result()?;
|
||||
let dap_binary = ext
|
||||
.call_dap_request_kind(store, &adapter_name, &config)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
Ok(Ok(dap_binary))
|
||||
}
|
||||
Extension::V0_6_0(ext) => {
|
||||
let config =
|
||||
serde_json::to_string(&config).context("Adapter config is not a valid JSON")?;
|
||||
let config = serde_json::to_string(&config)
|
||||
.context("Adapter config is not a valid JSON")
|
||||
.into_wasmtime_result()?;
|
||||
let dap_binary = ext
|
||||
.call_dap_request_kind(store, &adapter_name, &config)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
Ok(Ok(dap_binary.into()))
|
||||
}
|
||||
@@ -1133,9 +1145,9 @@ impl Extension {
|
||||
| Extension::V0_1_0(_)
|
||||
| Extension::V0_0_6(_)
|
||||
| Extension::V0_0_4(_)
|
||||
| Extension::V0_0_1(_) => {
|
||||
anyhow::bail!("`dap_request_kind` not available prior to v0.6.0");
|
||||
}
|
||||
| Extension::V0_0_1(_) => Err(wasmtime::Error::msg(
|
||||
"`dap_request_kind` not available prior to v0.6.0",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1143,26 +1155,26 @@ impl Extension {
|
||||
&self,
|
||||
store: &mut Store<WasmState>,
|
||||
config: ZedDebugConfig,
|
||||
) -> Result<Result<DebugScenario, String>> {
|
||||
) -> wasmtime::Result<Result<DebugScenario, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
let config = config.into();
|
||||
let dap_binary = ext
|
||||
.call_dap_config_to_scenario(store, &config)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
Ok(Ok(dap_binary.try_into()?))
|
||||
Ok(Ok(dap_binary.try_into().into_wasmtime_result()?))
|
||||
}
|
||||
Extension::V0_6_0(ext) => {
|
||||
let config: latest::DebugConfig = config.into();
|
||||
let dap_binary = ext
|
||||
.call_dap_config_to_scenario(store, &config.into())
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
let dap_binary: latest::DebugScenario = dap_binary.into();
|
||||
Ok(Ok(dap_binary.try_into()?))
|
||||
Ok(Ok(dap_binary.try_into().into_wasmtime_result()?))
|
||||
}
|
||||
Extension::V0_5_0(_)
|
||||
| Extension::V0_4_0(_)
|
||||
@@ -1171,9 +1183,9 @@ impl Extension {
|
||||
| Extension::V0_1_0(_)
|
||||
| Extension::V0_0_6(_)
|
||||
| Extension::V0_0_4(_)
|
||||
| Extension::V0_0_1(_) => {
|
||||
anyhow::bail!("`dap_config_to_scenario` not available prior to v0.6.0");
|
||||
}
|
||||
| Extension::V0_0_1(_) => Err(wasmtime::Error::msg(
|
||||
"`dap_config_to_scenario` not available prior to v0.6.0",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1184,7 +1196,7 @@ impl Extension {
|
||||
build_config_template: TaskTemplate,
|
||||
resolved_label: String,
|
||||
debug_adapter_name: String,
|
||||
) -> Result<Option<DebugScenario>> {
|
||||
) -> wasmtime::Result<Option<DebugScenario>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
let build_config_template = build_config_template.into();
|
||||
@@ -1198,7 +1210,10 @@ impl Extension {
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(dap_binary.map(TryInto::try_into).transpose()?)
|
||||
Ok(dap_binary
|
||||
.map(TryInto::try_into)
|
||||
.transpose()
|
||||
.into_wasmtime_result()?)
|
||||
}
|
||||
Extension::V0_6_0(ext) => {
|
||||
let build_config_template: latest::dap::TaskTemplate = build_config_template.into();
|
||||
@@ -1214,7 +1229,8 @@ impl Extension {
|
||||
|
||||
Ok(dap_binary
|
||||
.map(|s| latest::DebugScenario::from(s).try_into())
|
||||
.transpose()?)
|
||||
.transpose()
|
||||
.into_wasmtime_result()?)
|
||||
}
|
||||
Extension::V0_5_0(_)
|
||||
| Extension::V0_4_0(_)
|
||||
@@ -1223,9 +1239,9 @@ impl Extension {
|
||||
| Extension::V0_1_0(_)
|
||||
| Extension::V0_0_6(_)
|
||||
| Extension::V0_0_4(_)
|
||||
| Extension::V0_0_1(_) => {
|
||||
anyhow::bail!("`dap_locator_create_scenario` not available prior to v0.6.0");
|
||||
}
|
||||
| Extension::V0_0_1(_) => Err(wasmtime::Error::msg(
|
||||
"`dap_locator_create_scenario` not available prior to v0.6.0",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1234,24 +1250,25 @@ impl Extension {
|
||||
store: &mut Store<WasmState>,
|
||||
locator_name: String,
|
||||
resolved_build_task: SpawnInTerminal,
|
||||
) -> Result<Result<DebugRequest, String>> {
|
||||
) -> wasmtime::Result<Result<DebugRequest, String>> {
|
||||
match self {
|
||||
Extension::V0_8_0(ext) => {
|
||||
let build_config_template = resolved_build_task.try_into()?;
|
||||
let build_config_template =
|
||||
resolved_build_task.try_into().into_wasmtime_result()?;
|
||||
let dap_request = ext
|
||||
.call_run_dap_locator(store, &locator_name, &build_config_template)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
Ok(Ok(dap_request.into()))
|
||||
}
|
||||
Extension::V0_6_0(ext) => {
|
||||
let build_config_template: latest::dap::TaskTemplate =
|
||||
resolved_build_task.try_into()?;
|
||||
resolved_build_task.try_into().into_wasmtime_result()?;
|
||||
let dap_request = ext
|
||||
.call_run_dap_locator(store, &locator_name, &build_config_template.into())
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{e:?}"))?;
|
||||
.map_err(|error| wasmtime::Error::msg(format!("{error:?}")))?;
|
||||
|
||||
let dap_request: latest::DebugRequest = dap_request.into();
|
||||
Ok(Ok(dap_request.into()))
|
||||
@@ -1263,13 +1280,23 @@ impl Extension {
|
||||
| Extension::V0_1_0(_)
|
||||
| Extension::V0_0_6(_)
|
||||
| Extension::V0_0_4(_)
|
||||
| Extension::V0_0_1(_) => {
|
||||
anyhow::bail!("`run_dap_locator` not available prior to v0.6.0");
|
||||
}
|
||||
| Extension::V0_0_1(_) => Err(wasmtime::Error::msg(
|
||||
"`run_dap_locator` not available prior to v0.6.0",
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait IntoWasmtimeResult<T> {
|
||||
fn into_wasmtime_result(self) -> wasmtime::Result<T>;
|
||||
}
|
||||
|
||||
impl<T> IntoWasmtimeResult<T> for Result<T> {
|
||||
fn into_wasmtime_result(self) -> wasmtime::Result<T> {
|
||||
self.map_err(wasmtime::Error::from_anyhow)
|
||||
}
|
||||
}
|
||||
|
||||
trait ToWasmtimeResult<T> {
|
||||
fn to_wasmtime_result(self) -> wasmtime::Result<Result<T, String>>;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ impl ExtensionImports for WasmState {
|
||||
since_v0_6_0::zed::extension::github::Host::latest_github_release(self, repo, options).await
|
||||
}
|
||||
|
||||
async fn current_platform(&mut self) -> Result<(Os, Architecture)> {
|
||||
async fn current_platform(&mut self) -> wasmtime::Result<(Os, Architecture)> {
|
||||
since_v0_6_0::zed::extension::platform::Host::current_platform(self).await
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
@@ -140,7 +140,7 @@ impl ExtensionImports for WasmState {
|
||||
since_v0_6_0::zed::extension::github::Host::latest_github_release(self, repo, options).await
|
||||
}
|
||||
|
||||
async fn current_platform(&mut self) -> Result<(Os, Architecture)> {
|
||||
async fn current_platform(&mut self) -> wasmtime::Result<(Os, Architecture)> {
|
||||
since_v0_6_0::zed::extension::platform::Host::current_platform(self).await
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use crate::wasm_host::{WasmState, wit::ToWasmtimeResult};
|
||||
use crate::wasm_host::{
|
||||
WasmState,
|
||||
wit::{IntoWasmtimeResult, ToWasmtimeResult},
|
||||
};
|
||||
use ::http_client::{AsyncBody, HttpRequestExt};
|
||||
use ::settings::{Settings, WorktreeId};
|
||||
use anyhow::{Context as _, Result, bail};
|
||||
@@ -36,7 +39,7 @@ wasmtime::component::bindgen!({
|
||||
with: {
|
||||
"worktree": ExtensionWorktree,
|
||||
"key-value-store": ExtensionKeyValueStore,
|
||||
"zed:extension/http-client/http-response-stream": ExtensionHttpResponseStream,
|
||||
"zed:extension/http-client.http-response-stream": ExtensionHttpResponseStream,
|
||||
"zed:extension/github": since_v0_6_0::zed::extension::github,
|
||||
"zed:extension/nodejs": latest::zed::extension::nodejs,
|
||||
"zed:extension/platform": since_v0_6_0::zed::extension::platform,
|
||||
@@ -255,7 +258,7 @@ impl HostKeyValueStore for WasmState {
|
||||
kv_store.insert(key, value).await.to_wasmtime_result()
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -296,7 +299,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
@@ -327,7 +330,7 @@ impl http_client::Host for WasmState {
|
||||
&mut self,
|
||||
request: http_client::HttpRequest,
|
||||
) -> wasmtime::Result<Result<Resource<ExtensionHttpResponseStream>, String>> {
|
||||
let request = convert_request(&request)?;
|
||||
let request = convert_request(&request).into_wasmtime_result()?;
|
||||
let response = self.host.http_client.send(request);
|
||||
maybe!(async {
|
||||
let response = response.await?;
|
||||
@@ -361,7 +364,10 @@ impl http_client::HostHttpResponseStream for WasmState {
|
||||
.to_wasmtime_result()
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _resource: Resource<ExtensionHttpResponseStream>) -> Result<()> {
|
||||
async fn drop(
|
||||
&mut self,
|
||||
_resource: Resource<ExtensionHttpResponseStream>,
|
||||
) -> wasmtime::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -584,7 +590,8 @@ impl ExtensionImports for WasmState {
|
||||
let path = self
|
||||
.host
|
||||
.writeable_path_from_extension(&self.manifest.id, Path::new(&path))
|
||||
.await?;
|
||||
.await
|
||||
.into_wasmtime_result()?;
|
||||
|
||||
make_file_executable(&path)
|
||||
.await
|
||||
|
||||
@@ -139,7 +139,7 @@ impl HostKeyValueStore for WasmState {
|
||||
latest::HostKeyValueStore::insert(self, kv_store, key, value).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -153,7 +153,7 @@ impl HostProject for WasmState {
|
||||
latest::HostProject::worktree_ids(self, project).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of projects.
|
||||
Ok(())
|
||||
}
|
||||
@@ -194,7 +194,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ impl HostKeyValueStore for WasmState {
|
||||
latest::HostKeyValueStore::insert(self, kv_store, key, value).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -134,7 +134,7 @@ impl HostProject for WasmState {
|
||||
latest::HostProject::worktree_ids(self, project).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of projects.
|
||||
Ok(())
|
||||
}
|
||||
@@ -175,7 +175,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ impl HostKeyValueStore for WasmState {
|
||||
latest::HostKeyValueStore::insert(self, kv_store, key, value).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -134,7 +134,7 @@ impl HostProject for WasmState {
|
||||
latest::HostProject::worktree_ids(self, project).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of projects.
|
||||
Ok(())
|
||||
}
|
||||
@@ -175,7 +175,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ impl HostKeyValueStore for WasmState {
|
||||
latest::HostKeyValueStore::insert(self, kv_store, key, value).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -135,7 +135,7 @@ impl HostProject for WasmState {
|
||||
latest::HostProject::worktree_ids(self, project).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of projects.
|
||||
Ok(())
|
||||
}
|
||||
@@ -176,7 +176,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ impl HostKeyValueStore for WasmState {
|
||||
latest::HostKeyValueStore::insert(self, kv_store, key, value).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -293,7 +293,7 @@ impl HostProject for WasmState {
|
||||
latest::HostProject::worktree_ids(self, project).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of projects.
|
||||
Ok(())
|
||||
}
|
||||
@@ -334,7 +334,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
@@ -403,7 +403,9 @@ impl From<latest::platform::Os> for platform::Os {
|
||||
}
|
||||
|
||||
impl platform::Host for WasmState {
|
||||
async fn current_platform(&mut self) -> Result<(platform::Os, platform::Architecture)> {
|
||||
async fn current_platform(
|
||||
&mut self,
|
||||
) -> wasmtime::Result<(platform::Os, platform::Architecture)> {
|
||||
latest::platform::Host::current_platform(self)
|
||||
.await
|
||||
.map(|(os, arch)| (os.into(), arch.into()))
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use crate::wasm_host::wit::since_v0_6_0::slash_command::SlashCommandOutputSection;
|
||||
use crate::wasm_host::wit::{CompletionKind, CompletionLabelDetails, InsertTextFormat, SymbolKind};
|
||||
use crate::wasm_host::{WasmState, wit::ToWasmtimeResult};
|
||||
use crate::wasm_host::{
|
||||
WasmState,
|
||||
wit::{IntoWasmtimeResult, ToWasmtimeResult},
|
||||
};
|
||||
use ::http_client::{AsyncBody, HttpRequestExt};
|
||||
use ::settings::{Settings, WorktreeId};
|
||||
use anyhow::{Context as _, Result, bail};
|
||||
@@ -45,7 +48,7 @@ wasmtime::component::bindgen!({
|
||||
"worktree": ExtensionWorktree,
|
||||
"project": ExtensionProject,
|
||||
"key-value-store": ExtensionKeyValueStore,
|
||||
"zed:extension/http-client/http-response-stream": ExtensionHttpResponseStream
|
||||
"zed:extension/http-client.http-response-stream": ExtensionHttpResponseStream
|
||||
},
|
||||
});
|
||||
|
||||
@@ -553,7 +556,7 @@ impl HostKeyValueStore for WasmState {
|
||||
kv_store.insert(key, value).await.to_wasmtime_result()
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -568,7 +571,7 @@ impl HostProject for WasmState {
|
||||
Ok(project.worktree_ids())
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of projects.
|
||||
Ok(())
|
||||
}
|
||||
@@ -595,7 +598,9 @@ impl HostWorktree for WasmState {
|
||||
) -> wasmtime::Result<Result<String, String>> {
|
||||
let delegate = self.table.get(&delegate)?;
|
||||
Ok(delegate
|
||||
.read_text_file(&RelPath::new(Path::new(&path), PathStyle::Unix)?)
|
||||
.read_text_file(
|
||||
&RelPath::new(Path::new(&path), PathStyle::Unix).into_wasmtime_result()?,
|
||||
)
|
||||
.await
|
||||
.map_err(|error| error.to_string()))
|
||||
}
|
||||
@@ -617,7 +622,7 @@ impl HostWorktree for WasmState {
|
||||
Ok(delegate.which(binary_name).await)
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> wasmtime::Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
@@ -648,7 +653,7 @@ impl http_client::Host for WasmState {
|
||||
&mut self,
|
||||
request: http_client::HttpRequest,
|
||||
) -> wasmtime::Result<Result<Resource<ExtensionHttpResponseStream>, String>> {
|
||||
let request = convert_request(&request)?;
|
||||
let request = convert_request(&request).into_wasmtime_result()?;
|
||||
let response = self.host.http_client.send(request);
|
||||
maybe!(async {
|
||||
let response = response.await?;
|
||||
@@ -682,7 +687,10 @@ impl http_client::HostHttpResponseStream for WasmState {
|
||||
.to_wasmtime_result()
|
||||
}
|
||||
|
||||
async fn drop(&mut self, _resource: Resource<ExtensionHttpResponseStream>) -> Result<()> {
|
||||
async fn drop(
|
||||
&mut self,
|
||||
_resource: Resource<ExtensionHttpResponseStream>,
|
||||
) -> wasmtime::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -787,7 +795,8 @@ impl nodejs::Host for WasmState {
|
||||
version: String,
|
||||
) -> wasmtime::Result<Result<(), String>> {
|
||||
self.capability_granter
|
||||
.grant_npm_install_package(&package_name)?;
|
||||
.grant_npm_install_package(&package_name)
|
||||
.into_wasmtime_result()?;
|
||||
|
||||
self.host
|
||||
.node_runtime
|
||||
@@ -859,18 +868,20 @@ impl github::Host for WasmState {
|
||||
}
|
||||
|
||||
impl platform::Host for WasmState {
|
||||
async fn current_platform(&mut self) -> Result<(platform::Os, platform::Architecture)> {
|
||||
async fn current_platform(
|
||||
&mut self,
|
||||
) -> wasmtime::Result<(platform::Os, platform::Architecture)> {
|
||||
Ok((
|
||||
match env::consts::OS {
|
||||
"macos" => platform::Os::Mac,
|
||||
"linux" => platform::Os::Linux,
|
||||
"windows" => platform::Os::Windows,
|
||||
_ => bail!("unsupported os"),
|
||||
_ => return Err(wasmtime::Error::msg("unsupported os")),
|
||||
},
|
||||
match env::consts::ARCH {
|
||||
"aarch64" => platform::Architecture::Aarch64,
|
||||
"x86_64" => platform::Architecture::X8664,
|
||||
_ => bail!("unsupported architecture"),
|
||||
_ => return Err(wasmtime::Error::msg("unsupported architecture")),
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -1139,7 +1150,8 @@ impl ExtensionImports for WasmState {
|
||||
let path = self
|
||||
.host
|
||||
.writeable_path_from_extension(&self.manifest.id, Path::new(&path))
|
||||
.await?;
|
||||
.await
|
||||
.into_wasmtime_result()?;
|
||||
|
||||
make_file_executable(&path)
|
||||
.await
|
||||
|
||||
Reference in new issue
Block a user