1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
use super::ast::*;
use crate::syntax::language::*;
use crate::syntax::text::SyntaxNode;
use lsp_types::Range;
use std::sync::Arc;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct LatexGlossaryEntry {
pub command: Arc<LatexCommand>,
pub label_index: usize,
pub kind: LatexGlossaryEntryKind,
}
impl SyntaxNode for LatexGlossaryEntry {
fn range(&self) -> Range {
self.command.range()
}
}
impl LatexGlossaryEntry {
pub fn label(&self) -> &LatexToken {
self.command.extract_word(self.label_index).unwrap()
}
fn parse(commands: &[Arc<LatexCommand>]) -> Vec<Self> {
let mut entries = Vec::new();
for command in commands {
for LatexGlossaryEntryDefinitionCommand {
name,
label_index,
kind,
} in &LANGUAGE_DATA.glossary_entry_definition_commands
{
if command.name.text() == name && command.has_word(*label_index) {
entries.push(Self {
command: Arc::clone(&command),
label_index: *label_index,
kind: *kind,
});
}
}
}
entries
}
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct LatexGlossaryInfo {
pub entries: Vec<LatexGlossaryEntry>,
}
impl LatexGlossaryInfo {
pub fn parse(commands: &[Arc<LatexCommand>]) -> Self {
Self {
entries: LatexGlossaryEntry::parse(commands),
}
}
}
|