1- use std:: { path :: PathBuf , str:: FromStr , vec} ;
1+ use std:: { str:: FromStr , vec} ;
22
3- use log:: { debug, info} ;
4- use oxc_linter:: { ConfigStore , ConfigStoreBuilder , Oxlintrc } ;
3+ use log:: debug;
54use rustc_hash:: FxBuildHasher ;
65use tokio:: sync:: { Mutex , OnceCell , RwLock } ;
76use tower_lsp_server:: {
87 UriExt ,
9- lsp_types:: { CodeActionOrCommand , Diagnostic , FileChangeType , FileEvent , Range , TextEdit , Uri } ,
8+ lsp_types:: { CodeActionOrCommand , Diagnostic , FileEvent , Range , TextEdit , Uri } ,
109} ;
1110
1211use crate :: {
13- ConcurrentHashMap , OXC_CONFIG_FILE , Options , Run ,
12+ ConcurrentHashMap , Options , Run ,
1413 code_actions:: {
1514 apply_all_fix_code_action, apply_fix_code_action, ignore_this_line_code_action,
1615 ignore_this_rule_code_action,
@@ -23,22 +22,19 @@ pub struct WorkspaceWorker {
2322 server_linter : RwLock < ServerLinter > ,
2423 diagnostics_report_map : RwLock < ConcurrentHashMap < String , Vec < DiagnosticReport > > > ,
2524 options : Mutex < Options > ,
26- nested_configs : RwLock < ConcurrentHashMap < PathBuf , ConfigStore > > ,
2725}
2826
2927impl WorkspaceWorker {
3028 pub fn new ( root_uri : & Uri , options : Options ) -> Self {
3129 let root_uri_cell = OnceCell :: new ( ) ;
3230 root_uri_cell. set ( root_uri. clone ( ) ) . unwrap ( ) ;
3331
34- let nested_configs = ServerLinter :: create_nested_configs ( root_uri, & options) ;
35- let server_linter = ServerLinter :: create_server_linter ( root_uri, & options, & nested_configs) ;
32+ let server_linter = ServerLinter :: new ( root_uri, & options) ;
3633 Self {
3734 root_uri : root_uri_cell,
3835 server_linter : RwLock :: new ( server_linter) ,
3936 diagnostics_report_map : RwLock :: new ( ConcurrentHashMap :: default ( ) ) ,
4037 options : Mutex :: new ( options) ,
41- nested_configs : RwLock :: const_new ( nested_configs) ,
4238 }
4339 }
4440
@@ -59,22 +55,9 @@ impl WorkspaceWorker {
5955 self . diagnostics_report_map . read ( ) . await . pin ( ) . remove ( & uri. to_string ( ) ) ;
6056 }
6157
62- async fn refresh_nested_configs ( & self ) {
63- let options = self . options . lock ( ) . await ;
64- let nested_configs =
65- ServerLinter :: create_nested_configs ( self . root_uri . get ( ) . unwrap ( ) , & options) ;
66-
67- * self . nested_configs . write ( ) . await = nested_configs;
68- }
69-
7058 async fn refresh_server_linter ( & self ) {
7159 let options = self . options . lock ( ) . await ;
72- let nested_configs = self . nested_configs . read ( ) . await ;
73- let server_linter = ServerLinter :: create_server_linter (
74- self . root_uri . get ( ) . unwrap ( ) ,
75- & options,
76- & nested_configs,
77- ) ;
60+ let server_linter = ServerLinter :: new ( self . root_uri . get ( ) . unwrap ( ) , & options) ;
7861
7962 * self . server_linter . write ( ) . await = server_linter;
8063 }
@@ -224,48 +207,8 @@ impl WorkspaceWorker {
224207
225208 pub async fn did_change_watched_files (
226209 & self ,
227- file_event : & FileEvent ,
210+ _file_event : & FileEvent ,
228211 ) -> Option < ConcurrentHashMap < String , Vec < DiagnosticReport > > > {
229- if self . options . lock ( ) . await . use_nested_configs ( ) {
230- let nested_configs = self . nested_configs . read ( ) . await ;
231- let nested_configs = nested_configs. pin ( ) ;
232- let Some ( file_path) = file_event. uri . to_file_path ( ) else {
233- info ! ( "Unable to convert {:?} to a file path" , file_event. uri) ;
234- return None ;
235- } ;
236- let Some ( file_name) = file_path. file_name ( ) else {
237- info ! ( "Unable to retrieve file name from {file_path:?}" ) ;
238- return None ;
239- } ;
240-
241- if file_name != OXC_CONFIG_FILE {
242- return None ;
243- }
244-
245- let Some ( dir_path) = file_path. parent ( ) else {
246- info ! ( "Unable to retrieve parent from {file_path:?}" ) ;
247- return None ;
248- } ;
249-
250- // spellchecker:off -- "typ" is accurate
251- if file_event. typ == FileChangeType :: CREATED
252- || file_event. typ == FileChangeType :: CHANGED
253- {
254- // spellchecker:on
255- let oxlintrc =
256- Oxlintrc :: from_file ( & file_path) . expect ( "Failed to parse config file" ) ;
257- let config_store_builder = ConfigStoreBuilder :: from_oxlintrc ( false , oxlintrc)
258- . expect ( "Failed to create config store builder" ) ;
259- let config_store =
260- config_store_builder. build ( ) . expect ( "Failed to build config store" ) ;
261- nested_configs. insert ( dir_path. to_path_buf ( ) , config_store) ;
262- // spellchecker:off -- "typ" is accurate
263- } else if file_event. typ == FileChangeType :: DELETED {
264- // spellchecker:on
265- nested_configs. remove ( & dir_path. to_path_buf ( ) ) ;
266- }
267- }
268-
269212 self . refresh_server_linter ( ) . await ;
270213 Some ( self . revalidate_diagnostics ( ) . await )
271214 }
@@ -288,10 +231,6 @@ impl WorkspaceWorker {
288231
289232 * self . options . lock ( ) . await = changed_options. clone ( ) ;
290233
291- if changed_options. use_nested_configs ( ) != current_option. use_nested_configs ( ) {
292- self . refresh_nested_configs ( ) . await ;
293- }
294-
295234 if Self :: needs_linter_restart ( current_option, & changed_options) {
296235 self . refresh_server_linter ( ) . await ;
297236 return Some ( self . revalidate_diagnostics ( ) . await ) ;
0 commit comments