summaryrefslogtreecommitdiff
path: root/support/texlab/src/syntax/latex/analysis/command.rs
blob: 60aceef725b72dcc3817ad1e87379f97c9e7ea99 (plain)
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
use rowan::ast::AstNode;

use crate::syntax::latex;

use super::LatexAnalyzerContext;

pub fn analyze_command(context: &mut LatexAnalyzerContext, node: latex::SyntaxNode) -> Option<()> {
    let command = latex::GenericCommand::cast(node)?;
    context
        .extras
        .command_names
        .insert(command.name()?.text().into());
    Some(())
}

pub fn analyze_command_definition(
    context: &mut LatexAnalyzerContext,
    node: latex::SyntaxNode,
) -> Option<()> {
    let definition = latex::CommandDefinition::cast(node)?;
    context
        .extras
        .command_names
        .insert(definition.name()?.command()?.text().into());
    Some(())
}