diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-04-05 18:33:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 22:33:01 +0000 |
commit | 83f92474c5e8375ebe2213b4d62d4211fd011c2f (patch) | |
tree | 2fb1d6b80c68bd1f6f1b0f07e0ed41eac3bcf356 /tests/util/server/src/lsp.rs | |
parent | 61f1b8e8dc20846093a8b24a8f511a09bbf09919 (diff) |
perf(lsp): use lockfile to reduce npm pkg resolution time (#23247)
This functionality was broken. The series of events was:
1. Load the npm resolution from the lockfile.
2. Discover only a subset of the specifiers in the documents.
3. Clear the npm snapshot.
4. Redo npm resolution with the new specifiers (~500ms).
What this now does:
1. Load the npm resolution from the lockfile.
2. Discover only a subset of the specifiers in the documents and take
into account the specifiers from the lockfile.
3. Do not redo resolution (~1ms).
Diffstat (limited to 'tests/util/server/src/lsp.rs')
-rw-r--r-- | tests/util/server/src/lsp.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/util/server/src/lsp.rs b/tests/util/server/src/lsp.rs index be455b463..07b63c8a8 100644 --- a/tests/util/server/src/lsp.rs +++ b/tests/util/server/src/lsp.rs @@ -464,6 +464,7 @@ impl InitializeParamsBuilder { pub struct LspClientBuilder { print_stderr: bool, capture_stderr: bool, + log_debug: bool, deno_exe: PathRef, root_dir: PathRef, use_diagnostic_sync: bool, @@ -481,6 +482,7 @@ impl LspClientBuilder { Self { print_stderr: false, capture_stderr: false, + log_debug: false, deno_exe: deno_exe_path(), root_dir: deno_dir.path().clone(), use_diagnostic_sync: true, @@ -507,6 +509,11 @@ impl LspClientBuilder { self } + pub fn log_debug(mut self) -> Self { + self.log_debug = true; + self + } + /// Whether to use the synchronization messages to better sync diagnostics /// between the test client and server. pub fn use_diagnostic_sync(mut self, value: bool) -> Self { @@ -537,6 +544,10 @@ impl LspClientBuilder { pub fn build_result(&self) -> Result<LspClient> { let deno_dir = self.deno_dir.clone(); let mut command = Command::new(&self.deno_exe); + let mut args = vec!["lsp".to_string()]; + if self.log_debug { + args.push("--log-level=debug".to_string()); + } command .env("DENO_DIR", deno_dir.path()) .env("NPM_CONFIG_REGISTRY", npm_registry_url()) @@ -547,7 +558,7 @@ impl LspClientBuilder { if self.use_diagnostic_sync { "1" } else { "" }, ) .env("DENO_NO_UPDATE_CHECK", "1") - .arg("lsp") + .args(args) .stdin(Stdio::piped()) .stdout(Stdio::piped()); for (key, value) in &self.envs { @@ -651,7 +662,10 @@ impl LspClient { } #[track_caller] - pub fn wait_until_stderr_line(&self, condition: impl Fn(&str) -> bool) { + pub fn wait_until_stderr_line( + &self, + mut condition: impl FnMut(&str) -> bool, + ) { let timeout_time = Instant::now().checked_add(Duration::from_secs(5)).unwrap(); let lines_rx = self |