@@ -94,19 +94,16 @@ impl Server {
9494 let client = LspClient :: new ( connection. sender . clone ( ) ) ;
9595 let cancel_token = Arc :: new ( CancellationToken :: new ( ) ) ;
9696
97- let ( params , client_rx) = Self :: establish_client_connection ( connection, & cancel_token) ?;
97+ let ( client_flags , client_rx) = Self :: establish_client_connection ( connection, & cancel_token) ?;
9898
99- let client_flags = Arc :: new ( ClientFlags :: from_initialize_request_params ( & params) ) ;
100-
101- let pool = Arc :: new ( threadpool:: Builder :: new ( ) . build ( ) ) ;
10299
103100 let ide = Arc :: new ( Workspace :: new ( ) ) ;
104101
105102 let ( internal_tx, internal_rx) = mpsc:: unbounded_channel ( ) ;
106103
107104 let cloned_tx = internal_tx. clone ( ) ;
108105 let cloned_ide = ide. clone ( ) ;
109- let cloned_pool = pool . clone ( ) ;
106+ let pool = Arc :: new ( threadpool :: Builder :: new ( ) . build ( ) ) ;
110107 let cloned_client = client. clone ( ) ;
111108
112109 let server = Self {
@@ -115,7 +112,7 @@ impl Server {
115112 internal_rx,
116113 internal_tx,
117114 client,
118- client_flags,
115+ client_flags : Arc :: new ( client_flags ) ,
119116 db_conn : None ,
120117 ide,
121118 compute_debouncer : EventDebouncer :: new (
@@ -124,7 +121,7 @@ impl Server {
124121 let inner_cloned_ide = cloned_ide. clone ( ) ;
125122 let inner_cloned_tx = cloned_tx. clone ( ) ;
126123 let inner_cloned_client = cloned_client. clone ( ) ;
127- cloned_pool . execute ( move || {
124+ pool . execute ( move || {
128125 inner_cloned_client
129126 . send_notification :: < ShowMessage > ( ShowMessageParams {
130127 typ : lsp_types:: MessageType :: INFO ,
@@ -229,8 +226,10 @@ impl Server {
229226 . unwrap ( ) ;
230227 }
231228 Err ( why) => {
232- client. send_info_notification ( & format ! ( "Unable to update database connection: {}" , why) ) ;
233-
229+ client. send_info_notification ( & format ! (
230+ "Unable to update database connection: {}" ,
231+ why
232+ ) ) ;
234233 }
235234 }
236235 } ) ;
@@ -868,7 +867,7 @@ impl Server {
868867 fn establish_client_connection (
869868 connection : Connection ,
870869 cancel_token : & Arc < CancellationToken > ,
871- ) -> anyhow:: Result < ( InitializeParams , mpsc:: UnboundedReceiver < Message > ) > {
870+ ) -> anyhow:: Result < ( ClientFlags , mpsc:: UnboundedReceiver < Message > ) > {
872871 let ( id, params) = connection. initialize_start ( ) ?;
873872
874873 let params: InitializeParams = serde_json:: from_value ( params) ?;
@@ -885,9 +884,12 @@ impl Server {
885884
886885 let client_rx = get_client_receiver ( connection, cancel_token. clone ( ) ) ;
887886
888- Ok ( ( params, client_rx) )
887+ let client_flags = ClientFlags :: from_initialize_request_params ( & params) ;
888+
889+ Ok ( ( client_flags, client_rx) )
889890 }
890891
892+ /// Spawns an asynchronous task that can be cancelled with the `Server`'s `cancel_token`.
891893 fn spawn_with_cancel < F , O > ( & self , f : F ) -> tokio:: task:: JoinHandle < Option < F :: Output > >
892894 where
893895 F : Future < Output = O > + Send + ' static ,
@@ -911,8 +913,6 @@ impl Server {
911913 self . pull_options ( ) ;
912914 }
913915
914- self . process_messages ( ) . await ?;
915-
916- Ok ( ( ) )
916+ self . process_messages ( ) . await
917917 }
918918}
0 commit comments