diff options
Diffstat (limited to 'support/texlab/src/definition/mod.rs')
-rw-r--r-- | support/texlab/src/definition/mod.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/support/texlab/src/definition/mod.rs b/support/texlab/src/definition/mod.rs new file mode 100644 index 0000000000..9c7ac0145a --- /dev/null +++ b/support/texlab/src/definition/mod.rs @@ -0,0 +1,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>), +} |