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
48
49
50
51
52
53
|
mod bibtex_string;
mod latex_citation;
mod latex_command;
mod latex_label;
use self::bibtex_string::BibtexStringDefinitionProvider;
use self::latex_citation::LatexCitationDefinitionProvider;
use self::latex_command::LatexCommandDefinitionProvider;
use self::latex_label::LatexLabelDefinitionProvider;
use crate::workspace::*;
use futures_boxed::boxed;
use lsp_types::{Location, LocationLink, TextDocumentPositionParams};
use serde::{Deserialize, Serialize};
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()
}
}
impl FeatureProvider for DefinitionProvider {
type Params = TextDocumentPositionParams;
type Output = Vec<LocationLink>;
#[boxed]
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
self.provider.execute(request).await
}
}
#[serde(untagged)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum DefinitionResponse {
Locations(Vec<Location>),
LocationLinks(Vec<LocationLink>),
}
|