1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use crate::workspace::Uri;
use lsp_types::ProgressToken;
use std::mem;
use std::sync::Mutex;
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum LintReason {
Change,
Save,
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Action {
CheckInstalledDistribution,
DetectRoot(Uri),
PublishDiagnostics,
RunLinter(Uri, LintReason),
Build(Uri),
CancelBuild(ProgressToken),
}
#[derive(Debug, Default)]
pub struct ActionManager {
actions: Mutex<Vec<Action>>,
}
impl ActionManager {
pub fn push(&self, action: Action) {
let mut actions = self.actions.lock().unwrap();
actions.push(action);
}
pub fn take(&self) -> Vec<Action> {
let mut actions = self.actions.lock().unwrap();
mem::replace(&mut *actions, Vec::new())
}
}
|