11use std:: { path:: PathBuf , str:: FromStr , vec} ;
22
3- use ignore:: gitignore:: Gitignore ;
43use log:: { debug, info} ;
54use oxc_linter:: { ConfigStore , ConfigStoreBuilder , Oxlintrc } ;
65use rustc_hash:: FxBuildHasher ;
@@ -24,7 +23,6 @@ pub struct WorkspaceWorker {
2423 server_linter : RwLock < ServerLinter > ,
2524 diagnostics_report_map : RwLock < ConcurrentHashMap < String , Vec < DiagnosticReport > > > ,
2625 options : Mutex < Options > ,
27- gitignore_glob : Mutex < Vec < Gitignore > > ,
2826 nested_configs : RwLock < ConcurrentHashMap < PathBuf , ConfigStore > > ,
2927}
3028
@@ -34,14 +32,12 @@ impl WorkspaceWorker {
3432 root_uri_cell. set ( root_uri. clone ( ) ) . unwrap ( ) ;
3533
3634 let nested_configs = ServerLinter :: create_nested_configs ( root_uri, & options) ;
37- let ( server_linter, oxlintrc) =
38- ServerLinter :: create_server_linter ( root_uri, & options, & nested_configs) ;
35+ let server_linter = ServerLinter :: create_server_linter ( root_uri, & options, & nested_configs) ;
3936 Self {
4037 root_uri : root_uri_cell,
4138 server_linter : RwLock :: new ( server_linter) ,
4239 diagnostics_report_map : RwLock :: new ( ConcurrentHashMap :: default ( ) ) ,
4340 options : Mutex :: new ( options) ,
44- gitignore_glob : Mutex :: new ( ServerLinter :: create_ignore_glob ( root_uri, & oxlintrc) ) ,
4541 nested_configs : RwLock :: const_new ( nested_configs) ,
4642 }
4743 }
@@ -71,10 +67,10 @@ impl WorkspaceWorker {
7167 * self . nested_configs . write ( ) . await = nested_configs;
7268 }
7369
74- async fn refresh_linter_config ( & self ) {
70+ async fn refresh_server_linter ( & self ) {
7571 let options = self . options . lock ( ) . await ;
7672 let nested_configs = self . nested_configs . read ( ) . await ;
77- let ( server_linter, _ ) = ServerLinter :: create_server_linter (
73+ let server_linter = ServerLinter :: create_server_linter (
7874 self . root_uri . get ( ) . unwrap ( ) ,
7975 & options,
8076 & nested_configs,
@@ -114,10 +110,6 @@ impl WorkspaceWorker {
114110 uri : & Uri ,
115111 content : Option < String > ,
116112 ) -> Option < Vec < DiagnosticReport > > {
117- if self . is_ignored ( uri) . await {
118- return None ;
119- }
120-
121113 self . server_linter . read ( ) . await . run_single ( uri, content)
122114 }
123115
@@ -274,7 +266,7 @@ impl WorkspaceWorker {
274266 }
275267 }
276268
277- self . refresh_linter_config ( ) . await ;
269+ self . refresh_server_linter ( ) . await ;
278270 Some ( self . revalidate_diagnostics ( ) . await )
279271 }
280272
@@ -301,28 +293,12 @@ impl WorkspaceWorker {
301293 }
302294
303295 if Self :: needs_linter_restart ( current_option, & changed_options) {
304- self . refresh_linter_config ( ) . await ;
296+ self . refresh_server_linter ( ) . await ;
305297 return Some ( self . revalidate_diagnostics ( ) . await ) ;
306298 }
307299
308300 None
309301 }
310-
311- async fn is_ignored ( & self , uri : & Uri ) -> bool {
312- let gitignore_globs = & ( * self . gitignore_glob . lock ( ) . await ) ;
313- for gitignore in gitignore_globs {
314- if let Some ( uri_path) = uri. to_file_path ( ) {
315- if !uri_path. starts_with ( gitignore. path ( ) ) {
316- continue ;
317- }
318- if gitignore. matched_path_or_any_parents ( & uri_path, uri_path. is_dir ( ) ) . is_ignore ( ) {
319- debug ! ( "ignored: {uri:?}" ) ;
320- return true ;
321- }
322- }
323- }
324- false
325- }
326302}
327303
328304fn range_overlaps ( a : Range , b : Range ) -> bool {
0 commit comments