From e3c18c7072eebabaa706008b7fa42c73ec2ff83e Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 13 Mar 2023 03:04:43 +0000 Subject: CTAN sync 202303130304 --- support/texlab/src/client.rs | 2 +- support/texlab/src/config.rs | 230 ++++++ support/texlab/src/db.rs | 3 +- support/texlab/src/db/analysis.rs | 62 +- support/texlab/src/db/context.rs | 18 + support/texlab/src/db/diagnostics.rs | 6 +- support/texlab/src/db/diagnostics/bib.rs | 4 +- support/texlab/src/db/diagnostics/log.rs | 4 +- support/texlab/src/db/diagnostics/tex.rs | 38 +- support/texlab/src/db/discovery.rs | 9 +- support/texlab/src/db/document.rs | 41 +- support/texlab/src/db/workspace.rs | 35 +- support/texlab/src/features/build.rs | 15 +- support/texlab/src/features/completion/builder.rs | 19 +- .../texlab/src/features/completion/user_command.rs | 2 +- support/texlab/src/features/definition.rs | 3 +- support/texlab/src/features/definition/command.rs | 2 +- support/texlab/src/features/definition/document.rs | 2 +- support/texlab/src/features/folding.rs | 2 +- support/texlab/src/features/formatting.rs | 18 +- .../src/features/formatting/bibtex_internal.rs | 15 +- .../texlab/src/features/formatting/latexindent.rs | 18 +- support/texlab/src/features/forward_search.rs | 34 +- support/texlab/src/features/highlight/label.rs | 2 +- support/texlab/src/features/hover.rs | 2 +- support/texlab/src/features/inlay_hint.rs | 2 +- support/texlab/src/features/inlay_hint/label.rs | 21 +- support/texlab/src/features/link.rs | 2 +- support/texlab/src/features/reference.rs | 1 - support/texlab/src/features/rename.rs | 4 +- support/texlab/src/features/rename/command.rs | 4 +- support/texlab/src/features/symbol.rs | 4 +- support/texlab/src/features/symbol/bibtex.rs | 2 +- support/texlab/src/features/symbol/latex.rs | 29 +- support/texlab/src/features/symbol/types.rs | 10 +- support/texlab/src/features/workspace_command.rs | 106 +-- .../workspace_command/change_environment.rs | 108 +++ .../texlab/src/features/workspace_command/clean.rs | 95 +++ .../src/features/workspace_command/dep_graph.rs | 57 ++ support/texlab/src/lib.rs | 25 +- support/texlab/src/options.rs | 144 ---- support/texlab/src/parser/latex.rs | 811 ++++++++------------- support/texlab/src/parser/latex/lexer.rs | 656 +---------------- support/texlab/src/parser/latex/lexer/commands.rs | 93 +++ support/texlab/src/parser/latex/lexer/types.rs | 132 ++++ ...er__latex__tests__parse@block_comments.txt.snap | 16 +- ..._tests__parse@caption__caption_default.txt.snap | 4 +- ...__parse@caption__caption_default_error.txt.snap | 5 +- ...__tests__parse@caption__caption_figure.txt.snap | 6 +- ..._tests__parse@caption__caption_minimal.txt.snap | 4 +- ...__parse@caption__caption_minimal_error.txt.snap | 5 +- ..._tests__parse@citation__citation_empty.txt.snap | 2 +- ...parse@citation__citation_missing_brace.txt.snap | 3 +- ...parse@citation__citation_multiple_keys.txt.snap | 2 +- ...ests__parse@citation__citation_prenote.txt.snap | 2 +- ...se@citation__citation_prenote_postnote.txt.snap | 2 +- ...rse@citation__citation_redundant_comma.txt.snap | 2 +- ...tests__parse@citation__citation_simple.txt.snap | 2 +- ...__tests__parse@citation__citation_star.txt.snap | 2 +- ...__parse@color__color_definition_simple.txt.snap | 2 +- ...s__parse@color__color_reference_simple.txt.snap | 2 +- ...rse@color__color_set_definition_error1.txt.snap | 3 +- ...rse@color__color_set_definition_error2.txt.snap | 4 +- ...rse@color__color_set_definition_error3.txt.snap | 5 +- ...rse@color__color_set_definition_error4.txt.snap | 6 +- ...rse@color__color_set_definition_simple.txt.snap | 2 +- ...definition__command_definition_no_argc.txt.snap | 4 +- ...definition__command_definition_no_impl.txt.snap | 5 +- ...tion__command_definition_no_impl_error.txt.snap | 6 +- ...efinition__command_definition_optional.txt.snap | 4 +- ..._definition__command_definition_simple.txt.snap | 5 +- ...inition__command_definition_with_begin.txt.snap | 6 +- ...mand_definition__math_operator_no_impl.txt.snap | 5 +- ...mmand_definition__math_operator_simple.txt.snap | 4 +- ...rse@environment__environment_asymptote.txt.snap | 27 +- ...se@environment__environment_definition.txt.snap | 6 +- ...t__environment_definition_optional_arg.txt.snap | 2 +- ..._parse@environment__environment_nested.txt.snap | 8 +- ...ent__environment_nested_missing_braces.txt.snap | 11 +- ..._parse@environment__environment_simple.txt.snap | 4 +- ...__parser__latex__tests__parse@equation.txt.snap | 4 +- ...x__tests__parse@equation_missing_begin.txt.snap | 6 +- ...tex__tests__parse@generic_command_args.txt.snap | 2 +- ...ex__tests__parse@generic_command_empty.txt.snap | 2 +- ...x__tests__parse@generic_command_escape.txt.snap | 2 +- ...s__parse@glossary__acronym_declaration.txt.snap | 2 +- ...e@glossary__acronym_definition_options.txt.snap | 2 +- ...se@glossary__acronym_definition_simple.txt.snap | 2 +- ...tests__parse@glossary__acronym_package.txt.snap | 2 +- ...se@glossary__acronym_reference_options.txt.snap | 2 +- ...rse@glossary__acronym_reference_simple.txt.snap | 2 +- ...sary__glossary_entry_definition_simple.txt.snap | 2 +- ...sary__glossary_entry_reference_options.txt.snap | 2 +- ...ssary__glossary_entry_reference_simple.txt.snap | 2 +- ...ser__latex__tests__parse@graphics_path.txt.snap | 4 +- ...ex__tests__parse@graphics_path_command.txt.snap | 6 +- ...ex__tests__parse@graphics_path_options.txt.snap | 4 +- ...__parse@group__curly_group_missing_end.txt.snap | 1 - ...sts__parse@group__equation_missing_end.txt.snap | 7 +- ...__tests__parse@group__escaped_brackets.txt.snap | 1 - ...__tests__parse@group__unmatched_braces.txt.snap | 1 - ...tests__parse@group__unmatched_brackets.txt.snap | 1 - ...e@group__unmatched_brackets_with_group.txt.snap | 1 - ...arse@include__biblatex_include_options.txt.snap | 2 +- ...parse@include__biblatex_include_simple.txt.snap | 2 +- ...__parse@include__bibtex_include_simple.txt.snap | 2 +- ...ts__parse@include__class_include_empty.txt.snap | 2 +- ...__parse@include__class_include_options.txt.snap | 2 +- ...s__parse@include__class_include_simple.txt.snap | 2 +- ...arse@include__graphics_include_command.txt.snap | 8 +- ...__graphics_include_complicated_options.txt.snap | 4 +- ...arse@include__graphics_include_options.txt.snap | 2 +- ...parse@include__graphics_include_simple.txt.snap | 2 +- ...ests__parse@include__import_incomplete.txt.snap | 4 +- ...x__tests__parse@include__import_simple.txt.snap | 2 +- ...arse@include__inkscape_include_options.txt.snap | 2 +- ...parse@include__inkscape_include_simple.txt.snap | 2 +- ...e@include__latex_include_equality_sign.txt.snap | 2 +- ...s__parse@include__latex_include_simple.txt.snap | 2 +- ...rse@include__latex_input_path_brackets.txt.snap | 2 +- ...__parse@include__package_include_empty.txt.snap | 2 +- ...arse@include__package_include_multiple.txt.snap | 2 +- ...parse@include__package_include_options.txt.snap | 2 +- ..._parse@include__package_include_simple.txt.snap | 2 +- ...rse@include__pgf_library_import_simple.txt.snap | 2 +- ...ts__parse@include__svg_include_options.txt.snap | 2 +- ...sts__parse@include__svg_include_simple.txt.snap | 2 +- ...se@include__tikz_library_import_simple.txt.snap | 2 +- ...parse@include__verbatim_include_simple.txt.snap | 2 +- ...ab__parser__latex__tests__parse@inline.txt.snap | 4 +- ...tex__tests__parse@inline_double_dollar.txt.snap | 4 +- ..._parser__latex__tests__parse@issue_745.txt.snap | 61 +- ..._parser__latex__tests__parse@issue_789.txt.snap | 4 +- ..._parser__latex__tests__parse@issue_853.txt.snap | 62 ++ ..._parser__latex__tests__parse@issue_857.txt.snap | 33 + ...rse@label__label_definition_line_break.txt.snap | 3 +- ...__parse@label__label_definition_simple.txt.snap | 2 +- ...atex__tests__parse@label__label_number.txt.snap | 3 +- ..._parse@label__label_reference_equation.txt.snap | 2 +- ...arse@label__label_reference_incomplete.txt.snap | 5 +- ..._parse@label__label_reference_multiple.txt.snap | 2 +- ...rse@label__label_reference_range_error.txt.snap | 3 +- ...abel__label_reference_range_incomplete.txt.snap | 3 +- ...se@label__label_reference_range_simple.txt.snap | 2 +- ...s__parse@label__label_reference_simple.txt.snap | 2 +- ...__parse@structure__structure_enum_item.txt.snap | 10 +- ...e@structure__structure_invalid_nesting.txt.snap | 4 +- ...sts__parse@structure__structure_nested.txt.snap | 14 +- ...s__parse@structure__structure_siblings.txt.snap | 4 +- ...em_definition__theorem_definition_full.txt.snap | 2 +- ...__theorem_definition_name_with_counter.txt.snap | 3 +- ...eorem_definition_name_with_description.txt.snap | 2 +- ...tion_name_with_description_and_counter.txt.snap | 2 +- ...finition__theorem_definition_only_name.txt.snap | 3 +- .../src/parser/test_data/latex/issue_853.txt | 8 + .../src/parser/test_data/latex/issue_857.txt | 3 + support/texlab/src/server.rs | 127 ++-- support/texlab/src/server/options.rs | 214 ++++++ support/texlab/src/syntax/latex/cst.rs | 4 +- support/texlab/src/syntax/latex/kind.rs | 97 +-- support/texlab/src/tests.rs | 5 - support/texlab/src/util/chktex.rs | 2 +- support/texlab/src/util/cursor.rs | 27 +- support/texlab/src/util/label.rs | 22 +- support/texlab/src/util/lang_data.rs | 2 - support/texlab/src/util/regex_filter.rs | 12 +- 166 files changed, 1957 insertions(+), 1997 deletions(-) create mode 100644 support/texlab/src/config.rs create mode 100644 support/texlab/src/db/context.rs create mode 100644 support/texlab/src/features/workspace_command/change_environment.rs create mode 100644 support/texlab/src/features/workspace_command/clean.rs create mode 100644 support/texlab/src/features/workspace_command/dep_graph.rs delete mode 100644 support/texlab/src/options.rs create mode 100644 support/texlab/src/parser/latex/lexer/commands.rs create mode 100644 support/texlab/src/parser/latex/lexer/types.rs create mode 100644 support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_853.txt.snap create mode 100644 support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_857.txt.snap create mode 100644 support/texlab/src/parser/test_data/latex/issue_853.txt create mode 100644 support/texlab/src/parser/test_data/latex/issue_857.txt create mode 100644 support/texlab/src/server/options.rs delete mode 100644 support/texlab/src/tests.rs (limited to 'support/texlab/src') diff --git a/support/texlab/src/client.rs b/support/texlab/src/client.rs index ab912653b0..0439445092 100644 --- a/support/texlab/src/client.rs +++ b/support/texlab/src/client.rs @@ -10,7 +10,7 @@ use lsp_server::{ErrorCode, Message, Request, RequestId, Response}; use lsp_types::{notification::ShowMessage, MessageType, ShowMessageParams}; use serde::{de::DeserializeOwned, Serialize}; -use crate::Options; +use crate::server::options::Options; #[derive(Debug)] struct RawClient { diff --git a/support/texlab/src/config.rs b/support/texlab/src/config.rs new file mode 100644 index 0000000000..33cbacd3be --- /dev/null +++ b/support/texlab/src/config.rs @@ -0,0 +1,230 @@ +use std::time::Duration; + +use regex::Regex; +use rustc_hash::FxHashSet; + +#[derive(Debug)] +pub struct Config { + pub root_dir: Option, + pub build: BuildConfig, + pub diagnostics: DiagnosticsConfig, + pub formatting: FormattingConfig, + pub synctex: Option, + pub symbols: SymbolConfig, + pub syntax: SyntaxConfig, +} + +#[derive(Debug)] +pub struct BuildConfig { + pub program: String, + pub args: Vec, + pub on_save: bool, + pub forward_search_after: bool, + pub output_dir: String, +} + +#[derive(Debug)] +pub struct DiagnosticsConfig { + pub allowed_patterns: Vec, + pub ignored_patterns: Vec, + pub chktex: ChktexConfig, + pub delay: Duration, +} + +#[derive(Debug)] +pub struct ChktexConfig { + pub on_open: bool, + pub on_save: bool, + pub on_edit: bool, +} + +#[derive(Debug)] +pub struct SynctexConfig { + pub program: String, + pub args: Vec, +} + +#[derive(Debug)] +pub struct FormattingConfig { + pub tex_formatter: Formatter, + pub bib_formatter: Formatter, + pub latex_indent: LatexIndentConfig, + pub line_length: usize, +} + +#[derive(Debug)] +pub enum Formatter { + Null, + Server, + LatexIndent, +} + +#[derive(Debug)] +pub struct LatexIndentConfig { + pub local: Option, + pub modify_line_breaks: bool, +} + +#[derive(Debug)] +pub struct SymbolConfig { + pub allowed_patterns: Vec, + pub ignored_patterns: Vec, +} + +#[derive(Debug)] +pub struct SyntaxConfig { + pub math_environments: FxHashSet, + pub enum_environments: FxHashSet, + pub verbatim_environments: FxHashSet, +} + +impl Default for Config { + fn default() -> Self { + Self { + root_dir: None, + build: BuildConfig::default(), + diagnostics: DiagnosticsConfig::default(), + formatting: FormattingConfig::default(), + synctex: None, + symbols: SymbolConfig::default(), + syntax: SyntaxConfig::default(), + } + } +} + +impl Default for BuildConfig { + fn default() -> Self { + Self { + program: String::from("latexmk"), + args: ["-pdf", "-interaction=nonstopmode", "-synctex=1", "%f"] + .into_iter() + .map(String::from) + .collect(), + on_save: false, + forward_search_after: false, + output_dir: String::from("."), + } + } +} + +impl Default for DiagnosticsConfig { + fn default() -> Self { + Self { + allowed_patterns: Vec::new(), + ignored_patterns: Vec::new(), + delay: Duration::from_millis(300), + chktex: ChktexConfig::default(), + } + } +} + +impl Default for ChktexConfig { + fn default() -> Self { + Self { + on_open: false, + on_save: false, + on_edit: false, + } + } +} + +impl Default for FormattingConfig { + fn default() -> Self { + Self { + tex_formatter: Formatter::LatexIndent, + bib_formatter: Formatter::Server, + line_length: 80, + latex_indent: LatexIndentConfig::default(), + } + } +} + +impl Default for LatexIndentConfig { + fn default() -> Self { + Self { + local: None, + modify_line_breaks: false, + } + } +} + +impl Default for SymbolConfig { + fn default() -> Self { + Self { + allowed_patterns: Vec::new(), + ignored_patterns: Vec::new(), + } + } +} + +impl Default for SyntaxConfig { + fn default() -> Self { + let math_environments = [ + "align", + "align*", + "alignat", + "alignat*", + "aligned", + "aligned*", + "alignedat", + "alignedat*", + "array", + "array*", + "Bmatrix", + "Bmatrix*", + "bmatrix", + "bmatrix*", + "cases", + "cases*", + "CD", + "CD*", + "eqnarray", + "eqnarray*", + "equation", + "equation*", + "IEEEeqnarray", + "IEEEeqnarray*", + "subequations", + "subequations*", + "gather", + "gather*", + "gathered", + "gathered*", + "matrix", + "matrix*", + "multline", + "multline*", + "pmatrix", + "pmatrix*", + "smallmatrix", + "smallmatrix*", + "split", + "split*", + "subarray", + "subarray*", + "Vmatrix", + "Vmatrix*", + "vmatrix", + "vmatrix*", + ] + .into_iter() + .map(String::from) + .collect(); + + let enum_environments = ["enumerate", "itemize", "description"] + .into_iter() + .map(String::from) + .collect(); + + let verbatim_environments = ["pycode", "minted", "asy", "lstlisting", "verbatim"] + .into_iter() + .map(String::from) + .collect(); + + Self { + math_environments, + enum_environments, + verbatim_environments, + } + } +} diff --git a/support/texlab/src/db.rs b/support/texlab/src/db.rs index 64165b76c2..521655ce80 100644 --- a/support/texlab/src/db.rs +++ b/support/texlab/src/db.rs @@ -1,11 +1,12 @@ pub mod analysis; +mod context; pub mod diagnostics; mod discovery; mod document; pub mod parse; mod workspace; -pub use {discovery::*, document::*, workspace::*}; +pub use {context::*, discovery::*, document::*, workspace::*}; #[salsa::interned] pub struct Word { diff --git a/support/texlab/src/db/analysis.rs b/support/texlab/src/db/analysis.rs index 13b5bb1cb3..1f1bd508a8 100644 --- a/support/texlab/src/db/analysis.rs +++ b/support/texlab/src/db/analysis.rs @@ -1,6 +1,6 @@ pub mod label; -use rowan::{ast::AstNode, TextRange}; +use rowan::{ast::AstNode, NodeOrToken, TextRange}; use crate::{ syntax::latex::{self, HasCurly}, @@ -169,30 +169,42 @@ impl TexAnalysis { let mut command_name_ranges = Vec::new(); let mut environment_names = Vec::new(); - for node in root.descendants() { - TexLink::of_include(db, node.clone(), &mut links) - .or_else(|| TexLink::of_import(db, node.clone(), &mut links)) - .or_else(|| label::Name::of_definition(db, node.clone(), &mut labels)) - .or_else(|| label::Name::of_reference(db, node.clone(), &mut labels)) - .or_else(|| label::Name::of_reference_range(db, node.clone(), &mut labels)) - .or_else(|| label::Number::of_number(db, node.clone(), &mut label_numbers)) - .or_else(|| { - TheoremEnvironment::of_definition(db, node.clone(), &mut theorem_environments) - }) - .or_else(|| GraphicsPath::of_command(db, node.clone(), &mut graphics_paths)) - .or_else(|| { - let range = latex::GenericCommand::cast(node.clone())? - .name()? - .text_range(); - - command_name_ranges.push(range); - Some(()) - }) - .or_else(|| { - let begin = latex::Begin::cast(node.clone())?; - environment_names.push(begin.name()?.key()?.to_string()); - Some(()) - }); + for element in root.descendants_with_tokens() { + match element { + NodeOrToken::Token(token) if token.kind() == latex::COMMAND_NAME => { + command_name_ranges.push(token.text_range()); + } + NodeOrToken::Token(_) => {} + NodeOrToken::Node(node) => { + TexLink::of_include(db, node.clone(), &mut links) + .or_else(|| TexLink::of_import(db, node.clone(), &mut links)) + .or_else(|| label::Name::of_definition(db, node.clone(), &mut labels)) + .or_else(|| label::Name::of_reference(db, node.clone(), &mut labels)) + .or_else(|| label::Name::of_reference_range(db, node.clone(), &mut labels)) + .or_else(|| label::Number::of_number(db, node.clone(), &mut label_numbers)) + .or_else(|| { + TheoremEnvironment::of_definition( + db, + node.clone(), + &mut theorem_environments, + ) + }) + .or_else(|| GraphicsPath::of_command(db, node.clone(), &mut graphics_paths)) + .or_else(|| { + let range = latex::GenericCommand::cast(node.clone())? + .name()? + .text_range(); + + command_name_ranges.push(range); + Some(()) + }) + .or_else(|| { + let begin = latex::Begin::cast(node.clone())?; + environment_names.push(begin.name()?.key()?.to_string()); + Some(()) + }); + } + }; } Self::new( diff --git a/support/texlab/src/db/context.rs b/support/texlab/src/db/context.rs new file mode 100644 index 0000000000..c6277eb099 --- /dev/null +++ b/support/texlab/src/db/context.rs @@ -0,0 +1,18 @@ +use crate::Config; + +/// Contains the global context of the server throughout the application. +#[salsa::input(singleton)] +pub struct ServerContext { + /// The server configuration which is extracted from either + /// the `workspace/configuration` or `workspace/didChangeConfiguration` messages. + #[return_ref] + pub config: Config, + + /// Disable usage of `isIncomplete = false` in completion lists. + /// + /// Due to the large number of completion results, + /// the server can only send a subset of the items most of the time. + /// When the filtered list is small enough, `CompletionList.isIncomplete` can be set to `false`. + /// On VSCode, this optimization should not be done so this flag is needed. + pub always_incomplete_completion_list: bool, +} diff --git a/support/texlab/src/db/diagnostics.rs b/support/texlab/src/db/diagnostics.rs index 8abb856768..6b1a177133 100644 --- a/support/texlab/src/db/diagnostics.rs +++ b/support/texlab/src/db/diagnostics.rs @@ -131,7 +131,7 @@ pub fn collect_filtered( let all_diagnostics = collect(db, workspace); let mut all_filtered: FxHashMap> = FxHashMap::default(); - let options = &workspace.options(db).diagnostics; + let config = &db.config().diagnostics; for document in workspace.documents(db) { let mut filtered = Vec::new(); if !matches!(document.language(db), Language::Tex | Language::Bib) { @@ -142,8 +142,8 @@ pub fn collect_filtered( for diagnostic in diagnostics.iter().filter(|diag| { util::regex_filter::filter( &diag.message, - &options.allowed_patterns, - &options.ignored_patterns, + &config.allowed_patterns, + &config.ignored_patterns, ) }) { let source = match diagnostic.code { diff --git a/support/texlab/src/db/diagnostics/bib.rs b/support/texlab/src/db/diagnostics/bib.rs index 6d0f66e960..4f5dfc55a1 100644 --- a/support/texlab/src/db/diagnostics/bib.rs +++ b/support/texlab/src/db/diagnostics/bib.rs @@ -32,7 +32,7 @@ fn analyze_entry( node: bibtex::SyntaxNode, results: &mut Vec, ) -> Option<()> { - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let entry = bibtex::Entry::cast(node)?; if entry.left_delim_token().is_none() { @@ -81,7 +81,7 @@ fn analyze_field( node: bibtex::SyntaxNode, results: &mut Vec, ) -> Option<()> { - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let field = bibtex::Field::cast(node)?; if field.eq_token().is_none() { diff --git a/support/texlab/src/db/diagnostics/log.rs b/support/texlab/src/db/diagnostics/log.rs index 436999259b..368fd3fdcc 100644 --- a/support/texlab/src/db/diagnostics/log.rs +++ b/support/texlab/src/db/diagnostics/log.rs @@ -81,10 +81,10 @@ fn find_range_of_hint( error: &BuildError, ) -> Option { let document = workspace.lookup_uri(db, uri)?; - let text = document.contents(db).text(db); + let text = document.text(db); let line = error.line? as usize; let hint = error.hint.as_deref()?; - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let line_start = line_index.newlines.get(line).copied()?; let line_end = line_index diff --git a/support/texlab/src/db/diagnostics/tex.rs b/support/texlab/src/db/diagnostics/tex.rs index 50233f8bd6..a7b030a5bf 100644 --- a/support/texlab/src/db/diagnostics/tex.rs +++ b/support/texlab/src/db/diagnostics/tex.rs @@ -5,7 +5,7 @@ use crate::{db::document::Document, syntax::latex, util::line_index_ext::LineInd use super::{Diagnostic, DiagnosticCode, TexCode}; -#[salsa::tracked(return_ref)] +#[salsa::tracked] pub fn collect(db: &dyn Db, document: Document) -> Vec { let mut results = Vec::new(); @@ -18,10 +18,35 @@ pub fn collect(db: &dyn Db, document: Document) -> Vec { None => return results, }; - for node in data.root(db).descendants() { - analyze_environment(db, document, node.clone(), &mut results) - .or_else(|| analyze_curly_group(db, document, node.clone(), &mut results)) - .or_else(|| analyze_curly_braces(document, db, node, &mut results)); + let mut traversal = data.root(db).preorder(); + while let Some(event) = traversal.next() { + match event { + rowan::WalkEvent::Enter(node) => { + if let Some(environment) = latex::Environment::cast(node.clone()) { + if environment + .begin() + .and_then(|begin| begin.name()) + .and_then(|name| name.key()) + .map_or(false, |name| { + db.config() + .syntax + .verbatim_environments + .contains(&name.to_string()) + }) + { + traversal.skip_subtree(); + continue; + } + } + + analyze_environment(db, document, node.clone(), &mut results) + .or_else(|| analyze_curly_group(db, document, node.clone(), &mut results)) + .or_else(|| analyze_curly_braces(document, db, node, &mut results)); + } + rowan::WalkEvent::Leave(_) => { + continue; + } + }; } results @@ -41,7 +66,6 @@ fn analyze_environment( results.push(Diagnostic { severity: DiagnosticSeverity::ERROR, range: document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&name1)), code: DiagnosticCode::Tex(code), @@ -89,7 +113,6 @@ fn analyze_curly_group( results.push(Diagnostic { severity: DiagnosticSeverity::ERROR, range: document - .contents(db) .line_index(db) .line_col_lsp_range(TextRange::empty(node.text_range().end())), code: DiagnosticCode::Tex(code), @@ -111,7 +134,6 @@ fn analyze_curly_braces( results.push(Diagnostic { severity: DiagnosticSeverity::ERROR, range: document - .contents(db) .line_index(db) .line_col_lsp_range(node.text_range()), code: DiagnosticCode::Tex(code), diff --git a/support/texlab/src/db/discovery.rs b/support/texlab/src/db/discovery.rs index 12338f745e..9cc5a4e807 100644 --- a/support/texlab/src/db/discovery.rs +++ b/support/texlab/src/db/discovery.rs @@ -40,8 +40,11 @@ pub fn hidden_dependencies( base_dir: Location, dependencies: &mut Vec, ) { - dependencies.extend(hidden_dependency(db, document, base_dir, "log")); - dependencies.extend(hidden_dependency(db, document, base_dir, "aux")); + let uri = document.location(db).uri(db).as_str(); + if document.language(db) == Language::Tex && !uri.ends_with(".aux") { + dependencies.extend(hidden_dependency(db, document, base_dir, "log")); + dependencies.extend(hidden_dependency(db, document, base_dir, "aux")); + } } #[salsa::tracked] @@ -158,7 +161,7 @@ impl DependencyGraph { } } -#[salsa::tracked] +#[salsa::tracked(return_ref)] pub fn dependency_graph(db: &dyn Db, start: Document) -> DependencyGraph { let workspace = Workspace::get(db); diff --git a/support/texlab/src/db/document.rs b/support/texlab/src/db/document.rs index 81ed22e916..40d0ab025f 100644 --- a/support/texlab/src/db/document.rs +++ b/support/texlab/src/db/document.rs @@ -48,20 +48,6 @@ impl Location { } } -#[salsa::input] -pub struct Contents { - #[return_ref] - pub text: String, -} - -#[salsa::tracked] -impl Contents { - #[salsa::tracked(return_ref)] - pub fn line_index(self, db: &dyn Db) -> LineIndex { - LineIndex::new(self.text(db)) - } -} - #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] pub enum Owner { Client, @@ -115,19 +101,31 @@ pub struct LinterData { #[salsa::input] pub struct Document { + /// An object containing the URI of the document. pub location: Location, - pub contents: Contents, + + /// The source code. + #[return_ref] + pub text: String, + + /// The programming language. pub language: Language, + + /// The program (either server or client) which opened the document. pub owner: Owner, + + /// An estimate of the current cursor position. pub cursor: TextSize, + + /// The diagnostics reported from external linters such as ChkTeX. pub linter: LinterData, } impl Document { pub fn edit(self, db: &mut dyn Db, range: TextRange, replace_with: &str) { - let mut text = self.contents(db).set_text(db).to(String::new()); + let mut text = self.set_text(db).to(String::new()); text.replace_range(std::ops::Range::::from(range), replace_with); - self.contents(db).set_text(db).to(text); + self.set_text(db).to(text); self.set_cursor(db).to(range.start()); } @@ -149,7 +147,7 @@ impl Document { impl Document { #[salsa::tracked] pub fn parse(self, db: &dyn Db) -> DocumentData { - let text = self.contents(db).text(db); + let text = self.text(db); match self.language(db) { Language::Tex => { let data = TexDocumentData::new(db, parse_latex(text)); @@ -179,7 +177,7 @@ impl Document { self.parse(db).as_tex().map_or(false, |data| { let analysis = data.analyze(db); analysis.has_document_environment(db) - || !analysis + && !analysis .links(db) .iter() .filter(|link| link.kind(db) == TexLinkKind::Cls) @@ -193,4 +191,9 @@ impl Document { .as_tex() .map_or(false, |data| data.analyze(db).has_document_environment(db)) } + + #[salsa::tracked(return_ref)] + pub fn line_index(self, db: &dyn Db) -> LineIndex { + LineIndex::new(self.text(db)) + } } diff --git a/support/texlab/src/db/workspace.rs b/support/texlab/src/db/workspace.rs index 123d415fd9..67c99792a2 100644 --- a/support/texlab/src/db/workspace.rs +++ b/support/texlab/src/db/workspace.rs @@ -4,19 +4,19 @@ use std::{ }; use itertools::Itertools; -use lsp_types::{ClientCapabilities, ClientInfo, Url}; +use lsp_types::{ClientCapabilities, Url}; use rowan::TextSize; use rustc_hash::FxHashSet; use crate::{ db::document::{Document, Location}, distro::FileNameDB, - Db, Options, + Db, }; use super::{ dependency_graph, - document::{Contents, Language, LinterData, Owner}, + document::{Language, LinterData, Owner}, Word, }; @@ -25,15 +25,9 @@ pub struct Workspace { #[return_ref] pub documents: FxHashSet, - #[return_ref] - pub options: Options, - #[return_ref] pub client_capabilities: ClientCapabilities, - #[return_ref] - pub client_info: Option, - #[return_ref] pub root_dirs: Vec, @@ -79,11 +73,10 @@ impl Workspace { owner: Owner, ) -> Document { let location = Location::new(db, uri); - let contents = Contents::new(db, text); let cursor = TextSize::from(0); match self.lookup(db, location) { Some(document) => { - document.set_contents(db).to(contents); + document.set_text(db).to(text); document.set_language(db).to(language); document.set_owner(db).to(owner); document.set_cursor(db).to(cursor); @@ -93,7 +86,7 @@ impl Workspace { let document = Document::new( db, location, - contents, + text, language, owner, cursor, @@ -157,11 +150,10 @@ impl Workspace { impl Workspace { #[salsa::tracked] pub fn working_dir(self, db: &dyn Db, base_dir: Location) -> Location { - if let Some(dir) = self - .options(db) - .root_directory - .as_deref() - .and_then(|path| path.to_str()) + if let Some(dir) = db + .config() + .root_dir + .as_ref() .and_then(|path| base_dir.join(db, path)) { return dir; @@ -182,14 +174,7 @@ impl Workspace { #[salsa::tracked] pub fn output_dir(self, db: &dyn Db, base_dir: Location) -> Location { - let mut path = self - .options(db) - .aux_directory - .as_deref() - .and_then(|path| path.to_str()) - .unwrap_or(".") - .to_string(); - + let mut path = db.config().build.output_dir.clone(); if !path.ends_with('/') { path.push('/'); } diff --git a/support/texlab/src/features/build.rs b/support/texlab/src/features/build.rs index 69c3a7825c..83a1d4cb32 100644 --- a/support/texlab/src/features/build.rs +++ b/support/texlab/src/features/build.rs @@ -39,7 +39,7 @@ pub enum BuildStatus { pub struct Command { uri: Url, progress: bool, - executable: String, + program: String, args: Vec, working_dir: PathBuf, client: LspClient, @@ -63,12 +63,11 @@ impl Command { return None; } - let options = &workspace.options(db).build; - let executable = options.executable.0.clone(); + let config = &db.config().build; + let program = config.program.clone(); let path = document.location(db).path(db).as_deref().unwrap(); - let args = options + let args = config .args - .0 .iter() .map(|arg| replace_placeholder(arg, path)) .collect(); @@ -83,7 +82,7 @@ impl Command { progress: workspace .client_capabilities(db) .has_work_done_progress_support(), - executable, + program, args, working_dir, client, @@ -99,7 +98,7 @@ impl Command { None }; - let mut process = match std::process::Command::new(&self.executable) + let mut process = match std::process::Command::new(&self.program) .args(self.args) .stdin(Stdio::null()) .stdout(Stdio::piped()) @@ -111,7 +110,7 @@ impl Command { Err(why) => { log::error!( "Failed to spawn process {:?} in directory {}: {}", - self.executable, + self.program, self.working_dir.display(), why ); diff --git a/support/texlab/src/features/completion/builder.rs b/support/texlab/src/features/completion/builder.rs index 686d39b62b..0373587a06 100644 --- a/support/texlab/src/features/completion/builder.rs +++ b/support/texlab/src/features/completion/builder.rs @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize}; use smol_str::SmolStr; use crate::{ - db::{Document, Workspace}, + db::{Document, ServerContext, Workspace}, syntax::{ bibtex::{self, HasName, HasType}, latex, @@ -44,7 +44,7 @@ impl<'db> CompletionBuilder<'db> { let items = Vec::new(); let matcher = SkimMatcherV2::default().ignore_case(); let text_pattern = match &context.cursor { - Cursor::Tex(token) if token.kind().is_command_name() => { + Cursor::Tex(token) if token.kind() == latex::COMMAND_NAME => { if token.text_range().start() + TextSize::from(1) == context.offset { // Handle cases similar to this one correctly: // $\|$ % (| is the cursor) @@ -426,18 +426,9 @@ impl<'db> CompletionBuilder<'db> { .map(|(i, item)| self.convert_item(item, i)) .collect(); - list.is_incomplete = if self - .context - .workspace - .client_info(self.context.db) - .as_ref() - .map_or(false, |client| client.name.as_str() == "Visual Studio Code") - { - true - } else { - list.items.len() >= COMPLETION_LIMIT - }; - + let db = self.context.db; + let always_incomplete = ServerContext::get(db).always_incomplete_completion_list(db); + list.is_incomplete = always_incomplete || list.items.len() >= COMPLETION_LIMIT; list } diff --git a/support/texlab/src/features/completion/user_command.rs b/support/texlab/src/features/completion/user_command.rs index 99d9883ee9..14c2222701 100644 --- a/support/texlab/src/features/completion/user_command.rs +++ b/support/texlab/src/features/completion/user_command.rs @@ -12,7 +12,7 @@ pub fn complete<'db>( let db = context.db; for document in context.related() { if let Some(data) = document.parse(db).as_tex() { - let text = document.contents(db).text(db); + let text = document.text(db); for name in data .analyze(db) .command_name_ranges(db) diff --git a/support/texlab/src/features/definition.rs b/support/texlab/src/features/definition.rs index 7c9e6d4841..5843882bd0 100644 --- a/support/texlab/src/features/definition.rs +++ b/support/texlab/src/features/definition.rs @@ -31,12 +31,11 @@ pub fn goto_definition( let origin_selection_range = Some( context .document - .contents(db) .line_index(db) .line_col_lsp_range(result.origin_selection_range), ); - let target_line_index = result.target.contents(db).line_index(db); + let target_line_index = result.target.line_index(db); let target_uri = result.target.location(context.db).uri(context.db).clone(); let target_range = target_line_index.line_col_lsp_range(result.target_range); diff --git a/support/texlab/src/features/definition/command.rs b/support/texlab/src/features/definition/command.rs index cf9fe1b511..743a0f6d3c 100644 --- a/support/texlab/src/features/definition/command.rs +++ b/support/texlab/src/features/definition/command.rs @@ -8,7 +8,7 @@ pub(super) fn goto_definition(context: &CursorContext) -> Option Option Option> { let document = Workspace::get(db).lookup_uri(db, uri)?; - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let foldings = match document.parse(db) { DocumentData::Tex(data) => { let mut results = Vec::new(); diff --git a/support/texlab/src/features/formatting.rs b/support/texlab/src/features/formatting.rs index 5d7d1c0c1f..4a98df3f88 100644 --- a/support/texlab/src/features/formatting.rs +++ b/support/texlab/src/features/formatting.rs @@ -5,7 +5,7 @@ use lsp_types::{FormattingOptions, TextEdit, Url}; use crate::{ db::{Language, Workspace}, - BibtexFormatter, Db, LatexFormatter, + Db, Formatter, }; use self::{bibtex_internal::format_bibtex_internal, latexindent::format_with_latexindent}; @@ -18,15 +18,15 @@ pub fn format_source_code( let workspace = Workspace::get(db); let document = workspace.lookup_uri(db, uri)?; match document.language(db) { - Language::Tex => match workspace.options(db).latex_formatter { - LatexFormatter::None => None, - LatexFormatter::Texlab => None, - LatexFormatter::Latexindent => format_with_latexindent(db, document), + Language::Tex => match db.config().formatting.tex_formatter { + Formatter::Null => None, + Formatter::Server => None, + Formatter::LatexIndent => format_with_latexindent(db, document), }, - Language::Bib => match workspace.options(db).bibtex_formatter { - BibtexFormatter::None => None, - BibtexFormatter::Texlab => format_bibtex_internal(db, document, options), - BibtexFormatter::Latexindent => format_with_latexindent(db, document), + Language::Bib => match db.config().formatting.bib_formatter { + Formatter::Null => None, + Formatter::Server => format_bibtex_internal(db, document, options), + Formatter::LatexIndent => format_with_latexindent(db, document), }, Language::Log | Language::TexlabRoot | Language::Tectonic => None, } diff --git a/support/texlab/src/features/formatting/bibtex_internal.rs b/support/texlab/src/features/formatting/bibtex_internal.rs index 8447778d90..5026c512f2 100644 --- a/support/texlab/src/features/formatting/bibtex_internal.rs +++ b/support/texlab/src/features/formatting/bibtex_internal.rs @@ -2,7 +2,7 @@ use lsp_types::{FormattingOptions, TextEdit}; use rowan::{ast::AstNode, NodeOrToken}; use crate::{ - db::{Document, Workspace}, + db::Document, syntax::bibtex::{self, HasName, HasType, HasValue}, util::{line_index::LineIndex, line_index_ext::LineIndexExt}, Db, @@ -23,18 +23,9 @@ pub fn format_bibtex_internal( indent.push('\t'); } - let line_length = Workspace::get(db) - .options(db) - .formatter_line_length - .map_or(80, |value| { - if value <= 0 { - usize::MAX - } else { - value as usize - } - }); + let line_length = db.config().formatting.line_length; - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let data = document.parse(db).as_bib()?; let mut edits = Vec::new(); diff --git a/support/texlab/src/features/formatting/latexindent.rs b/support/texlab/src/features/formatting/latexindent.rs index 3dab10c923..087b8f0941 100644 --- a/support/texlab/src/features/formatting/latexindent.rs +++ b/support/texlab/src/features/formatting/latexindent.rs @@ -10,12 +10,12 @@ use tempfile::tempdir; use crate::{ db::{Document, Language, Workspace}, util::line_index_ext::LineIndexExt, - Db, LatexindentOptions, + Db, LatexIndentConfig, }; pub fn format_with_latexindent(db: &dyn Db, document: Document) -> Option> { let workspace = Workspace::get(db); - let options = workspace.options(db); + let config = db.config(); let target_dir = tempdir().ok()?; let source_dir = workspace .working_dir(db, document.directory(db)) @@ -29,9 +29,9 @@ pub fn format_with_latexindent(db: &dyn Db, document: Document) -> Option Option Option Vec { +fn build_arguments(config: &LatexIndentConfig, target_file: &Path) -> Vec { let mut args = Vec::new(); - args.push(match &options.local { + args.push(match &config.local { Some(yaml_file) => format!("--local={yaml_file}"), None => "--local".to_string(), }); - if options.modify_line_breaks { + if config.modify_line_breaks { args.push("--modifylinebreaks".to_string()); } diff --git a/support/texlab/src/features/forward_search.rs b/support/texlab/src/features/forward_search.rs index 8e5a2cc59c..350fdd02b9 100644 --- a/support/texlab/src/features/forward_search.rs +++ b/support/texlab/src/features/forward_search.rs @@ -32,7 +32,7 @@ pub enum Error { } pub struct Command { - executable: String, + program: String, args: Vec, } @@ -76,42 +76,30 @@ impl Command { return Err(Error::PdfNotFound(pdf_path)); } - let position = position.unwrap_or_else(|| { - child - .contents(db) - .line_index(db) - .line_col_lsp(child.cursor(db)) - }); + let position = + position.unwrap_or_else(|| child.line_index(db).line_col_lsp(child.cursor(db))); - let options = &workspace.options(db).forward_search; + let Some(config) = &db.config().synctex else { + return Err(Error::Unconfigured); + }; - let executable = options - .executable - .as_deref() - .ok_or(Error::Unconfigured)? - .to_string(); + let program = config.program.clone(); - let args: Vec<_> = options + let args: Vec<_> = config .args - .as_deref() - .ok_or(Error::Unconfigured)? .iter() .flat_map(|arg| replace_placeholder(tex_path, &pdf_path, position.line, arg)) .collect(); - Ok(Self { executable, args }) + Ok(Self { program, args }) } } impl Command { pub fn run(self) -> Result<(), Error> { - log::debug!( - "Executing forward search: {} {:?}", - self.executable, - self.args - ); + log::debug!("Executing forward search: {} {:?}", self.program, self.args); - std::process::Command::new(self.executable) + std::process::Command::new(self.program) .args(self.args) .stdin(Stdio::null()) .stdout(Stdio::null()) diff --git a/support/texlab/src/features/highlight/label.rs b/support/texlab/src/features/highlight/label.rs index 2ae66d5c47..e362295b04 100644 --- a/support/texlab/src/features/highlight/label.rs +++ b/support/texlab/src/features/highlight/label.rs @@ -11,7 +11,7 @@ pub fn find_highlights(context: &CursorContext) -> Option let data = context.document.parse(db).as_tex()?; let mut highlights = Vec::new(); - let line_index = context.document.contents(db).line_index(db); + let line_index = context.document.line_index(db); for label in data .analyze(db) .labels(db) diff --git a/support/texlab/src/features/hover.rs b/support/texlab/src/features/hover.rs index 27d07f74cd..6baeab8ad6 100644 --- a/support/texlab/src/features/hover.rs +++ b/support/texlab/src/features/hover.rs @@ -24,7 +24,7 @@ pub fn find(db: &dyn Db, uri: &Url, position: Position) -> Option { .or_else(|| field::find_hover(&context)) .or_else(|| entry_type::find_hover(&context))?; - let line_index = context.document.contents(db).line_index(db); + let line_index = context.document.line_index(db); Some(Hover { contents: HoverContents::Markup(MarkupContent { kind: result.value_kind, diff --git a/support/texlab/src/features/inlay_hint.rs b/support/texlab/src/features/inlay_hint.rs index 6d53259900..5d2f5d4e11 100644 --- a/support/texlab/src/features/inlay_hint.rs +++ b/support/texlab/src/features/inlay_hint.rs @@ -11,7 +11,7 @@ use crate::{ pub fn find_all(db: &dyn Db, uri: &Url, range: Range) -> Option> { let document = Workspace::get(db).lookup_uri(db, uri)?; - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let mut builder = InlayHintBuilder { line_index, diff --git a/support/texlab/src/features/inlay_hint/label.rs b/support/texlab/src/features/inlay_hint/label.rs index 5654f79bf4..ca52433e7b 100644 --- a/support/texlab/src/features/inlay_hint/label.rs +++ b/support/texlab/src/features/inlay_hint/label.rs @@ -2,7 +2,8 @@ use rowan::TextRange; use crate::{ db::{analysis::label, Document}, - util, Db, + util::{self, label::LabeledObject}, + Db, }; use super::InlayHintBuilder; @@ -23,7 +24,23 @@ pub(super) fn find_hints( .filter(|label| label.range(db).intersect(range).is_some()) { if let Some(rendered) = util::label::render(db, document, label) { - builder.push(label.range(db).end(), rendered.reference(db)); + if let Some(number) = &rendered.number { + let text = match &rendered.object { + LabeledObject::Section { prefix, .. } => { + format!("{} {}", prefix, number.text(db)) + } + LabeledObject::Float { kind, .. } => { + format!("{} {}", kind.as_str(), number.text(db)) + } + LabeledObject::Theorem { kind, .. } => { + format!("{} {}", kind.text(db), number.text(db)) + } + LabeledObject::Equation => format!("Equation ({})", number.text(db)), + LabeledObject::EnumItem => format!("Item {}", number.text(db)), + }; + + builder.push(label.range(db).end(), text); + } } } diff --git a/support/texlab/src/features/link.rs b/support/texlab/src/features/link.rs index 71bba58ba7..c252fc4a91 100644 --- a/support/texlab/src/features/link.rs +++ b/support/texlab/src/features/link.rs @@ -13,7 +13,7 @@ pub fn find_all(db: &dyn Db, uri: &Url) -> Option> { let document = Workspace::get(db).lookup_uri(db, uri)?; let mut builder = LinkBuilder { db, - line_index: document.contents(db).line_index(db), + line_index: document.line_index(db), links: Vec::new(), }; diff --git a/support/texlab/src/features/reference.rs b/support/texlab/src/features/reference.rs index 54a5fefb27..3815accc2f 100644 --- a/support/texlab/src/features/reference.rs +++ b/support/texlab/src/features/reference.rs @@ -30,7 +30,6 @@ pub fn find_all( uri: result.document.location(db).uri(db).clone(), range: result .document - .contents(db) .line_index(db) .line_col_lsp_range(result.range), }) diff --git a/support/texlab/src/features/rename.rs b/support/texlab/src/features/rename.rs index 57e1ef5763..51781517b6 100644 --- a/support/texlab/src/features/rename.rs +++ b/support/texlab/src/features/rename.rs @@ -18,7 +18,7 @@ pub fn prepare_rename_all(db: &dyn Db, uri: &Url, position: Position) -> Option< .or_else(|| label::prepare_rename(&context)) .or_else(|| command::prepare_rename(&context))?; - let line_index = context.document.contents(db).line_index(db); + let line_index = context.document.line_index(db); Some(line_index.line_col_lsp_range(range)) } @@ -37,7 +37,7 @@ pub fn rename_all( .changes .into_iter() .map(|(document, old_edits)| { - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let new_edits = old_edits .into_iter() .map(|Indel { delete, insert }| { diff --git a/support/texlab/src/features/rename/command.rs b/support/texlab/src/features/rename/command.rs index 5610b2f7ee..1e5f2ff0ca 100644 --- a/support/texlab/src/features/rename/command.rs +++ b/support/texlab/src/features/rename/command.rs @@ -1,7 +1,7 @@ use rowan::{TextRange, TextSize}; use rustc_hash::FxHashMap; -use crate::util::cursor::CursorContext; +use crate::{syntax::latex, util::cursor::CursorContext}; use super::{Indel, Params, RenameResult}; @@ -19,7 +19,7 @@ pub(super) fn rename(context: &CursorContext) -> Option { let edits = root .descendants_with_tokens() .filter_map(|element| element.into_token()) - .filter(|token| token.kind().is_command_name() && token.text() == name) + .filter(|token| token.kind() == latex::COMMAND_NAME && token.text() == name) .map(|token| { let range = token.text_range(); Indel { diff --git a/support/texlab/src/features/symbol.rs b/support/texlab/src/features/symbol.rs index 58004b50ef..26a0ec87ef 100644 --- a/support/texlab/src/features/symbol.rs +++ b/support/texlab/src/features/symbol.rs @@ -19,9 +19,9 @@ pub fn find_document_symbols(db: &dyn Db, uri: &Url) -> Option) -> Option<()> { let data = document.parse(db).as_bib()?; - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); for node in data.root(db).children() { process_string(node.clone(), line_index, buf) .or_else(|| process_entry(node, line_index, buf)); diff --git a/support/texlab/src/features/symbol/latex.rs b/support/texlab/src/features/symbol/latex.rs index 81927ab515..8bb5680483 100644 --- a/support/texlab/src/features/symbol/latex.rs +++ b/support/texlab/src/features/symbol/latex.rs @@ -9,7 +9,6 @@ use crate::{ syntax::latex::{self, HasBrack, HasCurly}, util::{ label::{find_caption_by_parent, LabeledFloatKind}, - lang_data::LANGUAGE_DATA, line_index_ext::LineIndexExt, }, Db, @@ -41,17 +40,9 @@ fn visit(db: &dyn Db, document: Document, node: latex::SyntaxNode) -> Vec Option { let section = latex::Section::cast(node)?; let full_range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(§ion)); @@ -133,6 +123,7 @@ fn visit_enum_item( document: Document, node: latex::SyntaxNode, ) -> Option { + let enum_envs = &db.config().syntax.enum_environments; let enum_item = latex::EnumItem::cast(node.clone())?; if !enum_item .syntax() @@ -141,18 +132,12 @@ fn visit_enum_item( .filter_map(|environment| environment.begin()) .filter_map(|begin| begin.name()) .filter_map(|name| name.key()) - .any(|name| { - LANGUAGE_DATA - .enum_environments - .iter() - .any(|e| e == &name.to_string()) - }) + .any(|name| enum_envs.contains(&name.to_string())) { return None; } let full_range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&enum_item)); @@ -198,7 +183,6 @@ fn visit_equation( let equation = latex::Equation::cast(node)?; let full_range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&equation)); @@ -213,7 +197,6 @@ fn visit_equation_environment( let environment = latex::Environment::cast(node)?; let full_range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&environment)); @@ -268,7 +251,6 @@ fn visit_enumeration( ) -> Option { let environment = latex::Environment::cast(node)?; let full_range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&environment)); @@ -315,7 +297,6 @@ fn visit_float( ) -> Option { let environment = latex::Environment::cast(node)?; let full_range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&environment)); @@ -382,7 +363,6 @@ fn visit_theorem( .and_then(|option| option.content_text()); let full_range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&node)); @@ -454,7 +434,6 @@ fn find_label_by_parent( let node = parent.children().find_map(latex::LabelDefinition::cast)?; let name = Word::new(db, node.name()?.key()?.to_string()); let range = document - .contents(db) .line_index(db) .line_col_lsp_range(latex::small_range(&node)); diff --git a/support/texlab/src/features/symbol/types.rs b/support/texlab/src/features/symbol/types.rs index fb3bca217b..96b26be153 100644 --- a/support/texlab/src/features/symbol/types.rs +++ b/support/texlab/src/features/symbol/types.rs @@ -3,7 +3,7 @@ use lsp_types::{DocumentSymbol, Location, Range, SymbolInformation, SymbolKind, use crate::{ db::Word, util::{self, lang_data::BibtexEntryTypeCategory, lsp_enums::Structure}, - Db, SymbolOptions, + Db, SymbolConfig, }; #[derive(Debug, PartialEq, Eq, Clone, Copy)] @@ -80,17 +80,17 @@ impl InternalSymbol { buffer.push(self); } - pub fn filter(container: &mut Vec, options: &SymbolOptions) { + pub fn filter(container: &mut Vec, config: &SymbolConfig) { let mut i = 0; while i < container.len() { let symbol = &mut container[i]; if util::regex_filter::filter( &symbol.name, - &options.allowed_patterns, - &options.ignored_patterns, + &config.allowed_patterns, + &config.ignored_patterns, ) { - Self::filter(&mut symbol.children, options); + Self::filter(&mut symbol.children, config); i += 1; } else { drop(symbol); diff --git a/support/texlab/src/features/workspace_command.rs b/support/texlab/src/features/workspace_command.rs index 8d6732cd1c..cac998125e 100644 --- a/support/texlab/src/features/workspace_command.rs +++ b/support/texlab/src/features/workspace_command.rs @@ -1,103 +1,3 @@ -use std::process::Stdio; - -use anyhow::{bail, Result}; -use lsp_types::{TextDocumentIdentifier, Url}; -use thiserror::Error; - -use crate::{db::Workspace, normalize_uri, Db}; - -pub fn select(db: &dyn Db, name: &str, args: Vec) -> Result { - Ok(match name { - "texlab.cleanAuxiliary" => CleanCommand::new(db, CleanOptions::Auxiliary, args)?, - "texlab.cleanArtifacts" => CleanCommand::new(db, CleanOptions::Artifacts, args)?, - _ => bail!("Unknown command: {}", name), - }) -} - -#[derive(Debug, Error)] -pub enum CleanError { - #[error("document '{0}' not found")] - DocumentNotFound(Url), - - #[error("document '{0}' is not a local file")] - NoLocalFile(Url), - - #[error("document was not provided as an argument")] - MissingArg, - - #[error("invalid argument: {0}")] - InvalidArg(serde_json::Error), - - #[error("failed to spawn process: {0}")] - Spawn(std::io::Error), -} - -#[derive(Debug)] -pub struct CleanCommand { - executable: String, - args: Vec, -} - -impl CleanCommand { - fn new(db: &dyn Db, options: CleanOptions, args: Vec) -> Result { - let params: TextDocumentIdentifier = - serde_json::from_value(args.into_iter().next().ok_or(CleanError::MissingArg)?) - .map_err(CleanError::InvalidArg)?; - - let mut uri = params.uri; - normalize_uri(&mut uri); - - let workspace = Workspace::get(db); - - let document = workspace - .lookup_uri(db, &uri) - .ok_or_else(|| CleanError::DocumentNotFound(uri.clone()))?; - - let working_dir = workspace.working_dir(db, document.directory(db)); - - let output_dir = workspace - .output_dir(db, working_dir) - .path(db) - .as_deref() - .ok_or_else(|| CleanError::NoLocalFile(uri.clone()))?; - - let path = document - .location(db) - .path(db) - .as_deref() - .ok_or_else(|| CleanError::NoLocalFile(uri.clone()))?; - - let flag = match options { - CleanOptions::Auxiliary => "-c", - CleanOptions::Artifacts => "-C", - }; - - let executable = "latexmk".to_string(); - let args = vec![ - format!("-outdir={}", output_dir.display()), - flag.to_string(), - path.display().to_string(), - ]; - - Ok(Self { executable, args }) - } - - pub fn run(self) -> Result<(), CleanError> { - log::debug!("Cleaning output files: {} {:?}", self.executable, self.args); - std::process::Command::new(self.executable) - .args(self.args) - .stdin(Stdio::null()) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status() - .map_err(CleanError::Spawn)?; - - Ok(()) - } -} - -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] -enum CleanOptions { - Auxiliary, - Artifacts, -} +pub mod change_environment; +pub mod clean; +pub mod dep_graph; diff --git a/support/texlab/src/features/workspace_command/change_environment.rs b/support/texlab/src/features/workspace_command/change_environment.rs new file mode 100644 index 0000000000..ef2c96eae1 --- /dev/null +++ b/support/texlab/src/features/workspace_command/change_environment.rs @@ -0,0 +1,108 @@ +use std::collections::hash_map::HashMap; + +use anyhow::Result; +use lsp_types::{ApplyWorkspaceEditParams, TextDocumentPositionParams, TextEdit, WorkspaceEdit}; +use rowan::ast::AstNode; +use serde::{Deserialize, Serialize}; +use thiserror::Error; + +use crate::{ + normalize_uri, + util::{cursor::CursorContext, line_index_ext::LineIndexExt}, + Db, +}; + +fn change_environment_context( + db: &dyn Db, + args: Vec, +) -> Result> { + let params: ChangeEnvironmentParams = serde_json::from_value( + args.into_iter() + .next() + .ok_or(ChangeEnvironmentError::MissingArg)?, + ) + .map_err(ChangeEnvironmentError::InvalidArg)?; + + let mut uri = params.text_document_position.text_document.uri; + normalize_uri(&mut uri); + let position = params.text_document_position.position; + + CursorContext::new( + db, + &uri, + position, + Params { + new_name: params.new_name, + }, + ) + .ok_or(ChangeEnvironmentError::FailedCreatingContext.into()) +} + +pub fn change_environment( + db: &dyn Db, + args: Vec, +) -> Option<((), ApplyWorkspaceEditParams)> { + let context = change_environment_context(db, args).ok()?; + let (beg, end) = context.find_environment()?; + + let beg_name = beg.to_string(); + let end_name = end.to_string(); + + if beg_name != end_name { + return None; + } + let new_name = &context.params.new_name; + + let line_index = context.document.line_index(db); + let mut changes = HashMap::default(); + changes.insert( + context.document.location(db).uri(db).clone(), + vec![ + TextEdit::new( + line_index.line_col_lsp_range(beg.syntax().text_range()), + new_name.clone(), + ), + TextEdit::new( + line_index.line_col_lsp_range(end.syntax().text_range()), + new_name.clone(), + ), + ], + ); + + Some(( + (), + ApplyWorkspaceEditParams { + label: Some(format!("change environment: {} -> {}", beg_name, new_name)), + edit: WorkspaceEdit::new(changes), + }, + )) +} + +#[derive(Debug, Error)] +pub enum ChangeEnvironmentError { + #[error("rename parameters was not provided as an argument")] + MissingArg, + + #[error("invalid argument: {0}")] + InvalidArg(serde_json::Error), + + #[error("failed creating context")] + FailedCreatingContext, + + #[error("could not create workspaces edit")] + CouldNotCreateWorkspaceEdit, +} + +#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ChangeEnvironmentParams { + #[serde(flatten)] + pub text_document_position: TextDocumentPositionParams, + + pub new_name: String, +} + +#[derive(Debug)] +pub struct Params { + new_name: String, +} diff --git a/support/texlab/src/features/workspace_command/clean.rs b/support/texlab/src/features/workspace_command/clean.rs new file mode 100644 index 0000000000..cea22fc687 --- /dev/null +++ b/support/texlab/src/features/workspace_command/clean.rs @@ -0,0 +1,95 @@ +use std::process::Stdio; + +use anyhow::Result; +use lsp_types::{TextDocumentIdentifier, Url}; +use thiserror::Error; + +use crate::{db::Workspace, normalize_uri, Db}; + +#[derive(Debug, Error)] +pub enum CleanError { + #[error("document '{0}' not found")] + DocumentNotFound(Url), + + #[error("document '{0}' is not a local file")] + NoLocalFile(Url), + + #[error("document was not provided as an argument")] + MissingArg, + + #[error("invalid argument: {0}")] + InvalidArg(serde_json::Error), + + #[error("failed to spawn process: {0}")] + Spawn(std::io::Error), +} + +#[derive(Debug)] +pub struct CleanCommand { + executable: String, + args: Vec, +} + +impl CleanCommand { + pub fn new(db: &dyn Db, options: CleanOptions, args: Vec) -> Result { + let params: TextDocumentIdentifier = + serde_json::from_value(args.into_iter().next().ok_or(CleanError::MissingArg)?) + .map_err(CleanError::InvalidArg)?; + + let mut uri = params.uri; + normalize_uri(&mut uri); + + let workspace = Workspace::get(db); + + let document = workspace + .lookup_uri(db, &uri) + .ok_or_else(|| CleanError::DocumentNotFound(uri.clone()))?; + + let working_dir = workspace.working_dir(db, document.directory(db)); + + let output_dir = workspace + .output_dir(db, working_dir) + .path(db) + .as_deref() + .ok_or_else(|| CleanError::NoLocalFile(uri.clone()))?; + + let path = document + .location(db) + .path(db) + .as_deref() + .ok_or_else(|| CleanError::NoLocalFile(uri.clone()))?; + + let flag = match options { + CleanOptions::Auxiliary => "-c", + CleanOptions::Artifacts => "-C", + }; + + let executable = "latexmk".to_string(); + let args = vec![ + format!("-outdir={}", output_dir.display()), + flag.to_string(), + path.display().to_string(), + ]; + + Ok(Self { executable, args }) + } + + pub fn run(self) -> Result<()> { + log::debug!("Cleaning output files: {} {:?}", self.executable, self.args); + std::process::Command::new(self.executable) + .args(self.args) + .stdin(Stdio::null()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() + .map_err(move |msg| anyhow::Error::new(CleanError::Spawn(msg)))?; + + Ok(()) + } +} + +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] +pub enum CleanOptions { + Auxiliary, + Artifacts, +} diff --git a/support/texlab/src/features/workspace_command/dep_graph.rs b/support/texlab/src/features/workspace_command/dep_graph.rs new file mode 100644 index 0000000000..84e87c4026 --- /dev/null +++ b/support/texlab/src/features/workspace_command/dep_graph.rs @@ -0,0 +1,57 @@ +use anyhow::Result; +use itertools::Itertools; +use std::io::Write; + +use rustc_hash::FxHashMap; + +use crate::{ + db::{dependency_graph, Document, Workspace}, + Db, +}; + +pub fn show_dependency_graph(db: &dyn Db) -> Result { + let workspace = Workspace::get(db); + + let documents = workspace + .documents(db) + .iter() + .enumerate() + .map(|(i, doc)| (*doc, format!("v{i:0>5}"))) + .collect::>(); + + let mut writer = Vec::new(); + writeln!(&mut writer, "digraph G {{")?; + writeln!(&mut writer, "rankdir = LR;")?; + + for (document, node) in &documents { + let label = document.location(db).uri(db).as_str(); + let shape = if document.can_be_root(db) { + "tripleoctagon" + } else if document.can_be_built(db) { + "doubleoctagon" + } else { + "octagon" + }; + + writeln!(&mut writer, "\t{node} [label=\"{label}\", shape={shape}];")?; + } + + for edge in workspace + .documents(db) + .iter() + .flat_map(|start| dependency_graph(db, *start).edges.iter()) + .unique() + { + let source = &documents[&edge.source]; + let target = &documents[&edge.target]; + let label = edge + .origin + .as_ref() + .map_or("", |origin| &origin.link.path(db).text(db)); + + writeln!(&mut writer, "\t{source} -> {target} [label=\"{label}\"];")?; + } + + writeln!(&mut writer, "}}")?; + Ok(String::from_utf8(writer)?) +} diff --git a/support/texlab/src/lib.rs b/support/texlab/src/lib.rs index 46ee3ddd1c..d80375fa03 100644 --- a/support/texlab/src/lib.rs +++ b/support/texlab/src/lib.rs @@ -2,29 +2,29 @@ pub(crate) mod citation; mod client; +mod config; pub mod db; pub(crate) mod distro; pub mod features; -mod options; pub mod parser; mod server; pub mod syntax; pub mod util; -pub use self::{client::LspClient, options::*, server::Server}; +pub use self::{client::LspClient, config::*, server::Server}; #[salsa::jar(db = Db)] pub struct Jar( db::Word, + db::ServerContext, db::Location, db::Location_path, - db::Contents, - db::Contents_line_index, db::LinterData, db::Document, db::Document_parse, db::Document_can_be_root, db::Document_can_be_built, + db::Document_line_index, db::parse::TexDocumentData, db::parse::TexDocumentData_analyze, db::parse::BibDocumentData, @@ -53,27 +53,34 @@ pub struct Jar( db::diagnostics::collect_filtered, ); -pub trait Db: salsa::DbWithJar {} - -impl Db for DB where DB: ?Sized + salsa::DbWithJar {} +pub trait Db: salsa::DbWithJar { + fn config(&self) -> &Config; +} #[salsa::db(crate::Jar)] pub struct Database { storage: salsa::Storage, } +impl Db for Database { + fn config(&self) -> &Config { + db::ServerContext::get(self).config(self) + } +} + impl Default for Database { fn default() -> Self { let storage = salsa::Storage::default(); let db = Self { storage }; + + db::ServerContext::new(&db, Default::default(), Default::default()); + db::Workspace::new( &db, Default::default(), Default::default(), Default::default(), Default::default(), - Default::default(), - Default::default(), ); db diff --git a/support/texlab/src/options.rs b/support/texlab/src/options.rs deleted file mode 100644 index 0e87d11fab..0000000000 --- a/support/texlab/src/options.rs +++ /dev/null @@ -1,144 +0,0 @@ -use std::{path::PathBuf, time::Duration}; - -use regex::Regex; -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct Options { - pub root_directory: Option, - pub aux_directory: Option, - pub bibtex_formatter: BibtexFormatter, - pub latex_formatter: LatexFormatter, - pub formatter_line_length: Option, - pub diagnostics: DiagnosticsOptions, - pub diagnostics_delay: DiagnosticsDelay, - pub build: BuildOptions, - pub chktex: ChktexOptions, - pub symbols: SymbolOptions, - pub latexindent: LatexindentOptions, - pub forward_search: ForwardSearchOptions, -} - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] -pub struct DiagnosticsDelay(#[serde(with = "serde_millis")] pub Duration); - -impl Default for DiagnosticsDelay { - fn default() -> Self { - Self(Duration::from_millis(300)) - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] -#[serde(rename_all = "kebab-case")] -pub enum BibtexFormatter { - None, - Texlab, - Latexindent, -} - -impl Default for BibtexFormatter { - fn default() -> Self { - Self::Texlab - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] -#[serde(rename_all = "kebab-case")] -pub enum LatexFormatter { - None, - Texlab, - Latexindent, -} - -impl Default for LatexFormatter { - fn default() -> Self { - Self::Latexindent - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct LatexindentOptions { - pub local: Option, - pub modify_line_breaks: bool, -} - -#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct BuildOptions { - pub executable: BuildExecutable, - pub args: BuildArgs, - pub on_save: bool, - pub forward_search_after: bool, -} - -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] -#[serde(transparent)] -pub struct BuildExecutable(pub String); - -impl Default for BuildExecutable { - fn default() -> Self { - Self("latexmk".to_string()) - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] -#[serde(transparent)] -pub struct BuildArgs(pub Vec); - -impl Default for BuildArgs { - fn default() -> Self { - Self(vec![ - "-pdf".to_string(), - "-interaction=nonstopmode".to_string(), - "-synctex=1".to_string(), - "%f".to_string(), - ]) - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct ChktexOptions { - pub on_open_and_save: bool, - pub on_edit: bool, -} - -#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct ForwardSearchOptions { - pub executable: Option, - pub args: Option>, -} - -#[derive(Debug, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct DiagnosticsOptions { - pub allowed_patterns: Vec, - pub ignored_patterns: Vec, -} - -#[derive(Debug, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct SymbolOptions { - pub allowed_patterns: Vec, - pub ignored_patterns: Vec, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct RegexPattern(#[serde(with = "serde_regex")] pub Regex); - -#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(default)] -pub struct StartupOptions { - pub skip_distro: bool, -} diff --git a/support/texlab/src/parser/latex.rs b/support/texlab/src/parser/latex.rs index a103561685..591d2a1583 100644 --- a/support/texlab/src/parser/latex.rs +++ b/support/texlab/src/parser/latex.rs @@ -4,7 +4,10 @@ use rowan::{GreenNode, GreenNodeBuilder}; use crate::syntax::latex::SyntaxKind::{self, *}; -use self::lexer::Lexer; +use self::lexer::{ + types::{CommandName, SectionLevel, Token}, + Lexer, +}; #[derive(Debug, Clone, Copy)] struct ParserContext { @@ -40,20 +43,18 @@ impl<'a> Parser<'a> { self.builder.token(kind.into(), text); } - fn peek(&self) -> Option { + fn peek(&self) -> Option { self.lexer.peek() } - fn expect(&mut self, kind: SyntaxKind) { + fn expect(&mut self, kind: Token) { if self.peek() == Some(kind) { self.eat(); self.trivia(); - } else { - self.builder.token(MISSING.into(), ""); } } - fn expect2(&mut self, kind1: SyntaxKind, kind2: SyntaxKind) { + fn expect2(&mut self, kind1: Token, kind2: Token) { if self .peek() .filter(|&kind| kind == kind1 || kind == kind2) @@ -61,17 +62,16 @@ impl<'a> Parser<'a> { { self.eat(); self.trivia(); - } else { - self.builder.token(MISSING.into(), ""); } } fn trivia(&mut self) { - while self - .peek() - .filter(|&kind| matches!(kind, LINE_BREAK | WHITESPACE | COMMENT)) - .is_some() - { + while self.peek().map_or(false, |kind| { + matches!( + kind, + Token::LineBreak | Token::Whitespace | Token::LineComment + ) + }) { self.eat(); } } @@ -88,66 +88,60 @@ impl<'a> Parser<'a> { fn content(&mut self, context: ParserContext) { match self.peek().unwrap() { - LINE_BREAK | WHITESPACE | COMMENT | VERBATIM => self.eat(), - L_CURLY if context.allow_environment => self.curly_group(), - L_CURLY => self.curly_group_without_environments(), - L_BRACK | L_PAREN => self.mixed_group(), - R_CURLY | R_BRACK | R_PAREN => { + Token::LineBreak | Token::Whitespace | Token::LineComment => self.eat(), + Token::LCurly if context.allow_environment => self.curly_group(), + Token::LCurly => self.curly_group_without_environments(), + Token::LBrack | Token::LParen => self.mixed_group(), + Token::RCurly | Token::RBrack | Token::RParen => { self.builder.start_node(ERROR.into()); self.eat(); self.builder.finish_node(); } - WORD | COMMA => self.text(context), - EQUALITY_SIGN => self.eat(), - DOLLAR => self.formula(), - GENERIC_COMMAND_NAME => self.generic_command(), - BEGIN_ENVIRONMENT_NAME if context.allow_environment => self.environment(), - BEGIN_ENVIRONMENT_NAME => self.generic_command(), - END_ENVIRONMENT_NAME => self.generic_command(), - BEGIN_EQUATION_NAME => self.equation(), - END_EQUATION_NAME => self.generic_command(), - MISSING | ERROR => self.eat(), - PART_NAME => self.part(), - CHAPTER_NAME => self.chapter(), - SECTION_NAME => self.section(), - SUBSECTION_NAME => self.subsection(), - SUBSUBSECTION_NAME => self.subsubsection(), - PARAGRAPH_NAME => self.paragraph(), - SUBPARAGRAPH_NAME => self.subparagraph(), - ENUM_ITEM_NAME => self.enum_item(), - CAPTION_NAME => self.caption(), - CITATION_NAME => self.citation(), - PACKAGE_INCLUDE_NAME => self.package_include(), - CLASS_INCLUDE_NAME => self.class_include(), - LATEX_INCLUDE_NAME => self.latex_include(), - BIBLATEX_INCLUDE_NAME => self.biblatex_include(), - BIBTEX_INCLUDE_NAME => self.bibtex_include(), - GRAPHICS_INCLUDE_NAME => self.graphics_include(), - SVG_INCLUDE_NAME => self.svg_include(), - INKSCAPE_INCLUDE_NAME => self.inkscape_include(), - VERBATIM_INCLUDE_NAME => self.verbatim_include(), - IMPORT_NAME => self.import(), - LABEL_DEFINITION_NAME => self.label_definition(), - LABEL_REFERENCE_NAME => self.label_reference(), - LABEL_REFERENCE_RANGE_NAME => self.label_reference_range(), - LABEL_NUMBER_NAME => self.label_number(), - COMMAND_DEFINITION_NAME => self.command_definition(), - MATH_OPERATOR_NAME => self.math_operator(), - GLOSSARY_ENTRY_DEFINITION_NAME => self.glossary_entry_definition(), - GLOSSARY_ENTRY_REFERENCE_NAME => self.glossary_entry_reference(), - ACRONYM_DEFINITION_NAME => self.acronym_definition(), - ACRONYM_DECLARATION_NAME => self.acronym_declaration(), - ACRONYM_REFERENCE_NAME => self.acronym_reference(), - THEOREM_DEFINITION_NAME => self.theorem_definition(), - COLOR_REFERENCE_NAME => self.color_reference(), - COLOR_DEFINITION_NAME => self.color_definition(), - COLOR_SET_DEFINITION_NAME => self.color_set_definition(), - TIKZ_LIBRARY_IMPORT_NAME => self.tikz_library_import(), - ENVIRONMENT_DEFINITION_NAME => self.environment_definition(), - BEGIN_BLOCK_COMMENT_NAME => self.block_comment(), - END_BLOCK_COMMENT_NAME => self.generic_command(), - GRAPHICS_PATH_NAME => self.graphics_path(), - _ => unreachable!(), + Token::Word | Token::Comma => self.text(context), + Token::Eq => self.eat(), + Token::Dollar => self.formula(), + Token::CommandName(name) => match name { + CommandName::Generic => self.generic_command(), + CommandName::BeginEnvironment if context.allow_environment => self.environment(), + CommandName::BeginEnvironment => self.generic_command(), + CommandName::EndEnvironment => self.generic_command(), + CommandName::BeginEquation => self.equation(), + CommandName::EndEquation => self.generic_command(), + CommandName::Section(level) => self.section(level), + CommandName::EnumItem => self.enum_item(), + CommandName::Caption => self.caption(), + CommandName::Citation => self.citation(), + CommandName::PackageInclude => self.package_include(), + CommandName::ClassInclude => self.class_include(), + CommandName::LatexInclude => self.latex_include(), + CommandName::BiblatexInclude => self.biblatex_include(), + CommandName::BibtexInclude => self.bibtex_include(), + CommandName::GraphicsInclude => self.graphics_include(), + CommandName::SvgInclude => self.svg_include(), + CommandName::InkscapeInclude => self.inkscape_include(), + CommandName::VerbatimInclude => self.verbatim_include(), + CommandName::Import => self.import(), + CommandName::LabelDefinition => self.label_definition(), + CommandName::LabelReference => self.label_reference(), + CommandName::LabelReferenceRange => self.label_reference_range(), + CommandName::LabelNumber => self.label_number(), + CommandName::CommandDefinition => self.command_definition(), + CommandName::MathOperator => self.math_operator(), + CommandName::GlossaryEntryDefinition => self.glossary_entry_definition(), + CommandName::GlossaryEntryReference => self.glossary_entry_reference(), + CommandName::AcronymDefinition => self.acronym_definition(), + CommandName::AcronymDeclaration => self.acronym_declaration(), + CommandName::AcronymReference => self.acronym_reference(), + CommandName::TheoremDefinition => self.theorem_definition(), + CommandName::ColorReference => self.color_reference(), + CommandName::ColorDefinition => self.color_definition(), + CommandName::ColorSetDefinition => self.color_set_definition(), + CommandName::TikzLibraryImport => self.tikz_library_import(), + CommandName::EnvironmentDefinition => self.environment_definition(), + CommandName::BeginBlockComment => self.block_comment(), + CommandName::EndBlockComment => self.generic_command(), + CommandName::GraphicsPath => self.graphics_path(), + }, } } @@ -157,8 +151,14 @@ impl<'a> Parser<'a> { while self .peek() .filter(|&kind| { - matches!(kind, LINE_BREAK | WHITESPACE | COMMENT | WORD | COMMA) - && (context.allow_comma || kind != COMMA) + matches!( + kind, + Token::LineBreak + | Token::Whitespace + | Token::LineComment + | Token::Word + | Token::Comma + ) && (context.allow_comma || kind != Token::Comma) }) .is_some() { @@ -172,12 +172,12 @@ impl<'a> Parser<'a> { self.eat(); while self .peek() - .filter(|&kind| !matches!(kind, R_CURLY)) + .filter(|&kind| !matches!(kind, Token::RCurly)) .is_some() { self.content(ParserContext::default()); } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } @@ -186,13 +186,13 @@ impl<'a> Parser<'a> { self.eat(); while let Some(kind) = self.peek() { match kind { - R_CURLY => break, - BEGIN_ENVIRONMENT_NAME => self.begin(), - END_ENVIRONMENT_NAME => self.end(), + Token::RCurly => break, + Token::CommandName(CommandName::BeginEnvironment) => self.begin(), + Token::CommandName(CommandName::EndEnvironment) => self.end(), _ => self.content(ParserContext::default()), }; } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } @@ -201,7 +201,7 @@ impl<'a> Parser<'a> { self.eat(); while self .peek() - .filter(|&kind| !matches!(kind, R_CURLY)) + .filter(|&kind| !matches!(kind, Token::RCurly)) .is_some() { self.content(ParserContext { @@ -209,7 +209,7 @@ impl<'a> Parser<'a> { allow_comma: true, }); } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } @@ -218,17 +218,15 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); match self.peek() { - Some(WORD) => { + Some(Token::Word) => { self.key(); } - Some(kind) if kind.is_command_name() => { + Some(Token::CommandName(_)) => { self.content(ParserContext::default()); } - Some(_) | None => { - self.builder.token(MISSING.into(), ""); - } + Some(_) | None => {} } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } @@ -238,17 +236,26 @@ impl<'a> Parser<'a> { while self .peek() - .filter(|&kind| matches!(kind, LINE_BREAK | WHITESPACE | COMMENT | WORD | COMMA)) + .filter(|&kind| { + matches!( + kind, + Token::LineBreak + | Token::Whitespace + | Token::LineComment + | Token::Word + | Token::Comma + ) + }) .is_some() { - if self.peek() == Some(WORD) { + if self.peek() == Some(Token::Word) { self.key(); } else { self.eat(); } } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } @@ -256,44 +263,32 @@ impl<'a> Parser<'a> { self.builder.start_node(CURLY_GROUP_COMMAND.into()); self.eat(); self.trivia(); - match self.peek() { - Some(kind) if kind.is_command_name() => { - self.eat(); - self.trivia(); - } - Some(_) | None => { - self.builder.token(MISSING.into(), ""); - } + if matches!(self.peek(), Some(Token::CommandName(_))) { + self.eat(); + self.trivia(); } - self.expect(R_CURLY); + + self.expect(Token::RCurly); self.builder.finish_node(); } fn brack_group(&mut self) { self.builder.start_node(BRACK_GROUP.into()); self.eat(); - while self - .peek() - .filter(|&kind| { - !matches!( - kind, - R_CURLY - | R_BRACK - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - | PARAGRAPH_NAME - | SUBPARAGRAPH_NAME - | ENUM_ITEM_NAME - | END_ENVIRONMENT_NAME - ) - }) - .is_some() - { + while self.peek().map_or(false, |kind| { + !matches!( + kind, + Token::RCurly + | Token::RBrack + | Token::CommandName(CommandName::Section(_)) + | Token::CommandName(CommandName::EnumItem) + | Token::CommandName(CommandName::EndEnvironment) + ) + }) { self.content(ParserContext::default()); } - self.expect(R_BRACK); + + self.expect(Token::RBrack); self.builder.finish_node(); } @@ -302,14 +297,12 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); match self.peek() { - Some(WORD) => { + Some(Token::Word) => { self.key(); } - Some(_) | None => { - self.builder.token(MISSING.into(), ""); - } + Some(_) | None => {} } - self.expect(R_BRACK); + self.expect(Token::RBrack); self.builder.finish_node(); } @@ -317,29 +310,21 @@ impl<'a> Parser<'a> { self.builder.start_node(MIXED_GROUP.into()); self.eat(); self.trivia(); - while self - .peek() - .filter(|&kind| { - !matches!( - kind, - R_CURLY - | R_BRACK - | R_PAREN - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - | PARAGRAPH_NAME - | SUBPARAGRAPH_NAME - | ENUM_ITEM_NAME - | END_ENVIRONMENT_NAME - ) - }) - .is_some() - { + while self.peek().map_or(false, |kind| { + !matches!( + kind, + Token::RCurly + | Token::RBrack + | Token::RParen + | Token::CommandName(CommandName::Section(_)) + | Token::CommandName(CommandName::EnumItem) + | Token::CommandName(CommandName::EndEnvironment) + ) + }) { self.content(ParserContext::default()); } - self.expect2(R_BRACK, R_PAREN); + + self.expect2(Token::RBrack, Token::RParen); self.builder.finish_node(); } @@ -348,7 +333,7 @@ impl<'a> Parser<'a> { self.eat(); while self .peek() - .filter(|&kind| matches!(kind, WHITESPACE | COMMENT | WORD)) + .filter(|&kind| matches!(kind, Token::Whitespace | Token::LineComment | Token::Word)) .is_some() { self.eat(); @@ -362,7 +347,7 @@ impl<'a> Parser<'a> { self.builder.start_node(VALUE.into()); while let Some(kind) = self.lexer.peek() { match kind { - COMMA | R_BRACK | R_CURLY => break, + Token::Comma | Token::RBrack | Token::RCurly => break, _ => self.content(ParserContext { allow_environment: true, allow_comma: false, @@ -375,7 +360,7 @@ impl<'a> Parser<'a> { fn key_value_pair(&mut self) { self.builder.start_node(KEY_VALUE_PAIR.into()); self.key(); - if self.peek() == Some(EQUALITY_SIGN) { + if self.peek() == Some(Token::Eq) { self.eat(); self.trivia(); if self @@ -383,14 +368,16 @@ impl<'a> Parser<'a> { .filter(|&kind| { !matches!( kind, - END_ENVIRONMENT_NAME | R_CURLY | R_BRACK | R_PAREN | COMMA + Token::CommandName(CommandName::EndEnvironment) + | Token::RCurly + | Token::RBrack + | Token::RParen + | Token::Comma ) }) .is_some() { self.value(); - } else { - self.builder.token(MISSING.into(), ""); } } @@ -401,10 +388,10 @@ impl<'a> Parser<'a> { self.builder.start_node(KEY_VALUE_BODY.into()); while let Some(kind) = self.peek() { match kind { - LINE_BREAK | WHITESPACE | COMMENT => self.eat(), - WORD => { + Token::LineBreak | Token::Whitespace | Token::LineComment => self.eat(), + Token::Word => { self.key_value_pair(); - if self.peek() == Some(COMMA) { + if self.peek() == Some(Token::Comma) { self.eat(); } else { break; @@ -416,7 +403,7 @@ impl<'a> Parser<'a> { self.builder.finish_node(); } - fn group_key_value(&mut self, node_kind: SyntaxKind, right_kind: SyntaxKind) { + fn group_key_value(&mut self, node_kind: SyntaxKind, right_kind: Token) { self.builder.start_node(node_kind.into()); self.eat(); self.trivia(); @@ -426,11 +413,11 @@ impl<'a> Parser<'a> { } fn curly_group_key_value(&mut self) { - self.group_key_value(CURLY_GROUP_KEY_VALUE, R_CURLY); + self.group_key_value(CURLY_GROUP_KEY_VALUE, Token::RCurly); } fn brack_group_key_value(&mut self) { - self.group_key_value(BRACK_GROUP_KEY_VALUE, R_BRACK); + self.group_key_value(BRACK_GROUP_KEY_VALUE, Token::RBrack); } fn formula(&mut self) { @@ -439,12 +426,17 @@ impl<'a> Parser<'a> { self.trivia(); while self .peek() - .filter(|&kind| !matches!(kind, R_CURLY | END_ENVIRONMENT_NAME | DOLLAR)) + .filter(|&kind| { + !matches!( + kind, + Token::RCurly | Token::CommandName(CommandName::EndEnvironment) | Token::Dollar + ) + }) .is_some() { self.content(ParserContext::default()); } - self.expect(DOLLAR); + self.expect(Token::Dollar); self.builder.finish_node(); } @@ -453,9 +445,9 @@ impl<'a> Parser<'a> { self.eat(); while let Some(kind) = self.peek() { match kind { - LINE_BREAK | WHITESPACE | COMMENT => self.eat(), - L_CURLY => self.curly_group(), - L_BRACK | L_PAREN => self.mixed_group(), + Token::LineBreak | Token::Whitespace | Token::LineComment => self.eat(), + Token::LCurly => self.curly_group(), + Token::LBrack | Token::LParen => self.mixed_group(), _ => break, } } @@ -467,12 +459,19 @@ impl<'a> Parser<'a> { self.eat(); while self .peek() - .filter(|&kind| !matches!(kind, END_ENVIRONMENT_NAME | R_CURLY | END_EQUATION_NAME)) + .filter(|&kind| { + !matches!( + kind, + Token::CommandName(CommandName::EndEnvironment) + | Token::RCurly + | Token::CommandName(CommandName::EndEquation) + ) + }) .is_some() { self.content(ParserContext::default()); } - self.expect(END_EQUATION_NAME); + self.expect(Token::CommandName(CommandName::EndEquation)); self.builder.finish_node(); } @@ -481,13 +480,11 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.peek() == Some(L_CURLY) { + if self.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.peek() == Some(L_BRACK) { + if self.peek() == Some(Token::LBrack) { self.brack_group(); } self.builder.finish_node(); @@ -498,10 +495,8 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.peek() == Some(L_CURLY) { + if self.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -511,131 +506,31 @@ impl<'a> Parser<'a> { self.builder.start_node(ENVIRONMENT.into()); self.begin(); - while self - .peek() - .filter(|&kind| !matches!(kind, R_CURLY | END_ENVIRONMENT_NAME)) - .is_some() - { - self.content(ParserContext::default()); - } - - if self.peek() == Some(END_ENVIRONMENT_NAME) { - self.end(); - } else { - self.builder.token(MISSING.into(), ""); - } - self.builder.finish_node(); - } - - fn preamble(&mut self) { - self.builder.start_node(PREAMBLE.into()); - while self - .peek() - .filter(|&kind| kind != END_ENVIRONMENT_NAME) - .is_some() - { - self.content(ParserContext::default()); - } - self.builder.finish_node(); - } - - fn part(&mut self) { - self.builder.start_node(PART.into()); - self.eat(); - self.trivia(); - - if self.peek() == Some(L_CURLY) { - self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); - } - - while self - .peek() - .filter(|&kind| !matches!(kind, END_ENVIRONMENT_NAME | R_CURLY | PART_NAME)) - .is_some() - { - self.content(ParserContext::default()); - } - self.builder.finish_node(); - } - - fn chapter(&mut self) { - self.builder.start_node(CHAPTER.into()); - self.eat(); - self.trivia(); - - if self.peek() == Some(L_CURLY) { - self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); - } - while self .peek() .filter(|&kind| { !matches!( kind, - END_ENVIRONMENT_NAME | R_CURLY | PART_NAME | CHAPTER_NAME + Token::RCurly | Token::CommandName(CommandName::EndEnvironment) ) }) .is_some() { self.content(ParserContext::default()); } - self.builder.finish_node(); - } - fn section(&mut self) { - self.builder.start_node(SECTION.into()); - self.eat(); - self.trivia(); - - if self.peek() == Some(L_CURLY) { - self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); + if self.peek() == Some(Token::CommandName(CommandName::EndEnvironment)) { + self.end(); } - while self - .peek() - .filter(|&kind| { - !matches!( - kind, - END_ENVIRONMENT_NAME | R_CURLY | PART_NAME | CHAPTER_NAME | SECTION_NAME - ) - }) - .is_some() - { - self.content(ParserContext::default()); - } self.builder.finish_node(); } - fn subsection(&mut self) { - self.builder.start_node(SUBSECTION.into()); - self.eat(); - self.trivia(); - - if self.peek() == Some(L_CURLY) { - self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); - } - + fn preamble(&mut self) { + self.builder.start_node(PREAMBLE.into()); while self .peek() - .filter(|&kind| { - !matches!( - kind, - END_ENVIRONMENT_NAME - | R_CURLY - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - ) - }) + .filter(|&kind| kind != Token::CommandName(CommandName::EndEnvironment)) .is_some() { self.content(ParserContext::default()); @@ -643,102 +538,34 @@ impl<'a> Parser<'a> { self.builder.finish_node(); } - fn subsubsection(&mut self) { - self.builder.start_node(SUBSUBSECTION.into()); - self.eat(); - self.trivia(); + fn section(&mut self, level: SectionLevel) { + let node_kind = match level { + SectionLevel::Part => PART, + SectionLevel::Chapter => CHAPTER, + SectionLevel::Section => SECTION, + SectionLevel::Subsection => SUBSECTION, + SectionLevel::Subsubsection => SUBSUBSECTION, + SectionLevel::Paragraph => PARAGRAPH, + SectionLevel::Subparagraph => SUBPARAGRAPH, + }; - if self.peek() == Some(L_CURLY) { - self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); - } - - while self - .peek() - .filter(|&kind| { - !matches!( - kind, - END_ENVIRONMENT_NAME - | R_CURLY - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - | SUBSUBSECTION_NAME - ) - }) - .is_some() - { - self.content(ParserContext::default()); - } - self.builder.finish_node(); - } - - fn paragraph(&mut self) { - self.builder.start_node(PARAGRAPH.into()); + self.builder.start_node(node_kind.into()); self.eat(); self.trivia(); - if self.peek() == Some(L_CURLY) { + if self.peek() == Some(Token::LCurly) { self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); - } - - while self - .peek() - .filter(|&kind| { - !matches!( - kind, - END_ENVIRONMENT_NAME - | R_CURLY - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - | SUBSUBSECTION_NAME - | PARAGRAPH_NAME - ) - }) - .is_some() - { - self.content(ParserContext::default()); } - self.builder.finish_node(); - } - fn subparagraph(&mut self) { - self.builder.start_node(SUBPARAGRAPH.into()); - self.eat(); - self.trivia(); - - if self.peek() == Some(L_CURLY) { - self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); + while let Some(kind) = self.peek() { + match kind { + Token::RCurly => break, + Token::CommandName(CommandName::EndEnvironment) => break, + Token::CommandName(CommandName::Section(nested)) if nested <= level => break, + _ => self.content(ParserContext::default()), + }; } - while self - .peek() - .filter(|&kind| { - !matches!( - kind, - END_ENVIRONMENT_NAME - | R_CURLY - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - | SUBSUBSECTION_NAME - | PARAGRAPH_NAME - | SUBPARAGRAPH_NAME - ) - }) - .is_some() - { - self.content(ParserContext::default()); - } self.builder.finish_node(); } @@ -747,31 +574,20 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.peek() == Some(L_BRACK) { + if self.peek() == Some(Token::LBrack) { self.brack_group(); } - while self - .peek() - .filter(|&kind| { - !matches!( - kind, - END_ENVIRONMENT_NAME - | R_CURLY - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - | SUBSUBSECTION_NAME - | PARAGRAPH_NAME - | SUBPARAGRAPH_NAME - | ENUM_ITEM_NAME - ) - }) - .is_some() - { - self.content(ParserContext::default()); + while let Some(kind) = self.peek() { + match kind { + Token::CommandName(CommandName::EndEnvironment) + | Token::RCurly + | Token::CommandName(CommandName::Section(_)) + | Token::CommandName(CommandName::EnumItem) => break, + _ => self.content(ParserContext::default()), + } } + self.builder.finish_node(); } @@ -779,14 +595,19 @@ impl<'a> Parser<'a> { self.builder.start_node(BLOCK_COMMENT.into()); self.eat(); - if self.peek() == Some(VERBATIM) { - self.eat(); - } - - if self.peek() == Some(END_BLOCK_COMMENT_NAME) { - self.eat(); - } else { - self.builder.token(MISSING.into(), ""); + while let Some(kind) = self.peek() { + match kind { + Token::CommandName(CommandName::BeginBlockComment) => { + self.block_comment(); + } + Token::CommandName(CommandName::EndBlockComment) => { + self.eat(); + break; + } + _ => { + self.eat(); + } + } } self.builder.finish_node(); @@ -797,14 +618,12 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.peek() == Some(L_BRACK) { + if self.peek() == Some(Token::LBrack) { self.brack_group(); } - if self.peek() == Some(L_CURLY) { + if self.peek() == Some(Token::LCurly) { self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -815,15 +634,13 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); for _ in 0..2 { - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group(); } } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word_list(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -833,14 +650,12 @@ impl<'a> Parser<'a> { self.builder.start_node(kind.into()); self.eat(); self.trivia(); - if options && self.lexer.peek() == Some(L_BRACK) { + if options && self.lexer.peek() == Some(Token::LBrack) { self.brack_group_key_value(); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_path_list(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -853,15 +668,20 @@ impl<'a> Parser<'a> { while let Some(kind) = self.lexer.peek() { match kind { - COMMENT | WORD | EQUALITY_SIGN | COMMA | L_BRACK | R_BRACK - | GENERIC_COMMAND_NAME => self.path(), - L_CURLY => self.curly_group_path(), - WHITESPACE => self.eat(), + Token::LineComment + | Token::Word + | Token::Eq + | Token::Comma + | Token::LBrack + | Token::RBrack + | Token::CommandName(CommandName::Generic) => self.path(), + Token::LCurly => self.curly_group_path(), + Token::Whitespace => self.eat(), _ => break, }; } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } @@ -872,16 +692,19 @@ impl<'a> Parser<'a> { while let Some(kind) = self.peek() { match kind { - COMMENT | WORD | EQUALITY_SIGN | L_BRACK | R_BRACK | GENERIC_COMMAND_NAME => { - self.path() - } - WHITESPACE | LINE_BREAK | COMMA => self.eat(), - L_CURLY => self.curly_group_path(), + Token::LineComment + | Token::Word + | Token::Eq + | Token::LBrack + | Token::RBrack + | Token::CommandName(CommandName::Generic) => self.path(), + Token::Whitespace | Token::LineBreak | Token::Comma => self.eat(), + Token::LCurly => self.curly_group_path(), _ => break, }; } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } @@ -891,9 +714,14 @@ impl<'a> Parser<'a> { while let Some(kind) = self.peek() { match kind { - WHITESPACE | COMMENT | WORD | EQUALITY_SIGN | L_BRACK | R_BRACK - | GENERIC_COMMAND_NAME => self.eat(), - L_CURLY => self.curly_group_path(), + Token::Whitespace + | Token::LineComment + | Token::Word + | Token::Eq + | Token::LBrack + | Token::RBrack + | Token::CommandName(CommandName::Generic) => self.eat(), + Token::LCurly => self.curly_group_path(), _ => break, }; } @@ -943,10 +771,8 @@ impl<'a> Parser<'a> { self.trivia(); for _ in 0..2 { - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } } @@ -957,11 +783,10 @@ impl<'a> Parser<'a> { self.builder.start_node(LABEL_DEFINITION.into()); self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } + self.builder.finish_node(); } @@ -969,11 +794,10 @@ impl<'a> Parser<'a> { self.builder.start_node(LABEL_REFERENCE.into()); self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word_list(); - } else { - self.builder.token(MISSING.into(), ""); } + self.builder.finish_node(); } @@ -983,10 +807,8 @@ impl<'a> Parser<'a> { self.trivia(); for _ in 0..2 { - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } } @@ -997,15 +819,12 @@ impl<'a> Parser<'a> { self.builder.start_node(LABEL_NUMBER.into()); self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group(); - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1016,24 +835,20 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_command(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_word(); - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group(); } } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_impl(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1044,16 +859,12 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_command(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_impl(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1064,16 +875,12 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_key_value(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1084,14 +891,12 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_key_value(); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1102,20 +907,20 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_key_value(); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); } - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group(); } for _ in 0..2 { - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group(); } } @@ -1128,16 +933,12 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_key_value(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1148,14 +949,12 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_key_value(); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1166,23 +965,19 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_word(); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_word(); } @@ -1194,10 +989,8 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1208,22 +1001,16 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1234,21 +1021,17 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_word(); } - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word_list(); - } else { - self.builder.token(MISSING.into(), ""); } for _ in 0..3 { - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } } @@ -1260,10 +1043,8 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word_list(); - } else { - self.builder.token(MISSING.into(), ""); } self.builder.finish_node(); @@ -1274,24 +1055,20 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_word(); - } else { - self.builder.token(MISSING.into(), ""); } - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group_word(); - if self.lexer.peek() == Some(L_BRACK) { + if self.lexer.peek() == Some(Token::LBrack) { self.brack_group(); } } for _ in 0..2 { - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.curly_group_without_environments(); - } else { - self.builder.token(MISSING.into(), ""); } } @@ -1304,25 +1081,31 @@ impl<'a> Parser<'a> { self.trivia(); let checkpoint = self.builder.checkpoint(); - if self.lexer.peek() == Some(L_CURLY) { + if self.lexer.peek() == Some(Token::LCurly) { self.eat(); self.trivia(); if matches!( self.lexer.peek(), - Some(WORD | EQUALITY_SIGN | L_BRACK | R_BRACK | GENERIC_COMMAND_NAME) + Some( + Token::Word + | Token::Eq + | Token::LBrack + | Token::RBrack + | Token::CommandName(CommandName::Generic) + ) ) { self.builder .start_node_at(checkpoint, CURLY_GROUP_WORD.into()); self.path(); } else { self.builder.start_node_at(checkpoint, CURLY_GROUP.into()); - while matches!(self.lexer.peek(), Some(L_CURLY)) { + while matches!(self.lexer.peek(), Some(Token::LCurly)) { self.curly_group_path(); } } - self.expect(R_CURLY); + self.expect(Token::RCurly); self.builder.finish_node(); } diff --git a/support/texlab/src/parser/latex/lexer.rs b/support/texlab/src/parser/latex/lexer.rs index 9b0a6726eb..ee5b8dd328 100644 --- a/support/texlab/src/parser/latex/lexer.rs +++ b/support/texlab/src/parser/latex/lexer.rs @@ -1,641 +1,65 @@ +mod commands; +pub(super) mod types; + use logos::Logos; use crate::syntax::latex::SyntaxKind; -#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, PartialOrd, Ord, Logos)] -#[repr(u16)] -enum RootToken { - #[regex(r"[\r\n]+", priority = 2)] - LineBreak = 2, - - #[regex(r"\s+", priority = 1)] - Whitespace, - - #[regex(r"%[^\r\n]*")] - LineComment, - - #[token("{")] - LCurly, - - #[token("}")] - RCurly, - - #[token("[")] - LBrack, - - #[token("]")] - RBrack, - - #[token("(")] - LParen, - - #[token(")")] - RParen, - - #[token(",")] - Comma, - - #[token("=")] - Eq, - - #[regex(r"[^\s\\%\{\},\$\[\]\(\)=]+")] - #[error] - Word, - - #[regex(r"\$\$?")] - Dollar, - - #[regex(r"\\([^\r\n]|[@a-zA-Z:_]+\*?)?")] - CommandName, - - #[token("\\iffalse")] - BeginBlockComment, - - #[token("\\begin{asy}")] - #[token("\\begin{verbatim}")] - #[token("\\begin{lstlisting}")] - #[token("\\begin{minted}")] - #[token("\\begin{pycode}")] - BeginVerbatimEnvironment, -} - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, PartialOrd, Ord, Logos)] -enum CommandNameToken { - #[token("\\begin")] - BeginEnvironment, - - #[token("\\end")] - EndEnvironment, - - #[token("\\[")] - BeginEquation, - - #[token("\\]")] - EndEquation, - - #[token("\\part")] - #[token("\\part*")] - Part, - - #[token("\\chapter")] - #[token("\\chapter*")] - Chapter, - - #[token("\\section")] - #[token("\\section*")] - Section, - - #[token("\\subsection")] - #[token("\\subsection*")] - Subsection, - - #[token("\\subsubsection")] - #[token("\\subsubsection*")] - Subsubsection, - - #[token("\\paragraph")] - #[token("\\paragraph*")] - Paragraph, - - #[token("\\subparagraph")] - #[token("\\subparagraph*")] - Subparagraph, - - #[token("\\item")] - EnumItem, - - #[token("\\caption")] - Caption, - - #[token("\\cite")] - #[token("\\cite*")] - #[token("\\Cite")] - #[token("\\nocite")] - #[token("\\citet")] - #[token("\\citet*")] - #[token("\\citep")] - #[token("\\citep*")] - #[token("\\citeauthor")] - #[token("\\citeauthor*")] - #[token("\\Citeauthor")] - #[token("\\Citeauthor*")] - #[token("\\citetitle")] - #[token("\\citetitle*")] - #[token("\\citeyear")] - #[token("\\citeyear*")] - #[token("\\citedate")] - #[token("\\citedate*")] - #[token("\\citeurl")] - #[token("\\fullcite")] - #[token("\\citeyearpar")] - #[token("\\citealt")] - #[token("\\citealp")] - #[token("\\citetext")] - #[token("\\parencite")] - #[token("\\parencite*")] - #[token("\\Parencite")] - #[token("\\footcite")] - #[token("\\footfullcite")] - #[token("\\footcitetext")] - #[token("\\textcite")] - #[token("\\Textcite")] - #[token("\\smartcite")] - #[token("\\supercite")] - #[token("\\autocite")] - #[token("\\autocite*")] - #[token("\\Autocite")] - #[token("\\Autocite*")] - #[token("\\volcite")] - #[token("\\Volcite")] - #[token("\\pvolcite")] - #[token("\\Pvolcite")] - #[token("\\fvolcite")] - #[token("\\ftvolcite")] - #[token("\\svolcite")] - #[token("\\Svolcite")] - #[token("\\tvolcite")] - #[token("\\Tvolcite")] - #[token("\\avolcite")] - #[token("\\Avolcite")] - #[token("\\notecite")] - #[token("\\pnotecite")] - #[token("\\Pnotecite")] - #[token("\\fnotecite")] - #[token("\\citeA")] - #[token("\\citeA*")] - Citation, - - #[token("\\usepackage")] - #[token("\\RequirePackage")] - PackageInclude, - - #[token("\\documentclass")] - ClassInclude, - - #[token("\\include")] - #[token("\\subfileinclude")] - #[token("\\input")] - #[token("\\subfile")] - LatexInclude, - - #[token("\\addbibresource")] - BiblatexInclude, - - #[token("\\bibliography")] - BibtexInclude, - - #[token("\\includegraphics")] - GraphicsInclude, - - #[token("\\includesvg")] - SvgInclude, - - #[token("\\includeinkscape")] - InkscapeInclude, - - #[token("\\verbatiminput")] - #[token("\\VerbatimInput")] - VerbatimInclude, - - #[token("\\import")] - #[token("\\subimport")] - #[token("\\inputfrom")] - #[token("\\subinputfrom")] - #[token("\\includefrom")] - #[token("\\subincludefrom")] - Import, - - #[token("\\label")] - LabelDefinition, - - #[token("\\ref")] - #[token("\\vref")] - #[token("\\Vref")] - #[token("\\autoref")] - #[token("\\pageref")] - #[token("\\cref")] - #[token("\\cref*")] - #[token("\\Cref")] - #[token("\\Cref*")] - #[token("\\namecref")] - #[token("\\nameCref")] - #[token("\\lcnamecref")] - #[token("\\namecrefs")] - #[token("\\nameCrefs")] - #[token("\\lcnamecrefs")] - #[token("\\labelcref")] - #[token("\\labelcpageref")] - #[token("\\eqref")] - LabelReference, - - #[token("\\crefrange")] - #[token("\\crefrange*")] - #[token("\\Crefrange")] - #[token("\\Crefrange*")] - LabelReferenceRange, - - #[token("\\newlabel")] - LabelNumber, - - #[token("\\newcommand")] - #[token("\\newcommand*")] - #[token("\\renewcommand")] - #[token("\\renewcommand*")] - #[token("\\DeclareRobustCommand")] - #[token("\\DeclareRobustCommand*")] - CommandDefinition, - - #[token("\\DeclareMathOperator")] - #[token("\\DeclareMathOperator*")] - MathOperator, - - #[token("\\newglossaryentry")] - GlossaryEntryDefinition, - - #[token("\\gls")] - #[token("\\Gls")] - #[token("\\GLS")] - #[token("\\glspl")] - #[token("\\Glspl")] - #[token("\\GLSpl")] - #[token("\\glsdisp")] - #[token("\\glslink")] - #[token("\\glstext")] - #[token("\\Glstext")] - #[token("\\GLStext")] - #[token("\\glsfirst")] - #[token("\\Glsfirst")] - #[token("\\GLSfirst")] - #[token("\\glsplural")] - #[token("\\Glsplural")] - #[token("\\GLSplural")] - #[token("\\glsfirstplural")] - #[token("\\Glsfirstplural")] - #[token("\\GLSfirstplural")] - #[token("\\glsname")] - #[token("\\Glsname")] - #[token("\\GLSname")] - #[token("\\glssymbol")] - #[token("\\Glssymbol")] - #[token("\\glsdesc")] - #[token("\\Glsdesc")] - #[token("\\GLSdesc")] - #[token("\\glsuseri")] - #[token("\\Glsuseri")] - #[token("\\GLSuseri")] - #[token("\\glsuserii")] - #[token("\\Glsuserii")] - #[token("\\glsuseriii")] - #[token("\\glsuseriv")] - #[token("\\Glsuseriv")] - #[token("\\GLSuseriv")] - #[token("\\glsuserv")] - #[token("\\Glsuserv")] - #[token("\\GLSuserv")] - #[token("\\glsuservi")] - #[token("\\Glsuservi")] - #[token("\\GLSuservi")] - GlossaryEntryReference, - - #[token("\\newacronym")] - #[token("\\newacro")] - #[token("\\acrodef")] - #[token("\\acro")] - #[token("\\newacroindefinite")] - #[token("\\acrodefindefinite")] - #[token("\\acroindefinite")] - #[token("\\acroplural")] - #[token("\\newacroplural")] - #[token("\\acrodefplural")] - AcronymDefinition, - - #[token("\\DeclareAcronym")] - AcronymDeclaration, - - #[token("\\acrshort")] - #[token("\\Acrshort")] - #[token("\\ACRshort")] - #[token("\\acrshortpl")] - #[token("\\Acrshortpl")] - #[token("\\ACRshortpl")] - #[token("\\acrlong")] - #[token("\\Acrlong")] - #[token("\\ACRlong")] - #[token("\\acrlongpl")] - #[token("\\Acrlongpl")] - #[token("\\ACRlongpl")] - #[token("\\acrfull")] - #[token("\\Acrfull")] - #[token("\\ACRfull")] - #[token("\\acrfullpl")] - #[token("\\Acrfullpl")] - #[token("\\ACRfullpl")] - #[token("\\acs")] - #[token("\\Acs")] - #[token("\\acsp")] - #[token("\\Acsp")] - #[token("\\acl")] - #[token("\\Acl")] - #[token("\\aclp")] - #[token("\\Aclp")] - #[token("\\acf")] - #[token("\\Acf")] - #[token("\\acfi")] - #[token("\\Acfi")] - #[token("\\acfp")] - #[token("\\Acfp")] - #[token("\\ac")] - #[token("\\Ac")] - #[token("\\acp")] - #[token("\\Acp")] - #[token("\\acused")] - #[token("\\acsu")] - #[token("\\Aclu")] - #[token("\\iac")] - #[token("\\Iac")] - #[token("\\acs*")] - #[token("\\Acs*")] - #[token("\\acsp*")] - #[token("\\Acsp*")] - #[token("\\acl*")] - #[token("\\Acl*")] - #[token("\\aclp*")] - #[token("\\Aclp*")] - #[token("\\acf*")] - #[token("\\Acf*")] - #[token("\\acfi*")] - #[token("\\Acfi*")] - #[token("\\acfp*")] - #[token("\\Acfp*")] - #[token("\\ac*")] - #[token("\\Ac*")] - #[token("\\acp*")] - #[token("\\Acp*")] - #[token("\\acused*")] - #[token("\\acsu*")] - #[token("\\Aclu*")] - #[token("\\iac*")] - #[token("\\Iac*")] - #[token("\\glsentrylong")] - #[token("\\Glsentrylong")] - #[token("\\glsentrylongpl")] - #[token("\\Glsentrylongpl")] - #[token("\\glsentryshort")] - #[token("\\Glsentryshort")] - #[token("\\glsentryshortpl")] - #[token("\\Glsentryshortpl")] - #[token("\\glsentryfullpl")] - #[token("\\Glsentryfullpl")] - AcronymReference, - - #[token("\\newtheorem")] - #[token("\\newtheorem*")] - #[token("\\declaretheorem")] - #[token("\\declaretheorem*")] - TheoremDefinition, - - #[token("\\color")] - #[token("\\colorbox")] - #[token("\\textcolor")] - #[token("\\pagecolor")] - ColorReference, - - #[token("\\definecolor")] - ColorDefinition, - - #[token("\\definecolorset")] - ColorSetDefinition, - - #[token("\\usepgflibrary")] - #[token("\\usetikzlibrary")] - TikzLibraryImport, - - #[token("\\newenvironment")] - #[token("\\newenvironment*")] - #[token("\\renewenvironment")] - #[token("\\renewenvironment*")] - EnvironmentDefinition, - - #[token("\\graphicspath")] - GraphicsPath, - - #[token("\\fi")] - EndBlockComment, - - #[regex(r"\\([^\r\n]|[@a-zA-Z:_]+\*?)?")] - #[error] - Generic, -} - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, PartialOrd, Ord, Logos)] -enum BlockCommentToken { - #[token("\\fi")] - End, - - #[regex(r"\\([^\r\n]|[@a-zA-Z:_]+\*?)?")] - #[regex(r"[^\\]+")] - #[error] - Verbatim, -} - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, PartialOrd, Ord, Logos)] -enum VerbatimEnvironmentToken { - #[token("\\end{asy}")] - #[token("\\end{verbatim}")] - #[token("\\end{lstlisting}")] - #[token("\\end{minted}")] - #[token("\\end{pycode}")] - End, - - #[regex(r"\\([^\r\n]|[@a-zA-Z:_]+\*?)?")] - #[regex(r"[^\\]+")] - #[error] - Verbatim, -} +use self::types::{CommandName, Token}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct Lexer<'a> { - tokens: Vec<(SyntaxKind, &'a str)>, + tokens: Vec<(Token, &'a str)>, } impl<'a> Lexer<'a> { pub fn new(input: &'a str) -> Self { - let mut tokens = Vec::new(); - tokenize(input, &mut tokens); + let mut tokens = tokenize(input); tokens.reverse(); Self { tokens } } - pub fn peek(&self) -> Option { + pub fn peek(&self) -> Option { self.tokens.last().map(|(kind, _)| *kind) } pub fn eat(&mut self) -> Option<(SyntaxKind, &'a str)> { - self.tokens.pop() - } -} - -fn tokenize<'a>(input: &'a str, tokens: &mut Vec<(SyntaxKind, &'a str)>) { - let mut lexer = RootToken::lexer(input); - while let Some(kind) = lexer.next() { - let text = lexer.slice(); - match kind { - RootToken::LineBreak => { - tokens.push((SyntaxKind::LINE_BREAK, text)); - } - RootToken::Whitespace => { - tokens.push((SyntaxKind::WHITESPACE, text)); - } - RootToken::LineComment => { - tokens.push((SyntaxKind::COMMENT, text)); - } - RootToken::LCurly => { - tokens.push((SyntaxKind::L_CURLY, text)); - } - RootToken::RCurly => { - tokens.push((SyntaxKind::R_CURLY, text)); - } - RootToken::LBrack => { - tokens.push((SyntaxKind::L_BRACK, text)); - } - RootToken::RBrack => { - tokens.push((SyntaxKind::R_BRACK, text)); - } - RootToken::LParen => { - tokens.push((SyntaxKind::L_PAREN, text)); - } - RootToken::RParen => { - tokens.push((SyntaxKind::R_PAREN, text)); - } - RootToken::Comma => { - tokens.push((SyntaxKind::COMMA, text)); - } - RootToken::Eq => { - tokens.push((SyntaxKind::EQUALITY_SIGN, text)); - } - RootToken::Word => { - tokens.push((SyntaxKind::WORD, text)); - } - RootToken::Dollar => { - tokens.push((SyntaxKind::DOLLAR, text)); - } - RootToken::CommandName => { - let kind = tokenize_command_name(text); - tokens.push((kind, text)); - } - RootToken::BeginBlockComment => { - tokens.push((SyntaxKind::BEGIN_BLOCK_COMMENT_NAME, text)); - let end = lexer.span().end; - lexer = RootToken::lexer(tokenize_block_comment(&lexer.source()[end..], tokens)); - } - RootToken::BeginVerbatimEnvironment => { - tokens.push((SyntaxKind::BEGIN_ENVIRONMENT_NAME, "\\begin")); - tokens.push((SyntaxKind::L_CURLY, "{")); - tokens.push((SyntaxKind::WORD, &text["\\begin{".len()..text.len() - 1])); - tokens.push((SyntaxKind::R_CURLY, "}")); - let end = lexer.span().end; - lexer = RootToken::lexer(tokenize_verbatim_environment( - &lexer.source()[end..], - tokens, - )); - } - } - } -} - -fn tokenize_command_name(text: &str) -> SyntaxKind { - let mut lexer = CommandNameToken::lexer(text); - match lexer.next().unwrap() { - CommandNameToken::BeginEnvironment => SyntaxKind::BEGIN_ENVIRONMENT_NAME, - CommandNameToken::EndEnvironment => SyntaxKind::END_ENVIRONMENT_NAME, - CommandNameToken::BeginEquation => SyntaxKind::BEGIN_EQUATION_NAME, - CommandNameToken::EndEquation => SyntaxKind::END_EQUATION_NAME, - CommandNameToken::Part => SyntaxKind::PART_NAME, - CommandNameToken::Chapter => SyntaxKind::CHAPTER_NAME, - CommandNameToken::Section => SyntaxKind::SECTION_NAME, - CommandNameToken::Subsection => SyntaxKind::SUBSECTION_NAME, - CommandNameToken::Subsubsection => SyntaxKind::SUBSUBSECTION_NAME, - CommandNameToken::Paragraph => SyntaxKind::PARAGRAPH_NAME, - CommandNameToken::Subparagraph => SyntaxKind::SUBPARAGRAPH_NAME, - CommandNameToken::EnumItem => SyntaxKind::ENUM_ITEM_NAME, - CommandNameToken::Caption => SyntaxKind::CAPTION_NAME, - CommandNameToken::Citation => SyntaxKind::CITATION_NAME, - CommandNameToken::PackageInclude => SyntaxKind::PACKAGE_INCLUDE_NAME, - CommandNameToken::ClassInclude => SyntaxKind::CLASS_INCLUDE_NAME, - CommandNameToken::LatexInclude => SyntaxKind::LATEX_INCLUDE_NAME, - CommandNameToken::BiblatexInclude => SyntaxKind::BIBLATEX_INCLUDE_NAME, - CommandNameToken::BibtexInclude => SyntaxKind::BIBTEX_INCLUDE_NAME, - CommandNameToken::GraphicsInclude => SyntaxKind::GRAPHICS_INCLUDE_NAME, - CommandNameToken::SvgInclude => SyntaxKind::SVG_INCLUDE_NAME, - CommandNameToken::InkscapeInclude => SyntaxKind::INKSCAPE_INCLUDE_NAME, - CommandNameToken::VerbatimInclude => SyntaxKind::VERBATIM_INCLUDE_NAME, - CommandNameToken::Import => SyntaxKind::IMPORT_NAME, - CommandNameToken::LabelDefinition => SyntaxKind::LABEL_DEFINITION_NAME, - CommandNameToken::LabelReference => SyntaxKind::LABEL_REFERENCE_NAME, - CommandNameToken::LabelReferenceRange => SyntaxKind::LABEL_REFERENCE_RANGE_NAME, - CommandNameToken::LabelNumber => SyntaxKind::LABEL_NUMBER_NAME, - CommandNameToken::CommandDefinition => SyntaxKind::COMMAND_DEFINITION_NAME, - CommandNameToken::MathOperator => SyntaxKind::MATH_OPERATOR_NAME, - CommandNameToken::GlossaryEntryDefinition => SyntaxKind::GLOSSARY_ENTRY_DEFINITION_NAME, - CommandNameToken::GlossaryEntryReference => SyntaxKind::GLOSSARY_ENTRY_REFERENCE_NAME, - CommandNameToken::AcronymDefinition => SyntaxKind::ACRONYM_DEFINITION_NAME, - CommandNameToken::AcronymDeclaration => SyntaxKind::ACRONYM_DECLARATION_NAME, - CommandNameToken::AcronymReference => SyntaxKind::ACRONYM_REFERENCE_NAME, - CommandNameToken::TheoremDefinition => SyntaxKind::THEOREM_DEFINITION_NAME, - CommandNameToken::ColorReference => SyntaxKind::COLOR_REFERENCE_NAME, - CommandNameToken::ColorDefinition => SyntaxKind::COLOR_DEFINITION_NAME, - CommandNameToken::ColorSetDefinition => SyntaxKind::COLOR_SET_DEFINITION_NAME, - CommandNameToken::TikzLibraryImport => SyntaxKind::TIKZ_LIBRARY_IMPORT_NAME, - CommandNameToken::EnvironmentDefinition => SyntaxKind::ENVIRONMENT_DEFINITION_NAME, - CommandNameToken::EndBlockComment => SyntaxKind::END_BLOCK_COMMENT_NAME, - CommandNameToken::GraphicsPath => SyntaxKind::GRAPHICS_PATH_NAME, - CommandNameToken::Generic => SyntaxKind::GENERIC_COMMAND_NAME, - } -} - -fn tokenize_block_comment<'a>(input: &'a str, tokens: &mut Vec<(SyntaxKind, &'a str)>) -> &'a str { - let mut lexer = BlockCommentToken::lexer(input); - let mut end = 0; - while let Some(kind) = lexer.next() { - match kind { - BlockCommentToken::Verbatim => { - end = lexer.span().end; - } - BlockCommentToken::End => { - end = lexer.span().start; - break; - } + let (kind, text) = self.tokens.pop()?; + let kind = match kind { + Token::LineBreak => SyntaxKind::LINE_BREAK, + Token::Whitespace => SyntaxKind::WHITESPACE, + Token::LineComment => SyntaxKind::COMMENT, + Token::LCurly => SyntaxKind::L_CURLY, + Token::RCurly => SyntaxKind::R_CURLY, + Token::LBrack => SyntaxKind::L_BRACK, + Token::RBrack => SyntaxKind::R_BRACK, + Token::LParen => SyntaxKind::L_PAREN, + Token::RParen => SyntaxKind::R_PAREN, + Token::Comma => SyntaxKind::COMMA, + Token::Eq => SyntaxKind::EQUALITY_SIGN, + Token::Word => SyntaxKind::WORD, + Token::Dollar => SyntaxKind::DOLLAR, + Token::CommandName(_) => SyntaxKind::COMMAND_NAME, }; - } - if end > 0 { - tokens.push((SyntaxKind::VERBATIM, &input[..end])); + Some((kind, text)) } - - &input[end..] } -fn tokenize_verbatim_environment<'a>( - input: &'a str, - tokens: &mut Vec<(SyntaxKind, &'a str)>, -) -> &'a str { - let mut lexer = VerbatimEnvironmentToken::lexer(input); - let mut end = 0; - while let Some(kind) = lexer.next() { - match kind { - VerbatimEnvironmentToken::Verbatim => { - end = lexer.span().end; - } - VerbatimEnvironmentToken::End => { - end = lexer.span().start; - break; - } - }; - } - - if end > 0 { - tokens.push((SyntaxKind::VERBATIM, &input[..end])); - } - - &input[end..] +fn tokenize(input: &str) -> Vec<(Token, &str)> { + let mut lexer = Token::lexer(input); + std::iter::from_fn(move || { + let kind = lexer.next()?; + let text = lexer.slice(); + Some((kind, text)) + }) + .map(|(kind, text)| { + if kind == Token::CommandName(CommandName::Generic) { + let name = commands::classify(&text[1..]); + (Token::CommandName(name), text) + } else { + (kind, text) + } + }) + .collect() } diff --git a/support/texlab/src/parser/latex/lexer/commands.rs b/support/texlab/src/parser/latex/lexer/commands.rs new file mode 100644 index 0000000000..ba609f5d7f --- /dev/null +++ b/support/texlab/src/parser/latex/lexer/commands.rs @@ -0,0 +1,93 @@ +use super::types::{CommandName, SectionLevel}; + +pub fn classify(name: &str) -> CommandName { + match name { + "begin" => CommandName::BeginEnvironment, + "end" => CommandName::EndEnvironment, + "[" => CommandName::BeginEquation, + "]" => CommandName::EndEquation, + "part" | "part*" => CommandName::Section(SectionLevel::Part), + "chapter" | "chapter*" => CommandName::Section(SectionLevel::Chapter), + "section" | "section*" => CommandName::Section(SectionLevel::Section), + "subsection" | "subsection*" => CommandName::Section(SectionLevel::Subsection), + "subsubsection" | "subsubsection*" => CommandName::Section(SectionLevel::Subsubsection), + "paragraph" | "paragraph*" => CommandName::Section(SectionLevel::Paragraph), + "subparagraph" | "subparagraph*" => CommandName::Section(SectionLevel::Subparagraph), + "item" => CommandName::EnumItem, + "caption" => CommandName::Caption, + "cite" | "cite*" | "Cite" | "nocite" | "citet" | "citet*" | "citep" | "citep*" + | "citeauthor" | "citeauthor*" | "Citeauthor" | "Citeauthor*" | "citetitle" + | "citetitle*" | "citeyear" | "citeyear*" | "citedate" | "citedate*" | "citeurl" + | "fullcite" | "citeyearpar" | "citealt" | "citealp" | "citetext" | "parencite" + | "parencite*" | "Parencite" | "footcite" | "footfullcite" | "footcitetext" + | "textcite" | "Textcite" | "smartcite" | "supercite" | "autocite" | "autocite*" + | "Autocite" | "Autocite*" | "volcite" | "Volcite" | "pvolcite" | "Pvolcite" + | "fvolcite" | "ftvolcite" | "svolcite" | "Svolcite" | "tvolcite" | "Tvolcite" + | "avolcite" | "Avolcite" | "notecite" | "pnotecite" | "Pnotecite" | "fnotecite" + | "citeA" | "citeA*" => CommandName::Citation, + "usepackage" | "RequirePackage" => CommandName::PackageInclude, + "documentclass" => CommandName::ClassInclude, + "include" | "subfileinclude" | "input" | "subfile" => CommandName::LatexInclude, + "addbibresource" => CommandName::BiblatexInclude, + "bibliography" => CommandName::BibtexInclude, + "includegraphics" => CommandName::GraphicsInclude, + "includesvg" => CommandName::SvgInclude, + "includeinkscape" => CommandName::InkscapeInclude, + "verbatiminput" | "VerbatimInput" => CommandName::VerbatimInclude, + "import" | "subimport" | "inputfrom" | "subinputfrom" | "subincludefrom" => { + CommandName::Import + } + "label" => CommandName::LabelDefinition, + "ref" | "vref" | "Vref" | "autoref" | "pageref" | "cref" | "cref*" | "Cref" | "Cref*" + | "namecref" | "nameCref" | "lcnamecref" | "namecrefs" | "nameCrefs" | "lcnamecrefs" + | "labelcref" | "labelcpageref" | "eqref" => CommandName::LabelReference, + "crefrange" | "crefrange*" | "Crefrange" | "Crefrange*" => CommandName::LabelReferenceRange, + "newlabel" => CommandName::LabelNumber, + "newcommand" + | "newcommand*" + | "renewcommand" + | "renewcommand*" + | "DeclareRobustCommand" + | "DeclareRobustCommand*" => CommandName::CommandDefinition, + "DeclareMathOperator" | "DeclareMathOperator*" => CommandName::MathOperator, + "newglossaryentry" => CommandName::GlossaryEntryDefinition, + "gls" | "Gls" | "GLS" | "glspl" | "Glspl" | "GLSpl" | "glsdisp" | "glslink" | "glstext" + | "Glstext" | "GLStext" | "glsfirst" | "Glsfirst" | "GLSfirst" | "glsplural" + | "Glsplural" | "GLSplural" | "glsfirstplural" | "Glsfirstplural" | "GLSfirstplural" + | "glsname" | "Glsname" | "GLSname" | "glssymbol" | "Glssymbol" | "glsdesc" | "Glsdesc" + | "GLSdesc" | "glsuseri" | "Glsuseri" | "GLSuseri" | "glsuserii" | "Glsuserii" + | "glsuseriii" | "glsuseriv" | "Glsuseriv" | "GLSuseriv" | "glsuserv" | "Glsuserv" + | "GLSuserv" | "glsuservi" | "Glsuservi" | "GLSuservi" => { + CommandName::GlossaryEntryReference + } + "newacronym" | "newacro" | "acrodef" | "acro" | "newacroindefinite" + | "acrodefindefinite" | "acroindefinite" | "acroplural" | "newacroplural" + | "acrodefplural" => CommandName::AcronymDefinition, + "DeclareAcronym" => CommandName::AcronymDeclaration, + "acrshort" | "Acrshort" | "ACRshort" | "acrshortpl" | "Acrshortpl" | "ACRshortpl" + | "acrlong" | "Acrlong" | "ACRlong" | "acrlongpl" | "Acrlongpl" | "ACRlongpl" + | "acrfull" | "Acrfull" | "ACRfull" | "acrfullpl" | "Acrfullpl" | "ACRfullpl" | "acs" + | "Acs" | "acsp" | "Acsp" | "acl" | "Acl" | "aclp" | "Aclp" | "acf" | "Acf" | "acfi" + | "Acfi" | "acfp" | "Acfp" | "ac" | "Ac" | "acp" | "Acp" | "acused" | "acsu" | "Aclu" + | "iac" | "Iac" | "acs*" | "Acs*" | "acsp*" | "Acsp*" | "acl*" | "Acl*" | "aclp*" + | "Aclp*" | "acf*" | "Acf*" | "acfi*" | "Acfi*" | "acfp*" | "Acfp*" | "ac*" | "Ac*" + | "acp*" | "Acp*" | "acused*" | "acsu*" | "Aclu*" | "iac*" | "Iac*" | "glsentrylong" + | "Glsentrylong" | "glsentrylongpl" | "Glsentrylongpl" | "glsentryshort" + | "Glsentryshort" | "glsentryshortpl" | "Glsentryshortpl" | "glsentryfullpl" + | "Glsentryfullpl" => CommandName::AcronymReference, + "newtheorem" | "newtheorem*" | "declaretheorem" | "declaretheorem*" => { + CommandName::TheoremDefinition + } + "color" | "colorbox" | "textcolor" | "pagecolor" => CommandName::ColorReference, + "definecolor" => CommandName::ColorDefinition, + "definecolorset" => CommandName::ColorSetDefinition, + "usepgflibrary" | "usetikzlibrary" => CommandName::TikzLibraryImport, + "newenvironment" | "newenvironment*" | "renewenvironment" | "renewenvironment*" => { + CommandName::EnvironmentDefinition + } + "graphicspath" => CommandName::GraphicsPath, + "iffalse" => CommandName::BeginBlockComment, + "fi" => CommandName::EndBlockComment, + _ => CommandName::Generic, + } +} diff --git a/support/texlab/src/parser/latex/lexer/types.rs b/support/texlab/src/parser/latex/lexer/types.rs new file mode 100644 index 0000000000..4355c021c1 --- /dev/null +++ b/support/texlab/src/parser/latex/lexer/types.rs @@ -0,0 +1,132 @@ +use logos::Logos; + +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Logos)] +pub enum Token { + #[regex(r"[\r\n]+", priority = 2)] + LineBreak, + + #[regex(r"[^\S\r\n]+", priority = 1)] + Whitespace, + + #[regex(r"%[^\r\n]*")] + LineComment, + + #[token("{")] + LCurly, + + #[token("}")] + RCurly, + + #[token("[")] + LBrack, + + #[token("]")] + RBrack, + + #[token("(")] + LParen, + + #[token(")")] + RParen, + + #[token(",")] + Comma, + + #[token("=")] + Eq, + + #[regex(r"[^\s\\%\{\},\$\[\]\(\)=]+")] + #[error] + Word, + + #[regex(r"\$\$?")] + Dollar, + + #[regex(r"\\", lex_command_name)] + CommandName(CommandName), +} + +fn lex_command_name(lexer: &mut logos::Lexer) -> CommandName { + let input = &lexer.source()[lexer.span().end..]; + + let mut chars = input.chars(); + let Some(c) = chars.next() else { return CommandName::Generic }; + lexer.bump(c.len_utf8()); + if !c.is_alphanumeric() && c != '@' { + return CommandName::Generic; + } + + while let Some(c) = chars.next() { + match c { + '*' => { + lexer.bump(c.len_utf8()); + break; + } + c if c.is_alphanumeric() => { + lexer.bump(c.len_utf8()); + } + '@' | ':' | '_' => { + lexer.bump(c.len_utf8()); + } + _ => { + break; + } + }; + } + + CommandName::Generic +} + +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] +pub enum CommandName { + Generic, + BeginEnvironment, + EndEnvironment, + BeginEquation, + EndEquation, + Section(SectionLevel), + EnumItem, + Caption, + Citation, + PackageInclude, + ClassInclude, + LatexInclude, + BiblatexInclude, + BibtexInclude, + GraphicsInclude, + SvgInclude, + InkscapeInclude, + VerbatimInclude, + Import, + LabelDefinition, + LabelReference, + LabelReferenceRange, + LabelNumber, + CommandDefinition, + MathOperator, + GlossaryEntryDefinition, + GlossaryEntryReference, + AcronymDefinition, + AcronymDeclaration, + AcronymReference, + TheoremDefinition, + ColorReference, + ColorDefinition, + ColorSetDefinition, + TikzLibraryImport, + EnvironmentDefinition, + GraphicsPath, + BeginBlockComment, + EndBlockComment, +} + +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] +pub enum SectionLevel { + Part, + Chapter, + Section, + Subsection, + Subsubsection, + Paragraph, + Subparagraph, +} diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@block_comments.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@block_comments.txt.snap index 14c73e7da5..1a12800267 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@block_comments.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@block_comments.txt.snap @@ -9,17 +9,21 @@ ROOT@0..48 WORD@0..3 "Foo" LINE_BREAK@3..4 "\n" BLOCK_COMMENT@4..22 - BEGIN_BLOCK_COMMENT_NAME@4..12 "\\iffalse" - VERBATIM@12..19 "\nTest1\n" - END_BLOCK_COMMENT_NAME@19..22 "\\fi" + COMMAND_NAME@4..12 "\\iffalse" + LINE_BREAK@12..13 "\n" + WORD@13..18 "Test1" + LINE_BREAK@18..19 "\n" + COMMAND_NAME@19..22 "\\fi" LINE_BREAK@22..23 "\n" TEXT@23..27 WORD@23..26 "Bar" LINE_BREAK@26..27 "\n" BLOCK_COMMENT@27..44 - BEGIN_BLOCK_COMMENT_NAME@27..35 "\\iffalse" - VERBATIM@35..41 "\n\\fii\n" - END_BLOCK_COMMENT_NAME@41..44 "\\fi" + COMMAND_NAME@27..35 "\\iffalse" + LINE_BREAK@35..36 "\n" + COMMAND_NAME@36..40 "\\fii" + LINE_BREAK@40..41 "\n" + COMMAND_NAME@41..44 "\\fi" LINE_BREAK@44..45 "\n" TEXT@45..48 WORD@45..48 "Baz" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default.txt.snap index 33e119c524..8b314f42ad 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/caption/caption_default.txt ROOT@0..27 PREAMBLE@0..27 CAPTION@0..27 - CAPTION_NAME@0..8 "\\caption" + COMMAND_NAME@0..8 "\\caption" BRACK_GROUP@8..13 L_BRACK@8..9 "[" TEXT@9..12 @@ -18,7 +18,7 @@ ROOT@0..27 WORD@14..17 "Foo" WHITESPACE@17..18 " " GENERIC_COMMAND@18..23 - GENERIC_COMMAND_NAME@18..22 "\\Bar" + COMMAND_NAME@18..22 "\\Bar" WHITESPACE@22..23 " " TEXT@23..26 WORD@23..26 "Baz" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default_error.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default_error.txt.snap index a016dcebed..9bbabd4b56 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default_error.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_default_error.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/caption/caption_default_error.txt ROOT@0..26 PREAMBLE@0..26 CAPTION@0..26 - CAPTION_NAME@0..8 "\\caption" + COMMAND_NAME@0..8 "\\caption" BRACK_GROUP@8..13 L_BRACK@8..9 "[" TEXT@9..12 @@ -18,9 +18,8 @@ ROOT@0..26 WORD@14..17 "Foo" WHITESPACE@17..18 " " GENERIC_COMMAND@18..23 - GENERIC_COMMAND_NAME@18..22 "\\Bar" + COMMAND_NAME@18..22 "\\Bar" WHITESPACE@22..23 " " TEXT@23..26 WORD@23..26 "Baz" - MISSING@26..26 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_figure.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_figure.txt.snap index 9303bd3ebe..4e12380396 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_figure.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_figure.txt.snap @@ -7,21 +7,21 @@ ROOT@0..39 PREAMBLE@0..39 ENVIRONMENT@0..39 BEGIN@0..14 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" + COMMAND_NAME@0..6 "\\begin" CURLY_GROUP_WORD@6..14 L_CURLY@6..7 "{" KEY@7..13 WORD@7..13 "figure" R_CURLY@13..14 "}" CAPTION@14..27 - CAPTION_NAME@14..22 "\\caption" + COMMAND_NAME@14..22 "\\caption" CURLY_GROUP@22..27 L_CURLY@22..23 "{" TEXT@23..26 WORD@23..26 "Foo" R_CURLY@26..27 "}" END@27..39 - END_ENVIRONMENT_NAME@27..31 "\\end" + COMMAND_NAME@27..31 "\\end" CURLY_GROUP_WORD@31..39 L_CURLY@31..32 "{" KEY@32..38 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal.txt.snap index 6af368cc21..9e0769dd57 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal.txt.snap @@ -6,14 +6,14 @@ input_file: src/parser/test_data/latex/caption/caption_minimal.txt ROOT@0..22 PREAMBLE@0..22 CAPTION@0..22 - CAPTION_NAME@0..8 "\\caption" + COMMAND_NAME@0..8 "\\caption" CURLY_GROUP@8..22 L_CURLY@8..9 "{" TEXT@9..13 WORD@9..12 "Foo" WHITESPACE@12..13 " " GENERIC_COMMAND@13..18 - GENERIC_COMMAND_NAME@13..17 "\\Bar" + COMMAND_NAME@13..17 "\\Bar" WHITESPACE@17..18 " " TEXT@18..21 WORD@18..21 "Baz" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal_error.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal_error.txt.snap index 68fc629613..845f1f3682 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal_error.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@caption__caption_minimal_error.txt.snap @@ -6,16 +6,15 @@ input_file: src/parser/test_data/latex/caption/caption_minimal_error.txt ROOT@0..21 PREAMBLE@0..21 CAPTION@0..21 - CAPTION_NAME@0..8 "\\caption" + COMMAND_NAME@0..8 "\\caption" CURLY_GROUP@8..21 L_CURLY@8..9 "{" TEXT@9..13 WORD@9..12 "Foo" WHITESPACE@12..13 " " GENERIC_COMMAND@13..18 - GENERIC_COMMAND_NAME@13..17 "\\Bar" + COMMAND_NAME@13..17 "\\Bar" WHITESPACE@17..18 " " TEXT@18..21 WORD@18..21 "Baz" - MISSING@21..21 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_empty.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_empty.txt.snap index fbf2b5123e..c075d59f77 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_empty.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_empty.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/citation/citation_empty.txt ROOT@0..7 PREAMBLE@0..7 CITATION@0..7 - CITATION_NAME@0..5 "\\cite" + COMMAND_NAME@0..5 "\\cite" CURLY_GROUP_WORD_LIST@5..7 L_CURLY@5..6 "{" R_CURLY@6..7 "}" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_missing_brace.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_missing_brace.txt.snap index 72bd618594..1a2993bfeb 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_missing_brace.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_missing_brace.txt.snap @@ -6,10 +6,9 @@ input_file: src/parser/test_data/latex/citation/citation_missing_brace.txt ROOT@0..9 PREAMBLE@0..9 CITATION@0..9 - CITATION_NAME@0..5 "\\cite" + COMMAND_NAME@0..5 "\\cite" CURLY_GROUP_WORD_LIST@5..9 L_CURLY@5..6 "{" KEY@6..9 WORD@6..9 "foo" - MISSING@9..9 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_multiple_keys.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_multiple_keys.txt.snap index 81716cf8b1..92ad9815e4 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_multiple_keys.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_multiple_keys.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/citation/citation_multiple_keys.txt ROOT@0..15 PREAMBLE@0..15 CITATION@0..15 - CITATION_NAME@0..5 "\\cite" + COMMAND_NAME@0..5 "\\cite" CURLY_GROUP_WORD_LIST@5..15 L_CURLY@5..6 "{" KEY@6..9 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote.txt.snap index f5afdca536..a14278731f 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/citation/citation_prenote.txt ROOT@0..15 PREAMBLE@0..15 CITATION@0..15 - CITATION_NAME@0..5 "\\cite" + COMMAND_NAME@0..5 "\\cite" BRACK_GROUP@5..10 L_BRACK@5..6 "[" TEXT@6..9 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote_postnote.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote_postnote.txt.snap index feecca0435..96c3996286 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote_postnote.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_prenote_postnote.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/citation/citation_prenote_postnote.txt ROOT@0..20 PREAMBLE@0..20 CITATION@0..20 - CITATION_NAME@0..5 "\\cite" + COMMAND_NAME@0..5 "\\cite" BRACK_GROUP@5..10 L_BRACK@5..6 "[" TEXT@6..9 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_redundant_comma.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_redundant_comma.txt.snap index 2a8acd1173..d97fad470c 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_redundant_comma.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_redundant_comma.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/citation/citation_redundant_comma.txt ROOT@0..12 PREAMBLE@0..12 CITATION@0..12 - CITATION_NAME@0..5 "\\cite" + COMMAND_NAME@0..5 "\\cite" CURLY_GROUP_WORD_LIST@5..12 L_CURLY@5..6 "{" COMMA@6..7 "," diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_simple.txt.snap index faa2e07155..3e2bb4cdf8 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/citation/citation_simple.txt ROOT@0..10 PREAMBLE@0..10 CITATION@0..10 - CITATION_NAME@0..5 "\\cite" + COMMAND_NAME@0..5 "\\cite" CURLY_GROUP_WORD_LIST@5..10 L_CURLY@5..6 "{" KEY@6..9 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_star.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_star.txt.snap index 3bcd74701c..7ab875d747 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_star.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@citation__citation_star.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/citation/citation_star.txt ROOT@0..10 PREAMBLE@0..10 CITATION@0..10 - CITATION_NAME@0..7 "\\nocite" + COMMAND_NAME@0..7 "\\nocite" CURLY_GROUP_WORD_LIST@7..10 L_CURLY@7..8 "{" KEY@8..9 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_definition_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_definition_simple.txt.snap index 163ea09071..92ec32991d 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_definition_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_definition_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/color/color_definition_simple.txt ROOT@0..33 PREAMBLE@0..33 COLOR_DEFINITION@0..33 - COLOR_DEFINITION_NAME@0..12 "\\definecolor" + COMMAND_NAME@0..12 "\\definecolor" CURLY_GROUP_WORD@12..17 L_CURLY@12..13 "{" KEY@13..16 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_reference_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_reference_simple.txt.snap index 0c68b5eae0..0033103085 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_reference_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_reference_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/color/color_reference_simple.txt ROOT@0..13 PREAMBLE@0..13 COLOR_REFERENCE@0..13 - COLOR_REFERENCE_NAME@0..6 "\\color" + COMMAND_NAME@0..6 "\\color" CURLY_GROUP_WORD@6..13 L_CURLY@6..7 "{" KEY@7..12 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error1.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error1.txt.snap index 2e3be43ecb..017f8aef82 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error1.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error1.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/color/color_set_definition_error1.txt ROOT@0..39 PREAMBLE@0..39 COLOR_SET_DEFINITION@0..39 - COLOR_SET_DEFINITION_NAME@0..15 "\\definecolorset" + COMMAND_NAME@0..15 "\\definecolorset" BRACK_GROUP_WORD@15..19 L_BRACK@15..16 "[" KEY@16..18 @@ -30,5 +30,4 @@ ROOT@0..39 KEY@35..38 WORD@35..38 "bar" R_CURLY@38..39 "}" - MISSING@39..39 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error2.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error2.txt.snap index ee15174688..984dfcbabb 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error2.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error2.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/color/color_set_definition_error2.txt ROOT@0..30 PREAMBLE@0..30 COLOR_SET_DEFINITION@0..30 - COLOR_SET_DEFINITION_NAME@0..15 "\\definecolorset" + COMMAND_NAME@0..15 "\\definecolorset" CURLY_GROUP_WORD_LIST@15..25 L_CURLY@15..16 "{" KEY@16..19 @@ -20,6 +20,4 @@ ROOT@0..30 KEY@26..29 WORD@26..29 "foo" R_CURLY@29..30 "}" - MISSING@30..30 "" - MISSING@30..30 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error3.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error3.txt.snap index 3416786dda..67fc1ed0bb 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error3.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error3.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/color/color_set_definition_error3.txt ROOT@0..25 PREAMBLE@0..25 COLOR_SET_DEFINITION@0..25 - COLOR_SET_DEFINITION_NAME@0..15 "\\definecolorset" + COMMAND_NAME@0..15 "\\definecolorset" CURLY_GROUP_WORD_LIST@15..25 L_CURLY@15..16 "{" KEY@16..19 @@ -15,7 +15,4 @@ ROOT@0..25 KEY@20..24 WORD@20..24 "HTML" R_CURLY@24..25 "}" - MISSING@25..25 "" - MISSING@25..25 "" - MISSING@25..25 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error4.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error4.txt.snap index 5c16d9d7a5..e939ab2230 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error4.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_error4.txt.snap @@ -6,9 +6,5 @@ input_file: src/parser/test_data/latex/color/color_set_definition_error4.txt ROOT@0..15 PREAMBLE@0..15 COLOR_SET_DEFINITION@0..15 - COLOR_SET_DEFINITION_NAME@0..15 "\\definecolorset" - MISSING@15..15 "" - MISSING@15..15 "" - MISSING@15..15 "" - MISSING@15..15 "" + COMMAND_NAME@0..15 "\\definecolorset" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_simple.txt.snap index a4cff9c7a1..b699543115 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@color__color_set_definition_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/color/color_set_definition_simple.txt ROOT@0..44 PREAMBLE@0..44 COLOR_SET_DEFINITION@0..44 - COLOR_SET_DEFINITION_NAME@0..15 "\\definecolorset" + COMMAND_NAME@0..15 "\\definecolorset" BRACK_GROUP_WORD@15..19 L_BRACK@15..16 "[" KEY@16..18 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_argc.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_argc.txt.snap index a10287b262..fac8dcb1e0 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_argc.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_argc.txt.snap @@ -6,10 +6,10 @@ input_file: src/parser/test_data/latex/command_definition/command_definition_no_ ROOT@0..22 PREAMBLE@0..22 COMMAND_DEFINITION@0..22 - COMMAND_DEFINITION_NAME@0..11 "\\newcommand" + COMMAND_NAME@0..11 "\\newcommand" CURLY_GROUP_COMMAND@11..17 L_CURLY@11..12 "{" - GENERIC_COMMAND_NAME@12..16 "\\foo" + COMMAND_NAME@12..16 "\\foo" R_CURLY@16..17 "}" CURLY_GROUP@17..22 L_CURLY@17..18 "{" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl.txt.snap index ae9b54e0c8..0096ebbe60 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl.txt.snap @@ -6,10 +6,9 @@ input_file: src/parser/test_data/latex/command_definition/command_definition_no_ ROOT@0..17 PREAMBLE@0..17 COMMAND_DEFINITION@0..17 - COMMAND_DEFINITION_NAME@0..11 "\\newcommand" + COMMAND_NAME@0..11 "\\newcommand" CURLY_GROUP_COMMAND@11..17 L_CURLY@11..12 "{" - GENERIC_COMMAND_NAME@12..16 "\\foo" + COMMAND_NAME@12..16 "\\foo" R_CURLY@16..17 "}" - MISSING@17..17 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl_error.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl_error.txt.snap index 2e1f2f2956..018824e5e2 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl_error.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_no_impl_error.txt.snap @@ -6,10 +6,8 @@ input_file: src/parser/test_data/latex/command_definition/command_definition_no_ ROOT@0..16 PREAMBLE@0..16 COMMAND_DEFINITION@0..16 - COMMAND_DEFINITION_NAME@0..11 "\\newcommand" + COMMAND_NAME@0..11 "\\newcommand" CURLY_GROUP_COMMAND@11..16 L_CURLY@11..12 "{" - GENERIC_COMMAND_NAME@12..16 "\\foo" - MISSING@16..16 "" - MISSING@16..16 "" + COMMAND_NAME@12..16 "\\foo" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_optional.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_optional.txt.snap index fe1a3ad6ec..3435088461 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_optional.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_optional.txt.snap @@ -6,10 +6,10 @@ input_file: src/parser/test_data/latex/command_definition/command_definition_opt ROOT@0..29 PREAMBLE@0..29 COMMAND_DEFINITION@0..29 - COMMAND_DEFINITION_NAME@0..11 "\\newcommand" + COMMAND_NAME@0..11 "\\newcommand" CURLY_GROUP_COMMAND@11..17 L_CURLY@11..12 "{" - GENERIC_COMMAND_NAME@12..16 "\\foo" + COMMAND_NAME@12..16 "\\foo" R_CURLY@16..17 "}" BRACK_GROUP_WORD@17..20 L_BRACK@17..18 "[" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_simple.txt.snap index 422fdd0d5b..806a0e2081 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_simple.txt.snap @@ -6,8 +6,7 @@ input_file: src/parser/test_data/latex/command_definition/command_definition_sim ROOT@0..23 PREAMBLE@0..23 COMMAND_DEFINITION@0..19 - COMMAND_DEFINITION_NAME@0..11 "\\newcommand" - MISSING@11..11 "" + COMMAND_NAME@0..11 "\\newcommand" BRACK_GROUP_WORD@11..14 L_BRACK@11..12 "[" KEY@12..13 @@ -16,7 +15,7 @@ ROOT@0..23 CURLY_GROUP@14..19 L_CURLY@14..15 "{" GENERIC_COMMAND@15..18 - GENERIC_COMMAND_NAME@15..18 "\\id" + COMMAND_NAME@15..18 "\\id" R_CURLY@18..19 "}" CURLY_GROUP@19..23 L_CURLY@19..20 "{" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_with_begin.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_with_begin.txt.snap index 9ee38a1796..2dfccb38dd 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_with_begin.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__command_definition_with_begin.txt.snap @@ -6,15 +6,15 @@ input_file: src/parser/test_data/latex/command_definition/command_definition_wit ROOT@0..80 PREAMBLE@0..80 COMMAND_DEFINITION@0..80 - COMMAND_DEFINITION_NAME@0..11 "\\newcommand" + COMMAND_NAME@0..11 "\\newcommand" CURLY_GROUP_COMMAND@11..35 L_CURLY@11..12 "{" - GENERIC_COMMAND_NAME@12..34 "\\CVSubHeadingListStart" + COMMAND_NAME@12..34 "\\CVSubHeadingListStart" R_CURLY@34..35 "}" CURLY_GROUP@35..80 L_CURLY@35..36 "{" BEGIN@36..79 - BEGIN_ENVIRONMENT_NAME@36..42 "\\begin" + COMMAND_NAME@36..42 "\\begin" CURLY_GROUP_WORD@42..51 L_CURLY@42..43 "{" KEY@43..50 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_no_impl.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_no_impl.txt.snap index 371d1272c4..4cdcd846b6 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_no_impl.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_no_impl.txt.snap @@ -6,10 +6,9 @@ input_file: src/parser/test_data/latex/command_definition/math_operator_no_impl. ROOT@0..26 PREAMBLE@0..26 MATH_OPERATOR@0..26 - MATH_OPERATOR_NAME@0..20 "\\DeclareMathOperator" + COMMAND_NAME@0..20 "\\DeclareMathOperator" CURLY_GROUP_COMMAND@20..26 L_CURLY@20..21 "{" - GENERIC_COMMAND_NAME@21..25 "\\foo" + COMMAND_NAME@21..25 "\\foo" R_CURLY@25..26 "}" - MISSING@26..26 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_simple.txt.snap index 004e6918e4..fe6beef40f 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@command_definition__math_operator_simple.txt.snap @@ -6,10 +6,10 @@ input_file: src/parser/test_data/latex/command_definition/math_operator_simple.t ROOT@0..31 PREAMBLE@0..31 MATH_OPERATOR@0..31 - MATH_OPERATOR_NAME@0..20 "\\DeclareMathOperator" + COMMAND_NAME@0..20 "\\DeclareMathOperator" CURLY_GROUP_COMMAND@20..26 L_CURLY@20..21 "{" - GENERIC_COMMAND_NAME@21..25 "\\foo" + COMMAND_NAME@21..25 "\\foo" R_CURLY@25..26 "}" CURLY_GROUP@26..31 L_CURLY@26..27 "{" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_asymptote.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_asymptote.txt.snap index abbc71e6ed..a16c3a2563 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_asymptote.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_asymptote.txt.snap @@ -6,16 +6,33 @@ input_file: src/parser/test_data/latex/environment/environment_asymptote.txt ROOT@0..50 PREAMBLE@0..50 ENVIRONMENT@0..50 - BEGIN@0..11 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" - CURLY_GROUP_WORD@6..11 + BEGIN@0..16 + COMMAND_NAME@0..6 "\\begin" + CURLY_GROUP_WORD@6..16 L_CURLY@6..7 "{" KEY@7..10 WORD@7..10 "asy" R_CURLY@10..11 "}" - VERBATIM@11..41 "\n printf(\"Hello Wo ..." + LINE_BREAK@11..12 "\n" + WHITESPACE@12..16 " " + TEXT@16..22 + WORD@16..22 "printf" + MIXED_GROUP@22..39 + L_PAREN@22..23 "(" + TEXT@23..35 + WORD@23..29 "\"Hello" + WHITESPACE@29..30 " " + WORD@30..35 "World" + GENERIC_COMMAND@35..37 + COMMAND_NAME@35..37 "\\n" + TEXT@37..38 + WORD@37..38 "\"" + R_PAREN@38..39 ")" + TEXT@39..41 + WORD@39..40 ";" + LINE_BREAK@40..41 "\n" END@41..50 - END_ENVIRONMENT_NAME@41..45 "\\end" + COMMAND_NAME@41..45 "\\end" CURLY_GROUP_WORD@45..50 L_CURLY@45..46 "{" KEY@46..49 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition.txt.snap index fb45f5d35b..4a99a3b175 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/environment/environment_definition.txt ROOT@0..47 PREAMBLE@0..47 ENVIRONMENT_DEFINITION@0..47 - ENVIRONMENT_DEFINITION_NAME@0..15 "\\newenvironment" + COMMAND_NAME@0..15 "\\newenvironment" CURLY_GROUP_WORD@15..20 L_CURLY@15..16 "{" KEY@16..19 @@ -20,7 +20,7 @@ ROOT@0..47 CURLY_GROUP@23..36 L_CURLY@23..24 "{" GENERIC_COMMAND@24..35 - BEGIN_ENVIRONMENT_NAME@24..30 "\\begin" + COMMAND_NAME@24..30 "\\begin" CURLY_GROUP@30..35 L_CURLY@30..31 "{" TEXT@31..34 @@ -30,7 +30,7 @@ ROOT@0..47 CURLY_GROUP@36..47 L_CURLY@36..37 "{" GENERIC_COMMAND@37..46 - END_ENVIRONMENT_NAME@37..41 "\\end" + COMMAND_NAME@37..41 "\\end" CURLY_GROUP@41..46 L_CURLY@41..42 "{" TEXT@42..45 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition_optional_arg.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition_optional_arg.txt.snap index 10009e851b..c9304ff387 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition_optional_arg.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_definition_optional_arg.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/environment/environment_definition_option ROOT@0..44 PREAMBLE@0..44 ENVIRONMENT_DEFINITION@0..44 - ENVIRONMENT_DEFINITION_NAME@0..15 "\\newenvironment" + COMMAND_NAME@0..15 "\\newenvironment" CURLY_GROUP_WORD@15..20 L_CURLY@15..16 "{" KEY@16..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested.txt.snap index e3274ef70e..35b8155fd8 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested.txt.snap @@ -7,7 +7,7 @@ ROOT@0..43 PREAMBLE@0..43 ENVIRONMENT@0..43 BEGIN@0..12 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" + COMMAND_NAME@0..6 "\\begin" CURLY_GROUP_WORD@6..12 L_CURLY@6..7 "{" KEY@7..10 @@ -16,7 +16,7 @@ ROOT@0..43 WHITESPACE@11..12 " " ENVIRONMENT@12..34 BEGIN@12..24 - BEGIN_ENVIRONMENT_NAME@12..18 "\\begin" + COMMAND_NAME@12..18 "\\begin" CURLY_GROUP_WORD@18..24 L_CURLY@18..19 "{" KEY@19..22 @@ -24,7 +24,7 @@ ROOT@0..43 R_CURLY@22..23 "}" WHITESPACE@23..24 " " END@24..34 - END_ENVIRONMENT_NAME@24..28 "\\end" + COMMAND_NAME@24..28 "\\end" CURLY_GROUP_WORD@28..34 L_CURLY@28..29 "{" KEY@29..32 @@ -32,7 +32,7 @@ ROOT@0..43 R_CURLY@32..33 "}" WHITESPACE@33..34 " " END@34..43 - END_ENVIRONMENT_NAME@34..38 "\\end" + COMMAND_NAME@34..38 "\\end" CURLY_GROUP_WORD@38..43 L_CURLY@38..39 "{" KEY@39..42 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested_missing_braces.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested_missing_braces.txt.snap index 698be0eae7..88f9d3b3fd 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested_missing_braces.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_nested_missing_braces.txt.snap @@ -7,16 +7,15 @@ ROOT@0..52 PREAMBLE@0..52 ENVIRONMENT@0..52 BEGIN@0..11 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" + COMMAND_NAME@0..6 "\\begin" CURLY_GROUP_WORD@6..11 L_CURLY@6..7 "{" KEY@7..11 WORD@7..10 "foo" WHITESPACE@10..11 " " - MISSING@11..11 "" ENVIRONMENT@11..44 BEGIN@11..34 - BEGIN_ENVIRONMENT_NAME@11..17 "\\begin" + COMMAND_NAME@11..17 "\\begin" CURLY_GROUP_WORD@17..34 L_CURLY@17..18 "{" KEY@18..34 @@ -26,9 +25,8 @@ ROOT@0..52 WHITESPACE@27..28 " " WORD@28..33 "World" WHITESPACE@33..34 " " - MISSING@34..34 "" END@34..44 - END_ENVIRONMENT_NAME@34..38 "\\end" + COMMAND_NAME@34..38 "\\end" CURLY_GROUP_WORD@38..44 L_CURLY@38..39 "{" KEY@39..42 @@ -36,10 +34,9 @@ ROOT@0..52 R_CURLY@42..43 "}" WHITESPACE@43..44 " " END@44..52 - END_ENVIRONMENT_NAME@44..48 "\\end" + COMMAND_NAME@44..48 "\\end" CURLY_GROUP_WORD@48..52 L_CURLY@48..49 "{" KEY@49..52 WORD@49..52 "bar" - MISSING@52..52 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_simple.txt.snap index db57d39580..996237cd42 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@environment__environment_simple.txt.snap @@ -7,7 +7,7 @@ ROOT@0..33 PREAMBLE@0..33 ENVIRONMENT@0..33 BEGIN@0..12 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" + COMMAND_NAME@0..6 "\\begin" CURLY_GROUP_WORD@6..12 L_CURLY@6..7 "{" KEY@7..10 @@ -20,7 +20,7 @@ ROOT@0..33 WORD@18..23 "World" WHITESPACE@23..24 " " END@24..33 - END_ENVIRONMENT_NAME@24..28 "\\end" + COMMAND_NAME@24..28 "\\end" CURLY_GROUP_WORD@28..33 L_CURLY@28..29 "{" KEY@29..32 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation.txt.snap index 0974c69449..55b92d4afb 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation.txt.snap @@ -6,12 +6,12 @@ input_file: src/parser/test_data/latex/equation.txt ROOT@0..13 PREAMBLE@0..13 EQUATION@0..13 - BEGIN_EQUATION_NAME@0..2 "\\[" + COMMAND_NAME@0..2 "\\[" WHITESPACE@2..3 " " TEXT@3..11 WORD@3..6 "foo" WHITESPACE@6..7 " " WORD@7..10 "bar" WHITESPACE@10..11 " " - END_EQUATION_NAME@11..13 "\\]" + COMMAND_NAME@11..13 "\\]" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation_missing_begin.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation_missing_begin.txt.snap index c649fc6a6a..57e520cf38 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation_missing_begin.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@equation_missing_begin.txt.snap @@ -7,7 +7,7 @@ ROOT@0..28 PREAMBLE@0..28 ENVIRONMENT@0..28 BEGIN@0..10 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" + COMMAND_NAME@0..6 "\\begin" CURLY_GROUP_WORD@6..10 L_CURLY@6..7 "{" KEY@7..8 @@ -20,10 +20,10 @@ ROOT@0..28 WORD@14..17 "bar" WHITESPACE@17..18 " " GENERIC_COMMAND@18..21 - END_EQUATION_NAME@18..20 "\\]" + COMMAND_NAME@18..20 "\\]" WHITESPACE@20..21 " " END@21..28 - END_ENVIRONMENT_NAME@21..25 "\\end" + COMMAND_NAME@21..25 "\\end" CURLY_GROUP_WORD@25..28 L_CURLY@25..26 "{" KEY@26..27 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_args.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_args.txt.snap index 9fee38a855..0db73ad9aa 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_args.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_args.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/generic_command_args.txt ROOT@0..14 PREAMBLE@0..14 GENERIC_COMMAND@0..14 - GENERIC_COMMAND_NAME@0..4 "\\foo" + COMMAND_NAME@0..4 "\\foo" CURLY_GROUP@4..9 L_CURLY@4..5 "{" TEXT@5..8 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_empty.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_empty.txt.snap index dcd2382d02..1886dedea7 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_empty.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_empty.txt.snap @@ -6,5 +6,5 @@ input_file: src/parser/test_data/latex/generic_command_empty.txt ROOT@0..4 PREAMBLE@0..4 GENERIC_COMMAND@0..4 - GENERIC_COMMAND_NAME@0..4 "\\foo" + COMMAND_NAME@0..4 "\\foo" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_escape.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_escape.txt.snap index d7d88a32ce..6ae6cd50be 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_escape.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@generic_command_escape.txt.snap @@ -6,5 +6,5 @@ input_file: src/parser/test_data/latex/generic_command_escape.txt ROOT@0..2 PREAMBLE@0..2 GENERIC_COMMAND@0..2 - GENERIC_COMMAND_NAME@0..2 "\\#" + COMMAND_NAME@0..2 "\\#" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_declaration.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_declaration.txt.snap index c1298e50fc..279817a877 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_declaration.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_declaration.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/acronym_declaration.txt ROOT@0..64 PREAMBLE@0..64 ACRONYM_DECLARATION@0..64 - ACRONYM_DECLARATION_NAME@0..15 "\\DeclareAcronym" + COMMAND_NAME@0..15 "\\DeclareAcronym" CURLY_GROUP_WORD@15..19 L_CURLY@15..16 "{" KEY@16..18 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_options.txt.snap index eac9b6e3ba..90388ec5ee 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/acronym_definition_options.txt ROOT@0..76 PREAMBLE@0..76 ACRONYM_DEFINITION@0..76 - ACRONYM_DEFINITION_NAME@0..11 "\\newacronym" + COMMAND_NAME@0..11 "\\newacronym" BRACK_GROUP_KEY_VALUE@11..43 L_BRACK@11..12 "[" KEY_VALUE_BODY@12..42 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_simple.txt.snap index e6bfe2a9d5..eadfed4596 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_definition_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/acronym_definition_simple.txt ROOT@0..44 PREAMBLE@0..44 ACRONYM_DEFINITION@0..44 - ACRONYM_DEFINITION_NAME@0..11 "\\newacronym" + COMMAND_NAME@0..11 "\\newacronym" CURLY_GROUP_WORD@11..21 L_CURLY@11..12 "{" KEY@12..20 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_package.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_package.txt.snap index 9babc04165..25c03edbad 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_package.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_package.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/acronym_package.txt ROOT@0..35 PREAMBLE@0..35 ACRONYM_DEFINITION@0..35 - ACRONYM_DEFINITION_NAME@0..5 "\\acro" + COMMAND_NAME@0..5 "\\acro" CURLY_GROUP_WORD@5..10 L_CURLY@5..6 "{" KEY@6..9 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_options.txt.snap index 99a8fbc562..1edbf986f8 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/acronym_reference_options.txt ROOT@0..32 PREAMBLE@0..32 ACRONYM_REFERENCE@0..32 - ACRONYM_REFERENCE_NAME@0..9 "\\acrshort" + COMMAND_NAME@0..9 "\\acrshort" BRACK_GROUP_KEY_VALUE@9..22 L_BRACK@9..10 "[" KEY_VALUE_BODY@10..21 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_simple.txt.snap index 08effadf7e..38e68a3a33 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__acronym_reference_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/acronym_reference_simple.txt ROOT@0..19 PREAMBLE@0..19 ACRONYM_REFERENCE@0..19 - ACRONYM_REFERENCE_NAME@0..9 "\\acrshort" + COMMAND_NAME@0..9 "\\acrshort" CURLY_GROUP_WORD@9..19 L_CURLY@9..10 "{" KEY@10..18 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_definition_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_definition_simple.txt.snap index 4ab51a0db3..901d0bf8c2 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_definition_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_definition_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/glossary_entry_definition_simple ROOT@0..39 PREAMBLE@0..39 GLOSSARY_ENTRY_DEFINITION@0..39 - GLOSSARY_ENTRY_DEFINITION_NAME@0..17 "\\newglossaryentry" + COMMAND_NAME@0..17 "\\newglossaryentry" CURLY_GROUP_WORD@17..22 L_CURLY@17..18 "{" KEY@18..21 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_options.txt.snap index d97e984b77..263f4a7146 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/glossary_entry_reference_options ROOT@0..25 PREAMBLE@0..25 GLOSSARY_ENTRY_REFERENCE@0..25 - GLOSSARY_ENTRY_REFERENCE_NAME@0..4 "\\gls" + COMMAND_NAME@0..4 "\\gls" BRACK_GROUP_KEY_VALUE@4..20 L_BRACK@4..5 "[" KEY_VALUE_BODY@5..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_simple.txt.snap index 8c8fb0c1e2..72713fee9a 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@glossary__glossary_entry_reference_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/glossary/glossary_entry_reference_simple. ROOT@0..9 PREAMBLE@0..9 GLOSSARY_ENTRY_REFERENCE@0..9 - GLOSSARY_ENTRY_REFERENCE_NAME@0..4 "\\gls" + COMMAND_NAME@0..4 "\\gls" CURLY_GROUP_WORD@4..9 L_CURLY@4..5 "{" KEY@5..8 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path.txt.snap index 9067d36c7d..392c6f3b6e 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path.txt.snap @@ -1,12 +1,12 @@ --- source: src/parser/latex.rs -assertion_line: 1361 expression: root +input_file: src/parser/test_data/latex/graphics_path.txt --- ROOT@0..28 PREAMBLE@0..28 GRAPHICS_PATH@0..28 - GRAPHICS_PATH_NAME@0..13 "\\graphicspath" + COMMAND_NAME@0..13 "\\graphicspath" CURLY_GROUP@13..28 L_CURLY@13..14 "{" CURLY_GROUP_WORD@14..27 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_command.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_command.txt.snap index 4092b2e8e9..34d958314d 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_command.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_command.txt.snap @@ -1,18 +1,18 @@ --- source: src/parser/latex.rs -assertion_line: 1348 expression: root +input_file: src/parser/test_data/latex/graphics_path_command.txt --- ROOT@0..32 PREAMBLE@0..32 GRAPHICS_PATH@0..32 - GRAPHICS_PATH_NAME@0..13 "\\graphicspath" + COMMAND_NAME@0..13 "\\graphicspath" CURLY_GROUP@13..32 L_CURLY@13..14 "{" CURLY_GROUP_WORD@14..31 L_CURLY@14..15 "{" KEY@15..30 - GENERIC_COMMAND_NAME@15..22 "\\subfix" + COMMAND_NAME@15..22 "\\subfix" CURLY_GROUP_WORD@22..30 L_CURLY@22..23 "{" KEY@23..29 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_options.txt.snap index 0eb034bbb3..88b92c1a3b 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@graphics_path_options.txt.snap @@ -1,12 +1,12 @@ --- source: src/parser/latex.rs -assertion_line: 1348 expression: root +input_file: src/parser/test_data/latex/graphics_path_options.txt --- ROOT@0..33 PREAMBLE@0..33 GRAPHICS_PATH@0..13 - GRAPHICS_PATH_NAME@0..13 "\\graphicspath" + COMMAND_NAME@0..13 "\\graphicspath" MIXED_GROUP@13..18 L_BRACK@13..14 "[" TEXT@14..17 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__curly_group_missing_end.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__curly_group_missing_end.txt.snap index 68969f9c11..bc3e6e68ef 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__curly_group_missing_end.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__curly_group_missing_end.txt.snap @@ -11,5 +11,4 @@ ROOT@0..12 WORD@1..6 "hello" WHITESPACE@6..7 " " WORD@7..12 "world" - MISSING@12..12 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__equation_missing_end.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__equation_missing_end.txt.snap index eae04433d1..fad46a2c97 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__equation_missing_end.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__equation_missing_end.txt.snap @@ -7,7 +7,7 @@ ROOT@0..28 PREAMBLE@0..28 ENVIRONMENT@0..28 BEGIN@0..10 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" + COMMAND_NAME@0..6 "\\begin" CURLY_GROUP_WORD@6..10 L_CURLY@6..7 "{" KEY@7..8 @@ -15,16 +15,15 @@ ROOT@0..28 R_CURLY@8..9 "}" WHITESPACE@9..10 " " EQUATION@10..21 - BEGIN_EQUATION_NAME@10..12 "\\[" + COMMAND_NAME@10..12 "\\[" WHITESPACE@12..13 " " TEXT@13..21 WORD@13..16 "foo" WHITESPACE@16..17 " " WORD@17..20 "bar" WHITESPACE@20..21 " " - MISSING@21..21 "" END@21..28 - END_ENVIRONMENT_NAME@21..25 "\\end" + COMMAND_NAME@21..25 "\\end" CURLY_GROUP_WORD@25..28 L_CURLY@25..26 "{" KEY@26..27 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__escaped_brackets.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__escaped_brackets.txt.snap index a396d2e984..9046238457 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__escaped_brackets.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__escaped_brackets.txt.snap @@ -9,7 +9,6 @@ ROOT@0..6 L_CURLY@0..1 "{" MIXED_GROUP@1..2 L_BRACK@1..2 "[" - MISSING@2..2 "" R_CURLY@2..3 "}" CURLY_GROUP@3..6 L_CURLY@3..4 "{" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_braces.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_braces.txt.snap index 82d7e9db45..cb181c7fdb 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_braces.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_braces.txt.snap @@ -9,5 +9,4 @@ ROOT@0..2 R_CURLY@0..1 "}" CURLY_GROUP@1..2 L_CURLY@1..2 "{" - MISSING@2..2 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets.txt.snap index 7dd82d48bc..8e8accd9fc 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets.txt.snap @@ -9,5 +9,4 @@ ROOT@0..2 R_BRACK@0..1 "]" MIXED_GROUP@1..2 L_BRACK@1..2 "[" - MISSING@2..2 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets_with_group.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets_with_group.txt.snap index 3c45c0c14c..82c14ec404 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets_with_group.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@group__unmatched_brackets_with_group.txt.snap @@ -11,6 +11,5 @@ ROOT@0..4 R_BRACK@1..2 "]" MIXED_GROUP@2..3 L_BRACK@2..3 "[" - MISSING@3..3 "" R_CURLY@3..4 "}" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_options.txt.snap index 897d693fd0..9e0c086956 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/biblatex_include_options.txt ROOT@0..42 PREAMBLE@0..42 BIBLATEX_INCLUDE@0..42 - BIBLATEX_INCLUDE_NAME@0..15 "\\addbibresource" + COMMAND_NAME@0..15 "\\addbibresource" BRACK_GROUP_KEY_VALUE@15..29 L_BRACK@15..16 "[" KEY_VALUE_BODY@16..28 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_simple.txt.snap index a4be9c38cb..80c0afdc78 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__biblatex_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/biblatex_include_simple.txt ROOT@0..28 PREAMBLE@0..28 BIBLATEX_INCLUDE@0..28 - BIBLATEX_INCLUDE_NAME@0..15 "\\addbibresource" + COMMAND_NAME@0..15 "\\addbibresource" CURLY_GROUP_WORD_LIST@15..28 L_CURLY@15..16 "{" KEY@16..27 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__bibtex_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__bibtex_include_simple.txt.snap index 0a8f9cd3f6..0273ad8d6b 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__bibtex_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__bibtex_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/bibtex_include_simple.txt ROOT@0..22 PREAMBLE@0..22 BIBTEX_INCLUDE@0..22 - BIBTEX_INCLUDE_NAME@0..13 "\\bibliography" + COMMAND_NAME@0..13 "\\bibliography" CURLY_GROUP_WORD_LIST@13..22 L_CURLY@13..14 "{" KEY@14..21 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_empty.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_empty.txt.snap index 37ea745308..68b9f3c94e 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_empty.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_empty.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/class_include_empty.txt ROOT@0..16 PREAMBLE@0..16 CLASS_INCLUDE@0..16 - CLASS_INCLUDE_NAME@0..14 "\\documentclass" + COMMAND_NAME@0..14 "\\documentclass" CURLY_GROUP_WORD_LIST@14..16 L_CURLY@14..15 "{" R_CURLY@15..16 "}" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_options.txt.snap index ff95f8358f..e501b654c4 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/class_include_options.txt ROOT@0..44 PREAMBLE@0..44 CLASS_INCLUDE@0..44 - CLASS_INCLUDE_NAME@0..14 "\\documentclass" + COMMAND_NAME@0..14 "\\documentclass" BRACK_GROUP_KEY_VALUE@14..35 L_BRACK@14..15 "[" KEY_VALUE_BODY@15..34 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_simple.txt.snap index 670fa2b902..5b4f6114a6 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__class_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/class_include_simple.txt ROOT@0..23 PREAMBLE@0..23 CLASS_INCLUDE@0..23 - CLASS_INCLUDE_NAME@0..14 "\\documentclass" + COMMAND_NAME@0..14 "\\documentclass" CURLY_GROUP_WORD_LIST@14..23 L_CURLY@14..15 "{" KEY@15..22 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_command.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_command.txt.snap index 0332499c66..ea3e96323d 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_command.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_command.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/graphics_include_command.txt ROOT@0..52 PREAMBLE@0..52 GRAPHICS_INCLUDE@0..52 - GRAPHICS_INCLUDE_NAME@0..16 "\\includegraphics" + COMMAND_NAME@0..16 "\\includegraphics" BRACK_GROUP_KEY_VALUE@16..37 L_BRACK@16..17 "[" KEY_VALUE_BODY@17..36 @@ -18,14 +18,14 @@ ROOT@0..52 TEXT@23..26 WORD@23..26 "0.5" GENERIC_COMMAND@26..36 - GENERIC_COMMAND_NAME@26..36 "\\textwidth" + COMMAND_NAME@26..36 "\\textwidth" R_BRACK@36..37 "]" CURLY_GROUP_WORD_LIST@37..52 L_CURLY@37..38 "{" KEY@38..51 - GENERIC_COMMAND_NAME@38..42 "\\foo" + COMMAND_NAME@38..42 "\\foo" WORD@42..43 "." - GENERIC_COMMAND_NAME@43..47 "\\bar" + COMMAND_NAME@43..47 "\\bar" WORD@47..51 ".pdf" R_CURLY@51..52 "}" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_complicated_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_complicated_options.txt.snap index 5259eb5072..3b60d765b8 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_complicated_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_complicated_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/graphics_include_complicated_opti ROOT@0..39 PREAMBLE@0..39 GRAPHICS_INCLUDE@0..39 - GRAPHICS_INCLUDE_NAME@0..16 "\\includegraphics" + COMMAND_NAME@0..16 "\\includegraphics" BRACK_GROUP_KEY_VALUE@16..37 L_BRACK@16..17 "[" KEY_VALUE_BODY@17..36 @@ -18,7 +18,7 @@ ROOT@0..39 TEXT@23..26 WORD@23..26 "0.5" GENERIC_COMMAND@26..36 - GENERIC_COMMAND_NAME@26..36 "\\textwidth" + COMMAND_NAME@26..36 "\\textwidth" R_BRACK@36..37 "]" CURLY_GROUP_WORD_LIST@37..39 L_CURLY@37..38 "{" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_options.txt.snap index 5ed7df9cfc..b0817db126 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/graphics_include_options.txt ROOT@0..39 PREAMBLE@0..39 GRAPHICS_INCLUDE@0..39 - GRAPHICS_INCLUDE_NAME@0..16 "\\includegraphics" + COMMAND_NAME@0..16 "\\includegraphics" BRACK_GROUP_KEY_VALUE@16..26 L_BRACK@16..17 "[" KEY_VALUE_BODY@17..25 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_simple.txt.snap index cabb065d24..ef53c6faa5 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__graphics_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/graphics_include_simple.txt ROOT@0..29 PREAMBLE@0..29 GRAPHICS_INCLUDE@0..29 - GRAPHICS_INCLUDE_NAME@0..16 "\\includegraphics" + COMMAND_NAME@0..16 "\\includegraphics" CURLY_GROUP_WORD_LIST@16..29 L_CURLY@16..17 "{" KEY@17..28 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_incomplete.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_incomplete.txt.snap index dad78222c2..b4fc1b4244 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_incomplete.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_incomplete.txt.snap @@ -6,11 +6,9 @@ input_file: src/parser/test_data/latex/include/import_incomplete.txt ROOT@0..11 PREAMBLE@0..11 IMPORT@0..11 - IMPORT_NAME@0..7 "\\import" + COMMAND_NAME@0..7 "\\import" CURLY_GROUP_WORD@7..11 L_CURLY@7..8 "{" KEY@8..11 WORD@8..11 "foo" - MISSING@11..11 "" - MISSING@11..11 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_simple.txt.snap index 9e4fdeb284..d703c0b994 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__import_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/import_simple.txt ROOT@0..17 PREAMBLE@0..17 IMPORT@0..17 - IMPORT_NAME@0..7 "\\import" + COMMAND_NAME@0..7 "\\import" CURLY_GROUP_WORD@7..12 L_CURLY@7..8 "{" KEY@8..11 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_options.txt.snap index d0e8321692..4594b959f3 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/inkscape_include_options.txt ROOT@0..30 PREAMBLE@0..30 SVG_INCLUDE@0..30 - SVG_INCLUDE_NAME@0..11 "\\includesvg" + COMMAND_NAME@0..11 "\\includesvg" BRACK_GROUP_KEY_VALUE@11..21 L_BRACK@11..12 "[" KEY_VALUE_BODY@12..20 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_simple.txt.snap index 1d1e68f33c..b74c855e53 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__inkscape_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/inkscape_include_simple.txt ROOT@0..20 PREAMBLE@0..20 SVG_INCLUDE@0..20 - SVG_INCLUDE_NAME@0..11 "\\includesvg" + COMMAND_NAME@0..11 "\\includesvg" CURLY_GROUP_WORD_LIST@11..20 L_CURLY@11..12 "{" KEY@12..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_equality_sign.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_equality_sign.txt.snap index abf7865a42..f49d0ccea6 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_equality_sign.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_equality_sign.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/latex_include_equality_sign.txt ROOT@0..17 PREAMBLE@0..17 LATEX_INCLUDE@0..17 - LATEX_INCLUDE_NAME@0..8 "\\include" + COMMAND_NAME@0..8 "\\include" CURLY_GROUP_WORD_LIST@8..17 L_CURLY@8..9 "{" KEY@9..16 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_simple.txt.snap index 2315a2ad7c..1b853f4686 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/latex_include_simple.txt ROOT@0..17 PREAMBLE@0..17 LATEX_INCLUDE@0..17 - LATEX_INCLUDE_NAME@0..8 "\\include" + COMMAND_NAME@0..8 "\\include" CURLY_GROUP_WORD_LIST@8..17 L_CURLY@8..9 "{" KEY@9..16 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_input_path_brackets.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_input_path_brackets.txt.snap index 0ba79f0c41..dee2e19577 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_input_path_brackets.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__latex_input_path_brackets.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/latex_input_path_brackets.txt ROOT@0..20 PREAMBLE@0..20 LATEX_INCLUDE@0..20 - LATEX_INCLUDE_NAME@0..6 "\\input" + COMMAND_NAME@0..6 "\\input" CURLY_GROUP_WORD_LIST@6..20 L_CURLY@6..7 "{" KEY@7..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_empty.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_empty.txt.snap index 36e2ab5aeb..c8746b66e5 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_empty.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_empty.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/package_include_empty.txt ROOT@0..13 PREAMBLE@0..13 PACKAGE_INCLUDE@0..13 - PACKAGE_INCLUDE_NAME@0..11 "\\usepackage" + COMMAND_NAME@0..11 "\\usepackage" CURLY_GROUP_WORD_LIST@11..13 L_CURLY@11..12 "{" R_CURLY@12..13 "}" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_multiple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_multiple.txt.snap index 876f7313d7..e6ca358d8b 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_multiple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_multiple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/package_include_multiple.txt ROOT@0..28 PREAMBLE@0..28 PACKAGE_INCLUDE@0..28 - PACKAGE_INCLUDE_NAME@0..11 "\\usepackage" + COMMAND_NAME@0..11 "\\usepackage" CURLY_GROUP_WORD_LIST@11..28 L_CURLY@11..12 "{" KEY@12..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_options.txt.snap index 32a624f769..a65948daf8 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/package_include_options.txt ROOT@0..41 PREAMBLE@0..41 PACKAGE_INCLUDE@0..41 - PACKAGE_INCLUDE_NAME@0..11 "\\usepackage" + COMMAND_NAME@0..11 "\\usepackage" BRACK_GROUP_KEY_VALUE@11..32 L_BRACK@11..12 "[" KEY_VALUE_BODY@12..31 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_simple.txt.snap index 014ed983dd..5f91723920 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__package_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/package_include_simple.txt ROOT@0..20 PREAMBLE@0..20 PACKAGE_INCLUDE@0..20 - PACKAGE_INCLUDE_NAME@0..11 "\\usepackage" + COMMAND_NAME@0..11 "\\usepackage" CURLY_GROUP_WORD_LIST@11..20 L_CURLY@11..12 "{" KEY@12..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__pgf_library_import_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__pgf_library_import_simple.txt.snap index 7f5f78415e..f20083a1bc 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__pgf_library_import_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__pgf_library_import_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/pgf_library_import_simple.txt ROOT@0..19 PREAMBLE@0..19 TIKZ_LIBRARY_IMPORT@0..19 - TIKZ_LIBRARY_IMPORT_NAME@0..14 "\\usepgflibrary" + COMMAND_NAME@0..14 "\\usepgflibrary" CURLY_GROUP_WORD_LIST@14..19 L_CURLY@14..15 "{" KEY@15..18 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_options.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_options.txt.snap index 2410aeaa5a..412e18691f 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_options.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_options.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/svg_include_options.txt ROOT@0..34 PREAMBLE@0..34 SVG_INCLUDE@0..34 - SVG_INCLUDE_NAME@0..11 "\\includesvg" + COMMAND_NAME@0..11 "\\includesvg" BRACK_GROUP_KEY_VALUE@11..21 L_BRACK@11..12 "[" KEY_VALUE_BODY@12..20 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_simple.txt.snap index 61dd22f045..da3a9b4a6d 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__svg_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/svg_include_simple.txt ROOT@0..24 PREAMBLE@0..24 SVG_INCLUDE@0..24 - SVG_INCLUDE_NAME@0..11 "\\includesvg" + COMMAND_NAME@0..11 "\\includesvg" CURLY_GROUP_WORD_LIST@11..24 L_CURLY@11..12 "{" KEY@12..23 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__tikz_library_import_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__tikz_library_import_simple.txt.snap index c68ff02964..e44115196a 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__tikz_library_import_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__tikz_library_import_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/tikz_library_import_simple.txt ROOT@0..20 PREAMBLE@0..20 TIKZ_LIBRARY_IMPORT@0..20 - TIKZ_LIBRARY_IMPORT_NAME@0..15 "\\usetikzlibrary" + COMMAND_NAME@0..15 "\\usetikzlibrary" CURLY_GROUP_WORD_LIST@15..20 L_CURLY@15..16 "{" KEY@16..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__verbatim_include_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__verbatim_include_simple.txt.snap index 3c35fddf18..ffdc042047 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__verbatim_include_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@include__verbatim_include_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/include/verbatim_include_simple.txt ROOT@0..27 PREAMBLE@0..27 VERBATIM_INCLUDE@0..27 - VERBATIM_INCLUDE_NAME@0..14 "\\verbatiminput" + COMMAND_NAME@0..14 "\\verbatiminput" CURLY_GROUP_WORD_LIST@14..27 L_CURLY@14..15 "{" KEY@15..26 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline.txt.snap index c055d183bd..fa5e02f35d 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline.txt.snap @@ -11,7 +11,7 @@ ROOT@0..19 WORD@1..2 "x" WHITESPACE@2..3 " " GENERIC_COMMAND@3..18 - GENERIC_COMMAND_NAME@3..6 "\\in" + COMMAND_NAME@3..6 "\\in" WHITESPACE@6..7 " " MIXED_GROUP@7..18 L_BRACK@7..8 "[" @@ -20,7 +20,7 @@ ROOT@0..19 COMMA@9..10 "," WHITESPACE@10..11 " " GENERIC_COMMAND@11..17 - GENERIC_COMMAND_NAME@11..17 "\\infty" + COMMAND_NAME@11..17 "\\infty" R_PAREN@17..18 ")" DOLLAR@18..19 "$" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline_double_dollar.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline_double_dollar.txt.snap index 7084156fce..692cd065a1 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline_double_dollar.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@inline_double_dollar.txt.snap @@ -11,7 +11,7 @@ ROOT@0..21 WORD@2..3 "x" WHITESPACE@3..4 " " GENERIC_COMMAND@4..19 - GENERIC_COMMAND_NAME@4..7 "\\in" + COMMAND_NAME@4..7 "\\in" WHITESPACE@7..8 " " MIXED_GROUP@8..19 L_BRACK@8..9 "[" @@ -20,7 +20,7 @@ ROOT@0..21 COMMA@10..11 "," WHITESPACE@11..12 " " GENERIC_COMMAND@12..18 - GENERIC_COMMAND_NAME@12..18 "\\infty" + COMMAND_NAME@12..18 "\\infty" R_PAREN@18..19 ")" DOLLAR@19..21 "$$" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_745.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_745.txt.snap index 8530953285..1d9f6db48b 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_745.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_745.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/issue_745.txt ROOT@0..271 PREAMBLE@0..271 CLASS_INCLUDE@0..24 - CLASS_INCLUDE_NAME@0..14 "\\documentclass" + COMMAND_NAME@0..14 "\\documentclass" CURLY_GROUP_WORD_LIST@14..24 L_CURLY@14..15 "{" KEY@15..22 @@ -14,18 +14,19 @@ ROOT@0..271 R_CURLY@22..23 "}" LINE_BREAK@23..24 "\n" PACKAGE_INCLUDE@24..50 - PACKAGE_INCLUDE_NAME@24..35 "\\usepackage" + COMMAND_NAME@24..35 "\\usepackage" CURLY_GROUP_WORD_LIST@35..50 L_CURLY@35..36 "{" KEY@36..46 WORD@36..46 "tabularray" R_CURLY@46..47 "}" - WHITESPACE@47..50 " \n\n" + WHITESPACE@47..48 " " + LINE_BREAK@48..50 "\n\n" GENERIC_COMMAND@50..64 - GENERIC_COMMAND_NAME@50..63 "\\ExplSyntaxOn" + COMMAND_NAME@50..63 "\\ExplSyntaxOn" LINE_BREAK@63..64 "\n" GENERIC_COMMAND@64..223 - GENERIC_COMMAND_NAME@64..87 "\\NewDocumentEnvironment" + COMMAND_NAME@64..87 "\\NewDocumentEnvironment" CURLY_GROUP@87..96 L_CURLY@87..88 "{" TEXT@88..95 @@ -41,69 +42,79 @@ ROOT@0..271 TEXT@100..101 WORD@100..101 "m" R_CURLY@101..102 "}" - WHITESPACE@102..107 "\n " + LINE_BREAK@102..103 "\n" + WHITESPACE@103..107 " " CURLY_GROUP@107..200 L_CURLY@107..108 "{" - WHITESPACE@108..113 "\n " + LINE_BREAK@108..109 "\n" + WHITESPACE@109..113 " " GENERIC_COMMAND@113..194 - GENERIC_COMMAND_NAME@113..119 "\\use:x" - WHITESPACE@119..124 "\n " + COMMAND_NAME@113..119 "\\use:x" + LINE_BREAK@119..120 "\n" + WHITESPACE@120..124 " " CURLY_GROUP@124..194 L_CURLY@124..125 "{" - WHITESPACE@125..130 "\n " + LINE_BREAK@125..126 "\n" + WHITESPACE@126..130 " " GENERIC_COMMAND@130..141 - GENERIC_COMMAND_NAME@130..140 "\\exp_not:N" + COMMAND_NAME@130..140 "\\exp_not:N" WHITESPACE@140..141 " " ENVIRONMENT@141..188 BEGIN@141..179 - BEGIN_ENVIRONMENT_NAME@141..147 "\\begin" + COMMAND_NAME@141..147 "\\begin" CURLY_GROUP_WORD@147..158 L_CURLY@147..148 "{" KEY@148..152 WORD@148..152 "tblr" R_CURLY@152..153 "}" - WHITESPACE@153..158 "\n " + LINE_BREAK@153..154 "\n" + WHITESPACE@154..158 " " BRACK_GROUP@158..179 L_BRACK@158..159 "[" GENERIC_COMMAND@159..173 - GENERIC_COMMAND_NAME@159..169 "\\exp_not:n" + COMMAND_NAME@159..169 "\\exp_not:n" CURLY_GROUP@169..173 L_CURLY@169..170 "{" TEXT@170..172 WORD@170..172 "#1" R_CURLY@172..173 "}" R_BRACK@173..174 "]" - WHITESPACE@174..179 "\n " + LINE_BREAK@174..175 "\n" + WHITESPACE@175..179 " " CURLY_GROUP@179..188 L_CURLY@179..180 "{" TEXT@180..182 WORD@180..182 "#2" R_CURLY@182..183 "}" - WHITESPACE@183..188 "\n " - MISSING@188..188 "" + LINE_BREAK@183..184 "\n" + WHITESPACE@184..188 " " R_CURLY@188..189 "}" - WHITESPACE@189..194 "\n " + LINE_BREAK@189..190 "\n" + WHITESPACE@190..194 " " R_CURLY@194..195 "}" - WHITESPACE@195..200 "\n " + LINE_BREAK@195..196 "\n" + WHITESPACE@196..200 " " CURLY_GROUP@200..223 L_CURLY@200..201 "{" - WHITESPACE@201..206 "\n " + LINE_BREAK@201..202 "\n" + WHITESPACE@202..206 " " GENERIC_COMMAND@206..221 - END_ENVIRONMENT_NAME@206..210 "\\end" + COMMAND_NAME@206..210 "\\end" CURLY_GROUP@210..221 L_CURLY@210..211 "{" TEXT@211..215 WORD@211..215 "tblr" R_CURLY@215..216 "}" - WHITESPACE@216..221 "\n " + LINE_BREAK@216..217 "\n" + WHITESPACE@217..221 " " R_CURLY@221..222 "}" LINE_BREAK@222..223 "\n" GENERIC_COMMAND@223..239 - GENERIC_COMMAND_NAME@223..237 "\\ExplSyntaxOff" + COMMAND_NAME@223..237 "\\ExplSyntaxOff" LINE_BREAK@237..239 "\n\n" ENVIRONMENT@239..271 BEGIN@239..257 - BEGIN_ENVIRONMENT_NAME@239..245 "\\begin" + COMMAND_NAME@239..245 "\\begin" CURLY_GROUP_WORD@245..257 L_CURLY@245..246 "{" KEY@246..254 @@ -111,7 +122,7 @@ ROOT@0..271 R_CURLY@254..255 "}" LINE_BREAK@255..257 "\n\n" END@257..271 - END_ENVIRONMENT_NAME@257..261 "\\end" + COMMAND_NAME@257..261 "\\end" CURLY_GROUP_WORD@261..271 L_CURLY@261..262 "{" KEY@262..270 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_789.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_789.txt.snap index ff20c01008..4756b13c49 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_789.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_789.txt.snap @@ -1,12 +1,12 @@ --- source: src/parser/latex.rs -assertion_line: 1361 expression: root +input_file: src/parser/test_data/latex/issue_789.txt --- ROOT@0..19 PREAMBLE@0..19 GRAPHICS_PATH@0..19 - GRAPHICS_PATH_NAME@0..13 "\\graphicspath" + COMMAND_NAME@0..13 "\\graphicspath" CURLY_GROUP_WORD@13..19 L_CURLY@13..14 "{" KEY@14..18 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_853.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_853.txt.snap new file mode 100644 index 0000000000..0069449097 --- /dev/null +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_853.txt.snap @@ -0,0 +1,62 @@ +--- +source: src/parser/latex.rs +expression: root +input_file: src/parser/test_data/latex/issue_853.txt +--- +ROOT@0..135 + PREAMBLE@0..135 + CLASS_INCLUDE@0..24 + COMMAND_NAME@0..14 "\\documentclass" + CURLY_GROUP_WORD_LIST@14..24 + L_CURLY@14..15 "{" + KEY@15..22 + WORD@15..22 "minimal" + R_CURLY@22..23 "}" + LINE_BREAK@23..24 "\n" + ENVIRONMENT@24..135 + BEGIN@24..41 + COMMAND_NAME@24..30 "\\begin" + CURLY_GROUP_WORD@30..41 + L_CURLY@30..31 "{" + KEY@31..39 + WORD@31..39 "document" + R_CURLY@39..40 "}" + LINE_BREAK@40..41 "\n" + TEXT@41..75 + WORD@41..45 "This" + WHITESPACE@45..46 " " + WORD@46..48 "is" + WHITESPACE@48..49 " " + WORD@49..51 "an" + WHITESPACE@51..52 " " + WORD@52..56 "asdf" + WHITESPACE@56..57 " " + WORD@57..66 "undefined" + WHITESPACE@66..67 " " + WORD@67..74 "command" + LINE_BREAK@74..75 "\n" + BLOCK_COMMENT@75..120 + COMMAND_NAME@75..83 "\\iffalse" + LINE_BREAK@83..84 "\n" + WHITESPACE@84..86 " " + BLOCK_COMMENT@86..97 + COMMAND_NAME@86..94 "\\iffalse" + COMMAND_NAME@94..97 "\\fi" + LINE_BREAK@97..98 "\n" + WHITESPACE@98..100 " " + COMMAND_NAME@100..104 "\\end" + L_CURLY@104..105 "{" + WORD@105..114 "enumerate" + R_CURLY@114..115 "}" + WHITESPACE@115..116 " " + LINE_BREAK@116..117 "\n" + COMMAND_NAME@117..120 "\\fi" + LINE_BREAK@120..121 "\n" + END@121..135 + COMMAND_NAME@121..125 "\\end" + CURLY_GROUP_WORD@125..135 + L_CURLY@125..126 "{" + KEY@126..134 + WORD@126..134 "document" + R_CURLY@134..135 "}" + diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_857.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_857.txt.snap new file mode 100644 index 0000000000..4ed4c71e59 --- /dev/null +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@issue_857.txt.snap @@ -0,0 +1,33 @@ +--- +source: src/parser/latex.rs +expression: root +input_file: src/parser/test_data/latex/issue_857.txt +--- +ROOT@0..55 + PREAMBLE@0..55 + COMMAND_DEFINITION@0..11 + COMMAND_NAME@0..11 "\\newcommand" + GENERIC_COMMAND@11..17 + COMMAND_NAME@11..14 "\\ö" + CURLY_GROUP@14..17 + L_CURLY@14..15 "{" + R_CURLY@15..16 "}" + LINE_BREAK@16..17 "\n" + COMMAND_DEFINITION@17..38 + COMMAND_NAME@17..28 "\\newcommand" + CURLY_GROUP_COMMAND@28..35 + L_CURLY@28..29 "{" + COMMAND_NAME@29..34 "\\öö" + R_CURLY@34..35 "}" + CURLY_GROUP@35..38 + L_CURLY@35..36 "{" + R_CURLY@36..37 "}" + LINE_BREAK@37..38 "\n" + COMMAND_DEFINITION@38..49 + COMMAND_NAME@38..49 "\\newcommand" + GENERIC_COMMAND@49..55 + COMMAND_NAME@49..53 "\\123" + CURLY_GROUP@53..55 + L_CURLY@53..54 "{" + R_CURLY@54..55 "}" + diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_line_break.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_line_break.txt.snap index 7f2ff377b8..57c3a3bf3a 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_line_break.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_line_break.txt.snap @@ -6,13 +6,12 @@ input_file: src/parser/test_data/latex/label/label_definition_line_break.txt ROOT@0..19 PREAMBLE@0..19 LABEL_DEFINITION@0..13 - LABEL_DEFINITION_NAME@0..6 "\\label" + COMMAND_NAME@0..6 "\\label" CURLY_GROUP_WORD@6..13 L_CURLY@6..7 "{" KEY@7..13 WORD@7..12 "hello" LINE_BREAK@12..13 "\n" - MISSING@13..13 "" TEXT@13..18 WORD@13..18 "world" ERROR@18..19 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_simple.txt.snap index a2e8b85b55..49c17d26eb 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_definition_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/label/label_definition_simple.txt ROOT@0..11 PREAMBLE@0..11 LABEL_DEFINITION@0..11 - LABEL_DEFINITION_NAME@0..6 "\\label" + COMMAND_NAME@0..6 "\\label" CURLY_GROUP_WORD@6..11 L_CURLY@6..7 "{" KEY@7..10 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_number.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_number.txt.snap index 9afdf9e88e..cc5824ea16 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_number.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_number.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/label/label_number.txt ROOT@0..21 PREAMBLE@0..21 LABEL_NUMBER@0..21 - LABEL_NUMBER_NAME@0..9 "\\newlabel" + COMMAND_NAME@0..9 "\\newlabel" CURLY_GROUP_WORD@9..14 L_CURLY@9..10 "{" KEY@10..13 @@ -20,5 +20,4 @@ ROOT@0..21 WORD@16..19 "1.1" R_CURLY@19..20 "}" R_CURLY@20..21 "}" - MISSING@21..21 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_equation.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_equation.txt.snap index 93580e846e..c44c7a2c5c 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_equation.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_equation.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/label/label_reference_equation.txt ROOT@0..11 PREAMBLE@0..11 LABEL_REFERENCE@0..11 - LABEL_REFERENCE_NAME@0..6 "\\eqref" + COMMAND_NAME@0..6 "\\eqref" CURLY_GROUP_WORD_LIST@6..11 L_CURLY@6..7 "{" KEY@7..10 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_incomplete.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_incomplete.txt.snap index 64e2d9af44..c654786a3e 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_incomplete.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_incomplete.txt.snap @@ -9,7 +9,7 @@ ROOT@0..47 WORD@0..8 "Equation" WHITESPACE@8..9 " " LABEL_REFERENCE@9..24 - LABEL_REFERENCE_NAME@9..15 "\\eqref" + COMMAND_NAME@9..15 "\\eqref" CURLY_GROUP_WORD_LIST@15..24 L_CURLY@15..16 "{" KEY@16..24 @@ -19,9 +19,8 @@ ROOT@0..47 WHITESPACE@21..22 " " WORD@22..23 "a" WHITESPACE@23..24 " " - MISSING@24..24 "" GENERIC_COMMAND@24..38 - GENERIC_COMMAND_NAME@24..29 "\\emph" + COMMAND_NAME@24..29 "\\emph" CURLY_GROUP@29..38 L_CURLY@29..30 "{" TEXT@30..36 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_multiple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_multiple.txt.snap index 27d56c6789..556a04766e 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_multiple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_multiple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/label/label_reference_multiple.txt ROOT@0..14 PREAMBLE@0..14 LABEL_REFERENCE@0..14 - LABEL_REFERENCE_NAME@0..4 "\\ref" + COMMAND_NAME@0..4 "\\ref" CURLY_GROUP_WORD_LIST@4..14 L_CURLY@4..5 "{" KEY@5..8 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_error.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_error.txt.snap index ce5e6a49b5..ff82c6f558 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_error.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_error.txt.snap @@ -6,12 +6,11 @@ input_file: src/parser/test_data/latex/label/label_reference_range_error.txt ROOT@0..19 PREAMBLE@0..19 LABEL_REFERENCE_RANGE@0..19 - LABEL_REFERENCE_RANGE_NAME@0..10 "\\crefrange" + COMMAND_NAME@0..10 "\\crefrange" CURLY_GROUP_WORD@10..14 L_CURLY@10..11 "{" KEY@11..14 WORD@11..14 "foo" - MISSING@14..14 "" CURLY_GROUP_WORD@14..19 L_CURLY@14..15 "{" KEY@15..18 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_incomplete.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_incomplete.txt.snap index b682f40ebc..5a8910b8d2 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_incomplete.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_incomplete.txt.snap @@ -6,11 +6,10 @@ input_file: src/parser/test_data/latex/label/label_reference_range_incomplete.tx ROOT@0..15 PREAMBLE@0..15 LABEL_REFERENCE_RANGE@0..15 - LABEL_REFERENCE_RANGE_NAME@0..10 "\\crefrange" + COMMAND_NAME@0..10 "\\crefrange" CURLY_GROUP_WORD@10..15 L_CURLY@10..11 "{" KEY@11..14 WORD@11..14 "foo" R_CURLY@14..15 "}" - MISSING@15..15 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_simple.txt.snap index e76708bf43..a03632ff5b 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_range_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/label/label_reference_range_simple.txt ROOT@0..20 PREAMBLE@0..20 LABEL_REFERENCE_RANGE@0..20 - LABEL_REFERENCE_RANGE_NAME@0..10 "\\crefrange" + COMMAND_NAME@0..10 "\\crefrange" CURLY_GROUP_WORD@10..15 L_CURLY@10..11 "{" KEY@11..14 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_simple.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_simple.txt.snap index 398a6c1682..3734ba74f9 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_simple.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@label__label_reference_simple.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/label/label_reference_simple.txt ROOT@0..9 PREAMBLE@0..9 LABEL_REFERENCE@0..9 - LABEL_REFERENCE_NAME@0..4 "\\ref" + COMMAND_NAME@0..4 "\\ref" CURLY_GROUP_WORD_LIST@4..9 L_CURLY@4..5 "{" KEY@5..8 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_enum_item.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_enum_item.txt.snap index 4c6222045c..45bcb12842 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_enum_item.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_enum_item.txt.snap @@ -7,7 +7,7 @@ ROOT@0..60 PREAMBLE@0..60 ENVIRONMENT@0..60 BEGIN@0..18 - BEGIN_ENVIRONMENT_NAME@0..6 "\\begin" + COMMAND_NAME@0..6 "\\begin" CURLY_GROUP_WORD@6..18 L_CURLY@6..7 "{" KEY@7..16 @@ -15,13 +15,13 @@ ROOT@0..60 R_CURLY@16..17 "}" WHITESPACE@17..18 " " ENUM_ITEM@18..26 - ENUM_ITEM_NAME@18..23 "\\item" + COMMAND_NAME@18..23 "\\item" WHITESPACE@23..24 " " TEXT@24..26 WORD@24..25 "1" WHITESPACE@25..26 " " ENUM_ITEM@26..37 - ENUM_ITEM_NAME@26..31 "\\item" + COMMAND_NAME@26..31 "\\item" BRACK_GROUP@31..35 L_BRACK@31..32 "[" TEXT@32..33 @@ -32,13 +32,13 @@ ROOT@0..60 WORD@35..36 "2" WHITESPACE@36..37 " " ENUM_ITEM@37..45 - ENUM_ITEM_NAME@37..42 "\\item" + COMMAND_NAME@37..42 "\\item" WHITESPACE@42..43 " " TEXT@43..45 WORD@43..44 "3" WHITESPACE@44..45 " " END@45..60 - END_ENVIRONMENT_NAME@45..49 "\\end" + COMMAND_NAME@45..49 "\\end" CURLY_GROUP_WORD@49..60 L_CURLY@49..50 "{" KEY@50..59 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_invalid_nesting.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_invalid_nesting.txt.snap index c5f7aede51..877d7e28d4 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_invalid_nesting.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_invalid_nesting.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/structure/structure_invalid_nesting.txt ROOT@0..27 PREAMBLE@0..27 SECTION@0..14 - SECTION_NAME@0..8 "\\section" + COMMAND_NAME@0..8 "\\section" CURLY_GROUP@8..14 L_CURLY@8..9 "{" TEXT@9..12 @@ -14,7 +14,7 @@ ROOT@0..27 R_CURLY@12..13 "}" WHITESPACE@13..14 " " CHAPTER@14..27 - CHAPTER_NAME@14..22 "\\chapter" + COMMAND_NAME@14..22 "\\chapter" CURLY_GROUP@22..27 L_CURLY@22..23 "{" TEXT@23..26 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_nested.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_nested.txt.snap index 1f93b8c11f..e4a3cddc7b 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_nested.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_nested.txt.snap @@ -6,49 +6,49 @@ input_file: src/parser/test_data/latex/structure/structure_nested.txt ROOT@0..90 PREAMBLE@0..90 PART@0..90 - PART_NAME@0..5 "\\part" + COMMAND_NAME@0..5 "\\part" CURLY_GROUP@5..8 L_CURLY@5..6 "{" TEXT@6..7 WORD@6..7 "1" R_CURLY@7..8 "}" CHAPTER@8..90 - CHAPTER_NAME@8..16 "\\chapter" + COMMAND_NAME@8..16 "\\chapter" CURLY_GROUP@16..19 L_CURLY@16..17 "{" TEXT@17..18 WORD@17..18 "2" R_CURLY@18..19 "}" SECTION@19..90 - SECTION_NAME@19..27 "\\section" + COMMAND_NAME@19..27 "\\section" CURLY_GROUP@27..30 L_CURLY@27..28 "{" TEXT@28..29 WORD@28..29 "3" R_CURLY@29..30 "}" SUBSECTION@30..90 - SUBSECTION_NAME@30..41 "\\subsection" + COMMAND_NAME@30..41 "\\subsection" CURLY_GROUP@41..44 L_CURLY@41..42 "{" TEXT@42..43 WORD@42..43 "4" R_CURLY@43..44 "}" SUBSUBSECTION@44..90 - SUBSUBSECTION_NAME@44..58 "\\subsubsection" + COMMAND_NAME@44..58 "\\subsubsection" CURLY_GROUP@58..61 L_CURLY@58..59 "{" TEXT@59..60 WORD@59..60 "5" R_CURLY@60..61 "}" PARAGRAPH@61..90 - PARAGRAPH_NAME@61..71 "\\paragraph" + COMMAND_NAME@61..71 "\\paragraph" CURLY_GROUP@71..74 L_CURLY@71..72 "{" TEXT@72..73 WORD@72..73 "6" R_CURLY@73..74 "}" SUBPARAGRAPH@74..90 - SUBPARAGRAPH_NAME@74..87 "\\subparagraph" + COMMAND_NAME@74..87 "\\subparagraph" CURLY_GROUP@87..90 L_CURLY@87..88 "{" TEXT@88..89 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_siblings.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_siblings.txt.snap index 03a29cb4bd..4a925e7e44 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_siblings.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@structure__structure_siblings.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/structure/structure_siblings.txt ROOT@0..35 PREAMBLE@0..35 SECTION@0..18 - SECTION_NAME@0..8 "\\section" + COMMAND_NAME@0..8 "\\section" CURLY_GROUP@8..14 L_CURLY@8..9 "{" TEXT@9..12 @@ -17,7 +17,7 @@ ROOT@0..35 WORD@14..17 "Foo" WHITESPACE@17..18 " " SECTION@18..35 - SECTION_NAME@18..26 "\\section" + COMMAND_NAME@18..26 "\\section" CURLY_GROUP@26..32 L_CURLY@26..27 "{" TEXT@27..30 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_full.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_full.txt.snap index 81b9c92758..6aa441cbba 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_full.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_full.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/theorem_definition/theorem_definition_ful ROOT@0..31 PREAMBLE@0..31 THEOREM_DEFINITION@0..31 - THEOREM_DEFINITION_NAME@0..11 "\\newtheorem" + COMMAND_NAME@0..11 "\\newtheorem" CURLY_GROUP_WORD@11..16 L_CURLY@11..12 "{" KEY@12..15 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_counter.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_counter.txt.snap index b422a2619f..d205e65183 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_counter.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_counter.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/theorem_definition/theorem_definition_nam ROOT@0..21 PREAMBLE@0..21 THEOREM_DEFINITION@0..21 - THEOREM_DEFINITION_NAME@0..11 "\\newtheorem" + COMMAND_NAME@0..11 "\\newtheorem" CURLY_GROUP_WORD@11..16 L_CURLY@11..12 "{" KEY@12..15 @@ -17,5 +17,4 @@ ROOT@0..21 KEY@17..20 WORD@17..20 "bar" R_BRACK@20..21 "]" - MISSING@21..21 "" diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description.txt.snap index 0b1a3f3e48..8d198b3940 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/theorem_definition/theorem_definition_nam ROOT@0..21 PREAMBLE@0..21 THEOREM_DEFINITION@0..21 - THEOREM_DEFINITION_NAME@0..11 "\\newtheorem" + COMMAND_NAME@0..11 "\\newtheorem" CURLY_GROUP_WORD@11..16 L_CURLY@11..12 "{" KEY@12..15 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description_and_counter.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description_and_counter.txt.snap index 1f84c653bd..ffa7d31541 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description_and_counter.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_name_with_description_and_counter.txt.snap @@ -6,7 +6,7 @@ input_file: src/parser/test_data/latex/theorem_definition/theorem_definition_nam ROOT@0..26 PREAMBLE@0..26 THEOREM_DEFINITION@0..26 - THEOREM_DEFINITION_NAME@0..11 "\\newtheorem" + COMMAND_NAME@0..11 "\\newtheorem" CURLY_GROUP_WORD@11..16 L_CURLY@11..12 "{" KEY@12..15 diff --git a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_only_name.txt.snap b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_only_name.txt.snap index 8c85579665..afad760dd2 100644 --- a/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_only_name.txt.snap +++ b/support/texlab/src/parser/snapshots/texlab__parser__latex__tests__parse@theorem_definition__theorem_definition_only_name.txt.snap @@ -6,11 +6,10 @@ input_file: src/parser/test_data/latex/theorem_definition/theorem_definition_onl ROOT@0..16 PREAMBLE@0..16 THEOREM_DEFINITION@0..16 - THEOREM_DEFINITION_NAME@0..11 "\\newtheorem" + COMMAND_NAME@0..11 "\\newtheorem" CURLY_GROUP_WORD@11..16 L_CURLY@11..12 "{" KEY@12..15 WORD@12..15 "foo" R_CURLY@15..16 "}" - MISSING@16..16 "" diff --git a/support/texlab/src/parser/test_data/latex/issue_853.txt b/support/texlab/src/parser/test_data/latex/issue_853.txt new file mode 100644 index 0000000000..312889717c --- /dev/null +++ b/support/texlab/src/parser/test_data/latex/issue_853.txt @@ -0,0 +1,8 @@ +\documentclass{minimal} +\begin{document} +This is an asdf undefined command +\iffalse + \iffalse\fi + \end{enumerate} +\fi +\end{document} \ No newline at end of file diff --git a/support/texlab/src/parser/test_data/latex/issue_857.txt b/support/texlab/src/parser/test_data/latex/issue_857.txt new file mode 100644 index 0000000000..0640263c84 --- /dev/null +++ b/support/texlab/src/parser/test_data/latex/issue_857.txt @@ -0,0 +1,3 @@ +\newcommand\ö{} +\newcommand{\öö}{} +\newcommand\123{} \ No newline at end of file diff --git a/support/texlab/src/server.rs b/support/texlab/src/server.rs index 567d912435..bf0ef64261 100644 --- a/support/texlab/src/server.rs +++ b/support/texlab/src/server.rs @@ -1,4 +1,5 @@ mod dispatch; +pub mod options; mod query; use std::{ @@ -27,7 +28,8 @@ use crate::{ build::{self, BuildParams, BuildResult, BuildStatus}, completion::{self, builder::CompletionItemData}, definition, folding, formatting, forward_search, highlight, hover, inlay_hint, link, - reference, rename, symbol, workspace_command, + reference, rename, symbol, + workspace_command::{change_environment, clean, dep_graph}, }, normalize_uri, syntax::bibtex, @@ -35,9 +37,11 @@ use crate::{ self, capabilities::ClientCapabilitiesExt, components::COMPONENT_DATABASE, line_index_ext::LineIndexExt, }, - Db, Options, StartupOptions, + Config, Db, }; +use self::options::{Options, StartupOptions}; + #[derive(Debug)] enum InternalMessage { SetDistro(Distro), @@ -86,6 +90,45 @@ impl Server { }); } + fn run_and_request_with_db(&self, id: RequestId, query: Q) + where + R: Request, + S: Serialize, + Q: FnOnce(&dyn Db) -> Option<(S, R::Params)> + Send + 'static, + { + let client = self.client.clone(); + self.engine.fork(move |db| match query(db) { + Some((result, request_params)) => { + let response = lsp_server::Response::new_ok(id, result); + client.send_response(response).unwrap(); + client.send_request::(request_params).unwrap(); + } + None => { + let response = lsp_server::Response::new_ok(id, Option::::None); + client.send_response(response).unwrap(); + } + }); + } + + fn run_errorable(&self, id: RequestId, query: Q) + where + R: Serialize, + Q: FnOnce() -> Result + Send + 'static, + { + let client = self.client.clone(); + self.pool.execute(move || match query() { + Ok(result) => { + let response = lsp_server::Response::new_ok(id, result); + client.send_response(response).unwrap(); + } + Err(why) => { + client + .send_error(id, ErrorCode::InternalError, why.to_string()) + .unwrap(); + } + }); + } + fn capabilities(&self) -> ServerCapabilities { ServerCapabilities { text_document_sync: Some(TextDocumentSyncCapability::Options( @@ -131,6 +174,7 @@ impl Server { commands: vec![ "texlab.cleanAuxiliary".into(), "texlab.cleanArtifacts".into(), + "texlab.changeEnvironment".into(), ], ..Default::default() }), @@ -150,10 +194,12 @@ impl Server { .with_durability(salsa::Durability::HIGH) .to(params.capabilities); - workspace - .set_client_info(db) + db::ServerContext::get(db) + .set_always_incomplete_completion_list(db) .with_durability(salsa::Durability::HIGH) - .to(params.client_info); + .to(params + .client_info + .map_or(false, |client| &client.name == "Visual Studio Code")); let root_dirs = params .workspace_folders @@ -260,7 +306,7 @@ impl Server { fn publish_diagnostics_with_delay(&mut self) { let db = self.engine.read(); let sender = self.internal_tx.clone(); - let delay = Workspace::get(db).options(db).diagnostics_delay.0; + let delay = db.config().diagnostics.delay; self.pool.execute(move || { std::thread::sleep(delay); sender.send(InternalMessage::Diagnostics).unwrap(); @@ -304,11 +350,10 @@ impl Server { fn update_options(&mut self, options: Options) { let db = self.engine.write(); - let workspace = Workspace::get(db); - workspace - .set_options(db) + db::ServerContext::get(db) + .set_config(db) .with_durability(salsa::Durability::MEDIUM) - .to(options); + .to(Config::from(options)); self.watcher.watch(db); } @@ -354,11 +399,7 @@ impl Server { self.update_workspace(); - if workspace - .options(self.engine.read()) - .chktex - .on_open_and_save - { + if self.engine.read().config().diagnostics.chktex.on_open { self.run_chktex(document); } @@ -379,12 +420,11 @@ impl Server { for change in params.content_changes { match change.range { Some(range) => { - let range = document.contents(db).line_index(db).offset_lsp_range(range); + let range = document.line_index(db).offset_lsp_range(range); document.edit(db, range, &change.text); } None => { document - .contents(db) .set_text(db) .with_durability(salsa::Durability::LOW) .to(change.text); @@ -399,7 +439,7 @@ impl Server { self.update_workspace(); - if workspace.options(self.engine.read()).chktex.on_edit { + if self.engine.read().config().diagnostics.chktex.on_edit { self.run_chktex(document); } @@ -412,7 +452,7 @@ impl Server { let db = self.engine.read(); let workspace = Workspace::get(db); - if workspace.options(db).build.on_save { + if db.config().build.on_save { self.build_internal(uri.clone(), |_| ())?; } @@ -420,7 +460,7 @@ impl Server { let db = self.engine.read(); if let Some(document) = workspace.lookup_uri(db, &uri) { - if workspace.options(db).chktex.on_open_and_save { + if db.config().diagnostics.chktex.on_save { self.run_chktex(document); } } @@ -550,7 +590,6 @@ impl Server { let workspace = Workspace::get(db); if let Some(document) = workspace.lookup_uri(db, &uri) { let position = document - .contents(db) .line_index(db) .offset_lsp(params.text_document_position_params.position); @@ -618,28 +657,34 @@ impl Server { } fn execute_command(&mut self, id: RequestId, params: ExecuteCommandParams) -> Result<()> { - let db = self.engine.read(); - match workspace_command::select(db, ¶ms.command, params.arguments) { - Ok(command) => { - let client = self.client.clone(); - self.pool.execute(move || { - match command.run() { - Ok(()) => { - client - .send_response(lsp_server::Response::new_ok(id, ())) - .unwrap(); - } - Err(why) => { - client - .send_error(id, ErrorCode::InternalError, why.to_string()) - .unwrap(); - } - }; + match params.command.as_str() { + "texlab.cleanAuxiliary" => { + let db = self.engine.read(); + let opt = clean::CleanOptions::Auxiliary; + let command = clean::CleanCommand::new(db, opt, params.arguments); + self.run_errorable(id, || command?.run()); + } + "texlab.cleanArtifacts" => { + let db = self.engine.read(); + let opt = clean::CleanOptions::Auxiliary; + let command = clean::CleanCommand::new(db, opt, params.arguments); + self.run_errorable(id, || command?.run()); + } + "texlab.changeEnvironment" => { + self.run_and_request_with_db::(id, move |db| { + change_environment::change_environment(db, params.arguments) }); } - Err(why) => { + "texlab.showDependencyGraph" => { + self.run_with_db(id, move |db| dep_graph::show_dependency_graph(db).unwrap()); + } + _ => { self.client - .send_error(id, ErrorCode::InvalidParams, why.to_string()) + .send_error( + id, + ErrorCode::InvalidParams, + format!("Unknown workspace command: {}", params.command), + ) .unwrap(); } }; @@ -699,7 +744,7 @@ impl Server { } }; - let forward_search_after = Workspace::get(db).options(db).build.forward_search_after; + let forward_search_after = db.config().build.forward_search_after; let sender = self.internal_tx.clone(); self.pool.execute(move || { diff --git a/support/texlab/src/server/options.rs b/support/texlab/src/server/options.rs new file mode 100644 index 0000000000..fb7260ebf2 --- /dev/null +++ b/support/texlab/src/server/options.rs @@ -0,0 +1,214 @@ +use std::time::Duration; + +use regex::Regex; +use serde::{Deserialize, Serialize}; + +use crate::{Config, Formatter, SynctexConfig}; + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct Options { + pub root_directory: Option, + pub aux_directory: Option, + pub bibtex_formatter: BibtexFormatter, + pub latex_formatter: LatexFormatter, + pub formatter_line_length: Option, + pub diagnostics: DiagnosticsOptions, + pub diagnostics_delay: Option, + pub build: BuildOptions, + pub chktex: ChktexOptions, + pub symbols: SymbolOptions, + pub latexindent: LatexindentOptions, + pub forward_search: ForwardSearchOptions, + pub experimental: ExperimentalOptions, +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum BibtexFormatter { + None, + Texlab, + Latexindent, +} + +impl Default for BibtexFormatter { + fn default() -> Self { + Self::Texlab + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum LatexFormatter { + None, + Texlab, + Latexindent, +} + +impl Default for LatexFormatter { + fn default() -> Self { + Self::Latexindent + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct LatexindentOptions { + pub local: Option, + pub modify_line_breaks: bool, +} + +#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct BuildOptions { + pub executable: Option, + pub args: Option>, + pub on_save: bool, + pub forward_search_after: bool, +} + +#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct ChktexOptions { + pub on_open_and_save: bool, + pub on_edit: bool, +} + +#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct ForwardSearchOptions { + pub executable: Option, + pub args: Option>, +} + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct DiagnosticsOptions { + pub allowed_patterns: Vec, + pub ignored_patterns: Vec, +} + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct SymbolOptions { + pub allowed_patterns: Vec, + pub ignored_patterns: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct RegexPattern(#[serde(with = "serde_regex")] pub Regex); + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct ExperimentalOptions { + pub math_environments: Vec, + pub enum_environments: Vec, + pub verbatim_environments: Vec, +} + +#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct StartupOptions { + pub skip_distro: bool, +} + +impl From for Config { + fn from(value: Options) -> Self { + let mut config = Config::default(); + config.root_dir = value.root_directory; + + config.build.program = value.build.executable.unwrap_or(config.build.program); + config.build.args = value.build.args.unwrap_or(config.build.args); + config.build.on_save = value.build.on_save; + config.build.forward_search_after = value.build.forward_search_after; + config.build.output_dir = value.aux_directory.unwrap_or_else(|| String::from(".")); + + config.diagnostics.allowed_patterns = value + .diagnostics + .allowed_patterns + .into_iter() + .map(|pattern| pattern.0) + .collect(); + + config.diagnostics.ignored_patterns = value + .diagnostics + .ignored_patterns + .into_iter() + .map(|pattern| pattern.0) + .collect(); + + config.diagnostics.delay = value + .diagnostics_delay + .map_or(config.diagnostics.delay, Duration::from_millis); + + config.diagnostics.chktex.on_open = value.chktex.on_open_and_save; + config.diagnostics.chktex.on_save = value.chktex.on_open_and_save; + config.diagnostics.chktex.on_edit = value.chktex.on_edit; + + config.formatting.tex_formatter = match value.latex_formatter { + LatexFormatter::None => Formatter::Null, + LatexFormatter::Texlab => Formatter::Server, + LatexFormatter::Latexindent => Formatter::LatexIndent, + }; + + config.formatting.tex_formatter = match value.bibtex_formatter { + BibtexFormatter::None => Formatter::Null, + BibtexFormatter::Texlab => Formatter::Server, + BibtexFormatter::Latexindent => Formatter::LatexIndent, + }; + + config.formatting.line_length = + value + .formatter_line_length + .map_or(80, |len| if len < 0 { usize::MAX } else { len as usize }); + + config.formatting.latex_indent.local = value.latexindent.local; + config.formatting.latex_indent.modify_line_breaks = value.latexindent.modify_line_breaks; + + config.synctex = value + .forward_search + .executable + .zip(value.forward_search.args) + .map(|(program, args)| SynctexConfig { program, args }); + + config.symbols.allowed_patterns = value + .symbols + .allowed_patterns + .into_iter() + .map(|pattern| pattern.0) + .collect(); + + config.symbols.ignored_patterns = value + .symbols + .ignored_patterns + .into_iter() + .map(|pattern| pattern.0) + .collect(); + + config + .syntax + .math_environments + .extend(value.experimental.math_environments); + + config + .syntax + .enum_environments + .extend(value.experimental.enum_environments); + + config + .syntax + .verbatim_environments + .extend(value.experimental.verbatim_environments); + + config + } +} diff --git a/support/texlab/src/syntax/latex/cst.rs b/support/texlab/src/syntax/latex/cst.rs index d7c9ec9bc7..767aa50ecc 100644 --- a/support/texlab/src/syntax/latex/cst.rs +++ b/support/texlab/src/syntax/latex/cst.rs @@ -222,7 +222,7 @@ impl CurlyGroupCommand { self.syntax() .children_with_tokens() .filter_map(|node| node.into_token()) - .find(|node| node.kind() == GENERIC_COMMAND_NAME) + .find(|node| node.kind() == COMMAND_NAME) } } @@ -312,7 +312,7 @@ impl GenericCommand { self.syntax() .children_with_tokens() .filter_map(|node| node.into_token()) - .find(|node| node.kind() == GENERIC_COMMAND_NAME) + .find(|node| node.kind() == COMMAND_NAME) } } diff --git a/support/texlab/src/syntax/latex/kind.rs b/support/texlab/src/syntax/latex/kind.rs index 81e0ea3588..3eadc90b48 100644 --- a/support/texlab/src/syntax/latex/kind.rs +++ b/support/texlab/src/syntax/latex/kind.rs @@ -3,7 +3,6 @@ #[repr(u16)] pub enum SyntaxKind { ERROR = 0, - MISSING, LINE_BREAK, WHITESPACE, @@ -19,51 +18,7 @@ pub enum SyntaxKind { EQUALITY_SIGN, WORD, DOLLAR, - GENERIC_COMMAND_NAME, - BEGIN_ENVIRONMENT_NAME, - END_ENVIRONMENT_NAME, - BEGIN_EQUATION_NAME, - END_EQUATION_NAME, - PART_NAME, - CHAPTER_NAME, - SECTION_NAME, - SUBSECTION_NAME, - SUBSUBSECTION_NAME, - PARAGRAPH_NAME, - SUBPARAGRAPH_NAME, - ENUM_ITEM_NAME, - CAPTION_NAME, - CITATION_NAME, - PACKAGE_INCLUDE_NAME, - CLASS_INCLUDE_NAME, - LATEX_INCLUDE_NAME, - BIBLATEX_INCLUDE_NAME, - BIBTEX_INCLUDE_NAME, - GRAPHICS_INCLUDE_NAME, - SVG_INCLUDE_NAME, - INKSCAPE_INCLUDE_NAME, - VERBATIM_INCLUDE_NAME, - IMPORT_NAME, - LABEL_DEFINITION_NAME, - LABEL_REFERENCE_NAME, - LABEL_REFERENCE_RANGE_NAME, - LABEL_NUMBER_NAME, - COMMAND_DEFINITION_NAME, - MATH_OPERATOR_NAME, - GLOSSARY_ENTRY_DEFINITION_NAME, - GLOSSARY_ENTRY_REFERENCE_NAME, - ACRONYM_DEFINITION_NAME, - ACRONYM_DECLARATION_NAME, - ACRONYM_REFERENCE_NAME, - THEOREM_DEFINITION_NAME, - COLOR_REFERENCE_NAME, - COLOR_DEFINITION_NAME, - COLOR_SET_DEFINITION_NAME, - TIKZ_LIBRARY_IMPORT_NAME, - ENVIRONMENT_DEFINITION_NAME, - BEGIN_BLOCK_COMMENT_NAME, - END_BLOCK_COMMENT_NAME, - GRAPHICS_PATH_NAME, + COMMAND_NAME, PREAMBLE, TEXT, @@ -129,56 +84,6 @@ pub enum SyntaxKind { ROOT, } -impl SyntaxKind { - pub fn is_command_name(&self) -> bool { - use SyntaxKind::*; - matches!( - self, - GENERIC_COMMAND_NAME - | BEGIN_ENVIRONMENT_NAME - | END_ENVIRONMENT_NAME - | BEGIN_EQUATION_NAME - | END_EQUATION_NAME - | PART_NAME - | CHAPTER_NAME - | SECTION_NAME - | SUBSECTION_NAME - | SUBSUBSECTION_NAME - | PARAGRAPH_NAME - | SUBPARAGRAPH_NAME - | ENUM_ITEM_NAME - | CAPTION_NAME - | CITATION_NAME - | PACKAGE_INCLUDE_NAME - | CLASS_INCLUDE_NAME - | LATEX_INCLUDE_NAME - | BIBLATEX_INCLUDE_NAME - | BIBTEX_INCLUDE_NAME - | GRAPHICS_INCLUDE_NAME - | SVG_INCLUDE_NAME - | INKSCAPE_INCLUDE_NAME - | VERBATIM_INCLUDE_NAME - | IMPORT_NAME - | LABEL_DEFINITION_NAME - | LABEL_REFERENCE_NAME - | LABEL_REFERENCE_RANGE_NAME - | LABEL_NUMBER_NAME - | COMMAND_DEFINITION_NAME - | MATH_OPERATOR_NAME - | GLOSSARY_ENTRY_DEFINITION_NAME - | GLOSSARY_ENTRY_REFERENCE_NAME - | ACRONYM_DEFINITION_NAME - | ACRONYM_DECLARATION_NAME - | ACRONYM_REFERENCE_NAME - | THEOREM_DEFINITION_NAME - | COLOR_REFERENCE_NAME - | COLOR_DEFINITION_NAME - | COLOR_SET_DEFINITION_NAME - | TIKZ_LIBRARY_IMPORT_NAME - ) - } -} - impl From for rowan::SyntaxKind { fn from(kind: SyntaxKind) -> Self { Self(kind as u16) diff --git a/support/texlab/src/tests.rs b/support/texlab/src/tests.rs deleted file mode 100644 index c6afcfc20c..0000000000 --- a/support/texlab/src/tests.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod client; -mod fixture; -mod issues; -mod text_document; -mod workspace; diff --git a/support/texlab/src/util/chktex.rs b/support/texlab/src/util/chktex.rs index d87eff5f9c..0774207917 100644 --- a/support/texlab/src/util/chktex.rs +++ b/support/texlab/src/util/chktex.rs @@ -42,7 +42,7 @@ impl Command { log::debug!("Calling ChkTeX from directory: {}", working_dir.display()); - let text = document.contents(db).text(db).clone(); + let text = document.text(db).clone(); Some(Self { text, working_dir }) } diff --git a/support/texlab/src/util/cursor.rs b/support/texlab/src/util/cursor.rs index 63579c433c..d3168155da 100644 --- a/support/texlab/src/util/cursor.rs +++ b/support/texlab/src/util/cursor.rs @@ -24,7 +24,7 @@ impl Cursor { let left = left?; let right = right?; - if left.kind().is_command_name() { + if left.kind() == latex::COMMAND_NAME { return Some(Self::Tex(left)); } @@ -36,7 +36,7 @@ impl Cursor { return Some(Self::Tex(left)); } - if right.kind().is_command_name() { + if right.kind() == latex::COMMAND_NAME { return Some(Self::Tex(right)); } @@ -105,7 +105,7 @@ impl Cursor { pub fn command_range(&self, offset: TextSize) -> Option { self.as_tex() - .filter(|token| token.kind().is_command_name()) + .filter(|token| token.kind() == latex::COMMAND_NAME) .filter(|token| token.text_range().start() != offset) .map(|token| token.text_range()) .map(|range| TextRange::new(range.start() + TextSize::from(1), range.end())) @@ -135,7 +135,7 @@ impl<'db, T> CursorContext<'db, T> { pub fn new(db: &'db dyn Db, uri: &Url, position: Position, params: T) -> Option { let workspace = Workspace::get(db); let document = workspace.lookup_uri(db, uri)?; - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); let offset = line_index.offset_lsp(position); let cursor = match document.parse(db) { @@ -251,6 +251,22 @@ impl<'db, T> CursorContext<'db, T> { Some((name, range)) } + pub fn find_environment(&self) -> Option<(latex::Key, latex::Key)> { + let token = self.cursor.as_tex()?; + + for env in token + .parent_ancestors() + .filter_map(latex::Environment::cast) + { + let beg = env.begin()?.name()?.key()?; + let end = env.end()?.name()?.key()?; + + return Some((beg, end)); + } + + None + } + pub fn find_curly_group_word(&self) -> Option<(String, TextRange, latex::CurlyGroupWord)> { let token = self.cursor.as_tex()?; let key = latex::Key::cast(token.parent()?); @@ -285,8 +301,7 @@ impl<'db, T> CursorContext<'db, T> { let range = if group .syntax() .last_token() - .filter(|tok| tok.kind() == latex::MISSING) - .is_some() + .map_or(false, |tok| tok.kind() != latex::R_CURLY) { TextRange::new(latex::small_range(&key).start(), token.text_range().end()) } else { diff --git a/support/texlab/src/util/label.rs b/support/texlab/src/util/label.rs index 50e2ea21e7..74c72b234a 100644 --- a/support/texlab/src/util/label.rs +++ b/support/texlab/src/util/label.rs @@ -10,8 +10,6 @@ use crate::{ use self::LabeledObject::*; -use super::lang_data::LANGUAGE_DATA; - #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum LabeledFloatKind { Figure, @@ -135,7 +133,7 @@ pub fn render(db: &dyn Db, document: Document, label_def: label::Name) -> Option render_label_float(parent.clone(), label_num) .or_else(|| render_label_section(parent.clone(), label_num)) .or_else(|| render_label_enum_item(db, parent.clone(), label_num)) - .or_else(|| render_label_equation(parent.clone(), label_num)) + .or_else(|| render_label_equation(db, parent.clone(), label_num)) .or_else(|| render_label_theorem(db, document, parent, label_num)) }) } @@ -214,20 +212,20 @@ fn render_label_enum_item( }) } -fn render_label_equation(parent: latex::SyntaxNode, number: Option) -> Option { - let environment = latex::Environment::cast(parent)?; - let environment_name = environment.begin()?.name()?.key()?.to_string(); +fn render_label_equation( + db: &dyn Db, + parent: latex::SyntaxNode, + number: Option, +) -> Option { + let env = latex::Environment::cast(parent)?; + let env_name = env.begin()?.name()?.key()?.to_string(); - if !LANGUAGE_DATA - .math_environments - .iter() - .any(|name| name == &environment_name) - { + if !db.config().syntax.math_environments.contains(&env_name) { return None; } Some(RenderedLabel { - range: latex::small_range(&environment), + range: latex::small_range(&env), number, object: LabeledObject::Equation, }) diff --git a/support/texlab/src/util/lang_data.rs b/support/texlab/src/util/lang_data.rs index f270c3f65e..734ceb6df2 100644 --- a/support/texlab/src/util/lang_data.rs +++ b/support/texlab/src/util/lang_data.rs @@ -36,8 +36,6 @@ pub struct LanguageData { pub fields: Vec, pub pgf_libraries: Vec, pub tikz_libraries: Vec, - pub math_environments: Vec, - pub enum_environments: Vec, } impl LanguageData { diff --git a/support/texlab/src/util/regex_filter.rs b/support/texlab/src/util/regex_filter.rs index f107ea16fe..a33417464e 100644 --- a/support/texlab/src/util/regex_filter.rs +++ b/support/texlab/src/util/regex_filter.rs @@ -1,21 +1,17 @@ -use crate::RegexPattern; +use regex::Regex; -pub fn filter( - text: &str, - allowed_patterns: &[RegexPattern], - ignored_patterns: &[RegexPattern], -) -> bool { +pub fn filter(text: &str, allowed_patterns: &[Regex], ignored_patterns: &[Regex]) -> bool { if !allowed_patterns.is_empty() && !allowed_patterns .iter() - .any(|pattern| pattern.0.is_match(text)) + .any(|pattern| pattern.is_match(text)) { return false; } if ignored_patterns .iter() - .any(|pattern| pattern.0.is_match(text)) + .any(|pattern| pattern.is_match(text)) { return false; } -- cgit v1.2.3