@@ -15,7 +15,7 @@ use crate::projects::ProjectKey;
1515use crate :: workspace:: DocumentFileSource ;
1616use crate :: { Workspace , WorkspaceError } ;
1717use biome_diagnostics:: serde:: Diagnostic ;
18- use biome_diagnostics:: { Diagnostic as _, Error , Severity } ;
18+ use biome_diagnostics:: { Diagnostic as _, DiagnosticExt , Error , Severity } ;
1919use biome_fs:: { BiomePath , PathInterner , PathKind , TraversalContext , TraversalScope } ;
2020use camino:: Utf8Path ;
2121use crossbeam:: channel:: { Receiver , Sender , unbounded} ;
@@ -48,11 +48,12 @@ impl WorkspaceServer {
4848 project_key : ProjectKey ,
4949 folder : & Utf8Path ,
5050 scan_kind : ScanKind ,
51+ verbose : bool ,
5152 ) -> Result < ScanResult , WorkspaceError > {
5253 let ( interner, _path_receiver) = PathInterner :: new ( ) ;
5354 let ( diagnostics_sender, diagnostics_receiver) = unbounded ( ) ;
5455
55- let collector = DiagnosticsCollector :: new ( ) ;
56+ let collector = DiagnosticsCollector :: new ( verbose ) ;
5657
5758 let ( duration, diagnostics, configuration_files) = thread:: scope ( |scope| {
5859 let handler = thread:: Builder :: new ( )
@@ -166,23 +167,22 @@ fn scan_folder(folder: &Utf8Path, ctx: ScanContext) -> (Duration, Vec<BiomePath>
166167struct DiagnosticsCollector {
167168 /// The minimum level of diagnostic we should collect.
168169 diagnostic_level : Severity ,
169-
170- /// Whether we should collect verbose diagnostics.
171- verbose : bool ,
172170}
173171
174172impl DiagnosticsCollector {
175- fn new ( ) -> Self {
173+ fn new ( verbose : bool ) -> Self {
176174 Self {
177- diagnostic_level : Severity :: Hint ,
178- verbose : false ,
175+ diagnostic_level : if verbose {
176+ Severity :: Hint
177+ } else {
178+ Severity :: Error
179+ } ,
179180 }
180181 }
181182
182183 /// Checks whether the given `diagnostic` should be collected or not.
183184 fn should_collect ( & self , diagnostic : & Diagnostic ) -> bool {
184185 diagnostic. severity ( ) >= self . diagnostic_level
185- && ( self . verbose || !diagnostic. tags ( ) . is_verbose ( ) )
186186 }
187187
188188 fn run ( & self , receiver : Receiver < Diagnostic > ) -> Vec < Diagnostic > {
@@ -408,7 +408,11 @@ fn open_file(ctx: &ScanContext, path: &BiomePath) {
408408 } ) {
409409 Ok ( Ok ( ( ) ) ) => { }
410410 Ok ( Err ( err) ) => {
411- ctx. send_diagnostic ( err) ;
411+ let mut error: Error = err. into ( ) ;
412+ if !path. is_config ( ) && error. severity ( ) == Severity :: Error {
413+ error = error. with_severity ( Severity :: Warning ) ;
414+ }
415+ ctx. send_diagnostic ( Diagnostic :: new ( error) ) ;
412416 }
413417 Err ( err) => {
414418 let error = match err. downcast :: < String > ( ) {
@@ -423,3 +427,7 @@ fn open_file(ctx: &ScanContext, path: &BiomePath) {
423427 }
424428 }
425429}
430+
431+ #[ cfg( test) ]
432+ #[ path = "scanner.tests.rs" ]
433+ mod tests;
0 commit comments