@@ -111,10 +111,10 @@ impl LanguageServer for Backend {
111111 let capabilities = Capabilities :: from ( params. capabilities ) ;
112112
113113 // client sent workspace folders
114- let workers = if let Some ( workspace_folders) = & params. workspace_folders {
114+ let workers = if let Some ( workspace_folders) = params. workspace_folders {
115115 workspace_folders
116- . iter ( )
117- . map ( |workspace_folder| WorkspaceWorker :: new ( workspace_folder. uri . clone ( ) ) )
116+ . into_iter ( )
117+ . map ( |workspace_folder| WorkspaceWorker :: new ( workspace_folder. uri ) )
118118 . collect ( )
119119 // client sent deprecated root uri
120120 } else if let Some ( root_uri) = params. root_uri {
@@ -130,8 +130,8 @@ impl LanguageServer for Backend {
130130 // we will init the linter after requesting for the workspace configuration.
131131 if !capabilities. workspace_configuration || options. is_some ( ) {
132132 for worker in & workers {
133- let option = & options
134- . clone ( )
133+ let option = options
134+ . as_deref ( )
135135 . unwrap_or_default ( )
136136 . iter ( )
137137 . find ( |workspace_option| {
@@ -140,7 +140,7 @@ impl LanguageServer for Backend {
140140 . map ( |workspace_options| workspace_options. options . clone ( ) )
141141 . unwrap_or_default ( ) ;
142142
143- worker. start_worker ( option. clone ( ) , & self . tool_builders ) . await ;
143+ worker. start_worker ( option, & self . tool_builders ) . await ;
144144 }
145145 }
146146
@@ -319,11 +319,11 @@ impl LanguageServer for Backend {
319319
320320 // Only create WorkspaceOption when the config is Some
321321 configs
322- . iter ( )
322+ . into_iter ( )
323323 . enumerate ( )
324- . map ( |( index, config ) | WorkspaceOption {
324+ . map ( |( index, options ) | WorkspaceOption {
325325 workspace_uri : workers[ index] . get_root_uri ( ) . clone ( ) ,
326- options : config . clone ( ) ,
326+ options,
327327 } )
328328 . collect :: < Vec < _ > > ( )
329329 } else {
@@ -456,8 +456,8 @@ impl LanguageServer for Backend {
456456 )
457457 . await ;
458458
459- for ( index, folder) in params. event . added . iter ( ) . enumerate ( ) {
460- let worker = WorkspaceWorker :: new ( folder. uri . clone ( ) ) ;
459+ for ( index, folder) in params. event . added . into_iter ( ) . enumerate ( ) {
460+ let worker = WorkspaceWorker :: new ( folder. uri ) ;
461461 // get the configuration from the response and init the linter
462462 let options = configurations. get ( index) . unwrap_or ( & serde_json:: Value :: Null ) ;
463463 worker. start_worker ( options. clone ( ) , & self . tool_builders ) . await ;
@@ -498,36 +498,36 @@ impl LanguageServer for Backend {
498498 /// See: <https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didSave>
499499 async fn did_save ( & self , params : DidSaveTextDocumentParams ) {
500500 debug ! ( "oxc server did save" ) ;
501- let uri = & params. text_document . uri ;
501+ let uri = params. text_document . uri ;
502502 let workers = self . workspace_workers . read ( ) . await ;
503- let Some ( worker) = workers. iter ( ) . find ( |worker| worker. is_responsible_for_uri ( uri) ) else {
503+ let Some ( worker) = workers. iter ( ) . find ( |worker| worker. is_responsible_for_uri ( & uri) ) else {
504504 return ;
505505 } ;
506506
507- if let Some ( diagnostics) = worker. run_diagnostic_on_save ( uri, params. text . as_deref ( ) ) . await
507+ if let Some ( diagnostics) = worker. run_diagnostic_on_save ( & uri, params. text . as_deref ( ) ) . await
508508 {
509- self . client . publish_diagnostics ( uri. clone ( ) , diagnostics, None ) . await ;
509+ self . client . publish_diagnostics ( uri, diagnostics, None ) . await ;
510510 }
511511 }
512512 /// It will update the in-memory file content if the client supports dynamic formatting.
513513 /// It will re-lint the file and send updated diagnostics, if necessary.
514514 ///
515515 /// See: <https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didChange>
516516 async fn did_change ( & self , params : DidChangeTextDocumentParams ) {
517- let uri = & params. text_document . uri ;
517+ let uri = params. text_document . uri ;
518518 let workers = self . workspace_workers . read ( ) . await ;
519- let Some ( worker) = workers. iter ( ) . find ( |worker| worker. is_responsible_for_uri ( uri) ) else {
519+ let Some ( worker) = workers. iter ( ) . find ( |worker| worker. is_responsible_for_uri ( & uri) ) else {
520520 return ;
521521 } ;
522522 let content = params. content_changes . first ( ) . map ( |c| c. text . clone ( ) ) ;
523523
524524 if let Some ( content) = & content {
525- self . file_system . write ( ) . await . set ( uri, content. clone ( ) ) ;
525+ self . file_system . write ( ) . await . set ( & uri, content. clone ( ) ) ;
526526 }
527527
528- if let Some ( diagnostics) = worker. run_diagnostic_on_change ( uri, content. as_deref ( ) ) . await {
528+ if let Some ( diagnostics) = worker. run_diagnostic_on_change ( & uri, content. as_deref ( ) ) . await {
529529 self . client
530- . publish_diagnostics ( uri. clone ( ) , diagnostics, Some ( params. text_document . version ) )
530+ . publish_diagnostics ( uri, diagnostics, Some ( params. text_document . version ) )
531531 . await ;
532532 }
533533 }
@@ -537,19 +537,19 @@ impl LanguageServer for Backend {
537537 ///
538538 /// See: <https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didOpen>
539539 async fn did_open ( & self , params : DidOpenTextDocumentParams ) {
540- let uri = & params. text_document . uri ;
540+ let uri = params. text_document . uri ;
541541 let workers = self . workspace_workers . read ( ) . await ;
542- let Some ( worker) = workers. iter ( ) . find ( |worker| worker. is_responsible_for_uri ( uri) ) else {
542+ let Some ( worker) = workers. iter ( ) . find ( |worker| worker. is_responsible_for_uri ( & uri) ) else {
543543 return ;
544544 } ;
545545
546546 let content = params. text_document . text ;
547547
548- self . file_system . write ( ) . await . set ( uri, content. clone ( ) ) ;
548+ self . file_system . write ( ) . await . set ( & uri, content. clone ( ) ) ;
549549
550- if let Some ( diagnostics) = worker. run_diagnostic ( uri, Some ( & content) ) . await {
550+ if let Some ( diagnostics) = worker. run_diagnostic ( & uri, Some ( & content) ) . await {
551551 self . client
552- . publish_diagnostics ( uri. clone ( ) , diagnostics, Some ( params. text_document . version ) )
552+ . publish_diagnostics ( uri, diagnostics, Some ( params. text_document . version ) )
553553 . await ;
554554 }
555555 }
0 commit comments