use std::sync::Arc; use lsp_types::Url; use rowan::TextRange; use rustc_hash::{FxHashMap, FxHashSet}; use smol_str::SmolStr; use crate::Environment; #[derive(Debug)] pub struct LatexAnalyzerContext<'a> { pub environment: &'a Environment, pub document_uri: Arc, pub base_uri: Arc, pub extras: Extras, } #[derive(Debug, Clone, Default)] pub struct Extras { pub implicit_links: ImplicitLinks, pub explicit_links: Vec, pub has_document_environment: bool, pub command_names: FxHashSet, pub environment_names: FxHashSet, pub label_names: Vec, pub label_numbers_by_name: FxHashMap, pub theorem_environments: Vec, pub graphics_paths: FxHashSet, } #[derive(Debug, PartialEq, Eq, Clone, Default, Hash)] pub struct ImplicitLinks { pub aux: Vec>, pub log: Vec>, pub pdf: Vec>, } #[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord, Hash)] pub enum ExplicitLinkKind { Package, Class, Latex, Bibtex, } #[derive(Debug, Clone)] pub struct ExplicitLink { pub stem: SmolStr, pub stem_range: TextRange, pub targets: Vec>, pub kind: ExplicitLinkKind, } impl ExplicitLink { pub fn as_component_name(&self) -> Option { match self.kind { ExplicitLinkKind::Package => Some(format!("{}.sty", self.stem)), ExplicitLinkKind::Class => Some(format!("{}.cls", self.stem)), ExplicitLinkKind::Latex | ExplicitLinkKind::Bibtex => None, } } } #[derive(Debug, PartialEq, Eq, Clone, Default, Hash)] pub struct TheoremEnvironment { pub name: String, pub description: String, } #[derive(Debug, PartialEq, Eq, Clone, Default, Hash)] pub struct LabelName { pub text: SmolStr, pub range: TextRange, pub is_definition: bool, }