diff options
Diffstat (limited to 'cli/lsp')
-rw-r--r-- | cli/lsp/language_server.rs | 11 | ||||
-rw-r--r-- | cli/lsp/testing/execution.rs | 40 |
2 files changed, 26 insertions, 25 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 288e45362..d49a2559c 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -76,6 +76,7 @@ use crate::args::LintOptions; use crate::args::TsConfig; use crate::cache::DenoDir; use crate::cache::HttpCache; +use crate::factory::CliFactory; use crate::file_fetcher::FileFetcher; use crate::graph_util; use crate::http_util::HttpClient; @@ -85,7 +86,6 @@ use crate::npm::CliNpmRegistryApi; use crate::npm::CliNpmResolver; use crate::npm::NpmCache; use crate::npm::NpmResolution; -use crate::proc_state::ProcState; use crate::tools::fmt::format_file; use crate::tools::fmt::format_parsed_source; use crate::util::fs::remove_dir_all_if_exists; @@ -185,15 +185,14 @@ impl LanguageServer { .into_iter() .map(|d| (d.specifier().clone(), d)) .collect::<HashMap<_, _>>(); - // todo(dsherret): don't use ProcState here - let ps = ProcState::from_cli_options(Arc::new(cli_options)).await?; - let mut inner_loader = ps.module_graph_builder.create_graph_loader(); + let factory = CliFactory::from_cli_options(Arc::new(cli_options)); + let module_graph_builder = factory.module_graph_builder().await?; + let mut inner_loader = module_graph_builder.create_graph_loader(); let mut loader = crate::lsp::documents::OpenDocumentsGraphLoader { inner_loader: &mut inner_loader, open_docs: &open_docs, }; - let graph = ps - .module_graph_builder + let graph = module_graph_builder .create_graph_with_loader(roots.clone(), &mut loader) .await?; graph_util::graph_valid( diff --git a/cli/lsp/testing/execution.rs b/cli/lsp/testing/execution.rs index 5dfb31013..4834cd0c9 100644 --- a/cli/lsp/testing/execution.rs +++ b/cli/lsp/testing/execution.rs @@ -6,11 +6,11 @@ use super::lsp_custom; use crate::args::flags_from_vec; use crate::args::DenoSubcommand; +use crate::factory::CliFactory; use crate::lsp::client::Client; use crate::lsp::client::TestingNotification; use crate::lsp::config; use crate::lsp::logging::lsp_log; -use crate::proc_state; use crate::tools::test; use crate::tools::test::FailFastTracker; use crate::tools::test::TestEventSender; @@ -218,16 +218,16 @@ impl TestRun { let args = self.get_args(); lsp_log!("Executing test run with arguments: {}", args.join(" ")); let flags = flags_from_vec(args.into_iter().map(String::from).collect())?; - let ps = proc_state::ProcState::from_flags(flags).await?; + let factory = CliFactory::from_flags(flags).await?; // Various test files should not share the same permissions in terms of // `PermissionsContainer` - otherwise granting/revoking permissions in one // file would have impact on other files, which is undesirable. let permissions = - Permissions::from_options(&ps.options.permissions_options())?; + Permissions::from_options(&factory.cli_options().permissions_options())?; test::check_specifiers( - &ps.options, - &ps.file_fetcher, - &ps.module_load_preparer, + factory.cli_options(), + factory.file_fetcher()?, + factory.module_load_preparer().await?, self .queue .iter() @@ -236,18 +236,19 @@ impl TestRun { ) .await?; - let (concurrent_jobs, fail_fast) = - if let DenoSubcommand::Test(test_flags) = ps.options.sub_command() { - ( - test_flags - .concurrent_jobs - .unwrap_or_else(|| NonZeroUsize::new(1).unwrap()) - .into(), - test_flags.fail_fast, - ) - } else { - unreachable!("Should always be Test subcommand."); - }; + let (concurrent_jobs, fail_fast) = if let DenoSubcommand::Test(test_flags) = + factory.cli_options().sub_command() + { + ( + test_flags + .concurrent_jobs + .unwrap_or_else(|| NonZeroUsize::new(1).unwrap()) + .into(), + test_flags.fail_fast, + ) + } else { + unreachable!("Should always be Test subcommand."); + }; let (sender, mut receiver) = mpsc::unbounded_channel::<test::TestEvent>(); let sender = TestEventSender::new(sender); @@ -259,7 +260,8 @@ impl TestRun { let tests: Arc<RwLock<IndexMap<usize, test::TestDescription>>> = Arc::new(RwLock::new(IndexMap::new())); let mut test_steps = IndexMap::new(); - let worker_factory = Arc::new(ps.create_cli_main_worker_factory()); + let worker_factory = + Arc::new(factory.create_cli_main_worker_factory().await?); let join_handles = queue.into_iter().map(move |specifier| { let specifier = specifier.clone(); |