Skip to content

Commit c12d719

Browse files
authored
Merge pull request #21755 from oeb25/lsp-server-has-pending
feature: Add `has_pending` methods to `Incoming`/`Outgoing`/`ReqQueue` in `lsp_server`
2 parents e8ee51a + 86c523f commit c12d719

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/lsp-server/src/req_queue.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ impl<I, O> Default for ReqQueue<I, O> {
1818
}
1919
}
2020

21+
impl<I, O> ReqQueue<I, O> {
22+
pub fn has_pending(&self) -> bool {
23+
self.incoming.has_pending() || self.outgoing.has_pending()
24+
}
25+
}
26+
2127
#[derive(Debug)]
2228
pub struct Incoming<I> {
2329
pending: HashMap<RequestId, I>,
@@ -51,6 +57,10 @@ impl<I> Incoming<I> {
5157
pub fn is_completed(&self, id: &RequestId) -> bool {
5258
!self.pending.contains_key(id)
5359
}
60+
61+
pub fn has_pending(&self) -> bool {
62+
!self.pending.is_empty()
63+
}
5464
}
5565

5666
impl<O> Outgoing<O> {
@@ -64,4 +74,8 @@ impl<O> Outgoing<O> {
6474
pub fn complete(&mut self, id: RequestId) -> Option<O> {
6575
self.pending.remove(&id)
6676
}
77+
78+
pub fn has_pending(&self) -> bool {
79+
!self.pending.is_empty()
80+
}
6781
}

0 commit comments

Comments
 (0)