mirror of
https://github.com/HigherOrderCO/Kind1.git
synced 2024-10-05 20:07:49 +03:00
feat: added flag to remove error dependenies
This commit is contained in:
parent
329ce529b2
commit
a8d0004fdd
@ -57,6 +57,10 @@ pub struct Cli {
|
||||
#[arg(long)]
|
||||
pub hide_vals: bool,
|
||||
|
||||
/// Show only the first error message
|
||||
#[arg(long)]
|
||||
pub hide_deps: bool,
|
||||
|
||||
/// Entrypoint of the file that makes the erasure checker
|
||||
/// not remove the entry.
|
||||
#[arg(short, long)]
|
||||
@ -174,11 +178,24 @@ pub fn compile_in_session<T>(
|
||||
|
||||
let mut contains_error = false;
|
||||
|
||||
let mut hidden = 0;
|
||||
let total = diagnostics.len() as u64;
|
||||
|
||||
for diagnostic in diagnostics {
|
||||
if diagnostic.get_severity() == Severity::Error {
|
||||
contains_error = true;
|
||||
}
|
||||
|
||||
let is_root = diagnostic
|
||||
.get_syntax_ctx()
|
||||
.map(|x| x.is_root())
|
||||
.unwrap_or_default();
|
||||
|
||||
if render_config.only_main && !is_root {
|
||||
hidden += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
render_to_stderr(render_config, &session, &diagnostic)
|
||||
}
|
||||
|
||||
@ -197,7 +214,7 @@ pub fn compile_in_session<T>(
|
||||
|
||||
res
|
||||
} else {
|
||||
render_to_stderr(render_config, &session, &Log::Failed(start.elapsed()));
|
||||
render_to_stderr(render_config, &session, &Log::Failed(start.elapsed(), total, hidden));
|
||||
eprintln!();
|
||||
|
||||
match res {
|
||||
@ -216,7 +233,14 @@ pub fn run_cli(config: Cli) -> anyhow::Result<()> {
|
||||
Mode::Classic
|
||||
};
|
||||
|
||||
let render_config = kind_report::check_if_utf8_is_supported(config.ascii, 2, config.hide_vals, mode);
|
||||
let render_config = kind_report::check_if_utf8_is_supported(
|
||||
config.ascii,
|
||||
2,
|
||||
config.hide_vals,
|
||||
mode,
|
||||
config.hide_deps,
|
||||
);
|
||||
|
||||
let root = config.root.unwrap_or_else(|| PathBuf::from("."));
|
||||
|
||||
let mut entrypoints = vec!["Main".to_string()];
|
||||
|
@ -72,7 +72,7 @@ pub enum Log {
|
||||
Checked(Duration),
|
||||
Compiled(Duration),
|
||||
Rewrites(u64),
|
||||
Failed(Duration),
|
||||
Failed(Duration, u64, u64),
|
||||
}
|
||||
|
||||
pub trait Diagnostic {
|
||||
|
@ -54,36 +54,40 @@ pub struct RenderConfig<'a> {
|
||||
pub hide_vals: bool,
|
||||
pub mode: Mode,
|
||||
pub not_align: bool,
|
||||
pub only_main: bool,
|
||||
}
|
||||
|
||||
impl<'a> RenderConfig<'a> {
|
||||
pub fn unicode(indent: usize, hide_vals: bool) -> RenderConfig<'a> {
|
||||
pub fn unicode(indent: usize, hide_vals: bool, only_main: bool) -> RenderConfig<'a> {
|
||||
RenderConfig {
|
||||
chars: Chars::unicode(),
|
||||
indent,
|
||||
hide_vals,
|
||||
mode: Mode::Classic,
|
||||
not_align: false,
|
||||
only_main
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ascii(indent: usize, hide_vals: bool) -> RenderConfig<'a> {
|
||||
pub fn ascii(indent: usize, hide_vals: bool, only_main: bool) -> RenderConfig<'a> {
|
||||
RenderConfig {
|
||||
chars: Chars::ascii(),
|
||||
indent,
|
||||
hide_vals,
|
||||
mode: Mode::Classic,
|
||||
not_align: false,
|
||||
only_main
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compact(indent: usize) -> RenderConfig<'a> {
|
||||
pub fn compact(indent: usize, only_main: bool) -> RenderConfig<'a> {
|
||||
RenderConfig {
|
||||
chars: Chars::ascii(),
|
||||
indent,
|
||||
hide_vals: true,
|
||||
mode: Mode::Compact,
|
||||
not_align: true,
|
||||
only_main
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,15 +98,15 @@ pub fn check_if_colors_are_supported(disable: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_if_utf8_is_supported<'a>(disable: bool, indent: usize, hide_vals: bool, mode: Mode) -> RenderConfig<'a> {
|
||||
pub fn check_if_utf8_is_supported<'a>(disable: bool, indent: usize, hide_vals: bool, mode: Mode, only_main: bool) -> RenderConfig<'a> {
|
||||
match mode {
|
||||
Mode::Classic => {
|
||||
if disable || (cfg!(windows) && !Paint::enable_windows_ascii()) {
|
||||
RenderConfig::ascii(indent, hide_vals)
|
||||
RenderConfig::ascii(indent, hide_vals, only_main)
|
||||
} else {
|
||||
RenderConfig::unicode(indent, hide_vals)
|
||||
RenderConfig::unicode(indent, hide_vals, only_main)
|
||||
}
|
||||
},
|
||||
Mode::Compact => RenderConfig::compact(0),
|
||||
Mode::Compact => RenderConfig::compact(0, only_main),
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
use super::CodeBlock;
|
||||
use super::{Classic, Renderable, Res};
|
||||
use crate::data::*;
|
||||
use crate::report::code::{count_width, group_markers, LineGuide, Spaces};
|
||||
use crate::report::code::Point;
|
||||
use crate::RenderConfig;
|
||||
use crate::report::code::{count_width, group_markers, LineGuide, Spaces};
|
||||
use crate::report::group_marker_lines;
|
||||
use crate::RenderConfig;
|
||||
|
||||
use pathdiff::diff_paths;
|
||||
use std::fmt::Write;
|
||||
@ -368,12 +368,18 @@ impl Renderable<Classic> for Log {
|
||||
duration.as_secs_f32()
|
||||
)
|
||||
}
|
||||
Log::Failed(duration) => {
|
||||
Log::Failed(duration, total, hidden) => {
|
||||
writeln!(
|
||||
fmt,
|
||||
" {} Took {}s",
|
||||
" {} Took {:.1}s, {}{} total",
|
||||
Paint::new(" FAILED ").bg(yansi::Color::Red).bold(),
|
||||
duration.as_secs()
|
||||
duration.as_secs_f32(),
|
||||
if *hidden == 0 {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!("{} hidden errors, ", hidden)
|
||||
},
|
||||
total
|
||||
)
|
||||
}
|
||||
Log::Rewrites(u64) => {
|
||||
@ -444,4 +450,4 @@ impl Renderable<Classic> for DiagnosticFrame {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ impl SyntaxCtxIndex {
|
||||
pub fn new(size: usize) -> SyntaxCtxIndex {
|
||||
SyntaxCtxIndex(size)
|
||||
}
|
||||
|
||||
/// WARNING: Probably ghost ranges cause problems with it
|
||||
pub fn is_root(&self) -> bool {
|
||||
self.0 == 0
|
||||
}
|
||||
}
|
||||
|
||||
/// A span in the encoded format that is required by
|
||||
|
@ -40,7 +40,7 @@ fn test_kind2(path: &Path, run: fn(&PathBuf, &mut Session) -> Option<String>) ->
|
||||
let res = run(&PathBuf::from(path), &mut session);
|
||||
|
||||
let diagnostics = tx.try_iter().collect::<Vec<Box<dyn Diagnostic>>>();
|
||||
let render = RenderConfig::ascii(2, false);
|
||||
let render = RenderConfig::ascii(2, false, false);
|
||||
|
||||
kind_report::check_if_colors_are_supported(true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user