summaryrefslogtreecommitdiff
path: root/support/texlab/crates/syntax/src/latex/cst.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/syntax/src/latex/cst.rs')
-rw-r--r--support/texlab/crates/syntax/src/latex/cst.rs35
1 files changed, 31 insertions, 4 deletions
diff --git a/support/texlab/crates/syntax/src/latex/cst.rs b/support/texlab/crates/syntax/src/latex/cst.rs
index 95aa1e4667..f16d703162 100644
--- a/support/texlab/crates/syntax/src/latex/cst.rs
+++ b/support/texlab/crates/syntax/src/latex/cst.rs
@@ -555,8 +555,19 @@ impl TheoremDefinition {
self.syntax().first_token()
}
- pub fn name(&self) -> Option<CurlyGroupWord> {
- self.syntax().children().find_map(CurlyGroupWord::cast)
+ pub fn names(&self) -> impl Iterator<Item = Key> {
+ self.syntax()
+ .children()
+ .find_map(CurlyGroupWordList::cast)
+ .into_iter()
+ .flat_map(|group| group.keys())
+ .chain(
+ self.syntax()
+ .children()
+ .find_map(CurlyGroupWord::cast)
+ .into_iter()
+ .filter_map(|group| group.key()),
+ )
}
pub fn heading(&self) -> Option<String> {
@@ -581,9 +592,25 @@ impl TheoremDefinition {
}
}
-cst_node!(CommandDefinition, COMMAND_DEFINITION, MATH_OPERATOR);
+cst_node!(OldCommandDefinition, OLD_COMMAND_DEFINITION);
+
+impl OldCommandDefinition {
+ pub fn command(&self) -> Option<SyntaxToken> {
+ self.syntax().first_token()
+ }
+
+ pub fn name(&self) -> Option<SyntaxToken> {
+ self.syntax()
+ .children_with_tokens()
+ .skip(1)
+ .filter_map(|elem| elem.into_token())
+ .find(|token| token.kind() == COMMAND_NAME)
+ }
+}
+
+cst_node!(NewCommandDefinition, NEW_COMMAND_DEFINITION, MATH_OPERATOR);
-impl CommandDefinition {
+impl NewCommandDefinition {
pub fn command(&self) -> Option<SyntaxToken> {
self.syntax().first_token()
}