Skip to content

Commit

Permalink
Move completion database to data module
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed May 19, 2019
1 parent a0cc325 commit e5e1644
Show file tree
Hide file tree
Showing 41 changed files with 41 additions and 136 deletions.
2 changes: 1 addition & 1 deletion src/completion/bibtex/entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl BibtexEntryTypeCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/bibtex/field_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl BibtexFieldNameCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/bibtex/kernel_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl BibtexKernelCommandCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/argument_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl LatexArgumentSymbolCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/citation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl LatexCitationCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const COLOR_NAMES: &'static [&'static str] = &[
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/color_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const MODEL_NAMES: &'static [&'static str] = &["gray", "rgb", "RGB", "HTML", "cm
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
91 changes: 0 additions & 91 deletions src/completion/latex/data/actor.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/completion/latex/data/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/completion/latex/kernel_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl LatexKernelCommandCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/kernel_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl LatexKernelEnvironmentCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
5 changes: 2 additions & 3 deletions src/completion/latex/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ impl LatexLabelCompletionProvider {
let mut items = Vec::new();
for document in &request.related_documents {
if let SyntaxTree::Latex(tree) = &document.tree {
tree
.labels
tree.labels
.iter()
.filter(|label| label.kind() == LatexLabelKind::Definition)
.map(|label| Cow::from(label.name().text().to_owned()))
Expand All @@ -36,7 +35,7 @@ impl LatexLabelCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
1 change: 0 additions & 1 deletion src/completion/latex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod color;
pub mod color_model;
mod combinators;
pub mod command_symbol;
pub mod data;
pub mod include;
pub mod kernel_command;
pub mod kernel_environment;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/pgf_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const LIBRARIES: &'static [&'static str] = &[
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/tikz_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const LIBRARIES: &'static [&'static str] = &[
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
5 changes: 2 additions & 3 deletions src/completion/latex/user_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ impl LatexUserCommandCompletionProvider {
let mut items = Vec::new();
for document in &request.related_documents {
if let SyntaxTree::Latex(tree) = &document.tree {
tree
.commands
tree.commands
.iter()
.filter(|command| command.range() != current_command.range())
.map(|command| &command.name.text()[1..])
Expand All @@ -42,7 +41,7 @@ impl LatexUserCommandCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod bibtex;
mod factory;
pub mod latex;
mod latex;
mod quality;

use self::bibtex::entry_type::BibtexEntryTypeCompletionProvider;
Expand Down
2 changes: 1 addition & 1 deletion src/data/bibtex_entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct BibtexEntryType {
pub documentation: Option<String>,
}

const JSON: &'static str = include_str!("bibtex_entry_type.json");
static JSON: &'static str = include_str!("bibtex_entry_type.json");

lazy_static! {
pub static ref BIBTEX_ENTRY_TYPES: Vec<BibtexEntryType> = serde_json::from_str(JSON).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/data/bibtex_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct BibtexField {
pub documentation: String,
}

const JSON: &'static str = include_str!("bibtex_field.json");
static JSON: &'static str = include_str!("bibtex_field.json");

lazy_static! {
pub static ref BIBTEX_FIELDS: Vec<BibtexField> = serde_json::from_str(JSON).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/completion/latex/data/types.rs → src/data/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::sync::Arc;

#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LatexComponent {
pub files: Vec<String>,
Expand All @@ -13,7 +13,7 @@ pub struct LatexComponent {
pub environments: Vec<String>,
}

#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)]
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LatexComponentDatabase {
pub components: Vec<Arc<LatexComponent>>,
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod bibtex_entry_type;
pub mod bibtex_field;
pub mod component_doc;
pub mod completion;
pub mod component;
pub mod symbols;
2 changes: 1 addition & 1 deletion src/data/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct LatexArgumentSymbol {
pub image: String,
}

const JSON: &'static str = include_str!("symbols.json");
static JSON: &'static str = include_str!("symbols.json");

lazy_static! {
pub static ref DATABASE: LatexSymbolDatabase = serde_json::from_str(JSON).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/definition/latex_citation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl LatexCitationDefinitionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::{Position, Range};
Expand Down
2 changes: 1 addition & 1 deletion src/definition/latex_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl LatexLabelDefinitionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::{Position, Range};
Expand Down
2 changes: 1 addition & 1 deletion src/feature.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
#[cfg(test)]
use crate::workspace::WorkspaceBuilder;
use crate::workspace::{Document, Workspace};
Expand Down
2 changes: 1 addition & 1 deletion src/folding/bibtex_declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl BibtexDeclarationFoldingProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/folding/latex_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl LatexEnvironmentFoldingProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/folding/latex_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl LatexSectionFoldingProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/highlight/latex_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl LatexLabelHighlightProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::{Position, Range};
Expand Down
2 changes: 1 addition & 1 deletion src/hover/bibtex_entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl BibtexEntryTypeHoverProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/hover/bibtex_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl BibtexFieldHoverProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand Down
2 changes: 1 addition & 1 deletion src/hover/latex_component.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::data::component_doc::ComponentDocumentation;
use crate::data::component::ComponentDocumentation;
use crate::feature::FeatureRequest;
use crate::syntax::latex::{LatexIncludeKind, LatexVisitor};
use crate::syntax::SyntaxTree;
Expand Down
2 changes: 1 addition & 1 deletion src/link/latex_include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl LatexIncludeLinkProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::completion::latex::data::types::LatexComponentDatabase;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::{Position, Range};
Expand Down
Loading

0 comments on commit e5e1644

Please sign in to comment.