@@ -19,7 +19,6 @@ use crate::linter::{
1919 error_with_position:: DiagnosticReport ,
2020 isolated_lint_handler:: { IsolatedLintHandler , IsolatedLintHandlerOptions } ,
2121 options:: { LintOptions as LSPLintOptions , Run } ,
22- tsgo_linter:: TsgoLinter ,
2322} ;
2423use crate :: utils:: normalize_path;
2524use crate :: { ConcurrentHashMap , LINT_CONFIG_FILE } ;
@@ -35,7 +34,6 @@ pub enum ServerLinterRun {
3534
3635pub struct ServerLinter {
3736 isolated_linter : Arc < Mutex < IsolatedLintHandler > > ,
38- tsgo_linter : Arc < Option < TsgoLinter > > ,
3937 ignore_matcher : LintIgnoreMatcher ,
4038 gitignore_glob : Vec < Gitignore > ,
4139 lint_on_run : Run ,
@@ -46,7 +44,6 @@ pub struct ServerLinter {
4644#[ derive( Debug , Default ) ]
4745struct ServerLinterDiagnostics {
4846 isolated_linter : Arc < ConcurrentHashMap < String , Option < Vec < DiagnosticReport > > > > ,
49- tsgo_linter : Arc < ConcurrentHashMap < String , Option < Vec < DiagnosticReport > > > > ,
5047}
5148
5249impl ServerLinterDiagnostics {
@@ -59,29 +56,15 @@ impl ServerLinterDiagnostics {
5956 reports. extend ( diagnostics. clone ( ) ) ;
6057 }
6158 }
62- if let Some ( entry) = self . tsgo_linter . pin ( ) . get ( path) {
63- found = true ;
64- if let Some ( diagnostics) = entry {
65- reports. extend ( diagnostics. clone ( ) ) ;
66- }
67- }
6859 if found { Some ( reports) } else { None }
6960 }
7061
7162 pub fn remove_diagnostics ( & self , path : & str ) {
7263 self . isolated_linter . pin ( ) . remove ( path) ;
73- self . tsgo_linter . pin ( ) . remove ( path) ;
7464 }
7565
7666 pub fn get_cached_files_of_diagnostics ( & self ) -> Vec < String > {
77- let isolated_files = self . isolated_linter . pin ( ) . keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
78- let tsgo_files = self . tsgo_linter . pin ( ) . keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
79-
80- let mut files = Vec :: with_capacity ( isolated_files. len ( ) + tsgo_files. len ( ) ) ;
81- files. extend ( isolated_files) ;
82- files. extend ( tsgo_files) ;
83- files. dedup ( ) ;
84- files
67+ self . isolated_linter . pin ( ) . keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( )
8568 }
8669}
8770
@@ -153,9 +136,10 @@ impl ServerLinter {
153136
154137 let isolated_linter = IsolatedLintHandler :: new (
155138 lint_options,
156- config_store. clone ( ) , // clone because tsgo linter needs it
139+ config_store,
157140 & IsolatedLintHandlerOptions {
158141 use_cross_module,
142+ type_aware : options. type_aware ,
159143 root_path : root_path. to_path_buf ( ) ,
160144 tsconfig_path : options. ts_config_path . as_ref ( ) . map ( |path| {
161145 let path = Path :: new ( path) . to_path_buf ( ) ;
@@ -175,11 +159,6 @@ impl ServerLinter {
175159 extended_paths,
176160 lint_on_run : options. run ,
177161 diagnostics : ServerLinterDiagnostics :: default ( ) ,
178- tsgo_linter : if options. type_aware {
179- Arc :: new ( Some ( TsgoLinter :: new ( & root_path, config_store) ) )
180- } else {
181- Arc :: new ( None )
182- } ,
183162 }
184163 }
185164
@@ -336,10 +315,7 @@ impl ServerLinter {
336315 ( ServerLinterRun :: OnType , Run :: OnSave ) => ( false , false ) ,
337316 // In onType mode, only TypeScript type checking runs on save
338317 // If type_aware is disabled (tsgo_linter is None), skip everything to preserve diagnostics
339- ( ServerLinterRun :: OnSave , Run :: OnType ) => {
340- let should_run_tsgo = self . tsgo_linter . as_ref ( ) . is_some ( ) ;
341- ( false , should_run_tsgo)
342- }
318+ ( ServerLinterRun :: OnSave , Run :: OnType ) => ( false , true ) ,
343319 } ;
344320
345321 // return `None` when both tools do not want to be used
@@ -359,13 +335,6 @@ impl ServerLinter {
359335 self . diagnostics . isolated_linter . pin ( ) . insert ( uri. to_string ( ) , diagnostics) ;
360336 }
361337
362- if tsgolint && let Some ( tsgo_linter) = self . tsgo_linter . as_ref ( ) {
363- self . diagnostics
364- . tsgo_linter
365- . pin ( )
366- . insert ( uri. to_string ( ) , tsgo_linter. lint_file ( uri, content. clone ( ) ) ) ;
367- }
368-
369338 self . diagnostics . get_diagnostics ( & uri. to_string ( ) )
370339 }
371340
@@ -466,31 +435,23 @@ mod test {
466435 fn test_get_diagnostics_found_and_none_entries ( ) {
467436 let key = "file:///test.js" . to_string ( ) ;
468437
469- // Case 1: Both entries present, Some diagnostics
438+ // Case 1: Entry present, Some diagnostics
470439 let diag = DiagnosticReport :: default ( ) ;
471440 let diag_map = ConcurrentHashMap :: default ( ) ;
472- diag_map. pin ( ) . insert ( key. clone ( ) , Some ( vec ! [ diag. clone( ) ] ) ) ;
473- let tsgo_map = ConcurrentHashMap :: default ( ) ;
474- tsgo_map. pin ( ) . insert ( key. clone ( ) , Some ( vec ! [ diag] ) ) ;
441+ diag_map. pin ( ) . insert ( key. clone ( ) , Some ( vec ! [ diag] ) ) ;
475442
476- let server_diag = super :: ServerLinterDiagnostics {
477- isolated_linter : std:: sync:: Arc :: new ( diag_map) ,
478- tsgo_linter : std:: sync:: Arc :: new ( tsgo_map) ,
479- } ;
443+ let server_diag =
444+ super :: ServerLinterDiagnostics { isolated_linter : std:: sync:: Arc :: new ( diag_map) } ;
480445 let result = server_diag. get_diagnostics ( & key) ;
481446 assert ! ( result. is_some( ) ) ;
482447 assert_eq ! ( result. unwrap( ) . len( ) , 2 ) ;
483448
484449 // Case 2: Entry present, but value is None
485450 let diag_map_none = ConcurrentHashMap :: default ( ) ;
486451 diag_map_none. pin ( ) . insert ( key. clone ( ) , None ) ;
487- let tsgo_map_none = ConcurrentHashMap :: default ( ) ;
488- tsgo_map_none. pin ( ) . insert ( key. clone ( ) , None ) ;
489452
490- let server_diag_none = ServerLinterDiagnostics {
491- isolated_linter : std:: sync:: Arc :: new ( diag_map_none) ,
492- tsgo_linter : std:: sync:: Arc :: new ( tsgo_map_none) ,
493- } ;
453+ let server_diag_none =
454+ ServerLinterDiagnostics { isolated_linter : std:: sync:: Arc :: new ( diag_map_none) } ;
494455 let result_none = server_diag_none. get_diagnostics ( & key) ;
495456 assert ! ( result_none. is_some( ) ) ;
496457 assert_eq ! ( result_none. unwrap( ) . len( ) , 0 ) ;
0 commit comments