@@ -320,29 +320,37 @@ impl TsGoLintState {
320320 /// A human-readable error message indicating why the linting failed.
321321 pub fn lint_source (
322322 & self ,
323- path : & Arc < OsStr > ,
323+ paths : & [ Arc < OsStr > ] ,
324324 file_system : & ( dyn crate :: RuntimeFileSystem + Sync + Send ) ,
325325 disable_directives_map : Arc < Mutex < FxHashMap < PathBuf , DisableDirectives > > > ,
326326 ) -> Result < Vec < Message > , String > {
327+ if paths. is_empty ( ) {
328+ return Ok ( vec ! [ ] ) ;
329+ }
330+
327331 let mut resolved_configs: FxHashMap < PathBuf , ResolvedLinterState > = FxHashMap :: default ( ) ;
328- let mut source_overrides = FxHashMap :: default ( ) ;
332+ let mut source_overrides: FxHashMap < String , String > = FxHashMap :: default ( ) ;
329333 let allocator = Allocator :: default ( ) ;
330- let Ok ( source_text) = file_system. read_to_arena_str ( Path :: new ( path. as_ref ( ) ) , & allocator)
331- else {
332- return Err ( format ! ( "Failed to read source text for file: {}" , path. to_string_lossy( ) ) ) ;
333- } ;
334334
335- // Clone source_text to own it for the spawned thread
336- let source_text_owned = source_text. to_string ( ) ;
337- source_overrides. insert ( path. to_string_lossy ( ) . to_string ( ) , source_text_owned. clone ( ) ) ;
335+ // Read all sources into overrides
336+ for path in paths {
337+ let path_ref = Path :: new ( path. as_ref ( ) ) ;
338+ let Ok ( source_text) = file_system. read_to_arena_str ( path_ref, & allocator) else {
339+ return Err ( format ! (
340+ "Failed to read source text for file: {}" ,
341+ path. to_string_lossy( )
342+ ) ) ;
343+ } ;
344+ source_overrides. insert ( path. to_string_lossy ( ) . to_string ( ) , source_text. to_string ( ) ) ;
345+ }
338346
339- let json_input = self . json_input (
340- std:: slice:: from_ref ( path) ,
341- Some ( source_overrides) ,
342- & mut resolved_configs,
343- ) ;
347+ let json_input =
348+ self . json_input ( paths, Some ( source_overrides. clone ( ) ) , & mut resolved_configs) ;
349+
350+ // Get the file name of the first path for internal diagnostic filtering
344351 let path_file_name =
345- Path :: new ( path. as_ref ( ) ) . file_name ( ) . unwrap_or_default ( ) . to_os_string ( ) ;
352+ Path :: new ( paths[ 0 ] . as_ref ( ) ) . file_name ( ) . unwrap_or_default ( ) . to_os_string ( ) ;
353+
346354 let mut child = self . spawn_tsgolint ( & json_input) ?;
347355 let handler = std:: thread:: spawn ( move || {
348356 let stdout = child. stdout . take ( ) . expect ( "Failed to open tsgolint stdout" ) ;
@@ -390,6 +398,15 @@ impl TsGoLintState {
390398 continue ;
391399 }
392400
401+ // Use the corresponding source override text
402+ let Some ( source_text_owned) = source_overrides
403+ . get ( & path. to_string_lossy ( ) . to_string ( ) )
404+ . cloned ( )
405+ else {
406+ // should never happen, because we populated source_overrides above
407+ continue ;
408+ } ;
409+
393410 let mut message = Message :: from_tsgo_lint_diagnostic (
394411 tsgolint_diagnostic,
395412 & source_text_owned,
0 commit comments