File tree Expand file tree Collapse file tree 5 files changed +28
-22
lines changed
oxc_language_server/src/linter Expand file tree Collapse file tree 5 files changed +28
-22
lines changed Original file line number Diff line number Diff line change @@ -258,8 +258,7 @@ impl Runner for LintRunner {
258258 } else {
259259 nested_configs. values ( ) . any ( |config| config. plugins ( ) . has_import ( ) )
260260 } ;
261- let mut options =
262- LintServiceOptions :: new ( self . cwd , paths) . with_cross_module ( use_cross_module) ;
261+ let mut options = LintServiceOptions :: new ( self . cwd ) . with_cross_module ( use_cross_module) ;
263262
264263 let lint_config = config_builder. build ( ) ;
265264
@@ -303,7 +302,8 @@ impl Runner for LintRunner {
303302
304303 // Spawn linting in another thread so diagnostics can be printed immediately from diagnostic_service.run.
305304 rayon:: spawn ( move || {
306- let mut lint_service = LintService :: new ( & linter, allocator_pool, options) ;
305+ let mut lint_service =
306+ LintService :: new ( & linter, allocator_pool, options) . with_paths ( paths) ;
307307 lint_service. run ( & tx_error) ;
308308 } ) ;
309309
Original file line number Diff line number Diff line change @@ -139,18 +139,16 @@ impl IsolatedLintHandler {
139139
140140 debug ! ( "lint {}" , path. display( ) ) ;
141141
142- let lint_service_options = LintServiceOptions :: new (
143- self . options . root_path . clone ( ) ,
144- vec ! [ Arc :: from( path. as_os_str( ) ) ] ,
145- )
146- . with_cross_module ( self . options . use_cross_module ) ;
142+ let lint_service_options = LintServiceOptions :: new ( self . options . root_path . clone ( ) )
143+ . with_cross_module ( self . options . use_cross_module ) ;
147144
148145 let mut lint_service =
149146 LintService :: new ( & self . linter , AllocatorPool :: default ( ) , lint_service_options)
150147 . with_file_system ( Box :: new ( IsolatedLintHandlerFileSystem :: new (
151148 path. to_path_buf ( ) ,
152149 source_text,
153- ) ) ) ;
150+ ) ) )
151+ . with_paths ( vec ! [ Arc :: from( path. as_os_str( ) ) ] ) ;
154152 let result = lint_service. run_source ( allocator) ;
155153
156154 Some ( result)
Original file line number Diff line number Diff line change @@ -18,10 +18,6 @@ pub mod offset_to_position;
1818pub struct LintServiceOptions {
1919 /// Current working directory
2020 cwd : Box < Path > ,
21-
22- /// All paths to lint
23- paths : Vec < Arc < OsStr > > ,
24-
2521 /// TypeScript `tsconfig.json` path for reading path alias and project references
2622 tsconfig : Option < PathBuf > ,
2723
@@ -30,11 +26,11 @@ pub struct LintServiceOptions {
3026
3127impl LintServiceOptions {
3228 #[ must_use]
33- pub fn new < T > ( cwd : T , paths : Vec < Arc < OsStr > > ) -> Self
29+ pub fn new < T > ( cwd : T ) -> Self
3430 where
3531 T : Into < Box < Path > > ,
3632 {
37- Self { cwd : cwd. into ( ) , paths , tsconfig : None , cross_module : false }
33+ Self { cwd : cwd. into ( ) , tsconfig : None , cross_module : false }
3834 }
3935
4036 #[ inline]
@@ -88,6 +84,12 @@ impl<'l> LintService<'l> {
8884 self
8985 }
9086
87+ #[ must_use]
88+ pub fn with_paths ( mut self , paths : Vec < Arc < OsStr > > ) -> Self {
89+ self . runtime = self . runtime . with_paths ( paths) ;
90+ self
91+ }
92+
9193 /// # Panics
9294 pub fn run ( & mut self , tx_error : & DiagnosticSender ) {
9395 self . runtime . run ( tx_error) ;
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ impl<'l> Runtime<'l> {
188188 Self {
189189 allocator_pool,
190190 cwd : options. cwd ,
191- paths : options . paths . iter ( ) . cloned ( ) . collect ( ) ,
191+ paths : IndexSet :: with_capacity_and_hasher ( 0 , FxBuildHasher ) ,
192192 linter,
193193 resolver,
194194 file_system : Box :: new ( OsFileSystem ) ,
@@ -203,6 +203,11 @@ impl<'l> Runtime<'l> {
203203 self
204204 }
205205
206+ pub fn with_paths ( mut self , paths : Vec < Arc < OsStr > > ) -> Self {
207+ self . paths = paths. into_iter ( ) . collect ( ) ;
208+ self
209+ }
210+
206211 fn get_resolver ( tsconfig_path : Option < PathBuf > ) -> Resolver {
207212 use oxc_resolver:: { ResolveOptions , TsconfigOptions , TsconfigReferences } ;
208213 let tsconfig = tsconfig_path. and_then ( |path| {
Original file line number Diff line number Diff line change @@ -535,12 +535,13 @@ impl Tester {
535535
536536 let cwd = self . current_working_directory . clone ( ) ;
537537 let paths = vec ! [ Arc :: <OsStr >:: from( path_to_lint. as_os_str( ) ) ] ;
538- let options =
539- LintServiceOptions :: new ( cwd, paths) . with_cross_module ( self . plugins . has_import ( ) ) ;
540- let mut lint_service =
541- LintService :: new ( & linter, AllocatorPool :: default ( ) , options) . with_file_system (
542- Box :: new ( TesterFileSystem :: new ( path_to_lint, source_text. to_string ( ) ) ) ,
543- ) ;
538+ let options = LintServiceOptions :: new ( cwd) . with_cross_module ( self . plugins . has_import ( ) ) ;
539+ let mut lint_service = LintService :: new ( & linter, AllocatorPool :: default ( ) , options)
540+ . with_file_system ( Box :: new ( TesterFileSystem :: new (
541+ path_to_lint,
542+ source_text. to_string ( ) ,
543+ ) ) )
544+ . with_paths ( paths) ;
544545
545546 let ( sender, _receiver) = mpsc:: channel ( ) ;
546547 let result = lint_service. run_test_source ( & allocator, false , & sender) ;
You can’t perform that action at this time.
0 commit comments