mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-22 11:32:27 +00:00
removed duplicate code
This commit is contained in:
parent
719e32e0f0
commit
00d1ac0aef
3 changed files with 42 additions and 30 deletions
|
@ -6,6 +6,8 @@ use roc_problem::can::Problem;
|
|||
use roc_region::all::LineInfo;
|
||||
use roc_solve_problem::TypeError;
|
||||
|
||||
use crate::report::ANSI_STYLE_CODES;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct Problems {
|
||||
pub fatally_errored: bool,
|
||||
|
@ -26,11 +28,11 @@ impl Problems {
|
|||
}
|
||||
|
||||
pub fn print_to_stdout(&self, total_time: std::time::Duration) {
|
||||
const GREEN: usize = 32;
|
||||
const YELLOW: usize = 33;
|
||||
const GREEN: &str = ANSI_STYLE_CODES.green;
|
||||
const YELLOW: &str = ANSI_STYLE_CODES.yellow;
|
||||
|
||||
print!(
|
||||
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms",
|
||||
"{}{}\x1B[39m {} and {}{}\x1B[39m {} found in {} ms",
|
||||
match self.errors {
|
||||
0 => GREEN,
|
||||
_ => YELLOW,
|
||||
|
@ -54,6 +56,39 @@ impl Problems {
|
|||
}
|
||||
}
|
||||
|
||||
// prints e.g. `1 error and 0 warnings found in 63 ms.`
|
||||
pub fn print_error_warning_count(
|
||||
error_count: usize,
|
||||
warning_count: usize,
|
||||
total_time: std::time::Duration,
|
||||
) {
|
||||
const GREEN: &str = ANSI_STYLE_CODES.green;
|
||||
const YELLOW: &str = ANSI_STYLE_CODES.yellow;
|
||||
|
||||
print!(
|
||||
"{}{}\x1B[39m {} and {}{}\x1B[39m {} found in {} ms",
|
||||
match error_count {
|
||||
0 => GREEN,
|
||||
_ => YELLOW,
|
||||
},
|
||||
error_count,
|
||||
match error_count {
|
||||
1 => "error",
|
||||
_ => "errors",
|
||||
},
|
||||
match warning_count {
|
||||
0 => GREEN,
|
||||
_ => YELLOW,
|
||||
},
|
||||
warning_count,
|
||||
match warning_count {
|
||||
1 => "warning",
|
||||
_ => "warnings",
|
||||
},
|
||||
total_time.as_millis()
|
||||
);
|
||||
}
|
||||
|
||||
pub fn report_problems(
|
||||
sources: &MutMap<ModuleId, (PathBuf, Box<str>)>,
|
||||
interns: &Interns,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue