@@ -26,8 +26,8 @@ pub struct ServerLinter {
2626
2727impl ServerLinter {
2828 pub fn new ( root_uri : & Uri , options : & Options ) -> Self {
29- let ( nested_configs, mut extended_paths) = Self :: create_nested_configs ( root_uri, options) ;
3029 let root_path = root_uri. to_file_path ( ) . unwrap ( ) ;
30+ let ( nested_configs, mut extended_paths) = Self :: create_nested_configs ( & root_path, options) ;
3131 let relative_config_path = options. config_path . clone ( ) ;
3232 let oxlintrc = if let Some ( relative_config_path) = relative_config_path {
3333 let config = normalize_path ( root_path. join ( relative_config_path) ) ;
@@ -89,15 +89,15 @@ impl ServerLinter {
8989
9090 Self {
9191 isolated_linter : Arc :: new ( isolated_linter) ,
92- gitignore_glob : Self :: create_ignore_glob ( root_uri , & oxlintrc) ,
92+ gitignore_glob : Self :: create_ignore_glob ( & root_path , & oxlintrc) ,
9393 extended_paths,
9494 }
9595 }
9696
9797 /// Searches inside root_uri recursively for the default oxlint config files
9898 /// and insert them inside the nested configuration
9999 fn create_nested_configs (
100- root_uri : & Uri ,
100+ root_path : & Path ,
101101 options : & Options ,
102102 ) -> ( ConcurrentHashMap < PathBuf , Config > , Vec < PathBuf > ) {
103103 let mut extended_paths = Vec :: new ( ) ;
@@ -106,9 +106,7 @@ impl ServerLinter {
106106 return ( ConcurrentHashMap :: default ( ) , extended_paths) ;
107107 }
108108
109- let root_path = root_uri. to_file_path ( ) . expect ( "Failed to convert URI to file path" ) ;
110-
111- let paths = ConfigWalker :: new ( & root_path) . paths ( ) ;
109+ let paths = ConfigWalker :: new ( root_path) . paths ( ) ;
112110 let nested_configs =
113111 ConcurrentHashMap :: with_capacity_and_hasher ( paths. capacity ( ) , FxBuildHasher ) ;
114112
@@ -134,15 +132,15 @@ impl ServerLinter {
134132 ( nested_configs, extended_paths)
135133 }
136134
137- fn create_ignore_glob ( root_uri : & Uri , oxlintrc : & Oxlintrc ) -> Vec < Gitignore > {
135+ fn create_ignore_glob ( root_path : & Path , oxlintrc : & Oxlintrc ) -> Vec < Gitignore > {
138136 let mut builder = globset:: GlobSetBuilder :: new ( ) ;
139137 // Collecting all ignore files
140138 builder. add ( Glob :: new ( "**/.eslintignore" ) . unwrap ( ) ) ;
141139 builder. add ( Glob :: new ( "**/.gitignore" ) . unwrap ( ) ) ;
142140
143141 let ignore_file_glob_set = builder. build ( ) . unwrap ( ) ;
144142
145- let walk = ignore:: WalkBuilder :: new ( root_uri . to_file_path ( ) . unwrap ( ) )
143+ let walk = ignore:: WalkBuilder :: new ( root_path )
146144 . ignore ( true )
147145 . hidden ( false )
148146 . git_global ( false )
@@ -233,19 +231,14 @@ pub fn normalize_path<P: AsRef<Path>>(path: P) -> PathBuf {
233231
234232#[ cfg( test) ]
235233mod test {
236- use std:: {
237- path:: { Path , PathBuf } ,
238- str:: FromStr ,
239- } ;
240-
241- use rustc_hash:: FxHashMap ;
242- use tower_lsp_server:: lsp_types:: Uri ;
234+ use std:: path:: { Path , PathBuf } ;
243235
244236 use crate :: {
245237 Options ,
246238 linter:: server_linter:: { ServerLinter , normalize_path} ,
247- tester:: { Tester , get_file_uri } ,
239+ tester:: { Tester , get_file_path } ,
248240 } ;
241+ use rustc_hash:: FxHashMap ;
249242
250243 #[ test]
251244 fn test_normalize_path ( ) {
@@ -261,7 +254,7 @@ mod test {
261254 flags. insert ( "disable_nested_configs" . to_string ( ) , "true" . to_string ( ) ) ;
262255
263256 let ( configs, _) = ServerLinter :: create_nested_configs (
264- & Uri :: from_str ( "file:/// root/") . unwrap ( ) ,
257+ Path :: new ( "/ root/") ,
265258 & Options { flags, ..Options :: default ( ) } ,
266259 ) ;
267260
@@ -271,7 +264,7 @@ mod test {
271264 #[ test]
272265 fn test_create_nested_configs ( ) {
273266 let ( configs, _) = ServerLinter :: create_nested_configs (
274- & get_file_uri ( "fixtures/linter/init_nested_configs" ) ,
267+ & get_file_path ( "fixtures/linter/init_nested_configs" ) ,
275268 & Options :: default ( ) ,
276269 ) ;
277270 let configs = configs. pin ( ) ;
0 commit comments