summaryrefslogtreecommitdiff
path: root/support/texlab/crates/base-db/src/document.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/base-db/src/document.rs')
-rw-r--r--support/texlab/crates/base-db/src/document.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/support/texlab/crates/base-db/src/document.rs b/support/texlab/crates/base-db/src/document.rs
index 7a388129fd..0b81fa2871 100644
--- a/support/texlab/crates/base-db/src/document.rs
+++ b/support/texlab/crates/base-db/src/document.rs
@@ -3,7 +3,7 @@ use std::path::PathBuf;
use distro::Language;
use line_index::{LineCol, LineIndex};
use rowan::TextRange;
-use syntax::{bibtex, latex, latexmkrc::LatexmkrcData, BuildError};
+use syntax::{bibtex, file_list::FileList, latex, latexmkrc::LatexmkrcData, BuildError};
use url::Url;
use crate::{semantics, Config};
@@ -28,7 +28,7 @@ pub struct DocumentParams<'a> {
#[derive(Clone)]
pub struct Document {
pub uri: Url,
- pub dir: Url,
+ pub dir: Option<Url>,
pub path: Option<PathBuf>,
pub text: String,
pub line_index: LineIndex,
@@ -42,7 +42,7 @@ impl Document {
pub fn parse(params: DocumentParams) -> Self {
let DocumentParams { uri, text, .. } = params;
- let dir = uri.join(".").unwrap();
+ let dir = uri.join(".").ok();
let path = if uri.scheme() == "file" {
uri.to_file_path().ok()
@@ -56,7 +56,10 @@ impl Document {
Language::Tex => {
let green = parser::parse_latex(&text, &params.config.syntax);
let mut semantics = semantics::tex::Semantics::default();
- semantics.process_root(&latex::SyntaxNode::new_root(green.clone()));
+ semantics.process_root(
+ &params.config.syntax,
+ &latex::SyntaxNode::new_root(green.clone()),
+ );
DocumentData::Tex(TexDocumentData { green, semantics })
}
Language::Bib => {
@@ -86,6 +89,7 @@ impl Document {
DocumentData::Latexmkrc(data)
}
Language::Tectonic => DocumentData::Tectonic,
+ Language::FileList => DocumentData::FileList(parser::parse_file_list(&text)),
};
Self {
@@ -143,6 +147,7 @@ pub enum DocumentData {
Root,
Latexmkrc(LatexmkrcData),
Tectonic,
+ FileList(FileList),
}
impl DocumentData {
@@ -185,6 +190,14 @@ impl DocumentData {
None
}
}
+
+ pub fn as_file_list(&self) -> Option<&FileList> {
+ if let DocumentData::FileList(data) = self {
+ Some(data)
+ } else {
+ None
+ }
+ }
}
#[derive(Debug, Clone)]