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
38
39
40
41
42
43
44
45
46
47
|
mod bibtex_string;
mod latex_citation;
mod latex_cmd;
mod latex_label;
use self::{
bibtex_string::BibtexStringDefinitionProvider, latex_citation::LatexCitationDefinitionProvider,
latex_cmd::LatexCommandDefinitionProvider, latex_label::LatexLabelDefinitionProvider,
};
use crate::{
feature::{ConcatProvider, FeatureProvider, FeatureRequest},
protocol::{LocationLink, TextDocumentPositionParams},
};
use async_trait::async_trait;
pub struct DefinitionProvider {
provider: ConcatProvider<TextDocumentPositionParams, LocationLink>,
}
impl DefinitionProvider {
pub fn new() -> Self {
Self {
provider: ConcatProvider::new(vec![
Box::new(BibtexStringDefinitionProvider),
Box::new(LatexCitationDefinitionProvider),
Box::new(LatexCommandDefinitionProvider),
Box::new(LatexLabelDefinitionProvider),
]),
}
}
}
impl Default for DefinitionProvider {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl FeatureProvider for DefinitionProvider {
type Params = TextDocumentPositionParams;
type Output = Vec<LocationLink>;
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
self.provider.execute(req).await
}
}
|