Move parsers into a separate crate

This commit is contained in:
Patrick Förster 2019-07-30 12:30:10 +02:00
parent 2e742d7c49
commit bacbcdb824
65 changed files with 145 additions and 198 deletions

13
Cargo.lock generated
View file

@ -2057,6 +2057,7 @@ dependencies = [
"serde_repr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"stderrlog 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"texlab-syntax 0.1.0",
"tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-process 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2067,6 +2068,18 @@ dependencies = [
"walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "texlab-syntax"
version = "0.1.0"
dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lsp-types 0.57.1 (git+https://github.com/latex-lsp/lsp-types?rev=9fcc5d9b9d3013ce84e20ef566267754d594b268)",
"once_cell 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"path-clean 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "textwrap"
version = "0.11.0"

View file

@ -8,7 +8,7 @@ authors = [
edition = "2018"
[workspace]
members = ["./jsonrpc", "./jsonrpc_derive"]
members = ["./jsonrpc", "./jsonrpc_derive", "crates/texlab_syntax"]
[dependencies]
base64 = "0.10.1"
@ -36,6 +36,7 @@ serde_json = "1.0.40"
serde_repr = "0.1"
stderrlog = "0.4.1"
tempfile = "3"
texlab-syntax = { path = "crates/texlab_syntax" }
tokio = "0.1"
tokio-codec = "0.1"
tokio-process = "0.2.4"

View file

@ -0,0 +1,15 @@
[package]
name = "texlab-syntax"
version = "0.1.0"
authors = [
"Eric Förster <efoerster@users.noreply.github.com>",
"Patrick Förster <pfoerster@users.noreply.github.com>"]
edition = "2018"
[dependencies]
itertools = "0.8.0"
lsp-types = { git = "https://github.com/latex-lsp/lsp-types", rev = "9fcc5d9b9d3013ce84e20ef566267754d594b268", features = ["proposed"] }
once_cell = "0.2.2"
path-clean = "0.1.0"
serde = { version = "1.0.97", features = ["derive", "rc"] }
serde_json = "1.0.40"

View file

@ -1,4 +1,4 @@
use crate::syntax::text::{Span, SyntaxNode};
use crate::text::{Span, SyntaxNode};
use lsp_types::Range;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]

View file

@ -1,5 +1,5 @@
use crate::syntax::bibtex::ast::*;
use crate::syntax::text::SyntaxNode;
use crate::bibtex::ast::*;
use crate::text::SyntaxNode;
use lsp_types::Position;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]

View file

@ -1,5 +1,5 @@
use crate::syntax::bibtex::ast::{BibtexToken, BibtexTokenKind};
use crate::syntax::text::CharStream;
use super::ast::{BibtexToken, BibtexTokenKind};
use crate::text::CharStream;
pub struct BibtexLexer<'a> {
stream: CharStream<'a>,
@ -100,7 +100,7 @@ impl<'a> Iterator for BibtexLexer<'a> {
#[cfg(test)]
mod tests {
use super::*;
use crate::syntax::text::Span;
use crate::text::Span;
use lsp_types::{Position, Range};
fn verify<'a>(

View file

@ -3,11 +3,11 @@ mod finder;
mod lexer;
mod parser;
use crate::syntax::bibtex::lexer::BibtexLexer;
use crate::syntax::bibtex::parser::BibtexParser;
use crate::bibtex::lexer::BibtexLexer;
use crate::bibtex::parser::BibtexParser;
pub use crate::syntax::bibtex::ast::*;
pub use crate::syntax::bibtex::finder::*;
pub use crate::bibtex::ast::*;
pub use crate::bibtex::finder::*;
use lsp_types::Position;
#[derive(Debug, PartialEq, Eq, Clone)]

View file

@ -1,4 +1,4 @@
use crate::syntax::bibtex::ast::*;
use crate::bibtex::ast::*;
use std::iter::Peekable;
pub struct BibtexParser<I: Iterator<Item = BibtexToken>> {

View file

@ -1,4 +1,4 @@
use once_cell::sync::OnceCell;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
@ -131,13 +131,13 @@ pub struct LatexColorModelCommand {
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BibtexEntryType {
pub struct BibtexEntryTypeDoc {
pub name: String,
pub documentation: Option<String>,
}
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct BibtexField {
pub struct BibtexFieldDoc {
pub name: String,
pub documentation: String,
}
@ -156,8 +156,8 @@ pub struct LanguageData {
pub colors: Vec<String>,
pub color_commands: Vec<LatexColorCommand>,
pub color_model_commands: Vec<LatexColorModelCommand>,
pub entry_types: Vec<BibtexEntryType>,
pub fields: Vec<BibtexField>,
pub entry_types: Vec<BibtexEntryTypeDoc>,
pub fields: Vec<BibtexFieldDoc>,
pub pgf_libraries: Vec<String>,
pub tikz_libraries: Vec<String>,
pub math_environments: Vec<String>,
@ -183,10 +183,7 @@ impl LanguageData {
}
}
pub fn language_data() -> &'static LanguageData {
static INSTANCE: OnceCell<LanguageData> = OnceCell::new();
INSTANCE.get_or_init(|| {
const JSON: &str = include_str!("language.json");
serde_json::from_str(JSON).expect("Failed to deserialize language.json")
})
}
pub static LANGUAGE_DATA: Lazy<LanguageData> = Lazy::new(|| {
const JSON: &str = include_str!("language.json");
serde_json::from_str(JSON).expect("Failed to deserialize language.json")
});

View file

@ -1,4 +1,4 @@
use crate::syntax::text::{Span, SyntaxNode};
use crate::text::{Span, SyntaxNode};
use itertools::Itertools;
use lsp_types::Range;
use std::sync::Arc;

View file

@ -1,5 +1,5 @@
use crate::syntax::latex::ast::*;
use crate::syntax::text::SyntaxNode;
use crate::latex::ast::*;
use crate::text::SyntaxNode;
use lsp_types::Position;
use std::sync::Arc;

View file

@ -1,5 +1,5 @@
use crate::syntax::latex::ast::{LatexToken, LatexTokenKind};
use crate::syntax::text::CharStream;
use super::ast::{LatexToken, LatexTokenKind};
use crate::text::CharStream;
pub struct LatexLexer<'a> {
stream: CharStream<'a>,
@ -106,7 +106,7 @@ fn is_word_char(c: char) -> bool {
#[cfg(test)]
mod tests {
use super::*;
use crate::syntax::text::Span;
use crate::text::Span;
use lsp_types::{Position, Range};
fn verify<'a>(

View file

@ -6,10 +6,10 @@ mod parser;
pub use self::ast::*;
use self::finder::LatexFinder;
pub use self::finder::LatexNode;
use crate::data::language::*;
use crate::syntax::latex::lexer::LatexLexer;
use crate::syntax::latex::parser::LatexParser;
use crate::syntax::text::SyntaxNode;
use super::language::*;
use self::lexer::LatexLexer;
use self::parser::LatexParser;
use super::text::SyntaxNode;
use lsp_types::{Position, Range, Uri};
use path_clean::PathClean;
use std::path::PathBuf;
@ -67,7 +67,7 @@ impl LatexEnvironmentDelimiter {
pub fn is_math(&self) -> bool {
if let Some(name) = self.name() {
language_data()
LANGUAGE_DATA
.math_environments
.iter()
.any(|env| env == name.text())
@ -159,7 +159,7 @@ impl LatexCitation {
fn parse(commands: &[Arc<LatexCommand>]) -> Vec<Self> {
let mut citations = Vec::new();
for command in commands {
for LatexCitationCommand { name, index } in &language_data().citation_commands {
for LatexCitationCommand { name, index } in &LANGUAGE_DATA.citation_commands {
if command.name.text() == name && command.has_comma_separated_words(*index) {
citations.push(Self {
command: Arc::clone(command),
@ -193,7 +193,7 @@ impl LatexLabel {
fn parse(commands: &[Arc<LatexCommand>]) -> Vec<Self> {
let mut labels = Vec::new();
for command in commands {
for LatexLabelCommand { name, index, kind } in &language_data().label_commands {
for LatexLabelCommand { name, index, kind } in &LANGUAGE_DATA.label_commands {
if command.name.text() == name && command.has_comma_separated_words(*index) {
labels.push(Self {
command: Arc::clone(command),
@ -224,7 +224,7 @@ impl LatexSection {
fn parse(commands: &[Arc<LatexCommand>]) -> Vec<Self> {
let mut sections = Vec::new();
for command in commands {
for LatexSectionCommand { name, index, level } in &language_data().section_commands {
for LatexSectionCommand { name, index, level } in &LANGUAGE_DATA.section_commands {
if command.name.text() == name && command.args.len() > *index {
sections.push(Self {
command: Arc::clone(command),
@ -278,7 +278,7 @@ impl LatexInclude {
fn parse(uri: &Uri, commands: &[Arc<LatexCommand>]) -> Vec<Self> {
let mut includes = Vec::new();
for command in commands {
for description in &language_data().include_commands {
for description in &LANGUAGE_DATA.include_commands {
if let Some(include) = Self::parse_single(uri, &command, &description) {
includes.push(include);
}
@ -449,7 +449,7 @@ impl LatexMathOperator {
name,
definition_index,
implementation_index,
} in &language_data().math_operator_commands
} in &LANGUAGE_DATA.math_operator_commands
{
if command.name.text() == name
&& command.args.len() > *definition_index
@ -496,7 +496,7 @@ impl LatexCommandDefinition {
definition_index,
argument_count_index,
implementation_index,
} in &language_data().command_definition_commands
} in &LANGUAGE_DATA.command_definition_commands
{
if command.name.text() == name
&& command.args.len() > *definition_index
@ -541,7 +541,7 @@ impl LatexTheoremDefinition {
let mut definitions = Vec::new();
for command in commands {
for LatexTheoremDefinitionCommand { name, index } in
&language_data().theorem_definition_commands
&LANGUAGE_DATA.theorem_definition_commands
{
if command.name.text() == name && command.has_word(*index) {
definitions.push(Self {

View file

@ -1,4 +1,4 @@
use crate::syntax::latex::ast::*;
use super::ast::*;
use std::iter::Peekable;
use std::sync::Arc;

View file

@ -1,10 +1,13 @@
pub mod bibtex;
pub mod latex;
pub mod text;
mod bibtex;
mod latex;
mod text;
mod language;
use crate::syntax::bibtex::BibtexSyntaxTree;
use crate::syntax::latex::LatexSyntaxTree;
use lsp_types::Uri;
pub use self::text::*;
pub use self::bibtex::*;
pub use self::latex::*;
pub use self::language::*;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Language {

View file

@ -1,9 +1,7 @@
use crate::completion::factory::{self, LatexComponentId};
use crate::data::completion::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::bibtex::BibtexNode;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;

View file

@ -1,9 +1,6 @@
use crate::completion::factory;
use crate::data::language::language_data;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::bibtex::{BibtexDeclaration, BibtexToken};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
@ -50,7 +47,7 @@ fn contains(ty: &BibtexToken, position: Position) -> bool {
fn make_items(request: &FeatureRequest<CompletionParams>, mut range: Range) -> Vec<CompletionItem> {
range.start.character += 1;
let mut items = Vec::new();
for ty in &language_data().entry_types {
for ty in &LANGUAGE_DATA.entry_types {
let text_edit = TextEdit::new(range, (&ty.name).into());
let item = factory::entry_type(request, ty, text_edit);
items.push(item);

View file

@ -1,9 +1,6 @@
use crate::completion::factory;
use crate::data::language::language_data;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::bibtex::BibtexNode;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, Range, TextEdit};
@ -48,7 +45,7 @@ fn make_items(
edit_range: Range,
) -> Vec<CompletionItem> {
let mut items = Vec::new();
for field in &language_data().fields {
for field in &LANGUAGE_DATA.fields {
let text_edit = TextEdit::new(edit_range, (&field.name).into());
let item = factory::field_name(request, field, text_edit);
items.push(item);

View file

@ -1,8 +1,7 @@
use crate::data::label::LabelContext;
use crate::data::language::{BibtexEntryType, BibtexField};
use crate::feature::FeatureRequest;
use crate::formatting::bibtex::{self, BibtexFormattingParams};
use crate::syntax::bibtex::BibtexEntry;
use texlab_syntax::*;
use lsp_types::*;
use once_cell::sync::Lazy;
use regex::Regex;
@ -295,7 +294,7 @@ pub fn citation(
pub fn entry_type(
request: &FeatureRequest<CompletionParams>,
ty: &'static BibtexEntryType,
ty: &'static BibtexEntryTypeDoc,
text_edit: TextEdit,
) -> CompletionItem {
CompletionItem {
@ -315,7 +314,7 @@ pub fn entry_type(
pub fn field_name(
request: &FeatureRequest<CompletionParams>,
field: &'static BibtexField,
field: &'static BibtexFieldDoc,
text_edit: TextEdit,
) -> CompletionItem {
CompletionItem {

View file

@ -1,8 +1,7 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::language::language_data;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, TextEdit};
@ -15,7 +14,7 @@ impl FeatureProvider for LatexCitationCompletionProvider {
#[boxed]
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
let parameters = language_data()
let parameters = LANGUAGE_DATA
.citation_commands
.iter()
.map(|cmd| Parameter::new(&cmd.name, cmd.index));

View file

@ -1,6 +1,6 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::language::language_data;
use texlab_syntax::*;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, TextEdit};
@ -14,14 +14,14 @@ impl FeatureProvider for LatexColorCompletionProvider {
#[boxed]
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
let parameters = language_data()
let parameters = LANGUAGE_DATA
.color_commands
.iter()
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
combinators::argument(request, parameters, async move |context| {
let mut items = Vec::new();
for name in &language_data().colors {
for name in &LANGUAGE_DATA.colors {
let text_edit = TextEdit::new(context.range, name.into());
let item = factory::color(request, name, text_edit);
items.push(item);

View file

@ -1,6 +1,6 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::language::language_data;
use texlab_syntax::LANGUAGE_DATA;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, TextEdit};
@ -14,7 +14,7 @@ impl FeatureProvider for LatexColorModelCompletionProvider {
#[boxed]
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
let parameters = language_data()
let parameters = LANGUAGE_DATA
.color_model_commands
.iter()
.map(|cmd| Parameter::new(&cmd.name, cmd.index));

View file

@ -1,8 +1,5 @@
use crate::data::language::language_data;
use crate::feature::FeatureRequest;
use crate::syntax::latex::*;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use lsp_types::*;
use std::future::Future;
use std::sync::Arc;
@ -133,7 +130,7 @@ where
E: FnOnce(ArgumentContext<'a>) -> F,
F: Future<Output = Vec<CompletionItem>>,
{
let parameters = language_data()
let parameters = LANGUAGE_DATA
.environment_commands
.iter()
.map(|cmd| Parameter::new(&cmd.name, cmd.index));

View file

@ -4,7 +4,6 @@ use crate::data::completion::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::*;
use lsp_types::{CompletionItem, CompletionParams};
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct LatexComponentCommandCompletionProvider;

View file

@ -1,7 +1,7 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::completion::DATABASE;
use crate::data::language::{language_data, LatexIncludeKind};
use texlab_syntax::*;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, TextEdit};
@ -46,7 +46,7 @@ where
"cls"
};
let parameters = language_data()
let parameters = LANGUAGE_DATA
.include_commands
.iter()
.filter(|cmd| cmd.kind == kind)

View file

@ -1,9 +1,7 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::language::language_data;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::LatexCommand;
use crate::syntax::text::SyntaxNode;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, Range, TextEdit};
use std::path::{Path, PathBuf};
@ -18,7 +16,7 @@ impl FeatureProvider for LatexIncludeCompletionProvider {
#[boxed]
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
let parameters = language_data()
let parameters = LANGUAGE_DATA
.include_commands
.iter()
.map(|cmd| Parameter::new(&cmd.name, cmd.index));
@ -52,7 +50,7 @@ impl FeatureProvider for LatexIncludeCompletionProvider {
{
if entry.file_type().is_file() && is_included(&command, &entry.path()) {
let mut path = entry.into_path();
let include_extension = language_data()
let include_extension = LANGUAGE_DATA
.include_commands
.iter()
.find(|cmd| command.name.text() == cmd.name)
@ -94,7 +92,7 @@ fn current_directory(
}
fn is_included(command: &LatexCommand, file: &Path) -> bool {
if let Some(allowed_extensions) = language_data()
if let Some(allowed_extensions) = LANGUAGE_DATA
.include_commands
.iter()
.find(|cmd| command.name.text() == cmd.name)

View file

@ -1,12 +1,9 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, ArgumentContext, Parameter};
use crate::data::label::LabelContext;
use crate::data::language::*;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::outline::Outline;
use crate::syntax::latex::{LatexLabel, LatexSyntaxTree};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
@ -19,7 +16,7 @@ impl FeatureProvider for LatexLabelCompletionProvider {
#[boxed]
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
let parameters = language_data()
let parameters = LANGUAGE_DATA
.label_commands
.iter()
.filter(|cmd| cmd.kind.is_reference())
@ -55,7 +52,7 @@ impl FeatureProvider for LatexLabelCompletionProvider {
impl LatexLabelCompletionProvider {
fn find_source(context: &ArgumentContext) -> LatexLabelReferenceSource {
match language_data()
match LANGUAGE_DATA
.label_commands
.iter()
.find(|cmd| cmd.name == context.parameter.name && cmd.index == context.parameter.index)

View file

@ -1,7 +1,7 @@
use crate::completion::factory::{self, LatexComponentId};
use crate::completion::latex::combinators;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, TextEdit};

View file

@ -1,6 +1,6 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::language::language_data;
use texlab_syntax::LANGUAGE_DATA;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, TextEdit};
@ -17,7 +17,7 @@ impl FeatureProvider for LatexPgfLibraryCompletionProvider {
let parameter = Parameter::new("\\usepgflibrary", 0);
combinators::argument(request, std::iter::once(parameter), async move |context| {
let mut items = Vec::new();
for name in &language_data().pgf_libraries {
for name in &LANGUAGE_DATA.pgf_libraries {
let text_edit = TextEdit::new(context.range, name.into());
let item = factory::pgf_library(request, name, text_edit);
items.push(item);
@ -40,7 +40,7 @@ impl FeatureProvider for LatexTikzLibraryCompletionProvider {
let parameter = Parameter::new("\\usetikzlibrary", 0);
combinators::argument(request, std::iter::once(parameter), async move |context| {
let mut items = Vec::new();
for name in &language_data().tikz_libraries {
for name in &LANGUAGE_DATA.tikz_libraries {
let text_edit = TextEdit::new(context.range, name.into());
let item = factory::tikz_library(request, name, text_edit);
items.push(item);

View file

@ -1,9 +1,7 @@
use crate::completion::factory::{self, LatexComponentId};
use crate::completion::latex::combinators;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::LatexEnvironmentDelimiter;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use itertools::Itertools;
use lsp_types::*;

View file

@ -1,6 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams};

View file

@ -1,8 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::bibtex::*;
use crate::syntax::latex::*;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::workspace::Document;
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, Position};

View file

@ -1,4 +1,4 @@
use crate::syntax::bibtex::BibtexSyntaxTree;
use texlab_syntax::*;
use futures::compat::*;
use lsp_types::*;
use std::process::{Command, Stdio};

View file

@ -1,4 +1,4 @@
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::workspace::Document;
use itertools::Itertools;
use lsp_types::{MarkupContent, MarkupKind};

View file

@ -1,7 +1,5 @@
use crate::outline::Outline;
use crate::syntax::latex::{LatexGroup, LatexToken};
use crate::syntax::text::{CharStream, SyntaxNode};
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::workspace::Document;
use lsp_types::*;

View file

@ -2,4 +2,3 @@ pub mod citation;
pub mod completion;
pub mod kernel_primitives;
pub mod label;
pub mod language;

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::{LatexCitation, LatexToken};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::workspace::Document;
use futures_boxed::boxed;
use lsp_types::{Location, TextDocumentPositionParams};

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::LatexNode;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{Location, TextDocumentPositionParams};

View file

@ -1,8 +1,5 @@
use crate::data::language::LatexLabelKind;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::*;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::workspace::Document;
use futures_boxed::boxed;
use lsp_types::{Location, TextDocumentPositionParams};

View file

@ -1,6 +1,4 @@
use crate::syntax::bibtex::{BibtexContent, BibtexSyntaxTree};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::workspace::Document;
use lsp_types::{Diagnostic, DiagnosticSeverity, Position, Range};

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::bibtex::BibtexDeclaration;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{FoldingRange, FoldingRangeKind, FoldingRangeParams};

View file

@ -1,6 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{FoldingRange, FoldingRangeKind, FoldingRangeParams};

View file

@ -1,6 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{FoldingRange, FoldingRangeKind, FoldingRangeParams};

View file

@ -1,5 +1,4 @@
use crate::syntax::bibtex::*;
use crate::syntax::text::SyntaxNode;
use texlab_syntax::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
@ -251,7 +250,6 @@ pub fn format_entry(entry: &BibtexEntry, params: &BibtexFormattingParams) -> Str
#[cfg(test)]
mod tests {
use super::*;
use crate::syntax::bibtex::BibtexSyntaxTree;
use indoc::indoc;
fn verify(source: &str, expected: &str, line_length: i32) {

View file

@ -1,8 +1,5 @@
use crate::data::language::LatexLabelKind;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::*;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{DocumentHighlight, DocumentHighlightKind, TextDocumentPositionParams};

View file

@ -1,7 +1,5 @@
use crate::data::language::language_data;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
@ -21,7 +19,7 @@ impl FeatureProvider for BibtexEntryTypeHoverProvider {
for entry in tree.entries() {
if entry.ty.range().contains(request.params.position) {
let ty = &entry.ty.text()[1..];
if let Some(documentation) = language_data().entry_type_documentation(ty) {
if let Some(documentation) = LANGUAGE_DATA.entry_type_documentation(ty) {
return Some(Hover {
contents: HoverContents::Markup(MarkupContent {
kind: MarkupKind::Markdown,
@ -59,7 +57,7 @@ mod tests {
Some(Hover {
contents: HoverContents::Markup(MarkupContent {
kind: MarkupKind::Markdown,
value: language_data()
value: LANGUAGE_DATA
.entry_type_documentation("article")
.unwrap()
.into(),

View file

@ -1,7 +1,5 @@
use crate::data::language::language_data;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::bibtex::*;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
@ -20,7 +18,7 @@ impl FeatureProvider for BibtexFieldHoverProvider {
if let SyntaxTree::Bibtex(tree) = &request.document().tree {
for node in tree.find(request.params.position) {
if let BibtexNode::Field(field) = node {
let documentation = language_data().field_documentation(field.name.text())?;
let documentation = LANGUAGE_DATA.field_documentation(field.name.text())?;
return Some(Hover {
contents: HoverContents::Markup(MarkupContent {
kind: MarkupKind::Markdown,
@ -57,7 +55,7 @@ mod tests {
Some(Hover {
contents: HoverContents::Markup(MarkupContent {
kind: MarkupKind::Markdown,
value: language_data()
value: LANGUAGE_DATA
.field_documentation("author")
.unwrap()
.into(),

View file

@ -2,10 +2,7 @@ use crate::data::citation::{render_citation, RenderCitationError};
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::formatting::bibtex;
use crate::formatting::bibtex::BibtexFormattingParams;
use crate::syntax::bibtex::BibtexEntry;
use crate::syntax::latex::{LatexCitation, LatexToken};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use log::warn;
use lsp_types::*;

View file

@ -1,8 +1,6 @@
use crate::data::completion::DATABASE;
use crate::data::language::LatexIncludeKind;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{Hover, HoverContents, TextDocumentPositionParams};

View file

@ -1,10 +1,7 @@
use crate::data::label::LabelContext;
use crate::data::language::LatexLabelKind;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::outline::Outline;
use crate::syntax::latex::LatexLabel;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{Hover, HoverContents, TextDocumentPositionParams};

View file

@ -1,9 +1,6 @@
use crate::data::completion::DATABASE;
use crate::data::language::LatexIncludeKind;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::*;
use crate::syntax::text::{CharStream, SyntaxNode};
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::tex;
use futures::compat::*;
use futures_boxed::boxed;

View file

@ -21,6 +21,5 @@ pub mod reference;
pub mod rename;
pub mod scenario;
pub mod server;
pub mod syntax;
pub mod tex;
pub mod workspace;

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::*;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{DocumentLink, DocumentLinkParams};

View file

@ -1,7 +1,5 @@
use crate::feature::DocumentView;
use crate::syntax::latex::{LatexInclude, LatexSection};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use crate::workspace::Document;
use lsp_types::{Position, Range, Uri};
use std::collections::HashSet;

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::{LatexCitation, LatexToken};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{Location, ReferenceParams};

View file

@ -1,8 +1,5 @@
use crate::data::language::LatexLabelKind;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::{LatexLabel, LatexToken};
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::{Location, ReferenceParams};

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::LatexCitation;
use crate::syntax::text::{Span, SyntaxNode};
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
use std::collections::HashMap;

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::LatexCommand;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
use std::collections::HashMap;

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::LatexEnvironment;
use crate::syntax::text::SyntaxNode;
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
use std::collections::HashMap;

View file

@ -1,7 +1,5 @@
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::syntax::latex::LatexLabel;
use crate::syntax::text::{Span, SyntaxNode};
use crate::syntax::SyntaxTree;
use texlab_syntax::*;
use futures_boxed::boxed;
use lsp_types::*;
use std::collections::HashMap;

View file

@ -16,9 +16,7 @@ use crate::link::LinkProvider;
use crate::reference::ReferenceProvider;
use crate::rename::{PrepareRenameProvider, RenameProvider};
use crate::request;
use crate::syntax::bibtex::BibtexDeclaration;
use crate::syntax::text::SyntaxNode;
use crate::syntax::{Language, SyntaxTree};
use texlab_syntax::*;
use crate::workspace::WorkspaceManager;
use futures::lock::Mutex;
use futures_boxed::boxed;

View file

@ -1,5 +1,4 @@
use crate::data::language::LatexIncludeKind;
use crate::syntax::{Language, SyntaxTree};
use texlab_syntax::*;
use log::*;
use lsp_types::{TextDocumentItem, Uri};
use std::ffi::OsStr;

View file

@ -2,7 +2,7 @@
use lsp_types::*;
use std::borrow::Cow;
use texlab::data::language::language_data;
use texlab_syntax::LANGUAGE_DATA;
use texlab::scenario::{Scenario, FULL_CAPABILITIES};
pub async fn run(
@ -33,7 +33,7 @@ async fn test_entry_type_known() {
contents,
HoverContents::Markup(MarkupContent {
kind: MarkupKind::Markdown,
value: Cow::from(language_data().entry_type_documentation("article").unwrap())
value: Cow::from(LANGUAGE_DATA.entry_type_documentation("article").unwrap())
})
);
}
@ -53,7 +53,7 @@ async fn test_field_known() {
contents,
HoverContents::Markup(MarkupContent {
kind: MarkupKind::Markdown,
value: Cow::from(language_data().field_documentation("author").unwrap())
value: Cow::from(LANGUAGE_DATA.field_documentation("author").unwrap())
})
)
}