diff --git a/CHANGELOG.md b/CHANGELOG.md index a762d41..cf70f08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ - Fixed issue where statements under top-level in-eachs were not correctly tracked. - Moved storage of reference->symbol mapping to on-demand timing, should significantly speed up device analysises +- CLI tool DFA now uses default one-indexed line count for reporting warnings on analyzed files. + `--zero-indexed` flag can be set to `true` when executing DFA for using zero-indexed counting if required. ## 0.9.12 - Added 'simics\_util\_vect' as a known provisional (with no DLS semantics) diff --git a/src/dfa/client.rs b/src/dfa/client.rs index c3663ab..7c0778d 100644 --- a/src/dfa/client.rs +++ b/src/dfa/client.rs @@ -385,13 +385,15 @@ impl ClientInterface { }{} } - pub fn output_errors(&self) { + pub fn output_errors(&self, zero_indexed: bool) { for (path, diagnostics) in &self.diagnostics { for diag in diagnostics { - println!("{} line {}: {}", - path.to_str().unwrap(), - diag.line, - diag.desc); + println!( + "{} line {}: {}", + path.to_str().unwrap(), + diag.line + if zero_indexed { 0 } else { 1 }, + diag.desc + ); } } } diff --git a/src/dfa/main.rs b/src/dfa/main.rs index 9252aec..0096bac 100644 --- a/src/dfa/main.rs +++ b/src/dfa/main.rs @@ -34,6 +34,7 @@ struct Args { workspaces: Vec, compile_info: Option, suppress_imports: Option, + zero_indexed: Option, linting_enabled: Option, lint_cfg_path: Option, test: bool, @@ -78,6 +79,11 @@ fn parse_args() -> Args { .action(ArgAction::Set) .value_parser(clap::value_parser!(bool)) .required(false)) + .arg(Arg::new("zero-indexed").short('z').long("zero-indexed") + .help("Diagnostics reported by the server will be zero-indexed (defaults to false)") + .action(ArgAction::Set) + .value_parser(clap::value_parser!(bool)) + .required(false)) .arg(Arg::new("linting-enabled").short('l').long("linting-enabled") .help("Turns linting on/off (defaults to true)") .action(ArgAction::Set) @@ -106,6 +112,8 @@ fn parse_args() -> Args { .cloned(), suppress_imports: args.get_one::("suppress-imports") .cloned(), + zero_indexed: args.get_one::("zero-indexed") + .cloned(), linting_enabled: args.get_one::("linting-enabled") .cloned(), lint_cfg_path: args.get_one::("lint-cfg-path") @@ -126,6 +134,7 @@ fn main_inner() -> Result<(), i32> { let first_workspace = workspace_rest.next(); let linting_enabled = arg.linting_enabled.unwrap_or(true); + let zero_indexed = arg.zero_indexed.unwrap_or(false); let root = match first_workspace { Some(w) => w, @@ -167,7 +176,7 @@ fn main_inner() -> Result<(), i32> { })?; if !arg.quiet { - dlsclient.output_errors(); + dlsclient.output_errors(zero_indexed); } if arg.test && !dlsclient.no_errors() { exit_code = Err(1);