diff --git a/src/frontend/cli.rs b/src/frontend/cli.rs index c68198a34..18fb1fde4 100644 --- a/src/frontend/cli.rs +++ b/src/frontend/cli.rs @@ -433,6 +433,7 @@ pub fn main() { &mut analysis_db, &settings.analysis, &annotations, + settings.analysis_settings, ) { Ok(diagnostics) => diagnostics, Err(diagnostics) => { diff --git a/src/lsp/clarity_language_backend.rs b/src/lsp/clarity_language_backend.rs index 7c8fbe8d5..3030057d2 100644 --- a/src/lsp/clarity_language_backend.rs +++ b/src/lsp/clarity_language_backend.rs @@ -121,31 +121,34 @@ impl ClarityLanguageBackend { .interpreter .collect_annotations(&ast, &code); diagnostics.append(&mut annotation_diagnostics); - let (analysis, mut analysis_diagnostics) = match incremental_session - .interpreter - .run_analysis(contract_id.clone(), &mut ast, &annotations) - { - Ok(analysis) => analysis, - Err((_, Some(diagnostic), _)) => { - diagnostics.push(diagnostic); - collected_diagnostics.insert( - contract_url.clone(), - diagnostics - .into_iter() - .map(|d| utils::convert_clarity_diagnotic_to_lsp_diagnostic(d)) - .collect::>(), - ); - continue; - } - Err((_, _, Some(error))) => { - logs.push(format!("Unable to get anaylis: {:?}", error).into()); - continue; - } - _ => { - logs.push("Unable to get diagnostic".into()); - continue; - } - }; + let (analysis, mut analysis_diagnostics) = + match incremental_session.interpreter.run_analysis( + contract_id.clone(), + &mut ast, + &annotations, + settings.analysis_settings, + ) { + Ok(analysis) => analysis, + Err((_, Some(diagnostic), _)) => { + diagnostics.push(diagnostic); + collected_diagnostics.insert( + contract_url.clone(), + diagnostics + .into_iter() + .map(|d| utils::convert_clarity_diagnotic_to_lsp_diagnostic(d)) + .collect::>(), + ); + continue; + } + Err((_, _, Some(error))) => { + logs.push(format!("Unable to get anaylis: {:?}", error).into()); + continue; + } + _ => { + logs.push("Unable to get diagnostic".into()); + continue; + } + }; diagnostics.append(&mut analysis_diagnostics); collected_diagnostics.insert( contract_url.clone(), @@ -221,27 +224,30 @@ impl ClarityLanguageBackend { .interpreter .collect_annotations(&ast, &code); diagnostics.append(&mut annotation_diagnostics); - let (analysis, mut analysis_diagnostics) = match incremental_session - .interpreter - .run_analysis(contract_id.clone(), &mut ast, &annotations) - { - Ok(analysis) => analysis, - Err((_, Some(diagnostic), _)) => { - diagnostics.push(diagnostic); - collected_diagnostics.insert( - contract_url.clone(), - diagnostics - .into_iter() - .map(|d| utils::convert_clarity_diagnotic_to_lsp_diagnostic(d)) - .collect::>(), - ); - return Ok((collected_diagnostics, logs)); - } - _ => { - logs.push("Unable to get diagnostic".into()); - return Ok((collected_diagnostics, logs)); - } - }; + let (analysis, mut analysis_diagnostics) = + match incremental_session.interpreter.run_analysis( + contract_id.clone(), + &mut ast, + &annotations, + settings.analysis_settings, + ) { + Ok(analysis) => analysis, + Err((_, Some(diagnostic), _)) => { + diagnostics.push(diagnostic); + collected_diagnostics.insert( + contract_url.clone(), + diagnostics + .into_iter() + .map(|d| utils::convert_clarity_diagnotic_to_lsp_diagnostic(d)) + .collect::>(), + ); + return Ok((collected_diagnostics, logs)); + } + _ => { + logs.push("Unable to get diagnostic".into()); + return Ok((collected_diagnostics, logs)); + } + }; diagnostics.append(&mut analysis_diagnostics); collected_diagnostics.insert( contract_url.clone(), diff --git a/src/poke/mod.rs b/src/poke/mod.rs index 0d084fcc8..d9d95c101 100644 --- a/src/poke/mod.rs +++ b/src/poke/mod.rs @@ -100,12 +100,12 @@ pub fn load_session_settings( ]; settings.initial_deployer = initial_deployer; settings.costs_version = project_config.project.costs_version; + settings.parser_version = project_config.project.parser_version; if let Some(ref analysis_passes) = project_config.project.analysis { settings.analysis = analysis_passes.clone(); } - - settings.parser_version = project_config.project.parser_version; + settings.analysis_settings = project_config.project.analysis_settings; Ok((settings, chain_config, project_config)) } diff --git a/src/types/project_manifest.rs b/src/types/project_manifest.rs index 22fd7bc04..7375d84be 100644 --- a/src/types/project_manifest.rs +++ b/src/types/project_manifest.rs @@ -1,3 +1,4 @@ +use clarity_repl::analysis::{AnalysisSettings, AnalysisSettingsFile}; use std::collections::{BTreeMap, HashSet}; use std::fs::File; use std::io::{BufReader, Read}; @@ -20,8 +21,9 @@ pub struct ProjectConfigFile { telemetry: Option, requirements: Option, analysis: Option>, + analysis_settings: Option, costs_version: Option, - parser_version: Option + parser_version: Option, } #[derive(Serialize, Deserialize, Debug, Default)] @@ -39,8 +41,9 @@ pub struct ProjectConfig { pub telemetry: bool, pub requirements: Option>, pub analysis: Option>, + pub analysis_settings: AnalysisSettings, pub costs_version: u32, - pub parser_version: u32 + pub parser_version: u32, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] @@ -160,8 +163,15 @@ impl ProjectManifest { authors: project_manifest_file.project.authors.unwrap_or(vec![]), telemetry: project_manifest_file.project.telemetry.unwrap_or(false), costs_version: project_manifest_file.project.costs_version.unwrap_or(2), - analysis: project_manifest_file.project.analysis, parser_version: project_manifest_file.project.parser_version.unwrap_or(2), + analysis: project_manifest_file.project.analysis, + analysis_settings: if let Some(analysis_settings) = + project_manifest_file.project.analysis_settings + { + AnalysisSettings::from(analysis_settings) + } else { + AnalysisSettings::default() + }, }; let mut config = ProjectManifest {