aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/pending_requests.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-08-30 15:24:39 +0100
committerGitHub <[email protected]>2019-08-30 15:24:39 +0100
commitffc95759c7b538d8dacc336912b62857d4919cdd (patch)
tree3f0e4056ba2e4b3799b72d71d709783aa6dffc49 /crates/ra_lsp_server/src/main_loop/pending_requests.rs
parent7d72ca80003b7915ed7fc64907b5b6dc5c88dacd (diff)
parent72a3722470e5297c72dcaccaf2f113e7b758606d (diff)
Merge #1739
1739: move lsp-server to a separate repository r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/pending_requests.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop/pending_requests.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/pending_requests.rs b/crates/ra_lsp_server/src/main_loop/pending_requests.rs
index 741770e45..7a99fc679 100644
--- a/crates/ra_lsp_server/src/main_loop/pending_requests.rs
+++ b/crates/ra_lsp_server/src/main_loop/pending_requests.rs
@@ -1,17 +1,18 @@
1use std::time::{Duration, Instant}; 1use std::time::{Duration, Instant};
2 2
3use lsp_server::RequestId;
3use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
4 5
5#[derive(Debug)] 6#[derive(Debug)]
6pub struct CompletedRequest { 7pub struct CompletedRequest {
7 pub id: u64, 8 pub id: RequestId,
8 pub method: String, 9 pub method: String,
9 pub duration: Duration, 10 pub duration: Duration,
10} 11}
11 12
12#[derive(Debug)] 13#[derive(Debug)]
13pub(crate) struct PendingRequest { 14pub(crate) struct PendingRequest {
14 pub(crate) id: u64, 15 pub(crate) id: RequestId,
15 pub(crate) method: String, 16 pub(crate) method: String,
16 pub(crate) received: Instant, 17 pub(crate) received: Instant,
17} 18}
@@ -28,20 +29,20 @@ impl From<PendingRequest> for CompletedRequest {
28 29
29#[derive(Debug, Default)] 30#[derive(Debug, Default)]
30pub(crate) struct PendingRequests { 31pub(crate) struct PendingRequests {
31 map: FxHashMap<u64, PendingRequest>, 32 map: FxHashMap<RequestId, PendingRequest>,
32} 33}
33 34
34impl PendingRequests { 35impl PendingRequests {
35 pub(crate) fn start(&mut self, request: PendingRequest) { 36 pub(crate) fn start(&mut self, request: PendingRequest) {
36 let id = request.id; 37 let id = request.id.clone();
37 let prev = self.map.insert(id, request); 38 let prev = self.map.insert(id.clone(), request);
38 assert!(prev.is_none(), "duplicate request with id {}", id); 39 assert!(prev.is_none(), "duplicate request with id {}", id);
39 } 40 }
40 pub(crate) fn cancel(&mut self, id: u64) -> bool { 41 pub(crate) fn cancel(&mut self, id: &RequestId) -> bool {
41 self.map.remove(&id).is_some() 42 self.map.remove(id).is_some()
42 } 43 }
43 pub(crate) fn finish(&mut self, id: u64) -> Option<CompletedRequest> { 44 pub(crate) fn finish(&mut self, id: &RequestId) -> Option<CompletedRequest> {
44 self.map.remove(&id).map(CompletedRequest::from) 45 self.map.remove(id).map(CompletedRequest::from)
45 } 46 }
46} 47}
47 48