diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/pending_requests.rs | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 3a559e845..eb805a6d3 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::{fmt::Write as _, io::Write as _}; | 1 | use std::{fmt::Write as _, io::Write as _}; |
2 | 2 | ||
3 | use gen_lsp_server::ErrorCode; | 3 | use lsp_server::ErrorCode; |
4 | use lsp_types::{ | 4 | use lsp_types::{ |
5 | CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic, | 5 | CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic, |
6 | DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeKind, | 6 | DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeKind, |
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 @@ | |||
1 | use std::time::{Duration, Instant}; | 1 | use std::time::{Duration, Instant}; |
2 | 2 | ||
3 | use lsp_server::RequestId; | ||
3 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
4 | 5 | ||
5 | #[derive(Debug)] | 6 | #[derive(Debug)] |
6 | pub struct CompletedRequest { | 7 | pub 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)] |
13 | pub(crate) struct PendingRequest { | 14 | pub(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)] |
30 | pub(crate) struct PendingRequests { | 31 | pub(crate) struct PendingRequests { |
31 | map: FxHashMap<u64, PendingRequest>, | 32 | map: FxHashMap<RequestId, PendingRequest>, |
32 | } | 33 | } |
33 | 34 | ||
34 | impl PendingRequests { | 35 | impl 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 | ||