summaryrefslogtreecommitdiff
path: root/support/texlab/src/definition/mod.rs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-12-03 03:01:24 +0000
committerNorbert Preining <norbert@preining.info>2019-12-03 03:01:24 +0000
commitb8d4bb76703bcb15578e2b23c5d256532180b894 (patch)
treebedd1df7a00521a2bd986b3c0289d6556a59e39b /support/texlab/src/definition/mod.rs
parent02e4625a78a5029e8b5dc2a4ec70193b232f497e (diff)
CTAN sync 201912030301
Diffstat (limited to 'support/texlab/src/definition/mod.rs')
-rw-r--r--support/texlab/src/definition/mod.rs53
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>),
+}