Upgrade tree sitter and all grammars (#17734)

Fixes https://github.com/zed-industries/zed/issues/5291

Release Notes:

- Fixed a bug where the 'toggle comments' command didn't use the right
comment syntax in JSX and TSX elements.

---------

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
Max Brunsfeld 2024-09-16 17:10:57 -07:00 committed by GitHub
parent b54b3d6246
commit bc5ed1334f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 366 additions and 387 deletions

View file

@ -18,7 +18,7 @@ use wasm_encoder::{ComponentSectionId, Encode as _, RawSection, Section as _};
use wasmparser::Parser;
use wit_component::ComponentEncoder;
/// Currently, we compile with Rust's `wasm32-wasi` target, which works with WASI `preview1`.
/// Currently, we compile with Rust's `wasm32-wasip1` target, which works with WASI `preview1`.
/// But the WASM component model is based on WASI `preview2`. So we need an 'adapter' WASM
/// module, which implements the `preview1` interface in terms of `preview2`.
///
@ -447,7 +447,7 @@ impl ExtensionBuilder {
}
// This was adapted from:
// https://github.com/bytecodealliance/wasm-tools/1791a8f139722e9f8679a2bd3d8e423e55132b22/src/bin/wasm-tools/strip.rs
// https://github.com/bytecodealliance/wasm-tools/blob/1791a8f139722e9f8679a2bd3d8e423e55132b22/src/bin/wasm-tools/strip.rs
fn strip_custom_sections(&self, input: &Vec<u8>) -> Result<Vec<u8>> {
use wasmparser::Payload::*;
@ -458,13 +458,15 @@ impl ExtensionBuilder {
for payload in Parser::new(0).parse_all(input) {
let payload = payload?;
let component_header = wasm_encoder::Component::HEADER;
let module_header = wasm_encoder::Module::HEADER;
// Track nesting depth, so that we don't mess with inner producer sections:
match payload {
Version { encoding, .. } => {
output.extend_from_slice(match encoding {
wasmparser::Encoding::Component => &wasm_encoder::Component::HEADER,
wasmparser::Encoding::Module => &wasm_encoder::Module::HEADER,
wasmparser::Encoding::Component => &component_header,
wasmparser::Encoding::Module => &module_header,
});
}
ModuleSection { .. } | ComponentSection { .. } => {
@ -476,7 +478,7 @@ impl ExtensionBuilder {
Some(c) => c,
None => break,
};
if output.starts_with(&wasm_encoder::Component::HEADER) {
if output.starts_with(&component_header) {
parent.push(ComponentSectionId::Component as u8);
output.encode(&mut parent);
} else {

View file

@ -127,7 +127,7 @@ impl WasmHost {
},
);
let (mut extension, instance) = Extension::instantiate_async(
let mut extension = Extension::instantiate_async(
&mut store,
this.release_channel,
zed_api_version,
@ -143,7 +143,6 @@ impl WasmHost {
let (tx, mut rx) = mpsc::unbounded::<ExtensionCall>();
executor
.spawn(async move {
let _instance = instance;
while let Some(call) = rx.next().await {
(call)(&mut extension, &mut store).await;
}

View file

@ -13,7 +13,7 @@ use language::{LanguageServerName, LspAdapterDelegate};
use semantic_version::SemanticVersion;
use std::{ops::RangeInclusive, sync::Arc};
use wasmtime::{
component::{Component, Instance, Linker, Resource},
component::{Component, Linker, Resource},
Store,
};
@ -75,57 +75,55 @@ impl Extension {
release_channel: ReleaseChannel,
version: SemanticVersion,
component: &Component,
) -> Result<(Self, Instance)> {
) -> Result<Self> {
// Note: The release channel can be used to stage a new version of the extension API.
let _ = release_channel;
let allow_latest_version = match release_channel {
ReleaseChannel::Dev | ReleaseChannel::Nightly => true,
ReleaseChannel::Stable | ReleaseChannel::Preview => false,
};
if allow_latest_version && version >= latest::MIN_VERSION {
let (extension, instance) =
let extension =
latest::Extension::instantiate_async(store, component, latest::linker())
.await
.context("failed to instantiate wasm extension")?;
Ok((Self::V020(extension), instance))
Ok(Self::V020(extension))
} else if version >= since_v0_1_0::MIN_VERSION {
let (extension, instance) = since_v0_1_0::Extension::instantiate_async(
let extension = since_v0_1_0::Extension::instantiate_async(
store,
component,
since_v0_1_0::linker(),
)
.await
.context("failed to instantiate wasm extension")?;
Ok((Self::V010(extension), instance))
Ok(Self::V010(extension))
} else if version >= since_v0_0_6::MIN_VERSION {
let (extension, instance) = since_v0_0_6::Extension::instantiate_async(
let extension = since_v0_0_6::Extension::instantiate_async(
store,
component,
since_v0_0_6::linker(),
)
.await
.context("failed to instantiate wasm extension")?;
Ok((Self::V006(extension), instance))
Ok(Self::V006(extension))
} else if version >= since_v0_0_4::MIN_VERSION {
let (extension, instance) = since_v0_0_4::Extension::instantiate_async(
let extension = since_v0_0_4::Extension::instantiate_async(
store,
component,
since_v0_0_4::linker(),
)
.await
.context("failed to instantiate wasm extension")?;
Ok((Self::V004(extension), instance))
Ok(Self::V004(extension))
} else {
let (extension, instance) = since_v0_0_1::Extension::instantiate_async(
let extension = since_v0_0_1::Extension::instantiate_async(
store,
component,
since_v0_0_1::linker(),
)
.await
.context("failed to instantiate wasm extension")?;
Ok((Self::V001(extension), instance))
Ok(Self::V001(extension))
}
}

View file

@ -30,15 +30,7 @@ pub type ExtensionWorktree = Arc<dyn LspAdapterDelegate>;
pub fn linker() -> &'static Linker<WasmState> {
static LINKER: OnceLock<Linker<WasmState>> = OnceLock::new();
LINKER.get_or_init(|| {
super::new_linker(|linker, f| {
Extension::add_to_linker(linker, f)?;
latest::zed::extension::github::add_to_linker(linker, f)?;
latest::zed::extension::nodejs::add_to_linker(linker, f)?;
latest::zed::extension::platform::add_to_linker(linker, f)?;
Ok(())
})
})
LINKER.get_or_init(|| super::new_linker(Extension::add_to_linker))
}
impl From<Command> for latest::Command {