summaryrefslogtreecommitdiff
path: root/crates/typst-syntax/src/node.rs
diff options
context:
space:
mode:
authorIan Wrzesinski <133046678+wrzian@users.noreply.github.com>2025-02-26 15:10:36 -0500
committerGitHub <noreply@github.com>2025-02-26 20:10:36 +0000
commitcfb3b1a2709107f0f06f89ea25cabc939cec15e5 (patch)
treef61f39cc3c1a6eec30d37aa4202d6c599e74b2f7 /crates/typst-syntax/src/node.rs
parent52f1f53973414be72bf22c3253ab365f8db067df (diff)
Improve clarity of `ast.rs` for newcomers to the codebase (#5784)
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com> Co-authored-by: T0mstone <39707032+T0mstone@users.noreply.github.com>
Diffstat (limited to 'crates/typst-syntax/src/node.rs')
-rw-r--r--crates/typst-syntax/src/node.rs21
1 files changed, 0 insertions, 21 deletions
diff --git a/crates/typst-syntax/src/node.rs b/crates/typst-syntax/src/node.rs
index fde2eaca..948657ca 100644
--- a/crates/typst-syntax/src/node.rs
+++ b/crates/typst-syntax/src/node.rs
@@ -5,7 +5,6 @@ use std::sync::Arc;
use ecow::{eco_format, eco_vec, EcoString, EcoVec};
-use crate::ast::AstNode;
use crate::{FileId, Span, SyntaxKind};
/// A node in the untyped syntax tree.
@@ -119,26 +118,6 @@ impl SyntaxNode {
}
}
- /// Whether the node can be cast to the given AST node.
- pub fn is<'a, T: AstNode<'a>>(&'a self) -> bool {
- self.cast::<T>().is_some()
- }
-
- /// Try to convert the node to a typed AST node.
- pub fn cast<'a, T: AstNode<'a>>(&'a self) -> Option<T> {
- T::from_untyped(self)
- }
-
- /// Cast the first child that can cast to the AST type `T`.
- pub fn cast_first_match<'a, T: AstNode<'a>>(&'a self) -> Option<T> {
- self.children().find_map(Self::cast)
- }
-
- /// Cast the last child that can cast to the AST type `T`.
- pub fn cast_last_match<'a, T: AstNode<'a>>(&'a self) -> Option<T> {
- self.children().rev().find_map(Self::cast)
- }
-
/// Whether the node or its children contain an error.
pub fn erroneous(&self) -> bool {
match &self.0 {