Simplify chaining code.
This commit is contained in:
@@ -624,6 +624,38 @@ impl Expr {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
/// Get the [options][ASTFlags] of the expression.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn options(&self) -> ASTFlags {
|
||||
match self {
|
||||
Self::Index(_, options, _) | Self::Dot(_, options, _) => *options,
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
Self::FloatConstant(..) => ASTFlags::NONE,
|
||||
|
||||
Self::DynamicConstant(..)
|
||||
| Self::BoolConstant(..)
|
||||
| Self::IntegerConstant(..)
|
||||
| Self::CharConstant(..)
|
||||
| Self::Unit(..)
|
||||
| Self::StringConstant(..)
|
||||
| Self::Array(..)
|
||||
| Self::Map(..)
|
||||
| Self::Variable(..)
|
||||
| Self::And(..)
|
||||
| Self::Or(..)
|
||||
| Self::Coalesce(..)
|
||||
| Self::FnCall(..)
|
||||
| Self::MethodCall(..)
|
||||
| Self::InterpolatedString(..)
|
||||
| Self::Property(..)
|
||||
| Self::Stmt(..) => ASTFlags::NONE,
|
||||
|
||||
#[cfg(not(feature = "no_custom_syntax"))]
|
||||
Self::Custom(..) => ASTFlags::NONE,
|
||||
}
|
||||
}
|
||||
/// Get the [position][Position] of the expression.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
|
@@ -656,6 +656,34 @@ impl Stmt {
|
||||
pub const fn is_noop(&self) -> bool {
|
||||
matches!(self, Self::Noop(..))
|
||||
}
|
||||
/// Get the [options][ASTFlags] of this statement.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn options(&self) -> ASTFlags {
|
||||
match self {
|
||||
Self::Do(_, options, _)
|
||||
| Self::Var(_, options, _)
|
||||
| Self::BreakLoop(_, options, _)
|
||||
| Self::Return(_, options, _) => *options,
|
||||
|
||||
Self::Noop(..)
|
||||
| Self::If(..)
|
||||
| Self::Switch(..)
|
||||
| Self::Block(..)
|
||||
| Self::Expr(..)
|
||||
| Self::FnCall(..)
|
||||
| Self::While(..)
|
||||
| Self::For(..)
|
||||
| Self::TryCatch(..)
|
||||
| Self::Assignment(..) => ASTFlags::NONE,
|
||||
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
Self::Import(..) | Self::Export(..) => ASTFlags::NONE,
|
||||
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::Share(..) => ASTFlags::NONE,
|
||||
}
|
||||
}
|
||||
/// Get the [position][Position] of this statement.
|
||||
#[must_use]
|
||||
pub fn position(&self) -> Position {
|
||||
|
Reference in New Issue
Block a user