aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/subscriptions.rs
blob: 27f92cc9a687c0abb58f1a1743f05c37cc5a796f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::collections::HashSet;
use ra_analysis::FileId;

pub struct Subscriptions {
    subs: HashSet<FileId>,
}

impl Subscriptions {
    pub fn new() -> Subscriptions {
        Subscriptions { subs: HashSet::new() }
    }
    pub fn add_sub(&mut self, file_id: FileId) {
        self.subs.insert(file_id);
    }
    pub fn remove_sub(&mut self, file_id: FileId) {
        self.subs.remove(&file_id);
    }
    pub fn subscriptions(&self) -> Vec<FileId> {
        self.subs.iter().cloned().collect()
    }
}