mirror of
https://github.com/biomejs/biome.git
synced 2025-12-23 08:21:13 +00:00
feat(lsp): report progress while scanning the project (#7961)
Some checks are pending
Benchmarks Configuration / Bench (push) Waiting to run
Benchmarks CSS / Bench (push) Waiting to run
Benchmarks GraphQL / Bench (push) Waiting to run
Benchmarks JS / Bench (push) Waiting to run
Benchmarks JSON / Bench (push) Waiting to run
Benchmarks Manifests / Bench (push) Waiting to run
Benchmarks Module Graph / Bench (push) Waiting to run
Repository dispatch on main / Build @biomejs/wasm-web (push) Waiting to run
Repository dispatch on main / Repository dispatch (push) Blocked by required conditions
Some checks are pending
Benchmarks Configuration / Bench (push) Waiting to run
Benchmarks CSS / Bench (push) Waiting to run
Benchmarks GraphQL / Bench (push) Waiting to run
Benchmarks JS / Bench (push) Waiting to run
Benchmarks JSON / Bench (push) Waiting to run
Benchmarks Manifests / Bench (push) Waiting to run
Benchmarks Module Graph / Bench (push) Waiting to run
Repository dispatch on main / Build @biomejs/wasm-web (push) Waiting to run
Repository dispatch on main / Repository dispatch (push) Blocked by required conditions
This commit is contained in:
parent
0b28f5f47a
commit
a04c8dfbd7
5 changed files with 47 additions and 2 deletions
5
.changeset/clever-clocks-decide.md
Normal file
5
.changeset/clever-clocks-decide.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@biomejs/biome": minor
|
||||
---
|
||||
|
||||
The Biome Language Server now reports progress while scanning files and dependencies in the project.
|
||||
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -1248,6 +1248,7 @@ dependencies = [
|
|||
"tower",
|
||||
"tower-lsp-server",
|
||||
"tracing",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -5641,11 +5642,13 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
|||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.15.1"
|
||||
version = "1.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
|
||||
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
||||
dependencies = [
|
||||
"getrandom 0.3.2",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ unicode-bom = "2.0.3"
|
|||
unicode-width = "0.1.12"
|
||||
ureq = "3.1.2"
|
||||
url = "2.5.7"
|
||||
uuid = "1.18.1"
|
||||
walkdir = "2.5.0"
|
||||
web-time = "1.1.0"
|
||||
windows = "0.61.3"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ serde_json = { workspace = true }
|
|||
tokio = { workspace = true, features = ["rt", "io-std"] }
|
||||
tower-lsp-server = { workspace = true }
|
||||
tracing = { workspace = true, features = ["attributes"] }
|
||||
uuid = { workspace = true, features = ["v4"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] }
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ use tower_lsp_server::lsp_types::{MessageType, Registration};
|
|||
use tower_lsp_server::lsp_types::{Unregistration, WorkspaceFolder};
|
||||
use tower_lsp_server::{Client, UriExt, lsp_types};
|
||||
use tracing::{debug, error, info, instrument, warn};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub(crate) struct ClientInformation {
|
||||
/// The name of the client
|
||||
|
|
@ -702,6 +703,36 @@ impl Session {
|
|||
scan_kind: ScanKind,
|
||||
force: bool,
|
||||
) {
|
||||
let progress_token = lsp_types::ProgressToken::String(Uuid::new_v4().to_string());
|
||||
let is_work_done_progress_supported = self.initialize_params.get().is_some_and(|params| {
|
||||
params
|
||||
.client_capabilities
|
||||
.window
|
||||
.as_ref()
|
||||
.is_some_and(|window| window.work_done_progress == Some(true))
|
||||
});
|
||||
|
||||
// Let the user know the scanning is taking long time using the $/progress notification.
|
||||
let progress = if is_work_done_progress_supported
|
||||
&& self
|
||||
.client
|
||||
.send_request::<lsp_types::request::WorkDoneProgressCreate>(
|
||||
lsp_types::WorkDoneProgressCreateParams {
|
||||
token: progress_token.clone(),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
let progress = self
|
||||
.client
|
||||
.progress(progress_token.clone(), "Biome is scanning the project");
|
||||
|
||||
Some(progress.begin().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let session = self.clone();
|
||||
|
||||
spawn_blocking(move || {
|
||||
|
|
@ -738,6 +769,10 @@ impl Session {
|
|||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
if let Some(progress) = progress {
|
||||
progress.finish().await;
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue