From 4364c48f3e3d6138b7da9879071427075453ae91 Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Fri, 9 Aug 2024 14:16:51 -0300 Subject: [PATCH] Re-shape file_manager_and_file_from to build_workspace_file_manager now it only returns a FileManager --- tooling/nargo/src/lib.rs | 11 ++--------- tooling/nargo_cli/src/cli/dap_cmd.rs | 7 +++---- tooling/nargo_cli/src/cli/debug_cmd.rs | 10 +++++----- tooling/nargo_cli/src/cli/test_cmd.rs | 8 +++++--- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/tooling/nargo/src/lib.rs b/tooling/nargo/src/lib.rs index 3f16419ba81..921cc6cb57b 100644 --- a/tooling/nargo/src/lib.rs +++ b/tooling/nargo/src/lib.rs @@ -43,17 +43,10 @@ pub fn prepare_dependencies( } } -// TODO: find a better name -// Also, should we create a type that englobe fileManager + parsed_files? -// functions that need file_manager needs parsed_files as well -pub fn file_manager_and_files_from( - root: &Path, - workspace: &workspace::Workspace, -) -> (FileManager, ParsedFiles) { +pub fn build_workspace_file_manager(root: &Path, workspace: &workspace::Workspace) -> FileManager { let mut workspace_file_manager = file_manager_with_stdlib(root); insert_all_files_for_workspace_into_file_manager(workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); - (workspace_file_manager, parsed_files) + workspace_file_manager } pub fn insert_all_files_for_workspace_into_file_manager( diff --git a/tooling/nargo_cli/src/cli/dap_cmd.rs b/tooling/nargo_cli/src/cli/dap_cmd.rs index 3faaaae2b72..e9f8836a5a9 100644 --- a/tooling/nargo_cli/src/cli/dap_cmd.rs +++ b/tooling/nargo_cli/src/cli/dap_cmd.rs @@ -4,9 +4,9 @@ use acvm::FieldElement; use bn254_blackbox_solver::Bn254BlackBoxSolver; use clap::Args; use nargo::constants::PROVER_INPUT_FILE; -use nargo::file_manager_and_files_from; use nargo::package::Package; use nargo::workspace::Workspace; +use nargo::{build_workspace_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; use noirc_driver::{ @@ -157,9 +157,8 @@ fn load_and_compile_test_function( package: &Package, compile_options: &CompileOptions, ) -> Result<(CompiledProgram, Option), LoadError> { - let (workspace_file_manager, mut parsed_files) = - file_manager_and_files_from(&workspace.root_dir, &workspace); - + let workspace_file_manager = build_workspace_file_manager(&workspace.root_dir, &workspace); + let mut parsed_files = parse_all(&workspace_file_manager); let test_functions = get_tests_in_package( &workspace_file_manager, &parsed_files, diff --git a/tooling/nargo_cli/src/cli/debug_cmd.rs b/tooling/nargo_cli/src/cli/debug_cmd.rs index 7f859252114..f9781e82fe9 100644 --- a/tooling/nargo_cli/src/cli/debug_cmd.rs +++ b/tooling/nargo_cli/src/cli/debug_cmd.rs @@ -15,7 +15,7 @@ use nargo::ops::{ }; use nargo::package::Package; use nargo::workspace::Workspace; -use nargo::{file_manager_and_files_from, prepare_package, NargoError}; +use nargo::{build_workspace_file_manager, parse_all, prepare_package, NargoError}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::{Format, InputValue}; @@ -131,8 +131,8 @@ pub(crate) fn compile_bin_package_for_debugging( package: &Package, compile_options: &CompileOptions, ) -> Result { - let (workspace_file_manager, mut parsed_files) = - file_manager_and_files_from(std::path::Path::new(""), workspace); + let workspace_file_manager = build_workspace_file_manager(std::path::Path::new(""), workspace); + let mut parsed_files = parse_all(&workspace_file_manager); let compilation_result = if compile_options.instrument_debug { let debug_state = @@ -195,8 +195,8 @@ fn debug_test( execution_params: ExecutionParams, expression_width: ExpressionWidth, ) -> Result<(), CliError> { - let (workspace_file_manager, mut parsed_files) = - file_manager_and_files_from(&workspace.root_dir, &workspace); + let workspace_file_manager = build_workspace_file_manager(&workspace.root_dir, &workspace); + let mut parsed_files = parse_all(&workspace_file_manager); let (mut context, crate_id) = prepare_package_for_debug(&workspace_file_manager, &mut parsed_files, package); diff --git a/tooling/nargo_cli/src/cli/test_cmd.rs b/tooling/nargo_cli/src/cli/test_cmd.rs index 49c571f95cd..d325a76abd9 100644 --- a/tooling/nargo_cli/src/cli/test_cmd.rs +++ b/tooling/nargo_cli/src/cli/test_cmd.rs @@ -4,7 +4,9 @@ use acvm::{BlackBoxFunctionSolver, FieldElement}; use bn254_blackbox_solver::Bn254BlackBoxSolver; use clap::Args; use fm::FileManager; -use nargo::{file_manager_and_files_from, ops::TestStatus, package::Package, prepare_package}; +use nargo::{ + build_workspace_file_manager, ops::TestStatus, package::Package, parse_all, prepare_package, +}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{check_crate, compile_no_check, CompileOptions, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::{ @@ -60,8 +62,8 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError Some(NOIR_ARTIFACT_VERSION_STRING.to_string()), )?; - let (workspace_file_manager, parsed_files) = - file_manager_and_files_from(&workspace.root_dir, &workspace); + let workspace_file_manager = build_workspace_file_manager(&workspace.root_dir, &workspace); + let parsed_files = parse_all(&workspace_file_manager); let pattern = match &args.test_name { Some(name) => {