@@ -15,16 +15,15 @@ use crate::{
1515 reporter:: { DiagnosticReporter , DiagnosticResult } ,
1616} ;
1717
18- pub type DiagnosticTuple = ( PathBuf , Vec < Error > ) ;
19- pub type DiagnosticSender = mpsc:: Sender < DiagnosticTuple > ;
20- pub type DiagnosticReceiver = mpsc:: Receiver < DiagnosticTuple > ;
18+ pub type DiagnosticSender = mpsc:: Sender < Vec < Error > > ;
19+ pub type DiagnosticReceiver = mpsc:: Receiver < Vec < Error > > ;
2120
2221/// Listens for diagnostics sent over a [channel](DiagnosticSender) by some job, and
2322/// formats/reports them to the user.
2423///
2524/// [`DiagnosticService`] is designed to support multi-threaded jobs that may produce
26- /// reports. These jobs can send [ messages](DiagnosticTuple) to the service over its
27- /// multi-producer, single-consumer channel.
25+ /// reports. These jobs can send messages to the service over its multi-producer,
26+ /// single-consumer channel.
2827///
2928/// # Example
3029/// ```rust
@@ -156,7 +155,7 @@ impl DiagnosticService {
156155 let mut warnings_count: usize = 0 ;
157156 let mut errors_count: usize = 0 ;
158157
159- while let Ok ( ( path , diagnostics) ) = self . receiver . recv ( ) {
158+ while let Ok ( diagnostics) = self . receiver . recv ( ) {
160159 let mut is_minified = false ;
161160 for diagnostic in diagnostics {
162161 let severity = diagnostic. severity ( ) ;
@@ -180,15 +179,23 @@ impl DiagnosticService {
180179 continue ;
181180 }
182181
182+ let path = diagnostic
183+ . source_code ( )
184+ . and_then ( |source| source. name ( ) )
185+ . map ( ToString :: to_string) ;
186+
183187 if let Some ( err_str) = self . reporter . render_error ( diagnostic) {
184188 // Skip large output and print only once.
185189 // Setting to 1200 because graphical output may contain ansi escape codes and other decorations.
186190 if err_str. lines ( ) . any ( |line| line. len ( ) >= 1200 ) {
187- let minified_diagnostic = Error :: new (
188- OxcDiagnostic :: warn ( "File is too long to fit on the screen" ) . with_help (
189- format ! ( "{} seems like a minified file" , path. display( ) ) ,
190- ) ,
191- ) ;
191+ let mut diagnostic =
192+ OxcDiagnostic :: warn ( "File is too long to fit on the screen" ) ;
193+ if let Some ( path) = path {
194+ diagnostic =
195+ diagnostic. with_help ( format ! ( "{path} seems like a minified file" ) ) ;
196+ }
197+
198+ let minified_diagnostic = Error :: new ( diagnostic) ;
192199
193200 if let Some ( err_str) = self . reporter . render_error ( minified_diagnostic) {
194201 writer
0 commit comments