diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 452499497..6080a3a4e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -24,7 +24,7 @@ use crate::{ | |||
24 | }, | 24 | }, |
25 | project_model::workspace_loader, | 25 | project_model::workspace_loader, |
26 | req, | 26 | req, |
27 | server_world::{ServerWorld, ServerWorldState}, | 27 | world::{WorldSnapshot, WorldState}, |
28 | Result, | 28 | Result, |
29 | InitializationOptions, | 29 | InitializationOptions, |
30 | }; | 30 | }; |
@@ -73,12 +73,11 @@ pub fn main_loop( | |||
73 | loaded_workspaces | 73 | loaded_workspaces |
74 | }; | 74 | }; |
75 | 75 | ||
76 | let mut state = ServerWorldState::new(ws_roots, workspaces); | 76 | let mut state = WorldState::new(ws_roots, workspaces); |
77 | 77 | ||
78 | let pool = ThreadPool::new(THREADPOOL_SIZE); | 78 | let pool = ThreadPool::new(THREADPOOL_SIZE); |
79 | let (task_sender, task_receiver) = unbounded::<Task>(); | 79 | let (task_sender, task_receiver) = unbounded::<Task>(); |
80 | let mut pending_requests = PendingRequests::default(); | 80 | let mut pending_requests = PendingRequests::default(); |
81 | let mut subs = Subscriptions::default(); | ||
82 | 81 | ||
83 | log::info!("server initialized, serving requests"); | 82 | log::info!("server initialized, serving requests"); |
84 | let main_res = main_loop_inner( | 83 | let main_res = main_loop_inner( |
@@ -90,7 +89,6 @@ pub fn main_loop( | |||
90 | task_receiver.clone(), | 89 | task_receiver.clone(), |
91 | &mut state, | 90 | &mut state, |
92 | &mut pending_requests, | 91 | &mut pending_requests, |
93 | &mut subs, | ||
94 | ); | 92 | ); |
95 | 93 | ||
96 | log::info!("waiting for tasks to finish..."); | 94 | log::info!("waiting for tasks to finish..."); |
@@ -163,10 +161,10 @@ fn main_loop_inner( | |||
163 | msg_receiver: &Receiver<RawMessage>, | 161 | msg_receiver: &Receiver<RawMessage>, |
164 | task_sender: Sender<Task>, | 162 | task_sender: Sender<Task>, |
165 | task_receiver: Receiver<Task>, | 163 | task_receiver: Receiver<Task>, |
166 | state: &mut ServerWorldState, | 164 | state: &mut WorldState, |
167 | pending_requests: &mut PendingRequests, | 165 | pending_requests: &mut PendingRequests, |
168 | subs: &mut Subscriptions, | ||
169 | ) -> Result<()> { | 166 | ) -> Result<()> { |
167 | let mut subs = Subscriptions::default(); | ||
170 | // We try not to index more than MAX_IN_FLIGHT_LIBS libraries at the same | 168 | // We try not to index more than MAX_IN_FLIGHT_LIBS libraries at the same |
171 | // time to always have a thread ready to react to input. | 169 | // time to always have a thread ready to react to input. |
172 | let mut in_flight_libraries = 0; | 170 | let mut in_flight_libraries = 0; |
@@ -230,7 +228,7 @@ fn main_loop_inner( | |||
230 | )? | 228 | )? |
231 | } | 229 | } |
232 | RawMessage::Notification(not) => { | 230 | RawMessage::Notification(not) => { |
233 | on_notification(msg_sender, state, pending_requests, subs, not)?; | 231 | on_notification(msg_sender, state, pending_requests, &mut subs, not)?; |
234 | state_changed = true; | 232 | state_changed = true; |
235 | } | 233 | } |
236 | RawMessage::Response(resp) => log::error!("unexpected response: {:?}", resp), | 234 | RawMessage::Response(resp) => log::error!("unexpected response: {:?}", resp), |
@@ -280,7 +278,7 @@ fn on_task( | |||
280 | task: Task, | 278 | task: Task, |
281 | msg_sender: &Sender<RawMessage>, | 279 | msg_sender: &Sender<RawMessage>, |
282 | pending_requests: &mut PendingRequests, | 280 | pending_requests: &mut PendingRequests, |
283 | state: &mut ServerWorldState, | 281 | state: &mut WorldState, |
284 | ) { | 282 | ) { |
285 | match task { | 283 | match task { |
286 | Task::Respond(response) => { | 284 | Task::Respond(response) => { |
@@ -297,7 +295,7 @@ fn on_task( | |||
297 | } | 295 | } |
298 | 296 | ||
299 | fn on_request( | 297 | fn on_request( |
300 | world: &mut ServerWorldState, | 298 | world: &mut WorldState, |
301 | pending_requests: &mut PendingRequests, | 299 | pending_requests: &mut PendingRequests, |
302 | pool: &ThreadPool, | 300 | pool: &ThreadPool, |
303 | sender: &Sender<Task>, | 301 | sender: &Sender<Task>, |
@@ -354,7 +352,7 @@ fn on_request( | |||
354 | 352 | ||
355 | fn on_notification( | 353 | fn on_notification( |
356 | msg_sender: &Sender<RawMessage>, | 354 | msg_sender: &Sender<RawMessage>, |
357 | state: &mut ServerWorldState, | 355 | state: &mut WorldState, |
358 | pending_requests: &mut PendingRequests, | 356 | pending_requests: &mut PendingRequests, |
359 | subs: &mut Subscriptions, | 357 | subs: &mut Subscriptions, |
360 | not: RawNotification, | 358 | not: RawNotification, |
@@ -424,7 +422,7 @@ fn on_notification( | |||
424 | struct PoolDispatcher<'a> { | 422 | struct PoolDispatcher<'a> { |
425 | req: Option<RawRequest>, | 423 | req: Option<RawRequest>, |
426 | pool: &'a ThreadPool, | 424 | pool: &'a ThreadPool, |
427 | world: &'a mut ServerWorldState, | 425 | world: &'a mut WorldState, |
428 | pending_requests: &'a mut PendingRequests, | 426 | pending_requests: &'a mut PendingRequests, |
429 | msg_sender: &'a Sender<RawMessage>, | 427 | msg_sender: &'a Sender<RawMessage>, |
430 | sender: &'a Sender<Task>, | 428 | sender: &'a Sender<Task>, |
@@ -435,7 +433,7 @@ impl<'a> PoolDispatcher<'a> { | |||
435 | /// Dispatches the request onto the current thread | 433 | /// Dispatches the request onto the current thread |
436 | fn on_sync<R>( | 434 | fn on_sync<R>( |
437 | &mut self, | 435 | &mut self, |
438 | f: fn(&mut ServerWorldState, R::Params) -> Result<R::Result>, | 436 | f: fn(&mut WorldState, R::Params) -> Result<R::Result>, |
439 | ) -> Result<&mut Self> | 437 | ) -> Result<&mut Self> |
440 | where | 438 | where |
441 | R: req::Request + 'static, | 439 | R: req::Request + 'static, |
@@ -455,7 +453,7 @@ impl<'a> PoolDispatcher<'a> { | |||
455 | } | 453 | } |
456 | 454 | ||
457 | /// Dispatches the request onto thread pool | 455 | /// Dispatches the request onto thread pool |
458 | fn on<R>(&mut self, f: fn(ServerWorld, R::Params) -> Result<R::Result>) -> Result<&mut Self> | 456 | fn on<R>(&mut self, f: fn(WorldSnapshot, R::Params) -> Result<R::Result>) -> Result<&mut Self> |
459 | where | 457 | where |
460 | R: req::Request + 'static, | 458 | R: req::Request + 'static, |
461 | R::Params: DeserializeOwned + Send + 'static, | 459 | R::Params: DeserializeOwned + Send + 'static, |
@@ -559,7 +557,7 @@ where | |||
559 | 557 | ||
560 | fn update_file_notifications_on_threadpool( | 558 | fn update_file_notifications_on_threadpool( |
561 | pool: &ThreadPool, | 559 | pool: &ThreadPool, |
562 | world: ServerWorld, | 560 | world: WorldSnapshot, |
563 | publish_decorations: bool, | 561 | publish_decorations: bool, |
564 | sender: Sender<Task>, | 562 | sender: Sender<Task>, |
565 | subscriptions: Vec<FileId>, | 563 | subscriptions: Vec<FileId>, |