Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable handling of grit files #4473

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/repository_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build WASM module for the web
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm --features experimental-html,experimental-grit
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm --features experimental-html

# https://github.com/actions/cache/issues/342
- name: Clear old wasm-pack cache
Expand Down
1 change: 0 additions & 1 deletion crates/biome_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ tokio = { workspace = true, features = ["io-util"] }

[features]
docgen = ["bpaf/docgen"]
experimental-grit = ["biome_service/experimental-grit"]
experimental-html = ["biome_service/experimental-html"]

[lints]
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_grit_formatter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ biome_fs = { path = "../biome_fs" }
biome_grit_factory = { path = "../biome_grit_factory" }
biome_grit_parser = { path = "../biome_grit_parser" }
biome_parser = { path = "../biome_parser" }
biome_service = { path = "../biome_service", features = ["experimental-grit"] }
biome_service = { path = "../biome_service" }
countme = { workspace = true, features = ["enable"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions crates/biome_service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ smallvec = { workspace = true, features = ["serde"] }
tracing = { workspace = true, features = ["attributes", "log"] }

[features]
experimental-grit = []
experimental-html = []

schema = [
Expand All @@ -83,7 +82,6 @@ schema = [
"biome_css_syntax/schema",
"biome_graphql_syntax/schema",
"biome_grit_syntax/schema",

]

[dev-dependencies]
Expand Down
6 changes: 2 additions & 4 deletions crates/biome_service/src/file_handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ impl DocumentFileSource {
return Ok(file_source.into());
}

#[cfg(feature = "experimental-grit")]
if let Ok(file_source) = GritFileSource::try_from_extension(extension) {
return Ok(file_source.into());
}
Expand Down Expand Up @@ -192,7 +191,6 @@ impl DocumentFileSource {
if let Ok(file_source) = HtmlFileSource::try_from_language_id(language_id) {
return Ok(file_source.into());
}
#[cfg(feature = "experimental-grit")]
if let Ok(file_source) = GritFileSource::try_from_language_id(language_id) {
return Ok(file_source.into());
}
Expand Down Expand Up @@ -350,9 +348,9 @@ impl DocumentFileSource {
},
DocumentFileSource::Css(_)
| DocumentFileSource::Graphql(_)
| DocumentFileSource::Json(_) => true,
| DocumentFileSource::Json(_)
| DocumentFileSource::Grit(_) => true,
DocumentFileSource::Html(_) => cfg!(feature = "experimental-html"),
DocumentFileSource::Grit(_) => cfg!(feature = "experimental-grit"),
DocumentFileSource::Unknown => false,
}
}
Expand Down
24 changes: 24 additions & 0 deletions crates/biome_service/tests/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,28 @@ type User {
let diagnostics = result.unwrap().diagnostics;
assert_eq!(diagnostics.len(), 1)
}

#[test]
fn pull_grit_debug_info() {
let workspace = create_server();

let grit_file = FileGuard::open(
workspace.as_ref(),
OpenFileParams {
path: BiomePath::new("file.grit"),
content: r#"`function ($args) { $body }` where {
$args <: contains `x`
}"#
.into(),
version: 0,
document_file_source: None,
},
)
.unwrap();
let result = grit_file.get_syntax_tree();
assert!(result.is_ok());
let syntax = result.unwrap().ast;

assert!(syntax.starts_with("GritRoot"))
}
}
1 change: 0 additions & 1 deletion crates/biome_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook"]
experimental-grit = ["biome_service/experimental-grit"]
experimental-html = ["biome_service/experimental-html"]

[dependencies]
Expand Down