aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/subscriptions.rs
blob: bee6437cf34b6f8664171cd6f7b9bbbcf51067d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! Keeps track of file subscriptions -- the set of currently opened files for
//! which we want to publish diagnostics, syntax highlighting, etc.

use ra_ide::FileId;
use rustc_hash::FxHashSet;

#[derive(Default, Debug)]
pub(crate) struct Subscriptions {
    subs: FxHashSet<FileId>,
}

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