difftreelog
refactor demote ::, ::: from full tokens to multiple colon tokens
in: master
21 files changed
crates/jrsonnet-formatter/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-formatter/Cargo.toml
+++ b/crates/jrsonnet-formatter/Cargo.toml
@@ -11,6 +11,7 @@
hi-doc.workspace = true
indoc.workspace = true
insta.workspace = true
+jrsonnet-lexer = { version = "0.5.0-pre97", path = "../jrsonnet-lexer" }
jrsonnet-rowan-parser.workspace = true
[lints]
crates/jrsonnet-formatter/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-formatter/src/lib.rs
+++ b/crates/jrsonnet-formatter/src/lib.rs
@@ -8,8 +8,8 @@
ConditionResolver, ConditionResolverContext, LineNumber, PrintItems, PrintOptions,
};
use hi_doc::{Formatting, SnippetBuilder};
+use jrsonnet_lexer::collect_lexed_str_block;
use jrsonnet_rowan_parser::{
- collect_lexed_str_block,
nodes::{
Arg, ArgsDesc, Assertion, BinaryOperator, Bind, CompSpec, Destruct, DestructArrayPart,
DestructRest, Expr, ExprArray, ExprBase, FieldName, ForSpec, IfSpec, ImportKind, Literal,
@@ -790,7 +790,7 @@
// pi
// }
Self::ExprObjExtend(ex) => {
- p!(out, {ex.lhs_work()} str(" ") {ex.rhs_work()});
+ p!(out, {ex.lhs()} str(" ") {ex.rhs()});
}
Self::ExprParened(p) => {
p!(out, str("(") {p.expr()} str(")"));
crates/jrsonnet-formatter/src/snapshots/jrsonnet_formatter__tests__snapshots@visibilities.jsonnet.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-formatter/src/snapshots/jrsonnet_formatter__tests__snapshots@visibilities.jsonnet.snap
@@ -0,0 +1,6 @@
+---
+source: crates/jrsonnet-formatter/src/tests.rs
+expression: reformat(&input)
+input_file: crates/jrsonnet-formatter/src/tests/visibilities.jsonnet
+---
+{ normal: 1, hide:: 2, unhide::: 3 }
crates/jrsonnet-formatter/src/tests/visibilities.jsonnetdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-formatter/src/tests/visibilities.jsonnet
@@ -0,0 +1 @@
+{normal:1,hide::2,unhide:::3}
crates/jrsonnet-lexer/src/generated/syntax_kinds.rsdiffbeforeafterboth--- a/crates/jrsonnet-lexer/src/generated/syntax_kinds.rs
+++ b/crates/jrsonnet-lexer/src/generated/syntax_kinds.rs
@@ -72,10 +72,6 @@
R_BRACE,
#[token(":")]
COLON,
- #[token("::")]
- COLONCOLON,
- #[token(":::")]
- COLONCOLONCOLON,
#[token(";")]
SEMI,
#[token(".")]
@@ -188,11 +184,10 @@
match self {
OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE
| LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | NOT | BIT_NOT | L_BRACK | R_BRACK
- | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | COLONCOLON | COLONCOLONCOLON
- | SEMI | DOT | DOTDOTDOT | COMMA | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW
- | LOCAL_KW | IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW
- | FUNCTION_KW | ERROR_KW | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW
- | SUPER_KW | FOR_KW | ASSERT_KW => true,
+ | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | SEMI | DOT | DOTDOTDOT | COMMA
+ | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW | LOCAL_KW | IMPORTSTR_KW
+ | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW | FUNCTION_KW | ERROR_KW
+ | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | SUPER_KW | FOR_KW | ASSERT_KW => true,
_ => false,
}
}
@@ -205,6 +200,6 @@
}
}
#[macro_export]
-macro_rules ! T { [||] => { $ crate :: SyntaxKind :: OR } ; [??] => { $ crate :: SyntaxKind :: NULL_COAELSE } ; [&&] => { $ crate :: SyntaxKind :: AND } ; [|] => { $ crate :: SyntaxKind :: BIT_OR } ; [^] => { $ crate :: SyntaxKind :: BIT_XOR } ; [&] => { $ crate :: SyntaxKind :: BIT_AND } ; [==] => { $ crate :: SyntaxKind :: EQ } ; [!=] => { $ crate :: SyntaxKind :: NE } ; [<] => { $ crate :: SyntaxKind :: LT } ; [>] => { $ crate :: SyntaxKind :: GT } ; [<=] => { $ crate :: SyntaxKind :: LE } ; [>=] => { $ crate :: SyntaxKind :: GE } ; [<<] => { $ crate :: SyntaxKind :: LHS } ; [>>] => { $ crate :: SyntaxKind :: RHS } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [*] => { $ crate :: SyntaxKind :: MUL } ; [/] => { $ crate :: SyntaxKind :: DIV } ; [%] => { $ crate :: SyntaxKind :: MODULO } ; [!] => { $ crate :: SyntaxKind :: NOT } ; [~] => { $ crate :: SyntaxKind :: BIT_NOT } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_BRACE } ; ['}'] => { $ crate :: SyntaxKind :: R_BRACE } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLONCOLON } ; [:::] => { $ crate :: SyntaxKind :: COLONCOLONCOLON } ; [;] => { $ crate :: SyntaxKind :: SEMI } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [...] => { $ crate :: SyntaxKind :: DOTDOTDOT } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['$'] => { $ crate :: SyntaxKind :: DOLLAR } ; [=] => { $ crate :: SyntaxKind :: ASSIGN } ; [?] => { $ crate :: SyntaxKind :: QUESTION_MARK } ; [tailstrict] => { $ crate :: SyntaxKind :: TAILSTRICT_KW } ; [local] => { $ crate :: SyntaxKind :: LOCAL_KW } ; [importstr] => { $ crate :: SyntaxKind :: IMPORTSTR_KW } ; [importbin] => { $ crate :: SyntaxKind :: IMPORTBIN_KW } ; [import] => { $ crate :: SyntaxKind :: IMPORT_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [then] => { $ crate :: SyntaxKind :: THEN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [function] => { $ crate :: SyntaxKind :: FUNCTION_KW } ; [error] => { $ crate :: SyntaxKind :: ERROR_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [null] => { $ crate :: SyntaxKind :: NULL_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [assert] => { $ crate :: SyntaxKind :: ASSERT_KW } }
+macro_rules ! T { [||] => { $ crate :: SyntaxKind :: OR } ; [??] => { $ crate :: SyntaxKind :: NULL_COAELSE } ; [&&] => { $ crate :: SyntaxKind :: AND } ; [|] => { $ crate :: SyntaxKind :: BIT_OR } ; [^] => { $ crate :: SyntaxKind :: BIT_XOR } ; [&] => { $ crate :: SyntaxKind :: BIT_AND } ; [==] => { $ crate :: SyntaxKind :: EQ } ; [!=] => { $ crate :: SyntaxKind :: NE } ; [<] => { $ crate :: SyntaxKind :: LT } ; [>] => { $ crate :: SyntaxKind :: GT } ; [<=] => { $ crate :: SyntaxKind :: LE } ; [>=] => { $ crate :: SyntaxKind :: GE } ; [<<] => { $ crate :: SyntaxKind :: LHS } ; [>>] => { $ crate :: SyntaxKind :: RHS } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [*] => { $ crate :: SyntaxKind :: MUL } ; [/] => { $ crate :: SyntaxKind :: DIV } ; [%] => { $ crate :: SyntaxKind :: MODULO } ; [!] => { $ crate :: SyntaxKind :: NOT } ; [~] => { $ crate :: SyntaxKind :: BIT_NOT } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_BRACE } ; ['}'] => { $ crate :: SyntaxKind :: R_BRACE } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [;] => { $ crate :: SyntaxKind :: SEMI } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [...] => { $ crate :: SyntaxKind :: DOTDOTDOT } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['$'] => { $ crate :: SyntaxKind :: DOLLAR } ; [=] => { $ crate :: SyntaxKind :: ASSIGN } ; [?] => { $ crate :: SyntaxKind :: QUESTION_MARK } ; [tailstrict] => { $ crate :: SyntaxKind :: TAILSTRICT_KW } ; [local] => { $ crate :: SyntaxKind :: LOCAL_KW } ; [importstr] => { $ crate :: SyntaxKind :: IMPORTSTR_KW } ; [importbin] => { $ crate :: SyntaxKind :: IMPORTBIN_KW } ; [import] => { $ crate :: SyntaxKind :: IMPORT_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [then] => { $ crate :: SyntaxKind :: THEN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [function] => { $ crate :: SyntaxKind :: FUNCTION_KW } ; [error] => { $ crate :: SyntaxKind :: ERROR_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [null] => { $ crate :: SyntaxKind :: NULL_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [assert] => { $ crate :: SyntaxKind :: ASSERT_KW } }
#[allow(unused_imports)]
pub use T;
crates/jrsonnet-lexer/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-lexer/src/lib.rs
+++ b/crates/jrsonnet-lexer/src/lib.rs
@@ -5,4 +5,6 @@
#[derive(Clone, Copy, Debug)]
pub struct Span(pub u32, pub u32);
+pub use generated::syntax_kinds::SyntaxKind;
pub use lex::{Lexeme, Lexer};
+pub use string_block::{collect_lexed_str_block, CollectStrBlock};
crates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/jsonnet.ungram
+++ b/crates/jrsonnet-rowan-parser/jsonnet.ungram
@@ -44,8 +44,8 @@
UnaryOperator
rhs:Expr
ExprObjExtend =
- Expr
- Expr
+ lhs:Expr
+ rhs:Expr
ExprParened =
'('
Expr
@@ -209,9 +209,7 @@
| FieldNameDynamic
Visibility =
- ':::'
-| '::'
-| ':'
+ ':' v1:':'? v2:':'?
Literal =
'null'
crates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth1//! This is a generated file, please do not edit manually. Changes can be2//! made in codegeneration that lives in `xtask` top-level dir.34#![allow(non_snake_case, clippy::match_like_matches_macro)]5use crate::{6 ast::{support, AstChildren, AstNode, AstToken},7 SyntaxKind::{self, *},8 SyntaxNode, SyntaxToken, T,9};1011#[derive(Debug, Clone, PartialEq, Eq, Hash)]12pub struct SourceFile {13 pub(crate) syntax: SyntaxNode,14}15impl SourceFile {16 pub fn expr(&self) -> Option<Expr> {17 support::children(&self.syntax).next()18 }19}2021#[derive(Debug, Clone, PartialEq, Eq, Hash)]22pub struct Expr {23 pub(crate) syntax: SyntaxNode,24}25impl Expr {26 pub fn stmts(&self) -> AstChildren<Stmt> {27 support::children(&self.syntax)28 }29 pub fn expr_base(&self) -> Option<ExprBase> {30 support::children(&self.syntax).next()31 }32 pub fn suffixs(&self) -> AstChildren<Suffix> {33 support::children(&self.syntax)34 }35}3637#[derive(Debug, Clone, PartialEq, Eq, Hash)]38pub struct SuffixIndex {39 pub(crate) syntax: SyntaxNode,40}41impl SuffixIndex {42 pub fn question_mark_token(&self) -> Option<SyntaxToken> {43 support::token(&self.syntax, T![?])44 }45 pub fn dot_token(&self) -> Option<SyntaxToken> {46 support::token(&self.syntax, T![.])47 }48 pub fn index(&self) -> Option<Name> {49 support::children(&self.syntax).next()50 }51}5253#[derive(Debug, Clone, PartialEq, Eq, Hash)]54pub struct Name {55 pub(crate) syntax: SyntaxNode,56}57impl Name {58 pub fn ident_lit(&self) -> Option<SyntaxToken> {59 support::token(&self.syntax, IDENT)60 }61}6263#[derive(Debug, Clone, PartialEq, Eq, Hash)]64pub struct SuffixIndexExpr {65 pub(crate) syntax: SyntaxNode,66}67impl SuffixIndexExpr {68 pub fn question_mark_token(&self) -> Option<SyntaxToken> {69 support::token(&self.syntax, T![?])70 }71 pub fn dot_token(&self) -> Option<SyntaxToken> {72 support::token(&self.syntax, T![.])73 }74 pub fn l_brack_token(&self) -> Option<SyntaxToken> {75 support::token(&self.syntax, T!['['])76 }77 pub fn index(&self) -> Option<Expr> {78 support::children(&self.syntax).next()79 }80 pub fn r_brack_token(&self) -> Option<SyntaxToken> {81 support::token(&self.syntax, T![']'])82 }83}8485#[derive(Debug, Clone, PartialEq, Eq, Hash)]86pub struct SuffixSlice {87 pub(crate) syntax: SyntaxNode,88}89impl SuffixSlice {90 pub fn slice_desc(&self) -> Option<SliceDesc> {91 support::children(&self.syntax).next()92 }93}9495#[derive(Debug, Clone, PartialEq, Eq, Hash)]96pub struct SliceDesc {97 pub(crate) syntax: SyntaxNode,98}99impl SliceDesc {100 pub fn l_brack_token(&self) -> Option<SyntaxToken> {101 support::token(&self.syntax, T!['['])102 }103 pub fn from(&self) -> Option<Expr> {104 support::children(&self.syntax).next()105 }106 pub fn colon_token(&self) -> Option<SyntaxToken> {107 support::token(&self.syntax, T![:])108 }109 pub fn end(&self) -> Option<SliceDescEnd> {110 support::children(&self.syntax).next()111 }112 pub fn step(&self) -> Option<SliceDescStep> {113 support::children(&self.syntax).next()114 }115 pub fn r_brack_token(&self) -> Option<SyntaxToken> {116 support::token(&self.syntax, T![']'])117 }118}119120#[derive(Debug, Clone, PartialEq, Eq, Hash)]121pub struct SuffixApply {122 pub(crate) syntax: SyntaxNode,123}124impl SuffixApply {125 pub fn args_desc(&self) -> Option<ArgsDesc> {126 support::children(&self.syntax).next()127 }128 pub fn tailstrict_kw_token(&self) -> Option<SyntaxToken> {129 support::token(&self.syntax, T![tailstrict])130 }131}132133#[derive(Debug, Clone, PartialEq, Eq, Hash)]134pub struct ArgsDesc {135 pub(crate) syntax: SyntaxNode,136}137impl ArgsDesc {138 pub fn l_paren_token(&self) -> Option<SyntaxToken> {139 support::token(&self.syntax, T!['('])140 }141 pub fn args(&self) -> AstChildren<Arg> {142 support::children(&self.syntax)143 }144 pub fn r_paren_token(&self) -> Option<SyntaxToken> {145 support::token(&self.syntax, T![')'])146 }147}148149#[derive(Debug, Clone, PartialEq, Eq, Hash)]150pub struct StmtLocal {151 pub(crate) syntax: SyntaxNode,152}153impl StmtLocal {154 pub fn local_kw_token(&self) -> Option<SyntaxToken> {155 support::token(&self.syntax, T![local])156 }157 pub fn binds(&self) -> AstChildren<Bind> {158 support::children(&self.syntax)159 }160 pub fn semi_token(&self) -> Option<SyntaxToken> {161 support::token(&self.syntax, T![;])162 }163}164165#[derive(Debug, Clone, PartialEq, Eq, Hash)]166pub struct StmtAssert {167 pub(crate) syntax: SyntaxNode,168}169impl StmtAssert {170 pub fn assertion(&self) -> Option<Assertion> {171 support::children(&self.syntax).next()172 }173 pub fn semi_token(&self) -> Option<SyntaxToken> {174 support::token(&self.syntax, T![;])175 }176}177178#[derive(Debug, Clone, PartialEq, Eq, Hash)]179pub struct Assertion {180 pub(crate) syntax: SyntaxNode,181}182impl Assertion {183 pub fn assert_kw_token(&self) -> Option<SyntaxToken> {184 support::token(&self.syntax, T![assert])185 }186 pub fn condition(&self) -> Option<Expr> {187 support::children(&self.syntax).next()188 }189 pub fn colon_token(&self) -> Option<SyntaxToken> {190 support::token(&self.syntax, T![:])191 }192 pub fn message(&self) -> Option<Expr> {193 support::children(&self.syntax).nth(1usize)194 }195}196197#[derive(Debug, Clone, PartialEq, Eq, Hash)]198pub struct ExprBinary {199 pub(crate) syntax: SyntaxNode,200}201impl ExprBinary {202 pub fn lhs(&self) -> Option<Expr> {203 support::children(&self.syntax).next()204 }205 pub fn binary_operator(&self) -> Option<BinaryOperator> {206 support::token_child(&self.syntax)207 }208 pub fn rhs(&self) -> Option<Expr> {209 support::children(&self.syntax).nth(1usize)210 }211}212213#[derive(Debug, Clone, PartialEq, Eq, Hash)]214pub struct ExprUnary {215 pub(crate) syntax: SyntaxNode,216}217impl ExprUnary {218 pub fn unary_operator(&self) -> Option<UnaryOperator> {219 support::token_child(&self.syntax)220 }221 pub fn rhs(&self) -> Option<Expr> {222 support::children(&self.syntax).next()223 }224}225226#[derive(Debug, Clone, PartialEq, Eq, Hash)]227pub struct ExprObjExtend {228 pub(crate) syntax: SyntaxNode,229}230impl ExprObjExtend {231 pub fn expr(&self) -> Option<Expr> {232 support::children(&self.syntax).next()233 }234}235236#[derive(Debug, Clone, PartialEq, Eq, Hash)]237pub struct ExprParened {238 pub(crate) syntax: SyntaxNode,239}240impl ExprParened {241 pub fn l_paren_token(&self) -> Option<SyntaxToken> {242 support::token(&self.syntax, T!['('])243 }244 pub fn expr(&self) -> Option<Expr> {245 support::children(&self.syntax).next()246 }247 pub fn r_paren_token(&self) -> Option<SyntaxToken> {248 support::token(&self.syntax, T![')'])249 }250}251252#[derive(Debug, Clone, PartialEq, Eq, Hash)]253pub struct ExprLiteral {254 pub(crate) syntax: SyntaxNode,255}256impl ExprLiteral {257 pub fn literal(&self) -> Option<Literal> {258 support::token_child(&self.syntax)259 }260}261262#[derive(Debug, Clone, PartialEq, Eq, Hash)]263pub struct ExprString {264 pub(crate) syntax: SyntaxNode,265}266impl ExprString {267 pub fn text(&self) -> Option<Text> {268 support::token_child(&self.syntax)269 }270}271272#[derive(Debug, Clone, PartialEq, Eq, Hash)]273pub struct ExprNumber {274 pub(crate) syntax: SyntaxNode,275}276impl ExprNumber {277 pub fn number(&self) -> Option<Number> {278 support::token_child(&self.syntax)279 }280}281282#[derive(Debug, Clone, PartialEq, Eq, Hash)]283pub struct ExprArray {284 pub(crate) syntax: SyntaxNode,285}286impl ExprArray {287 pub fn l_brack_token(&self) -> Option<SyntaxToken> {288 support::token(&self.syntax, T!['['])289 }290 pub fn exprs(&self) -> AstChildren<Expr> {291 support::children(&self.syntax)292 }293 pub fn r_brack_token(&self) -> Option<SyntaxToken> {294 support::token(&self.syntax, T![']'])295 }296}297298#[derive(Debug, Clone, PartialEq, Eq, Hash)]299pub struct ExprObject {300 pub(crate) syntax: SyntaxNode,301}302impl ExprObject {303 pub fn obj_body(&self) -> Option<ObjBody> {304 support::children(&self.syntax).next()305 }306}307308#[derive(Debug, Clone, PartialEq, Eq, Hash)]309pub struct ExprArrayComp {310 pub(crate) syntax: SyntaxNode,311}312impl ExprArrayComp {313 pub fn l_brack_token(&self) -> Option<SyntaxToken> {314 support::token(&self.syntax, T!['['])315 }316 pub fn expr(&self) -> Option<Expr> {317 support::children(&self.syntax).next()318 }319 pub fn comma_token(&self) -> Option<SyntaxToken> {320 support::token(&self.syntax, T![,])321 }322 pub fn comp_specs(&self) -> AstChildren<CompSpec> {323 support::children(&self.syntax)324 }325 pub fn r_brack_token(&self) -> Option<SyntaxToken> {326 support::token(&self.syntax, T![']'])327 }328}329330#[derive(Debug, Clone, PartialEq, Eq, Hash)]331pub struct ExprImport {332 pub(crate) syntax: SyntaxNode,333}334impl ExprImport {335 pub fn import_kind(&self) -> Option<ImportKind> {336 support::token_child(&self.syntax)337 }338 pub fn text(&self) -> Option<Text> {339 support::token_child(&self.syntax)340 }341}342343#[derive(Debug, Clone, PartialEq, Eq, Hash)]344pub struct ExprVar {345 pub(crate) syntax: SyntaxNode,346}347impl ExprVar {348 pub fn name(&self) -> Option<Name> {349 support::children(&self.syntax).next()350 }351}352353#[derive(Debug, Clone, PartialEq, Eq, Hash)]354pub struct ExprIfThenElse {355 pub(crate) syntax: SyntaxNode,356}357impl ExprIfThenElse {358 pub fn if_kw_token(&self) -> Option<SyntaxToken> {359 support::token(&self.syntax, T![if])360 }361 pub fn cond(&self) -> Option<Expr> {362 support::children(&self.syntax).next()363 }364 pub fn then_kw_token(&self) -> Option<SyntaxToken> {365 support::token(&self.syntax, T![then])366 }367 pub fn then(&self) -> Option<TrueExpr> {368 support::children(&self.syntax).next()369 }370 pub fn else_kw_token(&self) -> Option<SyntaxToken> {371 support::token(&self.syntax, T![else])372 }373 pub fn else_(&self) -> Option<FalseExpr> {374 support::children(&self.syntax).next()375 }376}377378#[derive(Debug, Clone, PartialEq, Eq, Hash)]379pub struct TrueExpr {380 pub(crate) syntax: SyntaxNode,381}382impl TrueExpr {383 pub fn expr(&self) -> Option<Expr> {384 support::children(&self.syntax).next()385 }386}387388#[derive(Debug, Clone, PartialEq, Eq, Hash)]389pub struct FalseExpr {390 pub(crate) syntax: SyntaxNode,391}392impl FalseExpr {393 pub fn expr(&self) -> Option<Expr> {394 support::children(&self.syntax).next()395 }396}397398#[derive(Debug, Clone, PartialEq, Eq, Hash)]399pub struct ExprFunction {400 pub(crate) syntax: SyntaxNode,401}402impl ExprFunction {403 pub fn function_kw_token(&self) -> Option<SyntaxToken> {404 support::token(&self.syntax, T![function])405 }406 pub fn l_paren_token(&self) -> Option<SyntaxToken> {407 support::token(&self.syntax, T!['('])408 }409 pub fn params_desc(&self) -> Option<ParamsDesc> {410 support::children(&self.syntax).next()411 }412 pub fn r_paren_token(&self) -> Option<SyntaxToken> {413 support::token(&self.syntax, T![')'])414 }415 pub fn expr(&self) -> Option<Expr> {416 support::children(&self.syntax).next()417 }418}419420#[derive(Debug, Clone, PartialEq, Eq, Hash)]421pub struct ParamsDesc {422 pub(crate) syntax: SyntaxNode,423}424impl ParamsDesc {425 pub fn l_paren_token(&self) -> Option<SyntaxToken> {426 support::token(&self.syntax, T!['('])427 }428 pub fn params(&self) -> AstChildren<Param> {429 support::children(&self.syntax)430 }431 pub fn r_paren_token(&self) -> Option<SyntaxToken> {432 support::token(&self.syntax, T![')'])433 }434}435436#[derive(Debug, Clone, PartialEq, Eq, Hash)]437pub struct ExprError {438 pub(crate) syntax: SyntaxNode,439}440impl ExprError {441 pub fn error_kw_token(&self) -> Option<SyntaxToken> {442 support::token(&self.syntax, T![error])443 }444 pub fn expr(&self) -> Option<Expr> {445 support::children(&self.syntax).next()446 }447}448449#[derive(Debug, Clone, PartialEq, Eq, Hash)]450pub struct SliceDescEnd {451 pub(crate) syntax: SyntaxNode,452}453impl SliceDescEnd {454 pub fn expr(&self) -> Option<Expr> {455 support::children(&self.syntax).next()456 }457}458459#[derive(Debug, Clone, PartialEq, Eq, Hash)]460pub struct SliceDescStep {461 pub(crate) syntax: SyntaxNode,462}463impl SliceDescStep {464 pub fn expr(&self) -> Option<Expr> {465 support::children(&self.syntax).next()466 }467}468469#[derive(Debug, Clone, PartialEq, Eq, Hash)]470pub struct Arg {471 pub(crate) syntax: SyntaxNode,472}473impl Arg {474 pub fn name(&self) -> Option<Name> {475 support::children(&self.syntax).next()476 }477 pub fn assign_token(&self) -> Option<SyntaxToken> {478 support::token(&self.syntax, T![=])479 }480 pub fn expr(&self) -> Option<Expr> {481 support::children(&self.syntax).next()482 }483}484485#[derive(Debug, Clone, PartialEq, Eq, Hash)]486pub struct ObjBodyComp {487 pub(crate) syntax: SyntaxNode,488}489impl ObjBodyComp {490 pub fn l_brace_token(&self) -> Option<SyntaxToken> {491 support::token(&self.syntax, T!['{'])492 }493 pub fn member_comps(&self) -> AstChildren<MemberComp> {494 support::children(&self.syntax)495 }496 pub fn comp_specs(&self) -> AstChildren<CompSpec> {497 support::children(&self.syntax)498 }499 pub fn r_brace_token(&self) -> Option<SyntaxToken> {500 support::token(&self.syntax, T!['}'])501 }502}503504#[derive(Debug, Clone, PartialEq, Eq, Hash)]505pub struct ObjBodyMemberList {506 pub(crate) syntax: SyntaxNode,507}508impl ObjBodyMemberList {509 pub fn l_brace_token(&self) -> Option<SyntaxToken> {510 support::token(&self.syntax, T!['{'])511 }512 pub fn members(&self) -> AstChildren<Member> {513 support::children(&self.syntax)514 }515 pub fn r_brace_token(&self) -> Option<SyntaxToken> {516 support::token(&self.syntax, T!['}'])517 }518}519520#[derive(Debug, Clone, PartialEq, Eq, Hash)]521pub struct MemberBindStmt {522 pub(crate) syntax: SyntaxNode,523}524impl MemberBindStmt {525 pub fn obj_local(&self) -> Option<ObjLocal> {526 support::children(&self.syntax).next()527 }528}529530#[derive(Debug, Clone, PartialEq, Eq, Hash)]531pub struct ObjLocal {532 pub(crate) syntax: SyntaxNode,533}534impl ObjLocal {535 pub fn local_kw_token(&self) -> Option<SyntaxToken> {536 support::token(&self.syntax, T![local])537 }538 pub fn bind(&self) -> Option<Bind> {539 support::children(&self.syntax).next()540 }541}542543#[derive(Debug, Clone, PartialEq, Eq, Hash)]544pub struct MemberAssertStmt {545 pub(crate) syntax: SyntaxNode,546}547impl MemberAssertStmt {548 pub fn assertion(&self) -> Option<Assertion> {549 support::children(&self.syntax).next()550 }551}552553#[derive(Debug, Clone, PartialEq, Eq, Hash)]554pub struct MemberFieldNormal {555 pub(crate) syntax: SyntaxNode,556}557impl MemberFieldNormal {558 pub fn field_name(&self) -> Option<FieldName> {559 support::children(&self.syntax).next()560 }561 pub fn plus_token(&self) -> Option<SyntaxToken> {562 support::token(&self.syntax, T![+])563 }564 pub fn visibility(&self) -> Option<Visibility> {565 support::token_child(&self.syntax)566 }567 pub fn expr(&self) -> Option<Expr> {568 support::children(&self.syntax).next()569 }570}571572#[derive(Debug, Clone, PartialEq, Eq, Hash)]573pub struct MemberFieldMethod {574 pub(crate) syntax: SyntaxNode,575}576impl MemberFieldMethod {577 pub fn field_name(&self) -> Option<FieldName> {578 support::children(&self.syntax).next()579 }580 pub fn params_desc(&self) -> Option<ParamsDesc> {581 support::children(&self.syntax).next()582 }583 pub fn visibility(&self) -> Option<Visibility> {584 support::token_child(&self.syntax)585 }586 pub fn expr(&self) -> Option<Expr> {587 support::children(&self.syntax).next()588 }589}590591#[derive(Debug, Clone, PartialEq, Eq, Hash)]592pub struct FieldNameFixed {593 pub(crate) syntax: SyntaxNode,594}595impl FieldNameFixed {596 pub fn id(&self) -> Option<Name> {597 support::children(&self.syntax).next()598 }599 pub fn text(&self) -> Option<Text> {600 support::token_child(&self.syntax)601 }602}603604#[derive(Debug, Clone, PartialEq, Eq, Hash)]605pub struct FieldNameDynamic {606 pub(crate) syntax: SyntaxNode,607}608impl FieldNameDynamic {609 pub fn l_brack_token(&self) -> Option<SyntaxToken> {610 support::token(&self.syntax, T!['['])611 }612 pub fn expr(&self) -> Option<Expr> {613 support::children(&self.syntax).next()614 }615 pub fn r_brack_token(&self) -> Option<SyntaxToken> {616 support::token(&self.syntax, T![']'])617 }618}619620#[derive(Debug, Clone, PartialEq, Eq, Hash)]621pub struct ForSpec {622 pub(crate) syntax: SyntaxNode,623}624impl ForSpec {625 pub fn for_kw_token(&self) -> Option<SyntaxToken> {626 support::token(&self.syntax, T![for])627 }628 pub fn bind(&self) -> Option<Destruct> {629 support::children(&self.syntax).next()630 }631 pub fn in_kw_token(&self) -> Option<SyntaxToken> {632 support::token(&self.syntax, T![in])633 }634 pub fn expr(&self) -> Option<Expr> {635 support::children(&self.syntax).next()636 }637}638639#[derive(Debug, Clone, PartialEq, Eq, Hash)]640pub struct IfSpec {641 pub(crate) syntax: SyntaxNode,642}643impl IfSpec {644 pub fn if_kw_token(&self) -> Option<SyntaxToken> {645 support::token(&self.syntax, T![if])646 }647 pub fn expr(&self) -> Option<Expr> {648 support::children(&self.syntax).next()649 }650}651652#[derive(Debug, Clone, PartialEq, Eq, Hash)]653pub struct BindDestruct {654 pub(crate) syntax: SyntaxNode,655}656impl BindDestruct {657 pub fn into(&self) -> Option<Destruct> {658 support::children(&self.syntax).next()659 }660 pub fn assign_token(&self) -> Option<SyntaxToken> {661 support::token(&self.syntax, T![=])662 }663 pub fn value(&self) -> Option<Expr> {664 support::children(&self.syntax).next()665 }666}667668#[derive(Debug, Clone, PartialEq, Eq, Hash)]669pub struct BindFunction {670 pub(crate) syntax: SyntaxNode,671}672impl BindFunction {673 pub fn name(&self) -> Option<Name> {674 support::children(&self.syntax).next()675 }676 pub fn params(&self) -> Option<ParamsDesc> {677 support::children(&self.syntax).next()678 }679 pub fn assign_token(&self) -> Option<SyntaxToken> {680 support::token(&self.syntax, T![=])681 }682 pub fn value(&self) -> Option<Expr> {683 support::children(&self.syntax).next()684 }685}686687#[derive(Debug, Clone, PartialEq, Eq, Hash)]688pub struct Param {689 pub(crate) syntax: SyntaxNode,690}691impl Param {692 pub fn destruct(&self) -> Option<Destruct> {693 support::children(&self.syntax).next()694 }695 pub fn assign_token(&self) -> Option<SyntaxToken> {696 support::token(&self.syntax, T![=])697 }698 pub fn expr(&self) -> Option<Expr> {699 support::children(&self.syntax).next()700 }701}702703#[derive(Debug, Clone, PartialEq, Eq, Hash)]704pub struct DestructFull {705 pub(crate) syntax: SyntaxNode,706}707impl DestructFull {708 pub fn name(&self) -> Option<Name> {709 support::children(&self.syntax).next()710 }711}712713#[derive(Debug, Clone, PartialEq, Eq, Hash)]714pub struct DestructSkip {715 pub(crate) syntax: SyntaxNode,716}717impl DestructSkip {718 pub fn question_mark_token(&self) -> Option<SyntaxToken> {719 support::token(&self.syntax, T![?])720 }721}722723#[derive(Debug, Clone, PartialEq, Eq, Hash)]724pub struct DestructArray {725 pub(crate) syntax: SyntaxNode,726}727impl DestructArray {728 pub fn l_brack_token(&self) -> Option<SyntaxToken> {729 support::token(&self.syntax, T!['['])730 }731 pub fn destruct_array_parts(&self) -> AstChildren<DestructArrayPart> {732 support::children(&self.syntax)733 }734 pub fn r_brack_token(&self) -> Option<SyntaxToken> {735 support::token(&self.syntax, T![']'])736 }737}738739#[derive(Debug, Clone, PartialEq, Eq, Hash)]740pub struct DestructObject {741 pub(crate) syntax: SyntaxNode,742}743impl DestructObject {744 pub fn l_brace_token(&self) -> Option<SyntaxToken> {745 support::token(&self.syntax, T!['{'])746 }747 pub fn destruct_object_fields(&self) -> AstChildren<DestructObjectField> {748 support::children(&self.syntax)749 }750 pub fn destruct_rest(&self) -> Option<DestructRest> {751 support::children(&self.syntax).next()752 }753 pub fn comma_token(&self) -> Option<SyntaxToken> {754 support::token(&self.syntax, T![,])755 }756 pub fn r_brace_token(&self) -> Option<SyntaxToken> {757 support::token(&self.syntax, T!['}'])758 }759}760761#[derive(Debug, Clone, PartialEq, Eq, Hash)]762pub struct DestructObjectField {763 pub(crate) syntax: SyntaxNode,764}765impl DestructObjectField {766 pub fn field(&self) -> Option<Name> {767 support::children(&self.syntax).next()768 }769 pub fn colon_token(&self) -> Option<SyntaxToken> {770 support::token(&self.syntax, T![:])771 }772 pub fn destruct(&self) -> Option<Destruct> {773 support::children(&self.syntax).next()774 }775 pub fn assign_token(&self) -> Option<SyntaxToken> {776 support::token(&self.syntax, T![=])777 }778 pub fn expr(&self) -> Option<Expr> {779 support::children(&self.syntax).next()780 }781}782783#[derive(Debug, Clone, PartialEq, Eq, Hash)]784pub struct DestructRest {785 pub(crate) syntax: SyntaxNode,786}787impl DestructRest {788 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> {789 support::token(&self.syntax, T![...])790 }791 pub fn into(&self) -> Option<Name> {792 support::children(&self.syntax).next()793 }794}795796#[derive(Debug, Clone, PartialEq, Eq, Hash)]797pub struct DestructArrayElement {798 pub(crate) syntax: SyntaxNode,799}800impl DestructArrayElement {801 pub fn destruct(&self) -> Option<Destruct> {802 support::children(&self.syntax).next()803 }804}805806#[derive(Debug, Clone, PartialEq, Eq, Hash)]807pub enum Suffix {808 SuffixIndex(SuffixIndex),809 SuffixIndexExpr(SuffixIndexExpr),810 SuffixSlice(SuffixSlice),811 SuffixApply(SuffixApply),812}813814#[derive(Debug, Clone, PartialEq, Eq, Hash)]815pub enum Bind {816 BindDestruct(BindDestruct),817 BindFunction(BindFunction),818}819820#[derive(Debug, Clone, PartialEq, Eq, Hash)]821pub enum Stmt {822 StmtLocal(StmtLocal),823 StmtAssert(StmtAssert),824}825826#[derive(Debug, Clone, PartialEq, Eq, Hash)]827pub enum ObjBody {828 ObjBodyComp(ObjBodyComp),829 ObjBodyMemberList(ObjBodyMemberList),830}831832#[derive(Debug, Clone, PartialEq, Eq, Hash)]833pub enum CompSpec {834 ForSpec(ForSpec),835 IfSpec(IfSpec),836}837838#[derive(Debug, Clone, PartialEq, Eq, Hash)]839pub enum ExprBase {840 ExprBinary(ExprBinary),841 ExprUnary(ExprUnary),842 ExprObjExtend(ExprObjExtend),843 ExprParened(ExprParened),844 ExprString(ExprString),845 ExprNumber(ExprNumber),846 ExprLiteral(ExprLiteral),847 ExprArray(ExprArray),848 ExprObject(ExprObject),849 ExprArrayComp(ExprArrayComp),850 ExprImport(ExprImport),851 ExprVar(ExprVar),852 ExprIfThenElse(ExprIfThenElse),853 ExprFunction(ExprFunction),854 ExprError(ExprError),855}856857#[derive(Debug, Clone, PartialEq, Eq, Hash)]858pub enum MemberComp {859 MemberBindStmt(MemberBindStmt),860 MemberFieldNormal(MemberFieldNormal),861 MemberFieldMethod(MemberFieldMethod),862}863864#[derive(Debug, Clone, PartialEq, Eq, Hash)]865pub enum Member {866 MemberBindStmt(MemberBindStmt),867 MemberAssertStmt(MemberAssertStmt),868 MemberFieldNormal(MemberFieldNormal),869 MemberFieldMethod(MemberFieldMethod),870}871872#[derive(Debug, Clone, PartialEq, Eq, Hash)]873pub enum FieldName {874 FieldNameFixed(FieldNameFixed),875 FieldNameDynamic(FieldNameDynamic),876}877878#[derive(Debug, Clone, PartialEq, Eq, Hash)]879pub enum Destruct {880 DestructFull(DestructFull),881 DestructSkip(DestructSkip),882 DestructArray(DestructArray),883 DestructObject(DestructObject),884}885886#[derive(Debug, Clone, PartialEq, Eq, Hash)]887pub enum DestructArrayPart {888 DestructArrayElement(DestructArrayElement),889 DestructRest(DestructRest),890}891892#[derive(Debug, Clone, PartialEq, Eq, Hash)]893pub struct BinaryOperator {894 syntax: SyntaxToken,895 kind: BinaryOperatorKind,896}897898#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]899pub enum BinaryOperatorKind {900 Or,901 NullCoaelse,902 And,903 BitOr,904 BitXor,905 BitAnd,906 Eq,907 Ne,908 Lt,909 Gt,910 Le,911 Ge,912 InKw,913 Lhs,914 Rhs,915 Plus,916 Minus,917 Mul,918 Div,919 Modulo,920 MetaObjectApply,921 ErrorNoOperator,922}923924#[derive(Debug, Clone, PartialEq, Eq, Hash)]925pub struct UnaryOperator {926 syntax: SyntaxToken,927 kind: UnaryOperatorKind,928}929930#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]931pub enum UnaryOperatorKind {932 Minus,933 Not,934 BitNot,935}936937#[derive(Debug, Clone, PartialEq, Eq, Hash)]938pub struct Literal {939 syntax: SyntaxToken,940 kind: LiteralKind,941}942943#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]944pub enum LiteralKind {945 NullKw,946 TrueKw,947 FalseKw,948 SelfKw,949 Dollar,950 SuperKw,951}952953#[derive(Debug, Clone, PartialEq, Eq, Hash)]954pub struct Text {955 syntax: SyntaxToken,956 kind: TextKind,957}958959#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]960pub enum TextKind {961 StringDouble,962 ErrorStringDoubleUnterminated,963 StringSingle,964 ErrorStringSingleUnterminated,965 StringDoubleVerbatim,966 ErrorStringDoubleVerbatimUnterminated,967 StringSingleVerbatim,968 ErrorStringSingleVerbatimUnterminated,969 ErrorStringVerbatimMissingQuotes,970 StringBlock,971 ErrorStringBlockUnexpectedEnd,972 ErrorStringBlockMissingNewLine,973 ErrorStringBlockMissingTermination,974 ErrorStringBlockMissingIndent,975}976977#[derive(Debug, Clone, PartialEq, Eq, Hash)]978pub struct Number {979 syntax: SyntaxToken,980 kind: NumberKind,981}982983#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]984pub enum NumberKind {985 Float,986 ErrorFloatJunkAfterPoint,987 ErrorFloatJunkAfterExponent,988 ErrorFloatJunkAfterExponentSign,989}990991#[derive(Debug, Clone, PartialEq, Eq, Hash)]992pub struct ImportKind {993 syntax: SyntaxToken,994 kind: ImportKindKind,995}996997#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]998pub enum ImportKindKind {999 ImportstrKw,1000 ImportbinKw,1001 ImportKw,1002}10031004#[derive(Debug, Clone, PartialEq, Eq, Hash)]1005pub struct Visibility {1006 syntax: SyntaxToken,1007 kind: VisibilityKind,1008}10091010#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1011pub enum VisibilityKind {1012 Coloncoloncolon,1013 Coloncolon,1014 Colon,1015}10161017#[derive(Debug, Clone, PartialEq, Eq, Hash)]1018pub struct Trivia {1019 syntax: SyntaxToken,1020 kind: TriviaKind,1021}10221023#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1024pub enum TriviaKind {1025 Whitespace,1026 MultiLineComment,1027 ErrorCommentTooShort,1028 ErrorCommentUnterminated,1029 SingleLineHashComment,1030 SingleLineSlashComment,1031}10321033#[derive(Debug, Clone, PartialEq, Eq, Hash)]1034pub struct CustomError {1035 syntax: SyntaxToken,1036 kind: CustomErrorKind,1037}10381039#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1040pub enum CustomErrorKind {1041 ErrorMissingToken,1042 ErrorUnexpectedToken,1043 ErrorCustom,1044}1045impl AstNode for SourceFile {1046 fn can_cast(kind: SyntaxKind) -> bool {1047 kind == SOURCE_FILE1048 }1049 fn cast(syntax: SyntaxNode) -> Option<Self> {1050 if Self::can_cast(syntax.kind()) {1051 Some(Self { syntax })1052 } else {1053 None1054 }1055 }1056 fn syntax(&self) -> &SyntaxNode {1057 &self.syntax1058 }1059}1060impl AstNode for Expr {1061 fn can_cast(kind: SyntaxKind) -> bool {1062 kind == EXPR1063 }1064 fn cast(syntax: SyntaxNode) -> Option<Self> {1065 if Self::can_cast(syntax.kind()) {1066 Some(Self { syntax })1067 } else {1068 None1069 }1070 }1071 fn syntax(&self) -> &SyntaxNode {1072 &self.syntax1073 }1074}1075impl AstNode for SuffixIndex {1076 fn can_cast(kind: SyntaxKind) -> bool {1077 kind == SUFFIX_INDEX1078 }1079 fn cast(syntax: SyntaxNode) -> Option<Self> {1080 if Self::can_cast(syntax.kind()) {1081 Some(Self { syntax })1082 } else {1083 None1084 }1085 }1086 fn syntax(&self) -> &SyntaxNode {1087 &self.syntax1088 }1089}1090impl AstNode for Name {1091 fn can_cast(kind: SyntaxKind) -> bool {1092 kind == NAME1093 }1094 fn cast(syntax: SyntaxNode) -> Option<Self> {1095 if Self::can_cast(syntax.kind()) {1096 Some(Self { syntax })1097 } else {1098 None1099 }1100 }1101 fn syntax(&self) -> &SyntaxNode {1102 &self.syntax1103 }1104}1105impl AstNode for SuffixIndexExpr {1106 fn can_cast(kind: SyntaxKind) -> bool {1107 kind == SUFFIX_INDEX_EXPR1108 }1109 fn cast(syntax: SyntaxNode) -> Option<Self> {1110 if Self::can_cast(syntax.kind()) {1111 Some(Self { syntax })1112 } else {1113 None1114 }1115 }1116 fn syntax(&self) -> &SyntaxNode {1117 &self.syntax1118 }1119}1120impl AstNode for SuffixSlice {1121 fn can_cast(kind: SyntaxKind) -> bool {1122 kind == SUFFIX_SLICE1123 }1124 fn cast(syntax: SyntaxNode) -> Option<Self> {1125 if Self::can_cast(syntax.kind()) {1126 Some(Self { syntax })1127 } else {1128 None1129 }1130 }1131 fn syntax(&self) -> &SyntaxNode {1132 &self.syntax1133 }1134}1135impl AstNode for SliceDesc {1136 fn can_cast(kind: SyntaxKind) -> bool {1137 kind == SLICE_DESC1138 }1139 fn cast(syntax: SyntaxNode) -> Option<Self> {1140 if Self::can_cast(syntax.kind()) {1141 Some(Self { syntax })1142 } else {1143 None1144 }1145 }1146 fn syntax(&self) -> &SyntaxNode {1147 &self.syntax1148 }1149}1150impl AstNode for SuffixApply {1151 fn can_cast(kind: SyntaxKind) -> bool {1152 kind == SUFFIX_APPLY1153 }1154 fn cast(syntax: SyntaxNode) -> Option<Self> {1155 if Self::can_cast(syntax.kind()) {1156 Some(Self { syntax })1157 } else {1158 None1159 }1160 }1161 fn syntax(&self) -> &SyntaxNode {1162 &self.syntax1163 }1164}1165impl AstNode for ArgsDesc {1166 fn can_cast(kind: SyntaxKind) -> bool {1167 kind == ARGS_DESC1168 }1169 fn cast(syntax: SyntaxNode) -> Option<Self> {1170 if Self::can_cast(syntax.kind()) {1171 Some(Self { syntax })1172 } else {1173 None1174 }1175 }1176 fn syntax(&self) -> &SyntaxNode {1177 &self.syntax1178 }1179}1180impl AstNode for StmtLocal {1181 fn can_cast(kind: SyntaxKind) -> bool {1182 kind == STMT_LOCAL1183 }1184 fn cast(syntax: SyntaxNode) -> Option<Self> {1185 if Self::can_cast(syntax.kind()) {1186 Some(Self { syntax })1187 } else {1188 None1189 }1190 }1191 fn syntax(&self) -> &SyntaxNode {1192 &self.syntax1193 }1194}1195impl AstNode for StmtAssert {1196 fn can_cast(kind: SyntaxKind) -> bool {1197 kind == STMT_ASSERT1198 }1199 fn cast(syntax: SyntaxNode) -> Option<Self> {1200 if Self::can_cast(syntax.kind()) {1201 Some(Self { syntax })1202 } else {1203 None1204 }1205 }1206 fn syntax(&self) -> &SyntaxNode {1207 &self.syntax1208 }1209}1210impl AstNode for Assertion {1211 fn can_cast(kind: SyntaxKind) -> bool {1212 kind == ASSERTION1213 }1214 fn cast(syntax: SyntaxNode) -> Option<Self> {1215 if Self::can_cast(syntax.kind()) {1216 Some(Self { syntax })1217 } else {1218 None1219 }1220 }1221 fn syntax(&self) -> &SyntaxNode {1222 &self.syntax1223 }1224}1225impl AstNode for ExprBinary {1226 fn can_cast(kind: SyntaxKind) -> bool {1227 kind == EXPR_BINARY1228 }1229 fn cast(syntax: SyntaxNode) -> Option<Self> {1230 if Self::can_cast(syntax.kind()) {1231 Some(Self { syntax })1232 } else {1233 None1234 }1235 }1236 fn syntax(&self) -> &SyntaxNode {1237 &self.syntax1238 }1239}1240impl AstNode for ExprUnary {1241 fn can_cast(kind: SyntaxKind) -> bool {1242 kind == EXPR_UNARY1243 }1244 fn cast(syntax: SyntaxNode) -> Option<Self> {1245 if Self::can_cast(syntax.kind()) {1246 Some(Self { syntax })1247 } else {1248 None1249 }1250 }1251 fn syntax(&self) -> &SyntaxNode {1252 &self.syntax1253 }1254}1255impl AstNode for ExprObjExtend {1256 fn can_cast(kind: SyntaxKind) -> bool {1257 kind == EXPR_OBJ_EXTEND1258 }1259 fn cast(syntax: SyntaxNode) -> Option<Self> {1260 if Self::can_cast(syntax.kind()) {1261 Some(Self { syntax })1262 } else {1263 None1264 }1265 }1266 fn syntax(&self) -> &SyntaxNode {1267 &self.syntax1268 }1269}1270impl AstNode for ExprParened {1271 fn can_cast(kind: SyntaxKind) -> bool {1272 kind == EXPR_PARENED1273 }1274 fn cast(syntax: SyntaxNode) -> Option<Self> {1275 if Self::can_cast(syntax.kind()) {1276 Some(Self { syntax })1277 } else {1278 None1279 }1280 }1281 fn syntax(&self) -> &SyntaxNode {1282 &self.syntax1283 }1284}1285impl AstNode for ExprLiteral {1286 fn can_cast(kind: SyntaxKind) -> bool {1287 kind == EXPR_LITERAL1288 }1289 fn cast(syntax: SyntaxNode) -> Option<Self> {1290 if Self::can_cast(syntax.kind()) {1291 Some(Self { syntax })1292 } else {1293 None1294 }1295 }1296 fn syntax(&self) -> &SyntaxNode {1297 &self.syntax1298 }1299}1300impl AstNode for ExprString {1301 fn can_cast(kind: SyntaxKind) -> bool {1302 kind == EXPR_STRING1303 }1304 fn cast(syntax: SyntaxNode) -> Option<Self> {1305 if Self::can_cast(syntax.kind()) {1306 Some(Self { syntax })1307 } else {1308 None1309 }1310 }1311 fn syntax(&self) -> &SyntaxNode {1312 &self.syntax1313 }1314}1315impl AstNode for ExprNumber {1316 fn can_cast(kind: SyntaxKind) -> bool {1317 kind == EXPR_NUMBER1318 }1319 fn cast(syntax: SyntaxNode) -> Option<Self> {1320 if Self::can_cast(syntax.kind()) {1321 Some(Self { syntax })1322 } else {1323 None1324 }1325 }1326 fn syntax(&self) -> &SyntaxNode {1327 &self.syntax1328 }1329}1330impl AstNode for ExprArray {1331 fn can_cast(kind: SyntaxKind) -> bool {1332 kind == EXPR_ARRAY1333 }1334 fn cast(syntax: SyntaxNode) -> Option<Self> {1335 if Self::can_cast(syntax.kind()) {1336 Some(Self { syntax })1337 } else {1338 None1339 }1340 }1341 fn syntax(&self) -> &SyntaxNode {1342 &self.syntax1343 }1344}1345impl AstNode for ExprObject {1346 fn can_cast(kind: SyntaxKind) -> bool {1347 kind == EXPR_OBJECT1348 }1349 fn cast(syntax: SyntaxNode) -> Option<Self> {1350 if Self::can_cast(syntax.kind()) {1351 Some(Self { syntax })1352 } else {1353 None1354 }1355 }1356 fn syntax(&self) -> &SyntaxNode {1357 &self.syntax1358 }1359}1360impl AstNode for ExprArrayComp {1361 fn can_cast(kind: SyntaxKind) -> bool {1362 kind == EXPR_ARRAY_COMP1363 }1364 fn cast(syntax: SyntaxNode) -> Option<Self> {1365 if Self::can_cast(syntax.kind()) {1366 Some(Self { syntax })1367 } else {1368 None1369 }1370 }1371 fn syntax(&self) -> &SyntaxNode {1372 &self.syntax1373 }1374}1375impl AstNode for ExprImport {1376 fn can_cast(kind: SyntaxKind) -> bool {1377 kind == EXPR_IMPORT1378 }1379 fn cast(syntax: SyntaxNode) -> Option<Self> {1380 if Self::can_cast(syntax.kind()) {1381 Some(Self { syntax })1382 } else {1383 None1384 }1385 }1386 fn syntax(&self) -> &SyntaxNode {1387 &self.syntax1388 }1389}1390impl AstNode for ExprVar {1391 fn can_cast(kind: SyntaxKind) -> bool {1392 kind == EXPR_VAR1393 }1394 fn cast(syntax: SyntaxNode) -> Option<Self> {1395 if Self::can_cast(syntax.kind()) {1396 Some(Self { syntax })1397 } else {1398 None1399 }1400 }1401 fn syntax(&self) -> &SyntaxNode {1402 &self.syntax1403 }1404}1405impl AstNode for ExprIfThenElse {1406 fn can_cast(kind: SyntaxKind) -> bool {1407 kind == EXPR_IF_THEN_ELSE1408 }1409 fn cast(syntax: SyntaxNode) -> Option<Self> {1410 if Self::can_cast(syntax.kind()) {1411 Some(Self { syntax })1412 } else {1413 None1414 }1415 }1416 fn syntax(&self) -> &SyntaxNode {1417 &self.syntax1418 }1419}1420impl AstNode for TrueExpr {1421 fn can_cast(kind: SyntaxKind) -> bool {1422 kind == TRUE_EXPR1423 }1424 fn cast(syntax: SyntaxNode) -> Option<Self> {1425 if Self::can_cast(syntax.kind()) {1426 Some(Self { syntax })1427 } else {1428 None1429 }1430 }1431 fn syntax(&self) -> &SyntaxNode {1432 &self.syntax1433 }1434}1435impl AstNode for FalseExpr {1436 fn can_cast(kind: SyntaxKind) -> bool {1437 kind == FALSE_EXPR1438 }1439 fn cast(syntax: SyntaxNode) -> Option<Self> {1440 if Self::can_cast(syntax.kind()) {1441 Some(Self { syntax })1442 } else {1443 None1444 }1445 }1446 fn syntax(&self) -> &SyntaxNode {1447 &self.syntax1448 }1449}1450impl AstNode for ExprFunction {1451 fn can_cast(kind: SyntaxKind) -> bool {1452 kind == EXPR_FUNCTION1453 }1454 fn cast(syntax: SyntaxNode) -> Option<Self> {1455 if Self::can_cast(syntax.kind()) {1456 Some(Self { syntax })1457 } else {1458 None1459 }1460 }1461 fn syntax(&self) -> &SyntaxNode {1462 &self.syntax1463 }1464}1465impl AstNode for ParamsDesc {1466 fn can_cast(kind: SyntaxKind) -> bool {1467 kind == PARAMS_DESC1468 }1469 fn cast(syntax: SyntaxNode) -> Option<Self> {1470 if Self::can_cast(syntax.kind()) {1471 Some(Self { syntax })1472 } else {1473 None1474 }1475 }1476 fn syntax(&self) -> &SyntaxNode {1477 &self.syntax1478 }1479}1480impl AstNode for ExprError {1481 fn can_cast(kind: SyntaxKind) -> bool {1482 kind == EXPR_ERROR1483 }1484 fn cast(syntax: SyntaxNode) -> Option<Self> {1485 if Self::can_cast(syntax.kind()) {1486 Some(Self { syntax })1487 } else {1488 None1489 }1490 }1491 fn syntax(&self) -> &SyntaxNode {1492 &self.syntax1493 }1494}1495impl AstNode for SliceDescEnd {1496 fn can_cast(kind: SyntaxKind) -> bool {1497 kind == SLICE_DESC_END1498 }1499 fn cast(syntax: SyntaxNode) -> Option<Self> {1500 if Self::can_cast(syntax.kind()) {1501 Some(Self { syntax })1502 } else {1503 None1504 }1505 }1506 fn syntax(&self) -> &SyntaxNode {1507 &self.syntax1508 }1509}1510impl AstNode for SliceDescStep {1511 fn can_cast(kind: SyntaxKind) -> bool {1512 kind == SLICE_DESC_STEP1513 }1514 fn cast(syntax: SyntaxNode) -> Option<Self> {1515 if Self::can_cast(syntax.kind()) {1516 Some(Self { syntax })1517 } else {1518 None1519 }1520 }1521 fn syntax(&self) -> &SyntaxNode {1522 &self.syntax1523 }1524}1525impl AstNode for Arg {1526 fn can_cast(kind: SyntaxKind) -> bool {1527 kind == ARG1528 }1529 fn cast(syntax: SyntaxNode) -> Option<Self> {1530 if Self::can_cast(syntax.kind()) {1531 Some(Self { syntax })1532 } else {1533 None1534 }1535 }1536 fn syntax(&self) -> &SyntaxNode {1537 &self.syntax1538 }1539}1540impl AstNode for ObjBodyComp {1541 fn can_cast(kind: SyntaxKind) -> bool {1542 kind == OBJ_BODY_COMP1543 }1544 fn cast(syntax: SyntaxNode) -> Option<Self> {1545 if Self::can_cast(syntax.kind()) {1546 Some(Self { syntax })1547 } else {1548 None1549 }1550 }1551 fn syntax(&self) -> &SyntaxNode {1552 &self.syntax1553 }1554}1555impl AstNode for ObjBodyMemberList {1556 fn can_cast(kind: SyntaxKind) -> bool {1557 kind == OBJ_BODY_MEMBER_LIST1558 }1559 fn cast(syntax: SyntaxNode) -> Option<Self> {1560 if Self::can_cast(syntax.kind()) {1561 Some(Self { syntax })1562 } else {1563 None1564 }1565 }1566 fn syntax(&self) -> &SyntaxNode {1567 &self.syntax1568 }1569}1570impl AstNode for MemberBindStmt {1571 fn can_cast(kind: SyntaxKind) -> bool {1572 kind == MEMBER_BIND_STMT1573 }1574 fn cast(syntax: SyntaxNode) -> Option<Self> {1575 if Self::can_cast(syntax.kind()) {1576 Some(Self { syntax })1577 } else {1578 None1579 }1580 }1581 fn syntax(&self) -> &SyntaxNode {1582 &self.syntax1583 }1584}1585impl AstNode for ObjLocal {1586 fn can_cast(kind: SyntaxKind) -> bool {1587 kind == OBJ_LOCAL1588 }1589 fn cast(syntax: SyntaxNode) -> Option<Self> {1590 if Self::can_cast(syntax.kind()) {1591 Some(Self { syntax })1592 } else {1593 None1594 }1595 }1596 fn syntax(&self) -> &SyntaxNode {1597 &self.syntax1598 }1599}1600impl AstNode for MemberAssertStmt {1601 fn can_cast(kind: SyntaxKind) -> bool {1602 kind == MEMBER_ASSERT_STMT1603 }1604 fn cast(syntax: SyntaxNode) -> Option<Self> {1605 if Self::can_cast(syntax.kind()) {1606 Some(Self { syntax })1607 } else {1608 None1609 }1610 }1611 fn syntax(&self) -> &SyntaxNode {1612 &self.syntax1613 }1614}1615impl AstNode for MemberFieldNormal {1616 fn can_cast(kind: SyntaxKind) -> bool {1617 kind == MEMBER_FIELD_NORMAL1618 }1619 fn cast(syntax: SyntaxNode) -> Option<Self> {1620 if Self::can_cast(syntax.kind()) {1621 Some(Self { syntax })1622 } else {1623 None1624 }1625 }1626 fn syntax(&self) -> &SyntaxNode {1627 &self.syntax1628 }1629}1630impl AstNode for MemberFieldMethod {1631 fn can_cast(kind: SyntaxKind) -> bool {1632 kind == MEMBER_FIELD_METHOD1633 }1634 fn cast(syntax: SyntaxNode) -> Option<Self> {1635 if Self::can_cast(syntax.kind()) {1636 Some(Self { syntax })1637 } else {1638 None1639 }1640 }1641 fn syntax(&self) -> &SyntaxNode {1642 &self.syntax1643 }1644}1645impl AstNode for FieldNameFixed {1646 fn can_cast(kind: SyntaxKind) -> bool {1647 kind == FIELD_NAME_FIXED1648 }1649 fn cast(syntax: SyntaxNode) -> Option<Self> {1650 if Self::can_cast(syntax.kind()) {1651 Some(Self { syntax })1652 } else {1653 None1654 }1655 }1656 fn syntax(&self) -> &SyntaxNode {1657 &self.syntax1658 }1659}1660impl AstNode for FieldNameDynamic {1661 fn can_cast(kind: SyntaxKind) -> bool {1662 kind == FIELD_NAME_DYNAMIC1663 }1664 fn cast(syntax: SyntaxNode) -> Option<Self> {1665 if Self::can_cast(syntax.kind()) {1666 Some(Self { syntax })1667 } else {1668 None1669 }1670 }1671 fn syntax(&self) -> &SyntaxNode {1672 &self.syntax1673 }1674}1675impl AstNode for ForSpec {1676 fn can_cast(kind: SyntaxKind) -> bool {1677 kind == FOR_SPEC1678 }1679 fn cast(syntax: SyntaxNode) -> Option<Self> {1680 if Self::can_cast(syntax.kind()) {1681 Some(Self { syntax })1682 } else {1683 None1684 }1685 }1686 fn syntax(&self) -> &SyntaxNode {1687 &self.syntax1688 }1689}1690impl AstNode for IfSpec {1691 fn can_cast(kind: SyntaxKind) -> bool {1692 kind == IF_SPEC1693 }1694 fn cast(syntax: SyntaxNode) -> Option<Self> {1695 if Self::can_cast(syntax.kind()) {1696 Some(Self { syntax })1697 } else {1698 None1699 }1700 }1701 fn syntax(&self) -> &SyntaxNode {1702 &self.syntax1703 }1704}1705impl AstNode for BindDestruct {1706 fn can_cast(kind: SyntaxKind) -> bool {1707 kind == BIND_DESTRUCT1708 }1709 fn cast(syntax: SyntaxNode) -> Option<Self> {1710 if Self::can_cast(syntax.kind()) {1711 Some(Self { syntax })1712 } else {1713 None1714 }1715 }1716 fn syntax(&self) -> &SyntaxNode {1717 &self.syntax1718 }1719}1720impl AstNode for BindFunction {1721 fn can_cast(kind: SyntaxKind) -> bool {1722 kind == BIND_FUNCTION1723 }1724 fn cast(syntax: SyntaxNode) -> Option<Self> {1725 if Self::can_cast(syntax.kind()) {1726 Some(Self { syntax })1727 } else {1728 None1729 }1730 }1731 fn syntax(&self) -> &SyntaxNode {1732 &self.syntax1733 }1734}1735impl AstNode for Param {1736 fn can_cast(kind: SyntaxKind) -> bool {1737 kind == PARAM1738 }1739 fn cast(syntax: SyntaxNode) -> Option<Self> {1740 if Self::can_cast(syntax.kind()) {1741 Some(Self { syntax })1742 } else {1743 None1744 }1745 }1746 fn syntax(&self) -> &SyntaxNode {1747 &self.syntax1748 }1749}1750impl AstNode for DestructFull {1751 fn can_cast(kind: SyntaxKind) -> bool {1752 kind == DESTRUCT_FULL1753 }1754 fn cast(syntax: SyntaxNode) -> Option<Self> {1755 if Self::can_cast(syntax.kind()) {1756 Some(Self { syntax })1757 } else {1758 None1759 }1760 }1761 fn syntax(&self) -> &SyntaxNode {1762 &self.syntax1763 }1764}1765impl AstNode for DestructSkip {1766 fn can_cast(kind: SyntaxKind) -> bool {1767 kind == DESTRUCT_SKIP1768 }1769 fn cast(syntax: SyntaxNode) -> Option<Self> {1770 if Self::can_cast(syntax.kind()) {1771 Some(Self { syntax })1772 } else {1773 None1774 }1775 }1776 fn syntax(&self) -> &SyntaxNode {1777 &self.syntax1778 }1779}1780impl AstNode for DestructArray {1781 fn can_cast(kind: SyntaxKind) -> bool {1782 kind == DESTRUCT_ARRAY1783 }1784 fn cast(syntax: SyntaxNode) -> Option<Self> {1785 if Self::can_cast(syntax.kind()) {1786 Some(Self { syntax })1787 } else {1788 None1789 }1790 }1791 fn syntax(&self) -> &SyntaxNode {1792 &self.syntax1793 }1794}1795impl AstNode for DestructObject {1796 fn can_cast(kind: SyntaxKind) -> bool {1797 kind == DESTRUCT_OBJECT1798 }1799 fn cast(syntax: SyntaxNode) -> Option<Self> {1800 if Self::can_cast(syntax.kind()) {1801 Some(Self { syntax })1802 } else {1803 None1804 }1805 }1806 fn syntax(&self) -> &SyntaxNode {1807 &self.syntax1808 }1809}1810impl AstNode for DestructObjectField {1811 fn can_cast(kind: SyntaxKind) -> bool {1812 kind == DESTRUCT_OBJECT_FIELD1813 }1814 fn cast(syntax: SyntaxNode) -> Option<Self> {1815 if Self::can_cast(syntax.kind()) {1816 Some(Self { syntax })1817 } else {1818 None1819 }1820 }1821 fn syntax(&self) -> &SyntaxNode {1822 &self.syntax1823 }1824}1825impl AstNode for DestructRest {1826 fn can_cast(kind: SyntaxKind) -> bool {1827 kind == DESTRUCT_REST1828 }1829 fn cast(syntax: SyntaxNode) -> Option<Self> {1830 if Self::can_cast(syntax.kind()) {1831 Some(Self { syntax })1832 } else {1833 None1834 }1835 }1836 fn syntax(&self) -> &SyntaxNode {1837 &self.syntax1838 }1839}1840impl AstNode for DestructArrayElement {1841 fn can_cast(kind: SyntaxKind) -> bool {1842 kind == DESTRUCT_ARRAY_ELEMENT1843 }1844 fn cast(syntax: SyntaxNode) -> Option<Self> {1845 if Self::can_cast(syntax.kind()) {1846 Some(Self { syntax })1847 } else {1848 None1849 }1850 }1851 fn syntax(&self) -> &SyntaxNode {1852 &self.syntax1853 }1854}1855impl From<SuffixIndex> for Suffix {1856 fn from(node: SuffixIndex) -> Suffix {1857 Suffix::SuffixIndex(node)1858 }1859}1860impl From<SuffixIndexExpr> for Suffix {1861 fn from(node: SuffixIndexExpr) -> Suffix {1862 Suffix::SuffixIndexExpr(node)1863 }1864}1865impl From<SuffixSlice> for Suffix {1866 fn from(node: SuffixSlice) -> Suffix {1867 Suffix::SuffixSlice(node)1868 }1869}1870impl From<SuffixApply> for Suffix {1871 fn from(node: SuffixApply) -> Suffix {1872 Suffix::SuffixApply(node)1873 }1874}1875impl AstNode for Suffix {1876 fn can_cast(kind: SyntaxKind) -> bool {1877 match kind {1878 SUFFIX_INDEX | SUFFIX_INDEX_EXPR | SUFFIX_SLICE | SUFFIX_APPLY => true,1879 _ => false,1880 }1881 }1882 fn cast(syntax: SyntaxNode) -> Option<Self> {1883 let res = match syntax.kind() {1884 SUFFIX_INDEX => Suffix::SuffixIndex(SuffixIndex { syntax }),1885 SUFFIX_INDEX_EXPR => Suffix::SuffixIndexExpr(SuffixIndexExpr { syntax }),1886 SUFFIX_SLICE => Suffix::SuffixSlice(SuffixSlice { syntax }),1887 SUFFIX_APPLY => Suffix::SuffixApply(SuffixApply { syntax }),1888 _ => return None,1889 };1890 Some(res)1891 }1892 fn syntax(&self) -> &SyntaxNode {1893 match self {1894 Suffix::SuffixIndex(it) => &it.syntax,1895 Suffix::SuffixIndexExpr(it) => &it.syntax,1896 Suffix::SuffixSlice(it) => &it.syntax,1897 Suffix::SuffixApply(it) => &it.syntax,1898 }1899 }1900}1901impl From<BindDestruct> for Bind {1902 fn from(node: BindDestruct) -> Bind {1903 Bind::BindDestruct(node)1904 }1905}1906impl From<BindFunction> for Bind {1907 fn from(node: BindFunction) -> Bind {1908 Bind::BindFunction(node)1909 }1910}1911impl AstNode for Bind {1912 fn can_cast(kind: SyntaxKind) -> bool {1913 match kind {1914 BIND_DESTRUCT | BIND_FUNCTION => true,1915 _ => false,1916 }1917 }1918 fn cast(syntax: SyntaxNode) -> Option<Self> {1919 let res = match syntax.kind() {1920 BIND_DESTRUCT => Bind::BindDestruct(BindDestruct { syntax }),1921 BIND_FUNCTION => Bind::BindFunction(BindFunction { syntax }),1922 _ => return None,1923 };1924 Some(res)1925 }1926 fn syntax(&self) -> &SyntaxNode {1927 match self {1928 Bind::BindDestruct(it) => &it.syntax,1929 Bind::BindFunction(it) => &it.syntax,1930 }1931 }1932}1933impl From<StmtLocal> for Stmt {1934 fn from(node: StmtLocal) -> Stmt {1935 Stmt::StmtLocal(node)1936 }1937}1938impl From<StmtAssert> for Stmt {1939 fn from(node: StmtAssert) -> Stmt {1940 Stmt::StmtAssert(node)1941 }1942}1943impl AstNode for Stmt {1944 fn can_cast(kind: SyntaxKind) -> bool {1945 match kind {1946 STMT_LOCAL | STMT_ASSERT => true,1947 _ => false,1948 }1949 }1950 fn cast(syntax: SyntaxNode) -> Option<Self> {1951 let res = match syntax.kind() {1952 STMT_LOCAL => Stmt::StmtLocal(StmtLocal { syntax }),1953 STMT_ASSERT => Stmt::StmtAssert(StmtAssert { syntax }),1954 _ => return None,1955 };1956 Some(res)1957 }1958 fn syntax(&self) -> &SyntaxNode {1959 match self {1960 Stmt::StmtLocal(it) => &it.syntax,1961 Stmt::StmtAssert(it) => &it.syntax,1962 }1963 }1964}1965impl From<ObjBodyComp> for ObjBody {1966 fn from(node: ObjBodyComp) -> ObjBody {1967 ObjBody::ObjBodyComp(node)1968 }1969}1970impl From<ObjBodyMemberList> for ObjBody {1971 fn from(node: ObjBodyMemberList) -> ObjBody {1972 ObjBody::ObjBodyMemberList(node)1973 }1974}1975impl AstNode for ObjBody {1976 fn can_cast(kind: SyntaxKind) -> bool {1977 match kind {1978 OBJ_BODY_COMP | OBJ_BODY_MEMBER_LIST => true,1979 _ => false,1980 }1981 }1982 fn cast(syntax: SyntaxNode) -> Option<Self> {1983 let res = match syntax.kind() {1984 OBJ_BODY_COMP => ObjBody::ObjBodyComp(ObjBodyComp { syntax }),1985 OBJ_BODY_MEMBER_LIST => ObjBody::ObjBodyMemberList(ObjBodyMemberList { syntax }),1986 _ => return None,1987 };1988 Some(res)1989 }1990 fn syntax(&self) -> &SyntaxNode {1991 match self {1992 ObjBody::ObjBodyComp(it) => &it.syntax,1993 ObjBody::ObjBodyMemberList(it) => &it.syntax,1994 }1995 }1996}1997impl From<ForSpec> for CompSpec {1998 fn from(node: ForSpec) -> CompSpec {1999 CompSpec::ForSpec(node)2000 }2001}2002impl From<IfSpec> for CompSpec {2003 fn from(node: IfSpec) -> CompSpec {2004 CompSpec::IfSpec(node)2005 }2006}2007impl AstNode for CompSpec {2008 fn can_cast(kind: SyntaxKind) -> bool {2009 match kind {2010 FOR_SPEC | IF_SPEC => true,2011 _ => false,2012 }2013 }2014 fn cast(syntax: SyntaxNode) -> Option<Self> {2015 let res = match syntax.kind() {2016 FOR_SPEC => CompSpec::ForSpec(ForSpec { syntax }),2017 IF_SPEC => CompSpec::IfSpec(IfSpec { syntax }),2018 _ => return None,2019 };2020 Some(res)2021 }2022 fn syntax(&self) -> &SyntaxNode {2023 match self {2024 CompSpec::ForSpec(it) => &it.syntax,2025 CompSpec::IfSpec(it) => &it.syntax,2026 }2027 }2028}2029impl From<ExprBinary> for ExprBase {2030 fn from(node: ExprBinary) -> ExprBase {2031 ExprBase::ExprBinary(node)2032 }2033}2034impl From<ExprUnary> for ExprBase {2035 fn from(node: ExprUnary) -> ExprBase {2036 ExprBase::ExprUnary(node)2037 }2038}2039impl From<ExprObjExtend> for ExprBase {2040 fn from(node: ExprObjExtend) -> ExprBase {2041 ExprBase::ExprObjExtend(node)2042 }2043}2044impl From<ExprParened> for ExprBase {2045 fn from(node: ExprParened) -> ExprBase {2046 ExprBase::ExprParened(node)2047 }2048}2049impl From<ExprString> for ExprBase {2050 fn from(node: ExprString) -> ExprBase {2051 ExprBase::ExprString(node)2052 }2053}2054impl From<ExprNumber> for ExprBase {2055 fn from(node: ExprNumber) -> ExprBase {2056 ExprBase::ExprNumber(node)2057 }2058}2059impl From<ExprLiteral> for ExprBase {2060 fn from(node: ExprLiteral) -> ExprBase {2061 ExprBase::ExprLiteral(node)2062 }2063}2064impl From<ExprArray> for ExprBase {2065 fn from(node: ExprArray) -> ExprBase {2066 ExprBase::ExprArray(node)2067 }2068}2069impl From<ExprObject> for ExprBase {2070 fn from(node: ExprObject) -> ExprBase {2071 ExprBase::ExprObject(node)2072 }2073}2074impl From<ExprArrayComp> for ExprBase {2075 fn from(node: ExprArrayComp) -> ExprBase {2076 ExprBase::ExprArrayComp(node)2077 }2078}2079impl From<ExprImport> for ExprBase {2080 fn from(node: ExprImport) -> ExprBase {2081 ExprBase::ExprImport(node)2082 }2083}2084impl From<ExprVar> for ExprBase {2085 fn from(node: ExprVar) -> ExprBase {2086 ExprBase::ExprVar(node)2087 }2088}2089impl From<ExprIfThenElse> for ExprBase {2090 fn from(node: ExprIfThenElse) -> ExprBase {2091 ExprBase::ExprIfThenElse(node)2092 }2093}2094impl From<ExprFunction> for ExprBase {2095 fn from(node: ExprFunction) -> ExprBase {2096 ExprBase::ExprFunction(node)2097 }2098}2099impl From<ExprError> for ExprBase {2100 fn from(node: ExprError) -> ExprBase {2101 ExprBase::ExprError(node)2102 }2103}2104impl AstNode for ExprBase {2105 fn can_cast(kind: SyntaxKind) -> bool {2106 match kind {2107 EXPR_BINARY | EXPR_UNARY | EXPR_OBJ_EXTEND | EXPR_PARENED | EXPR_STRING2108 | EXPR_NUMBER | EXPR_LITERAL | EXPR_ARRAY | EXPR_OBJECT | EXPR_ARRAY_COMP2109 | EXPR_IMPORT | EXPR_VAR | EXPR_IF_THEN_ELSE | EXPR_FUNCTION | EXPR_ERROR => true,2110 _ => false,2111 }2112 }2113 fn cast(syntax: SyntaxNode) -> Option<Self> {2114 let res = match syntax.kind() {2115 EXPR_BINARY => ExprBase::ExprBinary(ExprBinary { syntax }),2116 EXPR_UNARY => ExprBase::ExprUnary(ExprUnary { syntax }),2117 EXPR_OBJ_EXTEND => ExprBase::ExprObjExtend(ExprObjExtend { syntax }),2118 EXPR_PARENED => ExprBase::ExprParened(ExprParened { syntax }),2119 EXPR_STRING => ExprBase::ExprString(ExprString { syntax }),2120 EXPR_NUMBER => ExprBase::ExprNumber(ExprNumber { syntax }),2121 EXPR_LITERAL => ExprBase::ExprLiteral(ExprLiteral { syntax }),2122 EXPR_ARRAY => ExprBase::ExprArray(ExprArray { syntax }),2123 EXPR_OBJECT => ExprBase::ExprObject(ExprObject { syntax }),2124 EXPR_ARRAY_COMP => ExprBase::ExprArrayComp(ExprArrayComp { syntax }),2125 EXPR_IMPORT => ExprBase::ExprImport(ExprImport { syntax }),2126 EXPR_VAR => ExprBase::ExprVar(ExprVar { syntax }),2127 EXPR_IF_THEN_ELSE => ExprBase::ExprIfThenElse(ExprIfThenElse { syntax }),2128 EXPR_FUNCTION => ExprBase::ExprFunction(ExprFunction { syntax }),2129 EXPR_ERROR => ExprBase::ExprError(ExprError { syntax }),2130 _ => return None,2131 };2132 Some(res)2133 }2134 fn syntax(&self) -> &SyntaxNode {2135 match self {2136 ExprBase::ExprBinary(it) => &it.syntax,2137 ExprBase::ExprUnary(it) => &it.syntax,2138 ExprBase::ExprObjExtend(it) => &it.syntax,2139 ExprBase::ExprParened(it) => &it.syntax,2140 ExprBase::ExprString(it) => &it.syntax,2141 ExprBase::ExprNumber(it) => &it.syntax,2142 ExprBase::ExprLiteral(it) => &it.syntax,2143 ExprBase::ExprArray(it) => &it.syntax,2144 ExprBase::ExprObject(it) => &it.syntax,2145 ExprBase::ExprArrayComp(it) => &it.syntax,2146 ExprBase::ExprImport(it) => &it.syntax,2147 ExprBase::ExprVar(it) => &it.syntax,2148 ExprBase::ExprIfThenElse(it) => &it.syntax,2149 ExprBase::ExprFunction(it) => &it.syntax,2150 ExprBase::ExprError(it) => &it.syntax,2151 }2152 }2153}2154impl From<MemberBindStmt> for MemberComp {2155 fn from(node: MemberBindStmt) -> MemberComp {2156 MemberComp::MemberBindStmt(node)2157 }2158}2159impl From<MemberFieldNormal> for MemberComp {2160 fn from(node: MemberFieldNormal) -> MemberComp {2161 MemberComp::MemberFieldNormal(node)2162 }2163}2164impl From<MemberFieldMethod> for MemberComp {2165 fn from(node: MemberFieldMethod) -> MemberComp {2166 MemberComp::MemberFieldMethod(node)2167 }2168}2169impl AstNode for MemberComp {2170 fn can_cast(kind: SyntaxKind) -> bool {2171 match kind {2172 MEMBER_BIND_STMT | MEMBER_FIELD_NORMAL | MEMBER_FIELD_METHOD => true,2173 _ => false,2174 }2175 }2176 fn cast(syntax: SyntaxNode) -> Option<Self> {2177 let res = match syntax.kind() {2178 MEMBER_BIND_STMT => MemberComp::MemberBindStmt(MemberBindStmt { syntax }),2179 MEMBER_FIELD_NORMAL => MemberComp::MemberFieldNormal(MemberFieldNormal { syntax }),2180 MEMBER_FIELD_METHOD => MemberComp::MemberFieldMethod(MemberFieldMethod { syntax }),2181 _ => return None,2182 };2183 Some(res)2184 }2185 fn syntax(&self) -> &SyntaxNode {2186 match self {2187 MemberComp::MemberBindStmt(it) => &it.syntax,2188 MemberComp::MemberFieldNormal(it) => &it.syntax,2189 MemberComp::MemberFieldMethod(it) => &it.syntax,2190 }2191 }2192}2193impl From<MemberBindStmt> for Member {2194 fn from(node: MemberBindStmt) -> Member {2195 Member::MemberBindStmt(node)2196 }2197}2198impl From<MemberAssertStmt> for Member {2199 fn from(node: MemberAssertStmt) -> Member {2200 Member::MemberAssertStmt(node)2201 }2202}2203impl From<MemberFieldNormal> for Member {2204 fn from(node: MemberFieldNormal) -> Member {2205 Member::MemberFieldNormal(node)2206 }2207}2208impl From<MemberFieldMethod> for Member {2209 fn from(node: MemberFieldMethod) -> Member {2210 Member::MemberFieldMethod(node)2211 }2212}2213impl AstNode for Member {2214 fn can_cast(kind: SyntaxKind) -> bool {2215 match kind {2216 MEMBER_BIND_STMT | MEMBER_ASSERT_STMT | MEMBER_FIELD_NORMAL | MEMBER_FIELD_METHOD => {2217 true2218 }2219 _ => false,2220 }2221 }2222 fn cast(syntax: SyntaxNode) -> Option<Self> {2223 let res = match syntax.kind() {2224 MEMBER_BIND_STMT => Member::MemberBindStmt(MemberBindStmt { syntax }),2225 MEMBER_ASSERT_STMT => Member::MemberAssertStmt(MemberAssertStmt { syntax }),2226 MEMBER_FIELD_NORMAL => Member::MemberFieldNormal(MemberFieldNormal { syntax }),2227 MEMBER_FIELD_METHOD => Member::MemberFieldMethod(MemberFieldMethod { syntax }),2228 _ => return None,2229 };2230 Some(res)2231 }2232 fn syntax(&self) -> &SyntaxNode {2233 match self {2234 Member::MemberBindStmt(it) => &it.syntax,2235 Member::MemberAssertStmt(it) => &it.syntax,2236 Member::MemberFieldNormal(it) => &it.syntax,2237 Member::MemberFieldMethod(it) => &it.syntax,2238 }2239 }2240}2241impl From<FieldNameFixed> for FieldName {2242 fn from(node: FieldNameFixed) -> FieldName {2243 FieldName::FieldNameFixed(node)2244 }2245}2246impl From<FieldNameDynamic> for FieldName {2247 fn from(node: FieldNameDynamic) -> FieldName {2248 FieldName::FieldNameDynamic(node)2249 }2250}2251impl AstNode for FieldName {2252 fn can_cast(kind: SyntaxKind) -> bool {2253 match kind {2254 FIELD_NAME_FIXED | FIELD_NAME_DYNAMIC => true,2255 _ => false,2256 }2257 }2258 fn cast(syntax: SyntaxNode) -> Option<Self> {2259 let res = match syntax.kind() {2260 FIELD_NAME_FIXED => FieldName::FieldNameFixed(FieldNameFixed { syntax }),2261 FIELD_NAME_DYNAMIC => FieldName::FieldNameDynamic(FieldNameDynamic { syntax }),2262 _ => return None,2263 };2264 Some(res)2265 }2266 fn syntax(&self) -> &SyntaxNode {2267 match self {2268 FieldName::FieldNameFixed(it) => &it.syntax,2269 FieldName::FieldNameDynamic(it) => &it.syntax,2270 }2271 }2272}2273impl From<DestructFull> for Destruct {2274 fn from(node: DestructFull) -> Destruct {2275 Destruct::DestructFull(node)2276 }2277}2278impl From<DestructSkip> for Destruct {2279 fn from(node: DestructSkip) -> Destruct {2280 Destruct::DestructSkip(node)2281 }2282}2283impl From<DestructArray> for Destruct {2284 fn from(node: DestructArray) -> Destruct {2285 Destruct::DestructArray(node)2286 }2287}2288impl From<DestructObject> for Destruct {2289 fn from(node: DestructObject) -> Destruct {2290 Destruct::DestructObject(node)2291 }2292}2293impl AstNode for Destruct {2294 fn can_cast(kind: SyntaxKind) -> bool {2295 match kind {2296 DESTRUCT_FULL | DESTRUCT_SKIP | DESTRUCT_ARRAY | DESTRUCT_OBJECT => true,2297 _ => false,2298 }2299 }2300 fn cast(syntax: SyntaxNode) -> Option<Self> {2301 let res = match syntax.kind() {2302 DESTRUCT_FULL => Destruct::DestructFull(DestructFull { syntax }),2303 DESTRUCT_SKIP => Destruct::DestructSkip(DestructSkip { syntax }),2304 DESTRUCT_ARRAY => Destruct::DestructArray(DestructArray { syntax }),2305 DESTRUCT_OBJECT => Destruct::DestructObject(DestructObject { syntax }),2306 _ => return None,2307 };2308 Some(res)2309 }2310 fn syntax(&self) -> &SyntaxNode {2311 match self {2312 Destruct::DestructFull(it) => &it.syntax,2313 Destruct::DestructSkip(it) => &it.syntax,2314 Destruct::DestructArray(it) => &it.syntax,2315 Destruct::DestructObject(it) => &it.syntax,2316 }2317 }2318}2319impl From<DestructArrayElement> for DestructArrayPart {2320 fn from(node: DestructArrayElement) -> DestructArrayPart {2321 DestructArrayPart::DestructArrayElement(node)2322 }2323}2324impl From<DestructRest> for DestructArrayPart {2325 fn from(node: DestructRest) -> DestructArrayPart {2326 DestructArrayPart::DestructRest(node)2327 }2328}2329impl AstNode for DestructArrayPart {2330 fn can_cast(kind: SyntaxKind) -> bool {2331 match kind {2332 DESTRUCT_ARRAY_ELEMENT | DESTRUCT_REST => true,2333 _ => false,2334 }2335 }2336 fn cast(syntax: SyntaxNode) -> Option<Self> {2337 let res = match syntax.kind() {2338 DESTRUCT_ARRAY_ELEMENT => {2339 DestructArrayPart::DestructArrayElement(DestructArrayElement { syntax })2340 }2341 DESTRUCT_REST => DestructArrayPart::DestructRest(DestructRest { syntax }),2342 _ => return None,2343 };2344 Some(res)2345 }2346 fn syntax(&self) -> &SyntaxNode {2347 match self {2348 DestructArrayPart::DestructArrayElement(it) => &it.syntax,2349 DestructArrayPart::DestructRest(it) => &it.syntax,2350 }2351 }2352}2353impl AstToken for BinaryOperator {2354 fn can_cast(kind: SyntaxKind) -> bool {2355 BinaryOperatorKind::can_cast(kind)2356 }2357 fn cast(syntax: SyntaxToken) -> Option<Self> {2358 let kind = BinaryOperatorKind::cast(syntax.kind())?;2359 Some(BinaryOperator { syntax, kind })2360 }2361 fn syntax(&self) -> &SyntaxToken {2362 &self.syntax2363 }2364}2365impl BinaryOperatorKind {2366 fn can_cast(kind: SyntaxKind) -> bool {2367 match kind {2368 OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE2369 | IN_KW | LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | META_OBJECT_APPLY2370 | ERROR_NO_OPERATOR => true,2371 _ => false,2372 }2373 }2374 pub fn cast(kind: SyntaxKind) -> Option<Self> {2375 let res = match kind {2376 OR => Self::Or,2377 NULL_COAELSE => Self::NullCoaelse,2378 AND => Self::And,2379 BIT_OR => Self::BitOr,2380 BIT_XOR => Self::BitXor,2381 BIT_AND => Self::BitAnd,2382 EQ => Self::Eq,2383 NE => Self::Ne,2384 LT => Self::Lt,2385 GT => Self::Gt,2386 LE => Self::Le,2387 GE => Self::Ge,2388 IN_KW => Self::InKw,2389 LHS => Self::Lhs,2390 RHS => Self::Rhs,2391 PLUS => Self::Plus,2392 MINUS => Self::Minus,2393 MUL => Self::Mul,2394 DIV => Self::Div,2395 MODULO => Self::Modulo,2396 META_OBJECT_APPLY => Self::MetaObjectApply,2397 ERROR_NO_OPERATOR => Self::ErrorNoOperator,2398 _ => return None,2399 };2400 Some(res)2401 }2402}2403impl BinaryOperator {2404 pub fn kind(&self) -> BinaryOperatorKind {2405 self.kind2406 }2407}2408impl std::fmt::Display for BinaryOperator {2409 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2410 std::fmt::Display::fmt(self.syntax(), f)2411 }2412}2413impl AstToken for UnaryOperator {2414 fn can_cast(kind: SyntaxKind) -> bool {2415 UnaryOperatorKind::can_cast(kind)2416 }2417 fn cast(syntax: SyntaxToken) -> Option<Self> {2418 let kind = UnaryOperatorKind::cast(syntax.kind())?;2419 Some(UnaryOperator { syntax, kind })2420 }2421 fn syntax(&self) -> &SyntaxToken {2422 &self.syntax2423 }2424}2425impl UnaryOperatorKind {2426 fn can_cast(kind: SyntaxKind) -> bool {2427 match kind {2428 MINUS | NOT | BIT_NOT => true,2429 _ => false,2430 }2431 }2432 pub fn cast(kind: SyntaxKind) -> Option<Self> {2433 let res = match kind {2434 MINUS => Self::Minus,2435 NOT => Self::Not,2436 BIT_NOT => Self::BitNot,2437 _ => return None,2438 };2439 Some(res)2440 }2441}2442impl UnaryOperator {2443 pub fn kind(&self) -> UnaryOperatorKind {2444 self.kind2445 }2446}2447impl std::fmt::Display for UnaryOperator {2448 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2449 std::fmt::Display::fmt(self.syntax(), f)2450 }2451}2452impl AstToken for Literal {2453 fn can_cast(kind: SyntaxKind) -> bool {2454 LiteralKind::can_cast(kind)2455 }2456 fn cast(syntax: SyntaxToken) -> Option<Self> {2457 let kind = LiteralKind::cast(syntax.kind())?;2458 Some(Literal { syntax, kind })2459 }2460 fn syntax(&self) -> &SyntaxToken {2461 &self.syntax2462 }2463}2464impl LiteralKind {2465 fn can_cast(kind: SyntaxKind) -> bool {2466 match kind {2467 NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | DOLLAR | SUPER_KW => true,2468 _ => false,2469 }2470 }2471 pub fn cast(kind: SyntaxKind) -> Option<Self> {2472 let res = match kind {2473 NULL_KW => Self::NullKw,2474 TRUE_KW => Self::TrueKw,2475 FALSE_KW => Self::FalseKw,2476 SELF_KW => Self::SelfKw,2477 DOLLAR => Self::Dollar,2478 SUPER_KW => Self::SuperKw,2479 _ => return None,2480 };2481 Some(res)2482 }2483}2484impl Literal {2485 pub fn kind(&self) -> LiteralKind {2486 self.kind2487 }2488}2489impl std::fmt::Display for Literal {2490 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2491 std::fmt::Display::fmt(self.syntax(), f)2492 }2493}2494impl AstToken for Text {2495 fn can_cast(kind: SyntaxKind) -> bool {2496 TextKind::can_cast(kind)2497 }2498 fn cast(syntax: SyntaxToken) -> Option<Self> {2499 let kind = TextKind::cast(syntax.kind())?;2500 Some(Text { syntax, kind })2501 }2502 fn syntax(&self) -> &SyntaxToken {2503 &self.syntax2504 }2505}2506impl TextKind {2507 fn can_cast(kind: SyntaxKind) -> bool {2508 match kind {2509 STRING_DOUBLE2510 | ERROR_STRING_DOUBLE_UNTERMINATED2511 | STRING_SINGLE2512 | ERROR_STRING_SINGLE_UNTERMINATED2513 | STRING_DOUBLE_VERBATIM2514 | ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED2515 | STRING_SINGLE_VERBATIM2516 | ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED2517 | ERROR_STRING_VERBATIM_MISSING_QUOTES2518 | STRING_BLOCK2519 | ERROR_STRING_BLOCK_UNEXPECTED_END2520 | ERROR_STRING_BLOCK_MISSING_NEW_LINE2521 | ERROR_STRING_BLOCK_MISSING_TERMINATION2522 | ERROR_STRING_BLOCK_MISSING_INDENT => true,2523 _ => false,2524 }2525 }2526 pub fn cast(kind: SyntaxKind) -> Option<Self> {2527 let res = match kind {2528 STRING_DOUBLE => Self::StringDouble,2529 ERROR_STRING_DOUBLE_UNTERMINATED => Self::ErrorStringDoubleUnterminated,2530 STRING_SINGLE => Self::StringSingle,2531 ERROR_STRING_SINGLE_UNTERMINATED => Self::ErrorStringSingleUnterminated,2532 STRING_DOUBLE_VERBATIM => Self::StringDoubleVerbatim,2533 ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED => {2534 Self::ErrorStringDoubleVerbatimUnterminated2535 }2536 STRING_SINGLE_VERBATIM => Self::StringSingleVerbatim,2537 ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED => {2538 Self::ErrorStringSingleVerbatimUnterminated2539 }2540 ERROR_STRING_VERBATIM_MISSING_QUOTES => Self::ErrorStringVerbatimMissingQuotes,2541 STRING_BLOCK => Self::StringBlock,2542 ERROR_STRING_BLOCK_UNEXPECTED_END => Self::ErrorStringBlockUnexpectedEnd,2543 ERROR_STRING_BLOCK_MISSING_NEW_LINE => Self::ErrorStringBlockMissingNewLine,2544 ERROR_STRING_BLOCK_MISSING_TERMINATION => Self::ErrorStringBlockMissingTermination,2545 ERROR_STRING_BLOCK_MISSING_INDENT => Self::ErrorStringBlockMissingIndent,2546 _ => return None,2547 };2548 Some(res)2549 }2550}2551impl Text {2552 pub fn kind(&self) -> TextKind {2553 self.kind2554 }2555}2556impl std::fmt::Display for Text {2557 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2558 std::fmt::Display::fmt(self.syntax(), f)2559 }2560}2561impl AstToken for Number {2562 fn can_cast(kind: SyntaxKind) -> bool {2563 NumberKind::can_cast(kind)2564 }2565 fn cast(syntax: SyntaxToken) -> Option<Self> {2566 let kind = NumberKind::cast(syntax.kind())?;2567 Some(Number { syntax, kind })2568 }2569 fn syntax(&self) -> &SyntaxToken {2570 &self.syntax2571 }2572}2573impl NumberKind {2574 fn can_cast(kind: SyntaxKind) -> bool {2575 match kind {2576 FLOAT2577 | ERROR_FLOAT_JUNK_AFTER_POINT2578 | ERROR_FLOAT_JUNK_AFTER_EXPONENT2579 | ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => true,2580 _ => false,2581 }2582 }2583 pub fn cast(kind: SyntaxKind) -> Option<Self> {2584 let res = match kind {2585 FLOAT => Self::Float,2586 ERROR_FLOAT_JUNK_AFTER_POINT => Self::ErrorFloatJunkAfterPoint,2587 ERROR_FLOAT_JUNK_AFTER_EXPONENT => Self::ErrorFloatJunkAfterExponent,2588 ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => Self::ErrorFloatJunkAfterExponentSign,2589 _ => return None,2590 };2591 Some(res)2592 }2593}2594impl Number {2595 pub fn kind(&self) -> NumberKind {2596 self.kind2597 }2598}2599impl std::fmt::Display for Number {2600 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2601 std::fmt::Display::fmt(self.syntax(), f)2602 }2603}2604impl AstToken for ImportKind {2605 fn can_cast(kind: SyntaxKind) -> bool {2606 ImportKindKind::can_cast(kind)2607 }2608 fn cast(syntax: SyntaxToken) -> Option<Self> {2609 let kind = ImportKindKind::cast(syntax.kind())?;2610 Some(ImportKind { syntax, kind })2611 }2612 fn syntax(&self) -> &SyntaxToken {2613 &self.syntax2614 }2615}2616impl ImportKindKind {2617 fn can_cast(kind: SyntaxKind) -> bool {2618 match kind {2619 IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW => true,2620 _ => false,2621 }2622 }2623 pub fn cast(kind: SyntaxKind) -> Option<Self> {2624 let res = match kind {2625 IMPORTSTR_KW => Self::ImportstrKw,2626 IMPORTBIN_KW => Self::ImportbinKw,2627 IMPORT_KW => Self::ImportKw,2628 _ => return None,2629 };2630 Some(res)2631 }2632}2633impl ImportKind {2634 pub fn kind(&self) -> ImportKindKind {2635 self.kind2636 }2637}2638impl std::fmt::Display for ImportKind {2639 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2640 std::fmt::Display::fmt(self.syntax(), f)2641 }2642}2643impl AstToken for Visibility {2644 fn can_cast(kind: SyntaxKind) -> bool {2645 VisibilityKind::can_cast(kind)2646 }2647 fn cast(syntax: SyntaxToken) -> Option<Self> {2648 let kind = VisibilityKind::cast(syntax.kind())?;2649 Some(Visibility { syntax, kind })2650 }2651 fn syntax(&self) -> &SyntaxToken {2652 &self.syntax2653 }2654}2655impl VisibilityKind {2656 fn can_cast(kind: SyntaxKind) -> bool {2657 match kind {2658 COLONCOLONCOLON | COLONCOLON | COLON => true,2659 _ => false,2660 }2661 }2662 pub fn cast(kind: SyntaxKind) -> Option<Self> {2663 let res = match kind {2664 COLONCOLONCOLON => Self::Coloncoloncolon,2665 COLONCOLON => Self::Coloncolon,2666 COLON => Self::Colon,2667 _ => return None,2668 };2669 Some(res)2670 }2671}2672impl Visibility {2673 pub fn kind(&self) -> VisibilityKind {2674 self.kind2675 }2676}2677impl std::fmt::Display for Visibility {2678 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2679 std::fmt::Display::fmt(self.syntax(), f)2680 }2681}2682impl AstToken for Trivia {2683 fn can_cast(kind: SyntaxKind) -> bool {2684 TriviaKind::can_cast(kind)2685 }2686 fn cast(syntax: SyntaxToken) -> Option<Self> {2687 let kind = TriviaKind::cast(syntax.kind())?;2688 Some(Trivia { syntax, kind })2689 }2690 fn syntax(&self) -> &SyntaxToken {2691 &self.syntax2692 }2693}2694impl TriviaKind {2695 fn can_cast(kind: SyntaxKind) -> bool {2696 match kind {2697 WHITESPACE2698 | MULTI_LINE_COMMENT2699 | ERROR_COMMENT_TOO_SHORT2700 | ERROR_COMMENT_UNTERMINATED2701 | SINGLE_LINE_HASH_COMMENT2702 | SINGLE_LINE_SLASH_COMMENT => true,2703 _ => false,2704 }2705 }2706 pub fn cast(kind: SyntaxKind) -> Option<Self> {2707 let res = match kind {2708 WHITESPACE => Self::Whitespace,2709 MULTI_LINE_COMMENT => Self::MultiLineComment,2710 ERROR_COMMENT_TOO_SHORT => Self::ErrorCommentTooShort,2711 ERROR_COMMENT_UNTERMINATED => Self::ErrorCommentUnterminated,2712 SINGLE_LINE_HASH_COMMENT => Self::SingleLineHashComment,2713 SINGLE_LINE_SLASH_COMMENT => Self::SingleLineSlashComment,2714 _ => return None,2715 };2716 Some(res)2717 }2718}2719impl Trivia {2720 pub fn kind(&self) -> TriviaKind {2721 self.kind2722 }2723}2724impl std::fmt::Display for Trivia {2725 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2726 std::fmt::Display::fmt(self.syntax(), f)2727 }2728}2729impl AstToken for CustomError {2730 fn can_cast(kind: SyntaxKind) -> bool {2731 CustomErrorKind::can_cast(kind)2732 }2733 fn cast(syntax: SyntaxToken) -> Option<Self> {2734 let kind = CustomErrorKind::cast(syntax.kind())?;2735 Some(CustomError { syntax, kind })2736 }2737 fn syntax(&self) -> &SyntaxToken {2738 &self.syntax2739 }2740}2741impl CustomErrorKind {2742 fn can_cast(kind: SyntaxKind) -> bool {2743 match kind {2744 ERROR_MISSING_TOKEN | ERROR_UNEXPECTED_TOKEN | ERROR_CUSTOM => true,2745 _ => false,2746 }2747 }2748 pub fn cast(kind: SyntaxKind) -> Option<Self> {2749 let res = match kind {2750 ERROR_MISSING_TOKEN => Self::ErrorMissingToken,2751 ERROR_UNEXPECTED_TOKEN => Self::ErrorUnexpectedToken,2752 ERROR_CUSTOM => Self::ErrorCustom,2753 _ => return None,2754 };2755 Some(res)2756 }2757}2758impl CustomError {2759 pub fn kind(&self) -> CustomErrorKind {2760 self.kind2761 }2762}2763impl std::fmt::Display for CustomError {2764 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2765 std::fmt::Display::fmt(self.syntax(), f)2766 }2767}2768impl std::fmt::Display for Suffix {2769 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2770 std::fmt::Display::fmt(self.syntax(), f)2771 }2772}2773impl std::fmt::Display for Bind {2774 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2775 std::fmt::Display::fmt(self.syntax(), f)2776 }2777}2778impl std::fmt::Display for Stmt {2779 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2780 std::fmt::Display::fmt(self.syntax(), f)2781 }2782}2783impl std::fmt::Display for ObjBody {2784 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2785 std::fmt::Display::fmt(self.syntax(), f)2786 }2787}2788impl std::fmt::Display for CompSpec {2789 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2790 std::fmt::Display::fmt(self.syntax(), f)2791 }2792}2793impl std::fmt::Display for ExprBase {2794 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2795 std::fmt::Display::fmt(self.syntax(), f)2796 }2797}2798impl std::fmt::Display for MemberComp {2799 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2800 std::fmt::Display::fmt(self.syntax(), f)2801 }2802}2803impl std::fmt::Display for Member {2804 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2805 std::fmt::Display::fmt(self.syntax(), f)2806 }2807}2808impl std::fmt::Display for FieldName {2809 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2810 std::fmt::Display::fmt(self.syntax(), f)2811 }2812}2813impl std::fmt::Display for Destruct {2814 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2815 std::fmt::Display::fmt(self.syntax(), f)2816 }2817}2818impl std::fmt::Display for DestructArrayPart {2819 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2820 std::fmt::Display::fmt(self.syntax(), f)2821 }2822}2823impl std::fmt::Display for SourceFile {2824 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2825 std::fmt::Display::fmt(self.syntax(), f)2826 }2827}2828impl std::fmt::Display for Expr {2829 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2830 std::fmt::Display::fmt(self.syntax(), f)2831 }2832}2833impl std::fmt::Display for SuffixIndex {2834 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2835 std::fmt::Display::fmt(self.syntax(), f)2836 }2837}2838impl std::fmt::Display for Name {2839 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2840 std::fmt::Display::fmt(self.syntax(), f)2841 }2842}2843impl std::fmt::Display for SuffixIndexExpr {2844 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2845 std::fmt::Display::fmt(self.syntax(), f)2846 }2847}2848impl std::fmt::Display for SuffixSlice {2849 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2850 std::fmt::Display::fmt(self.syntax(), f)2851 }2852}2853impl std::fmt::Display for SliceDesc {2854 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2855 std::fmt::Display::fmt(self.syntax(), f)2856 }2857}2858impl std::fmt::Display for SuffixApply {2859 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2860 std::fmt::Display::fmt(self.syntax(), f)2861 }2862}2863impl std::fmt::Display for ArgsDesc {2864 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2865 std::fmt::Display::fmt(self.syntax(), f)2866 }2867}2868impl std::fmt::Display for StmtLocal {2869 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2870 std::fmt::Display::fmt(self.syntax(), f)2871 }2872}2873impl std::fmt::Display for StmtAssert {2874 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2875 std::fmt::Display::fmt(self.syntax(), f)2876 }2877}2878impl std::fmt::Display for Assertion {2879 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2880 std::fmt::Display::fmt(self.syntax(), f)2881 }2882}2883impl std::fmt::Display for ExprBinary {2884 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2885 std::fmt::Display::fmt(self.syntax(), f)2886 }2887}2888impl std::fmt::Display for ExprUnary {2889 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2890 std::fmt::Display::fmt(self.syntax(), f)2891 }2892}2893impl std::fmt::Display for ExprObjExtend {2894 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2895 std::fmt::Display::fmt(self.syntax(), f)2896 }2897}2898impl std::fmt::Display for ExprParened {2899 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2900 std::fmt::Display::fmt(self.syntax(), f)2901 }2902}2903impl std::fmt::Display for ExprLiteral {2904 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2905 std::fmt::Display::fmt(self.syntax(), f)2906 }2907}2908impl std::fmt::Display for ExprString {2909 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2910 std::fmt::Display::fmt(self.syntax(), f)2911 }2912}2913impl std::fmt::Display for ExprNumber {2914 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2915 std::fmt::Display::fmt(self.syntax(), f)2916 }2917}2918impl std::fmt::Display for ExprArray {2919 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2920 std::fmt::Display::fmt(self.syntax(), f)2921 }2922}2923impl std::fmt::Display for ExprObject {2924 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2925 std::fmt::Display::fmt(self.syntax(), f)2926 }2927}2928impl std::fmt::Display for ExprArrayComp {2929 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2930 std::fmt::Display::fmt(self.syntax(), f)2931 }2932}2933impl std::fmt::Display for ExprImport {2934 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2935 std::fmt::Display::fmt(self.syntax(), f)2936 }2937}2938impl std::fmt::Display for ExprVar {2939 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2940 std::fmt::Display::fmt(self.syntax(), f)2941 }2942}2943impl std::fmt::Display for ExprIfThenElse {2944 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2945 std::fmt::Display::fmt(self.syntax(), f)2946 }2947}2948impl std::fmt::Display for TrueExpr {2949 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2950 std::fmt::Display::fmt(self.syntax(), f)2951 }2952}2953impl std::fmt::Display for FalseExpr {2954 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2955 std::fmt::Display::fmt(self.syntax(), f)2956 }2957}2958impl std::fmt::Display for ExprFunction {2959 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2960 std::fmt::Display::fmt(self.syntax(), f)2961 }2962}2963impl std::fmt::Display for ParamsDesc {2964 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2965 std::fmt::Display::fmt(self.syntax(), f)2966 }2967}2968impl std::fmt::Display for ExprError {2969 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2970 std::fmt::Display::fmt(self.syntax(), f)2971 }2972}2973impl std::fmt::Display for SliceDescEnd {2974 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2975 std::fmt::Display::fmt(self.syntax(), f)2976 }2977}2978impl std::fmt::Display for SliceDescStep {2979 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2980 std::fmt::Display::fmt(self.syntax(), f)2981 }2982}2983impl std::fmt::Display for Arg {2984 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2985 std::fmt::Display::fmt(self.syntax(), f)2986 }2987}2988impl std::fmt::Display for ObjBodyComp {2989 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2990 std::fmt::Display::fmt(self.syntax(), f)2991 }2992}2993impl std::fmt::Display for ObjBodyMemberList {2994 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2995 std::fmt::Display::fmt(self.syntax(), f)2996 }2997}2998impl std::fmt::Display for MemberBindStmt {2999 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3000 std::fmt::Display::fmt(self.syntax(), f)3001 }3002}3003impl std::fmt::Display for ObjLocal {3004 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3005 std::fmt::Display::fmt(self.syntax(), f)3006 }3007}3008impl std::fmt::Display for MemberAssertStmt {3009 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3010 std::fmt::Display::fmt(self.syntax(), f)3011 }3012}3013impl std::fmt::Display for MemberFieldNormal {3014 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3015 std::fmt::Display::fmt(self.syntax(), f)3016 }3017}3018impl std::fmt::Display for MemberFieldMethod {3019 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3020 std::fmt::Display::fmt(self.syntax(), f)3021 }3022}3023impl std::fmt::Display for FieldNameFixed {3024 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3025 std::fmt::Display::fmt(self.syntax(), f)3026 }3027}3028impl std::fmt::Display for FieldNameDynamic {3029 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3030 std::fmt::Display::fmt(self.syntax(), f)3031 }3032}3033impl std::fmt::Display for ForSpec {3034 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3035 std::fmt::Display::fmt(self.syntax(), f)3036 }3037}3038impl std::fmt::Display for IfSpec {3039 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3040 std::fmt::Display::fmt(self.syntax(), f)3041 }3042}3043impl std::fmt::Display for BindDestruct {3044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3045 std::fmt::Display::fmt(self.syntax(), f)3046 }3047}3048impl std::fmt::Display for BindFunction {3049 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3050 std::fmt::Display::fmt(self.syntax(), f)3051 }3052}3053impl std::fmt::Display for Param {3054 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3055 std::fmt::Display::fmt(self.syntax(), f)3056 }3057}3058impl std::fmt::Display for DestructFull {3059 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3060 std::fmt::Display::fmt(self.syntax(), f)3061 }3062}3063impl std::fmt::Display for DestructSkip {3064 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3065 std::fmt::Display::fmt(self.syntax(), f)3066 }3067}3068impl std::fmt::Display for DestructArray {3069 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3070 std::fmt::Display::fmt(self.syntax(), f)3071 }3072}3073impl std::fmt::Display for DestructObject {3074 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3075 std::fmt::Display::fmt(self.syntax(), f)3076 }3077}3078impl std::fmt::Display for DestructObjectField {3079 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3080 std::fmt::Display::fmt(self.syntax(), f)3081 }3082}3083impl std::fmt::Display for DestructRest {3084 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3085 std::fmt::Display::fmt(self.syntax(), f)3086 }3087}3088impl std::fmt::Display for DestructArrayElement {3089 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3090 std::fmt::Display::fmt(self.syntax(), f)3091 }3092}1//! This is a generated file, please do not edit manually. Changes can be2//! made in codegeneration that lives in `xtask` top-level dir.34#![allow(non_snake_case, clippy::match_like_matches_macro)]5use crate::{6 ast::{support, AstChildren, AstNode, AstToken},7 SyntaxKind::{self, *},8 SyntaxNode, SyntaxToken, T,9};1011#[derive(Debug, Clone, PartialEq, Eq, Hash)]12pub struct SourceFile {13 pub(crate) syntax: SyntaxNode,14}15impl SourceFile {16 pub fn expr(&self) -> Option<Expr> {17 support::children(&self.syntax).next()18 }19}2021#[derive(Debug, Clone, PartialEq, Eq, Hash)]22pub struct Expr {23 pub(crate) syntax: SyntaxNode,24}25impl Expr {26 pub fn stmts(&self) -> AstChildren<Stmt> {27 support::children(&self.syntax)28 }29 pub fn expr_base(&self) -> Option<ExprBase> {30 support::children(&self.syntax).next()31 }32 pub fn suffixs(&self) -> AstChildren<Suffix> {33 support::children(&self.syntax)34 }35}3637#[derive(Debug, Clone, PartialEq, Eq, Hash)]38pub struct SuffixIndex {39 pub(crate) syntax: SyntaxNode,40}41impl SuffixIndex {42 pub fn question_mark_token(&self) -> Option<SyntaxToken> {43 support::token(&self.syntax, T![?])44 }45 pub fn dot_token(&self) -> Option<SyntaxToken> {46 support::token(&self.syntax, T![.])47 }48 pub fn index(&self) -> Option<Name> {49 support::children(&self.syntax).next()50 }51}5253#[derive(Debug, Clone, PartialEq, Eq, Hash)]54pub struct Name {55 pub(crate) syntax: SyntaxNode,56}57impl Name {58 pub fn ident_lit(&self) -> Option<SyntaxToken> {59 support::token(&self.syntax, IDENT)60 }61}6263#[derive(Debug, Clone, PartialEq, Eq, Hash)]64pub struct SuffixIndexExpr {65 pub(crate) syntax: SyntaxNode,66}67impl SuffixIndexExpr {68 pub fn question_mark_token(&self) -> Option<SyntaxToken> {69 support::token(&self.syntax, T![?])70 }71 pub fn dot_token(&self) -> Option<SyntaxToken> {72 support::token(&self.syntax, T![.])73 }74 pub fn l_brack_token(&self) -> Option<SyntaxToken> {75 support::token(&self.syntax, T!['['])76 }77 pub fn index(&self) -> Option<Expr> {78 support::children(&self.syntax).next()79 }80 pub fn r_brack_token(&self) -> Option<SyntaxToken> {81 support::token(&self.syntax, T![']'])82 }83}8485#[derive(Debug, Clone, PartialEq, Eq, Hash)]86pub struct SuffixSlice {87 pub(crate) syntax: SyntaxNode,88}89impl SuffixSlice {90 pub fn slice_desc(&self) -> Option<SliceDesc> {91 support::children(&self.syntax).next()92 }93}9495#[derive(Debug, Clone, PartialEq, Eq, Hash)]96pub struct SliceDesc {97 pub(crate) syntax: SyntaxNode,98}99impl SliceDesc {100 pub fn l_brack_token(&self) -> Option<SyntaxToken> {101 support::token(&self.syntax, T!['['])102 }103 pub fn from(&self) -> Option<Expr> {104 support::children(&self.syntax).next()105 }106 pub fn colon_token(&self) -> Option<SyntaxToken> {107 support::token(&self.syntax, T![:])108 }109 pub fn end(&self) -> Option<SliceDescEnd> {110 support::children(&self.syntax).next()111 }112 pub fn step(&self) -> Option<SliceDescStep> {113 support::children(&self.syntax).next()114 }115 pub fn r_brack_token(&self) -> Option<SyntaxToken> {116 support::token(&self.syntax, T![']'])117 }118}119120#[derive(Debug, Clone, PartialEq, Eq, Hash)]121pub struct SuffixApply {122 pub(crate) syntax: SyntaxNode,123}124impl SuffixApply {125 pub fn args_desc(&self) -> Option<ArgsDesc> {126 support::children(&self.syntax).next()127 }128 pub fn tailstrict_kw_token(&self) -> Option<SyntaxToken> {129 support::token(&self.syntax, T![tailstrict])130 }131}132133#[derive(Debug, Clone, PartialEq, Eq, Hash)]134pub struct ArgsDesc {135 pub(crate) syntax: SyntaxNode,136}137impl ArgsDesc {138 pub fn l_paren_token(&self) -> Option<SyntaxToken> {139 support::token(&self.syntax, T!['('])140 }141 pub fn args(&self) -> AstChildren<Arg> {142 support::children(&self.syntax)143 }144 pub fn r_paren_token(&self) -> Option<SyntaxToken> {145 support::token(&self.syntax, T![')'])146 }147}148149#[derive(Debug, Clone, PartialEq, Eq, Hash)]150pub struct StmtLocal {151 pub(crate) syntax: SyntaxNode,152}153impl StmtLocal {154 pub fn local_kw_token(&self) -> Option<SyntaxToken> {155 support::token(&self.syntax, T![local])156 }157 pub fn binds(&self) -> AstChildren<Bind> {158 support::children(&self.syntax)159 }160 pub fn semi_token(&self) -> Option<SyntaxToken> {161 support::token(&self.syntax, T![;])162 }163}164165#[derive(Debug, Clone, PartialEq, Eq, Hash)]166pub struct StmtAssert {167 pub(crate) syntax: SyntaxNode,168}169impl StmtAssert {170 pub fn assertion(&self) -> Option<Assertion> {171 support::children(&self.syntax).next()172 }173 pub fn semi_token(&self) -> Option<SyntaxToken> {174 support::token(&self.syntax, T![;])175 }176}177178#[derive(Debug, Clone, PartialEq, Eq, Hash)]179pub struct Assertion {180 pub(crate) syntax: SyntaxNode,181}182impl Assertion {183 pub fn assert_kw_token(&self) -> Option<SyntaxToken> {184 support::token(&self.syntax, T![assert])185 }186 pub fn condition(&self) -> Option<Expr> {187 support::children(&self.syntax).next()188 }189 pub fn colon_token(&self) -> Option<SyntaxToken> {190 support::token(&self.syntax, T![:])191 }192 pub fn message(&self) -> Option<Expr> {193 support::children(&self.syntax).nth(1usize)194 }195}196197#[derive(Debug, Clone, PartialEq, Eq, Hash)]198pub struct ExprBinary {199 pub(crate) syntax: SyntaxNode,200}201impl ExprBinary {202 pub fn lhs(&self) -> Option<Expr> {203 support::children(&self.syntax).next()204 }205 pub fn binary_operator(&self) -> Option<BinaryOperator> {206 support::token_child(&self.syntax)207 }208 pub fn rhs(&self) -> Option<Expr> {209 support::children(&self.syntax).nth(1usize)210 }211}212213#[derive(Debug, Clone, PartialEq, Eq, Hash)]214pub struct ExprUnary {215 pub(crate) syntax: SyntaxNode,216}217impl ExprUnary {218 pub fn unary_operator(&self) -> Option<UnaryOperator> {219 support::token_child(&self.syntax)220 }221 pub fn rhs(&self) -> Option<Expr> {222 support::children(&self.syntax).next()223 }224}225226#[derive(Debug, Clone, PartialEq, Eq, Hash)]227pub struct ExprObjExtend {228 pub(crate) syntax: SyntaxNode,229}230impl ExprObjExtend {231 pub fn lhs(&self) -> Option<Expr> {232 support::children(&self.syntax).next()233 }234 pub fn rhs(&self) -> Option<Expr> {235 support::children(&self.syntax).nth(1usize)236 }237}238239#[derive(Debug, Clone, PartialEq, Eq, Hash)]240pub struct ExprParened {241 pub(crate) syntax: SyntaxNode,242}243impl ExprParened {244 pub fn l_paren_token(&self) -> Option<SyntaxToken> {245 support::token(&self.syntax, T!['('])246 }247 pub fn expr(&self) -> Option<Expr> {248 support::children(&self.syntax).next()249 }250 pub fn r_paren_token(&self) -> Option<SyntaxToken> {251 support::token(&self.syntax, T![')'])252 }253}254255#[derive(Debug, Clone, PartialEq, Eq, Hash)]256pub struct ExprLiteral {257 pub(crate) syntax: SyntaxNode,258}259impl ExprLiteral {260 pub fn literal(&self) -> Option<Literal> {261 support::token_child(&self.syntax)262 }263}264265#[derive(Debug, Clone, PartialEq, Eq, Hash)]266pub struct ExprString {267 pub(crate) syntax: SyntaxNode,268}269impl ExprString {270 pub fn text(&self) -> Option<Text> {271 support::token_child(&self.syntax)272 }273}274275#[derive(Debug, Clone, PartialEq, Eq, Hash)]276pub struct ExprNumber {277 pub(crate) syntax: SyntaxNode,278}279impl ExprNumber {280 pub fn number(&self) -> Option<Number> {281 support::token_child(&self.syntax)282 }283}284285#[derive(Debug, Clone, PartialEq, Eq, Hash)]286pub struct ExprArray {287 pub(crate) syntax: SyntaxNode,288}289impl ExprArray {290 pub fn l_brack_token(&self) -> Option<SyntaxToken> {291 support::token(&self.syntax, T!['['])292 }293 pub fn exprs(&self) -> AstChildren<Expr> {294 support::children(&self.syntax)295 }296 pub fn r_brack_token(&self) -> Option<SyntaxToken> {297 support::token(&self.syntax, T![']'])298 }299}300301#[derive(Debug, Clone, PartialEq, Eq, Hash)]302pub struct ExprObject {303 pub(crate) syntax: SyntaxNode,304}305impl ExprObject {306 pub fn obj_body(&self) -> Option<ObjBody> {307 support::children(&self.syntax).next()308 }309}310311#[derive(Debug, Clone, PartialEq, Eq, Hash)]312pub struct ExprArrayComp {313 pub(crate) syntax: SyntaxNode,314}315impl ExprArrayComp {316 pub fn l_brack_token(&self) -> Option<SyntaxToken> {317 support::token(&self.syntax, T!['['])318 }319 pub fn expr(&self) -> Option<Expr> {320 support::children(&self.syntax).next()321 }322 pub fn comma_token(&self) -> Option<SyntaxToken> {323 support::token(&self.syntax, T![,])324 }325 pub fn comp_specs(&self) -> AstChildren<CompSpec> {326 support::children(&self.syntax)327 }328 pub fn r_brack_token(&self) -> Option<SyntaxToken> {329 support::token(&self.syntax, T![']'])330 }331}332333#[derive(Debug, Clone, PartialEq, Eq, Hash)]334pub struct ExprImport {335 pub(crate) syntax: SyntaxNode,336}337impl ExprImport {338 pub fn import_kind(&self) -> Option<ImportKind> {339 support::token_child(&self.syntax)340 }341 pub fn text(&self) -> Option<Text> {342 support::token_child(&self.syntax)343 }344}345346#[derive(Debug, Clone, PartialEq, Eq, Hash)]347pub struct ExprVar {348 pub(crate) syntax: SyntaxNode,349}350impl ExprVar {351 pub fn name(&self) -> Option<Name> {352 support::children(&self.syntax).next()353 }354}355356#[derive(Debug, Clone, PartialEq, Eq, Hash)]357pub struct ExprIfThenElse {358 pub(crate) syntax: SyntaxNode,359}360impl ExprIfThenElse {361 pub fn if_kw_token(&self) -> Option<SyntaxToken> {362 support::token(&self.syntax, T![if])363 }364 pub fn cond(&self) -> Option<Expr> {365 support::children(&self.syntax).next()366 }367 pub fn then_kw_token(&self) -> Option<SyntaxToken> {368 support::token(&self.syntax, T![then])369 }370 pub fn then(&self) -> Option<TrueExpr> {371 support::children(&self.syntax).next()372 }373 pub fn else_kw_token(&self) -> Option<SyntaxToken> {374 support::token(&self.syntax, T![else])375 }376 pub fn else_(&self) -> Option<FalseExpr> {377 support::children(&self.syntax).next()378 }379}380381#[derive(Debug, Clone, PartialEq, Eq, Hash)]382pub struct TrueExpr {383 pub(crate) syntax: SyntaxNode,384}385impl TrueExpr {386 pub fn expr(&self) -> Option<Expr> {387 support::children(&self.syntax).next()388 }389}390391#[derive(Debug, Clone, PartialEq, Eq, Hash)]392pub struct FalseExpr {393 pub(crate) syntax: SyntaxNode,394}395impl FalseExpr {396 pub fn expr(&self) -> Option<Expr> {397 support::children(&self.syntax).next()398 }399}400401#[derive(Debug, Clone, PartialEq, Eq, Hash)]402pub struct ExprFunction {403 pub(crate) syntax: SyntaxNode,404}405impl ExprFunction {406 pub fn function_kw_token(&self) -> Option<SyntaxToken> {407 support::token(&self.syntax, T![function])408 }409 pub fn l_paren_token(&self) -> Option<SyntaxToken> {410 support::token(&self.syntax, T!['('])411 }412 pub fn params_desc(&self) -> Option<ParamsDesc> {413 support::children(&self.syntax).next()414 }415 pub fn r_paren_token(&self) -> Option<SyntaxToken> {416 support::token(&self.syntax, T![')'])417 }418 pub fn expr(&self) -> Option<Expr> {419 support::children(&self.syntax).next()420 }421}422423#[derive(Debug, Clone, PartialEq, Eq, Hash)]424pub struct ParamsDesc {425 pub(crate) syntax: SyntaxNode,426}427impl ParamsDesc {428 pub fn l_paren_token(&self) -> Option<SyntaxToken> {429 support::token(&self.syntax, T!['('])430 }431 pub fn params(&self) -> AstChildren<Param> {432 support::children(&self.syntax)433 }434 pub fn r_paren_token(&self) -> Option<SyntaxToken> {435 support::token(&self.syntax, T![')'])436 }437}438439#[derive(Debug, Clone, PartialEq, Eq, Hash)]440pub struct ExprError {441 pub(crate) syntax: SyntaxNode,442}443impl ExprError {444 pub fn error_kw_token(&self) -> Option<SyntaxToken> {445 support::token(&self.syntax, T![error])446 }447 pub fn expr(&self) -> Option<Expr> {448 support::children(&self.syntax).next()449 }450}451452#[derive(Debug, Clone, PartialEq, Eq, Hash)]453pub struct SliceDescEnd {454 pub(crate) syntax: SyntaxNode,455}456impl SliceDescEnd {457 pub fn expr(&self) -> Option<Expr> {458 support::children(&self.syntax).next()459 }460}461462#[derive(Debug, Clone, PartialEq, Eq, Hash)]463pub struct SliceDescStep {464 pub(crate) syntax: SyntaxNode,465}466impl SliceDescStep {467 pub fn expr(&self) -> Option<Expr> {468 support::children(&self.syntax).next()469 }470}471472#[derive(Debug, Clone, PartialEq, Eq, Hash)]473pub struct Arg {474 pub(crate) syntax: SyntaxNode,475}476impl Arg {477 pub fn name(&self) -> Option<Name> {478 support::children(&self.syntax).next()479 }480 pub fn assign_token(&self) -> Option<SyntaxToken> {481 support::token(&self.syntax, T![=])482 }483 pub fn expr(&self) -> Option<Expr> {484 support::children(&self.syntax).next()485 }486}487488#[derive(Debug, Clone, PartialEq, Eq, Hash)]489pub struct ObjBodyComp {490 pub(crate) syntax: SyntaxNode,491}492impl ObjBodyComp {493 pub fn l_brace_token(&self) -> Option<SyntaxToken> {494 support::token(&self.syntax, T!['{'])495 }496 pub fn member_comps(&self) -> AstChildren<MemberComp> {497 support::children(&self.syntax)498 }499 pub fn comp_specs(&self) -> AstChildren<CompSpec> {500 support::children(&self.syntax)501 }502 pub fn r_brace_token(&self) -> Option<SyntaxToken> {503 support::token(&self.syntax, T!['}'])504 }505}506507#[derive(Debug, Clone, PartialEq, Eq, Hash)]508pub struct ObjBodyMemberList {509 pub(crate) syntax: SyntaxNode,510}511impl ObjBodyMemberList {512 pub fn l_brace_token(&self) -> Option<SyntaxToken> {513 support::token(&self.syntax, T!['{'])514 }515 pub fn members(&self) -> AstChildren<Member> {516 support::children(&self.syntax)517 }518 pub fn r_brace_token(&self) -> Option<SyntaxToken> {519 support::token(&self.syntax, T!['}'])520 }521}522523#[derive(Debug, Clone, PartialEq, Eq, Hash)]524pub struct MemberBindStmt {525 pub(crate) syntax: SyntaxNode,526}527impl MemberBindStmt {528 pub fn obj_local(&self) -> Option<ObjLocal> {529 support::children(&self.syntax).next()530 }531}532533#[derive(Debug, Clone, PartialEq, Eq, Hash)]534pub struct ObjLocal {535 pub(crate) syntax: SyntaxNode,536}537impl ObjLocal {538 pub fn local_kw_token(&self) -> Option<SyntaxToken> {539 support::token(&self.syntax, T![local])540 }541 pub fn bind(&self) -> Option<Bind> {542 support::children(&self.syntax).next()543 }544}545546#[derive(Debug, Clone, PartialEq, Eq, Hash)]547pub struct MemberAssertStmt {548 pub(crate) syntax: SyntaxNode,549}550impl MemberAssertStmt {551 pub fn assertion(&self) -> Option<Assertion> {552 support::children(&self.syntax).next()553 }554}555556#[derive(Debug, Clone, PartialEq, Eq, Hash)]557pub struct MemberFieldNormal {558 pub(crate) syntax: SyntaxNode,559}560impl MemberFieldNormal {561 pub fn field_name(&self) -> Option<FieldName> {562 support::children(&self.syntax).next()563 }564 pub fn plus_token(&self) -> Option<SyntaxToken> {565 support::token(&self.syntax, T![+])566 }567 pub fn visibility(&self) -> Option<Visibility> {568 support::children(&self.syntax).next()569 }570 pub fn expr(&self) -> Option<Expr> {571 support::children(&self.syntax).next()572 }573}574575#[derive(Debug, Clone, PartialEq, Eq, Hash)]576pub struct Visibility {577 pub(crate) syntax: SyntaxNode,578}579impl Visibility {580 pub fn colon_token(&self) -> Option<SyntaxToken> {581 support::token(&self.syntax, T![:])582 }583}584585#[derive(Debug, Clone, PartialEq, Eq, Hash)]586pub struct MemberFieldMethod {587 pub(crate) syntax: SyntaxNode,588}589impl MemberFieldMethod {590 pub fn field_name(&self) -> Option<FieldName> {591 support::children(&self.syntax).next()592 }593 pub fn params_desc(&self) -> Option<ParamsDesc> {594 support::children(&self.syntax).next()595 }596 pub fn visibility(&self) -> Option<Visibility> {597 support::children(&self.syntax).next()598 }599 pub fn expr(&self) -> Option<Expr> {600 support::children(&self.syntax).next()601 }602}603604#[derive(Debug, Clone, PartialEq, Eq, Hash)]605pub struct FieldNameFixed {606 pub(crate) syntax: SyntaxNode,607}608impl FieldNameFixed {609 pub fn id(&self) -> Option<Name> {610 support::children(&self.syntax).next()611 }612 pub fn text(&self) -> Option<Text> {613 support::token_child(&self.syntax)614 }615}616617#[derive(Debug, Clone, PartialEq, Eq, Hash)]618pub struct FieldNameDynamic {619 pub(crate) syntax: SyntaxNode,620}621impl FieldNameDynamic {622 pub fn l_brack_token(&self) -> Option<SyntaxToken> {623 support::token(&self.syntax, T!['['])624 }625 pub fn expr(&self) -> Option<Expr> {626 support::children(&self.syntax).next()627 }628 pub fn r_brack_token(&self) -> Option<SyntaxToken> {629 support::token(&self.syntax, T![']'])630 }631}632633#[derive(Debug, Clone, PartialEq, Eq, Hash)]634pub struct ForSpec {635 pub(crate) syntax: SyntaxNode,636}637impl ForSpec {638 pub fn for_kw_token(&self) -> Option<SyntaxToken> {639 support::token(&self.syntax, T![for])640 }641 pub fn bind(&self) -> Option<Destruct> {642 support::children(&self.syntax).next()643 }644 pub fn in_kw_token(&self) -> Option<SyntaxToken> {645 support::token(&self.syntax, T![in])646 }647 pub fn expr(&self) -> Option<Expr> {648 support::children(&self.syntax).next()649 }650}651652#[derive(Debug, Clone, PartialEq, Eq, Hash)]653pub struct IfSpec {654 pub(crate) syntax: SyntaxNode,655}656impl IfSpec {657 pub fn if_kw_token(&self) -> Option<SyntaxToken> {658 support::token(&self.syntax, T![if])659 }660 pub fn expr(&self) -> Option<Expr> {661 support::children(&self.syntax).next()662 }663}664665#[derive(Debug, Clone, PartialEq, Eq, Hash)]666pub struct BindDestruct {667 pub(crate) syntax: SyntaxNode,668}669impl BindDestruct {670 pub fn into(&self) -> Option<Destruct> {671 support::children(&self.syntax).next()672 }673 pub fn assign_token(&self) -> Option<SyntaxToken> {674 support::token(&self.syntax, T![=])675 }676 pub fn value(&self) -> Option<Expr> {677 support::children(&self.syntax).next()678 }679}680681#[derive(Debug, Clone, PartialEq, Eq, Hash)]682pub struct BindFunction {683 pub(crate) syntax: SyntaxNode,684}685impl BindFunction {686 pub fn name(&self) -> Option<Name> {687 support::children(&self.syntax).next()688 }689 pub fn params(&self) -> Option<ParamsDesc> {690 support::children(&self.syntax).next()691 }692 pub fn assign_token(&self) -> Option<SyntaxToken> {693 support::token(&self.syntax, T![=])694 }695 pub fn value(&self) -> Option<Expr> {696 support::children(&self.syntax).next()697 }698}699700#[derive(Debug, Clone, PartialEq, Eq, Hash)]701pub struct Param {702 pub(crate) syntax: SyntaxNode,703}704impl Param {705 pub fn destruct(&self) -> Option<Destruct> {706 support::children(&self.syntax).next()707 }708 pub fn assign_token(&self) -> Option<SyntaxToken> {709 support::token(&self.syntax, T![=])710 }711 pub fn expr(&self) -> Option<Expr> {712 support::children(&self.syntax).next()713 }714}715716#[derive(Debug, Clone, PartialEq, Eq, Hash)]717pub struct DestructFull {718 pub(crate) syntax: SyntaxNode,719}720impl DestructFull {721 pub fn name(&self) -> Option<Name> {722 support::children(&self.syntax).next()723 }724}725726#[derive(Debug, Clone, PartialEq, Eq, Hash)]727pub struct DestructSkip {728 pub(crate) syntax: SyntaxNode,729}730impl DestructSkip {731 pub fn question_mark_token(&self) -> Option<SyntaxToken> {732 support::token(&self.syntax, T![?])733 }734}735736#[derive(Debug, Clone, PartialEq, Eq, Hash)]737pub struct DestructArray {738 pub(crate) syntax: SyntaxNode,739}740impl DestructArray {741 pub fn l_brack_token(&self) -> Option<SyntaxToken> {742 support::token(&self.syntax, T!['['])743 }744 pub fn destruct_array_parts(&self) -> AstChildren<DestructArrayPart> {745 support::children(&self.syntax)746 }747 pub fn r_brack_token(&self) -> Option<SyntaxToken> {748 support::token(&self.syntax, T![']'])749 }750}751752#[derive(Debug, Clone, PartialEq, Eq, Hash)]753pub struct DestructObject {754 pub(crate) syntax: SyntaxNode,755}756impl DestructObject {757 pub fn l_brace_token(&self) -> Option<SyntaxToken> {758 support::token(&self.syntax, T!['{'])759 }760 pub fn destruct_object_fields(&self) -> AstChildren<DestructObjectField> {761 support::children(&self.syntax)762 }763 pub fn destruct_rest(&self) -> Option<DestructRest> {764 support::children(&self.syntax).next()765 }766 pub fn comma_token(&self) -> Option<SyntaxToken> {767 support::token(&self.syntax, T![,])768 }769 pub fn r_brace_token(&self) -> Option<SyntaxToken> {770 support::token(&self.syntax, T!['}'])771 }772}773774#[derive(Debug, Clone, PartialEq, Eq, Hash)]775pub struct DestructObjectField {776 pub(crate) syntax: SyntaxNode,777}778impl DestructObjectField {779 pub fn field(&self) -> Option<Name> {780 support::children(&self.syntax).next()781 }782 pub fn colon_token(&self) -> Option<SyntaxToken> {783 support::token(&self.syntax, T![:])784 }785 pub fn destruct(&self) -> Option<Destruct> {786 support::children(&self.syntax).next()787 }788 pub fn assign_token(&self) -> Option<SyntaxToken> {789 support::token(&self.syntax, T![=])790 }791 pub fn expr(&self) -> Option<Expr> {792 support::children(&self.syntax).next()793 }794}795796#[derive(Debug, Clone, PartialEq, Eq, Hash)]797pub struct DestructRest {798 pub(crate) syntax: SyntaxNode,799}800impl DestructRest {801 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> {802 support::token(&self.syntax, T![...])803 }804 pub fn into(&self) -> Option<Name> {805 support::children(&self.syntax).next()806 }807}808809#[derive(Debug, Clone, PartialEq, Eq, Hash)]810pub struct DestructArrayElement {811 pub(crate) syntax: SyntaxNode,812}813impl DestructArrayElement {814 pub fn destruct(&self) -> Option<Destruct> {815 support::children(&self.syntax).next()816 }817}818819#[derive(Debug, Clone, PartialEq, Eq, Hash)]820pub enum Suffix {821 SuffixIndex(SuffixIndex),822 SuffixIndexExpr(SuffixIndexExpr),823 SuffixSlice(SuffixSlice),824 SuffixApply(SuffixApply),825}826827#[derive(Debug, Clone, PartialEq, Eq, Hash)]828pub enum Bind {829 BindDestruct(BindDestruct),830 BindFunction(BindFunction),831}832833#[derive(Debug, Clone, PartialEq, Eq, Hash)]834pub enum Stmt {835 StmtLocal(StmtLocal),836 StmtAssert(StmtAssert),837}838839#[derive(Debug, Clone, PartialEq, Eq, Hash)]840pub enum ObjBody {841 ObjBodyComp(ObjBodyComp),842 ObjBodyMemberList(ObjBodyMemberList),843}844845#[derive(Debug, Clone, PartialEq, Eq, Hash)]846pub enum CompSpec {847 ForSpec(ForSpec),848 IfSpec(IfSpec),849}850851#[derive(Debug, Clone, PartialEq, Eq, Hash)]852pub enum ExprBase {853 ExprBinary(ExprBinary),854 ExprUnary(ExprUnary),855 ExprObjExtend(ExprObjExtend),856 ExprParened(ExprParened),857 ExprString(ExprString),858 ExprNumber(ExprNumber),859 ExprLiteral(ExprLiteral),860 ExprArray(ExprArray),861 ExprObject(ExprObject),862 ExprArrayComp(ExprArrayComp),863 ExprImport(ExprImport),864 ExprVar(ExprVar),865 ExprIfThenElse(ExprIfThenElse),866 ExprFunction(ExprFunction),867 ExprError(ExprError),868}869870#[derive(Debug, Clone, PartialEq, Eq, Hash)]871pub enum MemberComp {872 MemberBindStmt(MemberBindStmt),873 MemberFieldNormal(MemberFieldNormal),874 MemberFieldMethod(MemberFieldMethod),875}876877#[derive(Debug, Clone, PartialEq, Eq, Hash)]878pub enum Member {879 MemberBindStmt(MemberBindStmt),880 MemberAssertStmt(MemberAssertStmt),881 MemberFieldNormal(MemberFieldNormal),882 MemberFieldMethod(MemberFieldMethod),883}884885#[derive(Debug, Clone, PartialEq, Eq, Hash)]886pub enum FieldName {887 FieldNameFixed(FieldNameFixed),888 FieldNameDynamic(FieldNameDynamic),889}890891#[derive(Debug, Clone, PartialEq, Eq, Hash)]892pub enum Destruct {893 DestructFull(DestructFull),894 DestructSkip(DestructSkip),895 DestructArray(DestructArray),896 DestructObject(DestructObject),897}898899#[derive(Debug, Clone, PartialEq, Eq, Hash)]900pub enum DestructArrayPart {901 DestructArrayElement(DestructArrayElement),902 DestructRest(DestructRest),903}904905#[derive(Debug, Clone, PartialEq, Eq, Hash)]906pub struct BinaryOperator {907 syntax: SyntaxToken,908 kind: BinaryOperatorKind,909}910911#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]912pub enum BinaryOperatorKind {913 Or,914 NullCoaelse,915 And,916 BitOr,917 BitXor,918 BitAnd,919 Eq,920 Ne,921 Lt,922 Gt,923 Le,924 Ge,925 InKw,926 Lhs,927 Rhs,928 Plus,929 Minus,930 Mul,931 Div,932 Modulo,933 MetaObjectApply,934 ErrorNoOperator,935}936937#[derive(Debug, Clone, PartialEq, Eq, Hash)]938pub struct UnaryOperator {939 syntax: SyntaxToken,940 kind: UnaryOperatorKind,941}942943#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]944pub enum UnaryOperatorKind {945 Minus,946 Not,947 BitNot,948}949950#[derive(Debug, Clone, PartialEq, Eq, Hash)]951pub struct Literal {952 syntax: SyntaxToken,953 kind: LiteralKind,954}955956#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]957pub enum LiteralKind {958 NullKw,959 TrueKw,960 FalseKw,961 SelfKw,962 Dollar,963 SuperKw,964}965966#[derive(Debug, Clone, PartialEq, Eq, Hash)]967pub struct Text {968 syntax: SyntaxToken,969 kind: TextKind,970}971972#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]973pub enum TextKind {974 StringDouble,975 ErrorStringDoubleUnterminated,976 StringSingle,977 ErrorStringSingleUnterminated,978 StringDoubleVerbatim,979 ErrorStringDoubleVerbatimUnterminated,980 StringSingleVerbatim,981 ErrorStringSingleVerbatimUnterminated,982 ErrorStringVerbatimMissingQuotes,983 StringBlock,984 ErrorStringBlockUnexpectedEnd,985 ErrorStringBlockMissingNewLine,986 ErrorStringBlockMissingTermination,987 ErrorStringBlockMissingIndent,988}989990#[derive(Debug, Clone, PartialEq, Eq, Hash)]991pub struct Number {992 syntax: SyntaxToken,993 kind: NumberKind,994}995996#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]997pub enum NumberKind {998 Float,999 ErrorFloatJunkAfterPoint,1000 ErrorFloatJunkAfterExponent,1001 ErrorFloatJunkAfterExponentSign,1002}10031004#[derive(Debug, Clone, PartialEq, Eq, Hash)]1005pub struct ImportKind {1006 syntax: SyntaxToken,1007 kind: ImportKindKind,1008}10091010#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1011pub enum ImportKindKind {1012 ImportstrKw,1013 ImportbinKw,1014 ImportKw,1015}10161017#[derive(Debug, Clone, PartialEq, Eq, Hash)]1018pub struct Trivia {1019 syntax: SyntaxToken,1020 kind: TriviaKind,1021}10221023#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1024pub enum TriviaKind {1025 Whitespace,1026 MultiLineComment,1027 ErrorCommentTooShort,1028 ErrorCommentUnterminated,1029 SingleLineHashComment,1030 SingleLineSlashComment,1031}10321033#[derive(Debug, Clone, PartialEq, Eq, Hash)]1034pub struct CustomError {1035 syntax: SyntaxToken,1036 kind: CustomErrorKind,1037}10381039#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1040pub enum CustomErrorKind {1041 ErrorMissingToken,1042 ErrorUnexpectedToken,1043 ErrorCustom,1044}1045impl AstNode for SourceFile {1046 fn can_cast(kind: SyntaxKind) -> bool {1047 kind == SOURCE_FILE1048 }1049 fn cast(syntax: SyntaxNode) -> Option<Self> {1050 if Self::can_cast(syntax.kind()) {1051 Some(Self { syntax })1052 } else {1053 None1054 }1055 }1056 fn syntax(&self) -> &SyntaxNode {1057 &self.syntax1058 }1059}1060impl AstNode for Expr {1061 fn can_cast(kind: SyntaxKind) -> bool {1062 kind == EXPR1063 }1064 fn cast(syntax: SyntaxNode) -> Option<Self> {1065 if Self::can_cast(syntax.kind()) {1066 Some(Self { syntax })1067 } else {1068 None1069 }1070 }1071 fn syntax(&self) -> &SyntaxNode {1072 &self.syntax1073 }1074}1075impl AstNode for SuffixIndex {1076 fn can_cast(kind: SyntaxKind) -> bool {1077 kind == SUFFIX_INDEX1078 }1079 fn cast(syntax: SyntaxNode) -> Option<Self> {1080 if Self::can_cast(syntax.kind()) {1081 Some(Self { syntax })1082 } else {1083 None1084 }1085 }1086 fn syntax(&self) -> &SyntaxNode {1087 &self.syntax1088 }1089}1090impl AstNode for Name {1091 fn can_cast(kind: SyntaxKind) -> bool {1092 kind == NAME1093 }1094 fn cast(syntax: SyntaxNode) -> Option<Self> {1095 if Self::can_cast(syntax.kind()) {1096 Some(Self { syntax })1097 } else {1098 None1099 }1100 }1101 fn syntax(&self) -> &SyntaxNode {1102 &self.syntax1103 }1104}1105impl AstNode for SuffixIndexExpr {1106 fn can_cast(kind: SyntaxKind) -> bool {1107 kind == SUFFIX_INDEX_EXPR1108 }1109 fn cast(syntax: SyntaxNode) -> Option<Self> {1110 if Self::can_cast(syntax.kind()) {1111 Some(Self { syntax })1112 } else {1113 None1114 }1115 }1116 fn syntax(&self) -> &SyntaxNode {1117 &self.syntax1118 }1119}1120impl AstNode for SuffixSlice {1121 fn can_cast(kind: SyntaxKind) -> bool {1122 kind == SUFFIX_SLICE1123 }1124 fn cast(syntax: SyntaxNode) -> Option<Self> {1125 if Self::can_cast(syntax.kind()) {1126 Some(Self { syntax })1127 } else {1128 None1129 }1130 }1131 fn syntax(&self) -> &SyntaxNode {1132 &self.syntax1133 }1134}1135impl AstNode for SliceDesc {1136 fn can_cast(kind: SyntaxKind) -> bool {1137 kind == SLICE_DESC1138 }1139 fn cast(syntax: SyntaxNode) -> Option<Self> {1140 if Self::can_cast(syntax.kind()) {1141 Some(Self { syntax })1142 } else {1143 None1144 }1145 }1146 fn syntax(&self) -> &SyntaxNode {1147 &self.syntax1148 }1149}1150impl AstNode for SuffixApply {1151 fn can_cast(kind: SyntaxKind) -> bool {1152 kind == SUFFIX_APPLY1153 }1154 fn cast(syntax: SyntaxNode) -> Option<Self> {1155 if Self::can_cast(syntax.kind()) {1156 Some(Self { syntax })1157 } else {1158 None1159 }1160 }1161 fn syntax(&self) -> &SyntaxNode {1162 &self.syntax1163 }1164}1165impl AstNode for ArgsDesc {1166 fn can_cast(kind: SyntaxKind) -> bool {1167 kind == ARGS_DESC1168 }1169 fn cast(syntax: SyntaxNode) -> Option<Self> {1170 if Self::can_cast(syntax.kind()) {1171 Some(Self { syntax })1172 } else {1173 None1174 }1175 }1176 fn syntax(&self) -> &SyntaxNode {1177 &self.syntax1178 }1179}1180impl AstNode for StmtLocal {1181 fn can_cast(kind: SyntaxKind) -> bool {1182 kind == STMT_LOCAL1183 }1184 fn cast(syntax: SyntaxNode) -> Option<Self> {1185 if Self::can_cast(syntax.kind()) {1186 Some(Self { syntax })1187 } else {1188 None1189 }1190 }1191 fn syntax(&self) -> &SyntaxNode {1192 &self.syntax1193 }1194}1195impl AstNode for StmtAssert {1196 fn can_cast(kind: SyntaxKind) -> bool {1197 kind == STMT_ASSERT1198 }1199 fn cast(syntax: SyntaxNode) -> Option<Self> {1200 if Self::can_cast(syntax.kind()) {1201 Some(Self { syntax })1202 } else {1203 None1204 }1205 }1206 fn syntax(&self) -> &SyntaxNode {1207 &self.syntax1208 }1209}1210impl AstNode for Assertion {1211 fn can_cast(kind: SyntaxKind) -> bool {1212 kind == ASSERTION1213 }1214 fn cast(syntax: SyntaxNode) -> Option<Self> {1215 if Self::can_cast(syntax.kind()) {1216 Some(Self { syntax })1217 } else {1218 None1219 }1220 }1221 fn syntax(&self) -> &SyntaxNode {1222 &self.syntax1223 }1224}1225impl AstNode for ExprBinary {1226 fn can_cast(kind: SyntaxKind) -> bool {1227 kind == EXPR_BINARY1228 }1229 fn cast(syntax: SyntaxNode) -> Option<Self> {1230 if Self::can_cast(syntax.kind()) {1231 Some(Self { syntax })1232 } else {1233 None1234 }1235 }1236 fn syntax(&self) -> &SyntaxNode {1237 &self.syntax1238 }1239}1240impl AstNode for ExprUnary {1241 fn can_cast(kind: SyntaxKind) -> bool {1242 kind == EXPR_UNARY1243 }1244 fn cast(syntax: SyntaxNode) -> Option<Self> {1245 if Self::can_cast(syntax.kind()) {1246 Some(Self { syntax })1247 } else {1248 None1249 }1250 }1251 fn syntax(&self) -> &SyntaxNode {1252 &self.syntax1253 }1254}1255impl AstNode for ExprObjExtend {1256 fn can_cast(kind: SyntaxKind) -> bool {1257 kind == EXPR_OBJ_EXTEND1258 }1259 fn cast(syntax: SyntaxNode) -> Option<Self> {1260 if Self::can_cast(syntax.kind()) {1261 Some(Self { syntax })1262 } else {1263 None1264 }1265 }1266 fn syntax(&self) -> &SyntaxNode {1267 &self.syntax1268 }1269}1270impl AstNode for ExprParened {1271 fn can_cast(kind: SyntaxKind) -> bool {1272 kind == EXPR_PARENED1273 }1274 fn cast(syntax: SyntaxNode) -> Option<Self> {1275 if Self::can_cast(syntax.kind()) {1276 Some(Self { syntax })1277 } else {1278 None1279 }1280 }1281 fn syntax(&self) -> &SyntaxNode {1282 &self.syntax1283 }1284}1285impl AstNode for ExprLiteral {1286 fn can_cast(kind: SyntaxKind) -> bool {1287 kind == EXPR_LITERAL1288 }1289 fn cast(syntax: SyntaxNode) -> Option<Self> {1290 if Self::can_cast(syntax.kind()) {1291 Some(Self { syntax })1292 } else {1293 None1294 }1295 }1296 fn syntax(&self) -> &SyntaxNode {1297 &self.syntax1298 }1299}1300impl AstNode for ExprString {1301 fn can_cast(kind: SyntaxKind) -> bool {1302 kind == EXPR_STRING1303 }1304 fn cast(syntax: SyntaxNode) -> Option<Self> {1305 if Self::can_cast(syntax.kind()) {1306 Some(Self { syntax })1307 } else {1308 None1309 }1310 }1311 fn syntax(&self) -> &SyntaxNode {1312 &self.syntax1313 }1314}1315impl AstNode for ExprNumber {1316 fn can_cast(kind: SyntaxKind) -> bool {1317 kind == EXPR_NUMBER1318 }1319 fn cast(syntax: SyntaxNode) -> Option<Self> {1320 if Self::can_cast(syntax.kind()) {1321 Some(Self { syntax })1322 } else {1323 None1324 }1325 }1326 fn syntax(&self) -> &SyntaxNode {1327 &self.syntax1328 }1329}1330impl AstNode for ExprArray {1331 fn can_cast(kind: SyntaxKind) -> bool {1332 kind == EXPR_ARRAY1333 }1334 fn cast(syntax: SyntaxNode) -> Option<Self> {1335 if Self::can_cast(syntax.kind()) {1336 Some(Self { syntax })1337 } else {1338 None1339 }1340 }1341 fn syntax(&self) -> &SyntaxNode {1342 &self.syntax1343 }1344}1345impl AstNode for ExprObject {1346 fn can_cast(kind: SyntaxKind) -> bool {1347 kind == EXPR_OBJECT1348 }1349 fn cast(syntax: SyntaxNode) -> Option<Self> {1350 if Self::can_cast(syntax.kind()) {1351 Some(Self { syntax })1352 } else {1353 None1354 }1355 }1356 fn syntax(&self) -> &SyntaxNode {1357 &self.syntax1358 }1359}1360impl AstNode for ExprArrayComp {1361 fn can_cast(kind: SyntaxKind) -> bool {1362 kind == EXPR_ARRAY_COMP1363 }1364 fn cast(syntax: SyntaxNode) -> Option<Self> {1365 if Self::can_cast(syntax.kind()) {1366 Some(Self { syntax })1367 } else {1368 None1369 }1370 }1371 fn syntax(&self) -> &SyntaxNode {1372 &self.syntax1373 }1374}1375impl AstNode for ExprImport {1376 fn can_cast(kind: SyntaxKind) -> bool {1377 kind == EXPR_IMPORT1378 }1379 fn cast(syntax: SyntaxNode) -> Option<Self> {1380 if Self::can_cast(syntax.kind()) {1381 Some(Self { syntax })1382 } else {1383 None1384 }1385 }1386 fn syntax(&self) -> &SyntaxNode {1387 &self.syntax1388 }1389}1390impl AstNode for ExprVar {1391 fn can_cast(kind: SyntaxKind) -> bool {1392 kind == EXPR_VAR1393 }1394 fn cast(syntax: SyntaxNode) -> Option<Self> {1395 if Self::can_cast(syntax.kind()) {1396 Some(Self { syntax })1397 } else {1398 None1399 }1400 }1401 fn syntax(&self) -> &SyntaxNode {1402 &self.syntax1403 }1404}1405impl AstNode for ExprIfThenElse {1406 fn can_cast(kind: SyntaxKind) -> bool {1407 kind == EXPR_IF_THEN_ELSE1408 }1409 fn cast(syntax: SyntaxNode) -> Option<Self> {1410 if Self::can_cast(syntax.kind()) {1411 Some(Self { syntax })1412 } else {1413 None1414 }1415 }1416 fn syntax(&self) -> &SyntaxNode {1417 &self.syntax1418 }1419}1420impl AstNode for TrueExpr {1421 fn can_cast(kind: SyntaxKind) -> bool {1422 kind == TRUE_EXPR1423 }1424 fn cast(syntax: SyntaxNode) -> Option<Self> {1425 if Self::can_cast(syntax.kind()) {1426 Some(Self { syntax })1427 } else {1428 None1429 }1430 }1431 fn syntax(&self) -> &SyntaxNode {1432 &self.syntax1433 }1434}1435impl AstNode for FalseExpr {1436 fn can_cast(kind: SyntaxKind) -> bool {1437 kind == FALSE_EXPR1438 }1439 fn cast(syntax: SyntaxNode) -> Option<Self> {1440 if Self::can_cast(syntax.kind()) {1441 Some(Self { syntax })1442 } else {1443 None1444 }1445 }1446 fn syntax(&self) -> &SyntaxNode {1447 &self.syntax1448 }1449}1450impl AstNode for ExprFunction {1451 fn can_cast(kind: SyntaxKind) -> bool {1452 kind == EXPR_FUNCTION1453 }1454 fn cast(syntax: SyntaxNode) -> Option<Self> {1455 if Self::can_cast(syntax.kind()) {1456 Some(Self { syntax })1457 } else {1458 None1459 }1460 }1461 fn syntax(&self) -> &SyntaxNode {1462 &self.syntax1463 }1464}1465impl AstNode for ParamsDesc {1466 fn can_cast(kind: SyntaxKind) -> bool {1467 kind == PARAMS_DESC1468 }1469 fn cast(syntax: SyntaxNode) -> Option<Self> {1470 if Self::can_cast(syntax.kind()) {1471 Some(Self { syntax })1472 } else {1473 None1474 }1475 }1476 fn syntax(&self) -> &SyntaxNode {1477 &self.syntax1478 }1479}1480impl AstNode for ExprError {1481 fn can_cast(kind: SyntaxKind) -> bool {1482 kind == EXPR_ERROR1483 }1484 fn cast(syntax: SyntaxNode) -> Option<Self> {1485 if Self::can_cast(syntax.kind()) {1486 Some(Self { syntax })1487 } else {1488 None1489 }1490 }1491 fn syntax(&self) -> &SyntaxNode {1492 &self.syntax1493 }1494}1495impl AstNode for SliceDescEnd {1496 fn can_cast(kind: SyntaxKind) -> bool {1497 kind == SLICE_DESC_END1498 }1499 fn cast(syntax: SyntaxNode) -> Option<Self> {1500 if Self::can_cast(syntax.kind()) {1501 Some(Self { syntax })1502 } else {1503 None1504 }1505 }1506 fn syntax(&self) -> &SyntaxNode {1507 &self.syntax1508 }1509}1510impl AstNode for SliceDescStep {1511 fn can_cast(kind: SyntaxKind) -> bool {1512 kind == SLICE_DESC_STEP1513 }1514 fn cast(syntax: SyntaxNode) -> Option<Self> {1515 if Self::can_cast(syntax.kind()) {1516 Some(Self { syntax })1517 } else {1518 None1519 }1520 }1521 fn syntax(&self) -> &SyntaxNode {1522 &self.syntax1523 }1524}1525impl AstNode for Arg {1526 fn can_cast(kind: SyntaxKind) -> bool {1527 kind == ARG1528 }1529 fn cast(syntax: SyntaxNode) -> Option<Self> {1530 if Self::can_cast(syntax.kind()) {1531 Some(Self { syntax })1532 } else {1533 None1534 }1535 }1536 fn syntax(&self) -> &SyntaxNode {1537 &self.syntax1538 }1539}1540impl AstNode for ObjBodyComp {1541 fn can_cast(kind: SyntaxKind) -> bool {1542 kind == OBJ_BODY_COMP1543 }1544 fn cast(syntax: SyntaxNode) -> Option<Self> {1545 if Self::can_cast(syntax.kind()) {1546 Some(Self { syntax })1547 } else {1548 None1549 }1550 }1551 fn syntax(&self) -> &SyntaxNode {1552 &self.syntax1553 }1554}1555impl AstNode for ObjBodyMemberList {1556 fn can_cast(kind: SyntaxKind) -> bool {1557 kind == OBJ_BODY_MEMBER_LIST1558 }1559 fn cast(syntax: SyntaxNode) -> Option<Self> {1560 if Self::can_cast(syntax.kind()) {1561 Some(Self { syntax })1562 } else {1563 None1564 }1565 }1566 fn syntax(&self) -> &SyntaxNode {1567 &self.syntax1568 }1569}1570impl AstNode for MemberBindStmt {1571 fn can_cast(kind: SyntaxKind) -> bool {1572 kind == MEMBER_BIND_STMT1573 }1574 fn cast(syntax: SyntaxNode) -> Option<Self> {1575 if Self::can_cast(syntax.kind()) {1576 Some(Self { syntax })1577 } else {1578 None1579 }1580 }1581 fn syntax(&self) -> &SyntaxNode {1582 &self.syntax1583 }1584}1585impl AstNode for ObjLocal {1586 fn can_cast(kind: SyntaxKind) -> bool {1587 kind == OBJ_LOCAL1588 }1589 fn cast(syntax: SyntaxNode) -> Option<Self> {1590 if Self::can_cast(syntax.kind()) {1591 Some(Self { syntax })1592 } else {1593 None1594 }1595 }1596 fn syntax(&self) -> &SyntaxNode {1597 &self.syntax1598 }1599}1600impl AstNode for MemberAssertStmt {1601 fn can_cast(kind: SyntaxKind) -> bool {1602 kind == MEMBER_ASSERT_STMT1603 }1604 fn cast(syntax: SyntaxNode) -> Option<Self> {1605 if Self::can_cast(syntax.kind()) {1606 Some(Self { syntax })1607 } else {1608 None1609 }1610 }1611 fn syntax(&self) -> &SyntaxNode {1612 &self.syntax1613 }1614}1615impl AstNode for MemberFieldNormal {1616 fn can_cast(kind: SyntaxKind) -> bool {1617 kind == MEMBER_FIELD_NORMAL1618 }1619 fn cast(syntax: SyntaxNode) -> Option<Self> {1620 if Self::can_cast(syntax.kind()) {1621 Some(Self { syntax })1622 } else {1623 None1624 }1625 }1626 fn syntax(&self) -> &SyntaxNode {1627 &self.syntax1628 }1629}1630impl AstNode for Visibility {1631 fn can_cast(kind: SyntaxKind) -> bool {1632 kind == VISIBILITY1633 }1634 fn cast(syntax: SyntaxNode) -> Option<Self> {1635 if Self::can_cast(syntax.kind()) {1636 Some(Self { syntax })1637 } else {1638 None1639 }1640 }1641 fn syntax(&self) -> &SyntaxNode {1642 &self.syntax1643 }1644}1645impl AstNode for MemberFieldMethod {1646 fn can_cast(kind: SyntaxKind) -> bool {1647 kind == MEMBER_FIELD_METHOD1648 }1649 fn cast(syntax: SyntaxNode) -> Option<Self> {1650 if Self::can_cast(syntax.kind()) {1651 Some(Self { syntax })1652 } else {1653 None1654 }1655 }1656 fn syntax(&self) -> &SyntaxNode {1657 &self.syntax1658 }1659}1660impl AstNode for FieldNameFixed {1661 fn can_cast(kind: SyntaxKind) -> bool {1662 kind == FIELD_NAME_FIXED1663 }1664 fn cast(syntax: SyntaxNode) -> Option<Self> {1665 if Self::can_cast(syntax.kind()) {1666 Some(Self { syntax })1667 } else {1668 None1669 }1670 }1671 fn syntax(&self) -> &SyntaxNode {1672 &self.syntax1673 }1674}1675impl AstNode for FieldNameDynamic {1676 fn can_cast(kind: SyntaxKind) -> bool {1677 kind == FIELD_NAME_DYNAMIC1678 }1679 fn cast(syntax: SyntaxNode) -> Option<Self> {1680 if Self::can_cast(syntax.kind()) {1681 Some(Self { syntax })1682 } else {1683 None1684 }1685 }1686 fn syntax(&self) -> &SyntaxNode {1687 &self.syntax1688 }1689}1690impl AstNode for ForSpec {1691 fn can_cast(kind: SyntaxKind) -> bool {1692 kind == FOR_SPEC1693 }1694 fn cast(syntax: SyntaxNode) -> Option<Self> {1695 if Self::can_cast(syntax.kind()) {1696 Some(Self { syntax })1697 } else {1698 None1699 }1700 }1701 fn syntax(&self) -> &SyntaxNode {1702 &self.syntax1703 }1704}1705impl AstNode for IfSpec {1706 fn can_cast(kind: SyntaxKind) -> bool {1707 kind == IF_SPEC1708 }1709 fn cast(syntax: SyntaxNode) -> Option<Self> {1710 if Self::can_cast(syntax.kind()) {1711 Some(Self { syntax })1712 } else {1713 None1714 }1715 }1716 fn syntax(&self) -> &SyntaxNode {1717 &self.syntax1718 }1719}1720impl AstNode for BindDestruct {1721 fn can_cast(kind: SyntaxKind) -> bool {1722 kind == BIND_DESTRUCT1723 }1724 fn cast(syntax: SyntaxNode) -> Option<Self> {1725 if Self::can_cast(syntax.kind()) {1726 Some(Self { syntax })1727 } else {1728 None1729 }1730 }1731 fn syntax(&self) -> &SyntaxNode {1732 &self.syntax1733 }1734}1735impl AstNode for BindFunction {1736 fn can_cast(kind: SyntaxKind) -> bool {1737 kind == BIND_FUNCTION1738 }1739 fn cast(syntax: SyntaxNode) -> Option<Self> {1740 if Self::can_cast(syntax.kind()) {1741 Some(Self { syntax })1742 } else {1743 None1744 }1745 }1746 fn syntax(&self) -> &SyntaxNode {1747 &self.syntax1748 }1749}1750impl AstNode for Param {1751 fn can_cast(kind: SyntaxKind) -> bool {1752 kind == PARAM1753 }1754 fn cast(syntax: SyntaxNode) -> Option<Self> {1755 if Self::can_cast(syntax.kind()) {1756 Some(Self { syntax })1757 } else {1758 None1759 }1760 }1761 fn syntax(&self) -> &SyntaxNode {1762 &self.syntax1763 }1764}1765impl AstNode for DestructFull {1766 fn can_cast(kind: SyntaxKind) -> bool {1767 kind == DESTRUCT_FULL1768 }1769 fn cast(syntax: SyntaxNode) -> Option<Self> {1770 if Self::can_cast(syntax.kind()) {1771 Some(Self { syntax })1772 } else {1773 None1774 }1775 }1776 fn syntax(&self) -> &SyntaxNode {1777 &self.syntax1778 }1779}1780impl AstNode for DestructSkip {1781 fn can_cast(kind: SyntaxKind) -> bool {1782 kind == DESTRUCT_SKIP1783 }1784 fn cast(syntax: SyntaxNode) -> Option<Self> {1785 if Self::can_cast(syntax.kind()) {1786 Some(Self { syntax })1787 } else {1788 None1789 }1790 }1791 fn syntax(&self) -> &SyntaxNode {1792 &self.syntax1793 }1794}1795impl AstNode for DestructArray {1796 fn can_cast(kind: SyntaxKind) -> bool {1797 kind == DESTRUCT_ARRAY1798 }1799 fn cast(syntax: SyntaxNode) -> Option<Self> {1800 if Self::can_cast(syntax.kind()) {1801 Some(Self { syntax })1802 } else {1803 None1804 }1805 }1806 fn syntax(&self) -> &SyntaxNode {1807 &self.syntax1808 }1809}1810impl AstNode for DestructObject {1811 fn can_cast(kind: SyntaxKind) -> bool {1812 kind == DESTRUCT_OBJECT1813 }1814 fn cast(syntax: SyntaxNode) -> Option<Self> {1815 if Self::can_cast(syntax.kind()) {1816 Some(Self { syntax })1817 } else {1818 None1819 }1820 }1821 fn syntax(&self) -> &SyntaxNode {1822 &self.syntax1823 }1824}1825impl AstNode for DestructObjectField {1826 fn can_cast(kind: SyntaxKind) -> bool {1827 kind == DESTRUCT_OBJECT_FIELD1828 }1829 fn cast(syntax: SyntaxNode) -> Option<Self> {1830 if Self::can_cast(syntax.kind()) {1831 Some(Self { syntax })1832 } else {1833 None1834 }1835 }1836 fn syntax(&self) -> &SyntaxNode {1837 &self.syntax1838 }1839}1840impl AstNode for DestructRest {1841 fn can_cast(kind: SyntaxKind) -> bool {1842 kind == DESTRUCT_REST1843 }1844 fn cast(syntax: SyntaxNode) -> Option<Self> {1845 if Self::can_cast(syntax.kind()) {1846 Some(Self { syntax })1847 } else {1848 None1849 }1850 }1851 fn syntax(&self) -> &SyntaxNode {1852 &self.syntax1853 }1854}1855impl AstNode for DestructArrayElement {1856 fn can_cast(kind: SyntaxKind) -> bool {1857 kind == DESTRUCT_ARRAY_ELEMENT1858 }1859 fn cast(syntax: SyntaxNode) -> Option<Self> {1860 if Self::can_cast(syntax.kind()) {1861 Some(Self { syntax })1862 } else {1863 None1864 }1865 }1866 fn syntax(&self) -> &SyntaxNode {1867 &self.syntax1868 }1869}1870impl From<SuffixIndex> for Suffix {1871 fn from(node: SuffixIndex) -> Suffix {1872 Suffix::SuffixIndex(node)1873 }1874}1875impl From<SuffixIndexExpr> for Suffix {1876 fn from(node: SuffixIndexExpr) -> Suffix {1877 Suffix::SuffixIndexExpr(node)1878 }1879}1880impl From<SuffixSlice> for Suffix {1881 fn from(node: SuffixSlice) -> Suffix {1882 Suffix::SuffixSlice(node)1883 }1884}1885impl From<SuffixApply> for Suffix {1886 fn from(node: SuffixApply) -> Suffix {1887 Suffix::SuffixApply(node)1888 }1889}1890impl AstNode for Suffix {1891 fn can_cast(kind: SyntaxKind) -> bool {1892 match kind {1893 SUFFIX_INDEX | SUFFIX_INDEX_EXPR | SUFFIX_SLICE | SUFFIX_APPLY => true,1894 _ => false,1895 }1896 }1897 fn cast(syntax: SyntaxNode) -> Option<Self> {1898 let res = match syntax.kind() {1899 SUFFIX_INDEX => Suffix::SuffixIndex(SuffixIndex { syntax }),1900 SUFFIX_INDEX_EXPR => Suffix::SuffixIndexExpr(SuffixIndexExpr { syntax }),1901 SUFFIX_SLICE => Suffix::SuffixSlice(SuffixSlice { syntax }),1902 SUFFIX_APPLY => Suffix::SuffixApply(SuffixApply { syntax }),1903 _ => return None,1904 };1905 Some(res)1906 }1907 fn syntax(&self) -> &SyntaxNode {1908 match self {1909 Suffix::SuffixIndex(it) => &it.syntax,1910 Suffix::SuffixIndexExpr(it) => &it.syntax,1911 Suffix::SuffixSlice(it) => &it.syntax,1912 Suffix::SuffixApply(it) => &it.syntax,1913 }1914 }1915}1916impl From<BindDestruct> for Bind {1917 fn from(node: BindDestruct) -> Bind {1918 Bind::BindDestruct(node)1919 }1920}1921impl From<BindFunction> for Bind {1922 fn from(node: BindFunction) -> Bind {1923 Bind::BindFunction(node)1924 }1925}1926impl AstNode for Bind {1927 fn can_cast(kind: SyntaxKind) -> bool {1928 match kind {1929 BIND_DESTRUCT | BIND_FUNCTION => true,1930 _ => false,1931 }1932 }1933 fn cast(syntax: SyntaxNode) -> Option<Self> {1934 let res = match syntax.kind() {1935 BIND_DESTRUCT => Bind::BindDestruct(BindDestruct { syntax }),1936 BIND_FUNCTION => Bind::BindFunction(BindFunction { syntax }),1937 _ => return None,1938 };1939 Some(res)1940 }1941 fn syntax(&self) -> &SyntaxNode {1942 match self {1943 Bind::BindDestruct(it) => &it.syntax,1944 Bind::BindFunction(it) => &it.syntax,1945 }1946 }1947}1948impl From<StmtLocal> for Stmt {1949 fn from(node: StmtLocal) -> Stmt {1950 Stmt::StmtLocal(node)1951 }1952}1953impl From<StmtAssert> for Stmt {1954 fn from(node: StmtAssert) -> Stmt {1955 Stmt::StmtAssert(node)1956 }1957}1958impl AstNode for Stmt {1959 fn can_cast(kind: SyntaxKind) -> bool {1960 match kind {1961 STMT_LOCAL | STMT_ASSERT => true,1962 _ => false,1963 }1964 }1965 fn cast(syntax: SyntaxNode) -> Option<Self> {1966 let res = match syntax.kind() {1967 STMT_LOCAL => Stmt::StmtLocal(StmtLocal { syntax }),1968 STMT_ASSERT => Stmt::StmtAssert(StmtAssert { syntax }),1969 _ => return None,1970 };1971 Some(res)1972 }1973 fn syntax(&self) -> &SyntaxNode {1974 match self {1975 Stmt::StmtLocal(it) => &it.syntax,1976 Stmt::StmtAssert(it) => &it.syntax,1977 }1978 }1979}1980impl From<ObjBodyComp> for ObjBody {1981 fn from(node: ObjBodyComp) -> ObjBody {1982 ObjBody::ObjBodyComp(node)1983 }1984}1985impl From<ObjBodyMemberList> for ObjBody {1986 fn from(node: ObjBodyMemberList) -> ObjBody {1987 ObjBody::ObjBodyMemberList(node)1988 }1989}1990impl AstNode for ObjBody {1991 fn can_cast(kind: SyntaxKind) -> bool {1992 match kind {1993 OBJ_BODY_COMP | OBJ_BODY_MEMBER_LIST => true,1994 _ => false,1995 }1996 }1997 fn cast(syntax: SyntaxNode) -> Option<Self> {1998 let res = match syntax.kind() {1999 OBJ_BODY_COMP => ObjBody::ObjBodyComp(ObjBodyComp { syntax }),2000 OBJ_BODY_MEMBER_LIST => ObjBody::ObjBodyMemberList(ObjBodyMemberList { syntax }),2001 _ => return None,2002 };2003 Some(res)2004 }2005 fn syntax(&self) -> &SyntaxNode {2006 match self {2007 ObjBody::ObjBodyComp(it) => &it.syntax,2008 ObjBody::ObjBodyMemberList(it) => &it.syntax,2009 }2010 }2011}2012impl From<ForSpec> for CompSpec {2013 fn from(node: ForSpec) -> CompSpec {2014 CompSpec::ForSpec(node)2015 }2016}2017impl From<IfSpec> for CompSpec {2018 fn from(node: IfSpec) -> CompSpec {2019 CompSpec::IfSpec(node)2020 }2021}2022impl AstNode for CompSpec {2023 fn can_cast(kind: SyntaxKind) -> bool {2024 match kind {2025 FOR_SPEC | IF_SPEC => true,2026 _ => false,2027 }2028 }2029 fn cast(syntax: SyntaxNode) -> Option<Self> {2030 let res = match syntax.kind() {2031 FOR_SPEC => CompSpec::ForSpec(ForSpec { syntax }),2032 IF_SPEC => CompSpec::IfSpec(IfSpec { syntax }),2033 _ => return None,2034 };2035 Some(res)2036 }2037 fn syntax(&self) -> &SyntaxNode {2038 match self {2039 CompSpec::ForSpec(it) => &it.syntax,2040 CompSpec::IfSpec(it) => &it.syntax,2041 }2042 }2043}2044impl From<ExprBinary> for ExprBase {2045 fn from(node: ExprBinary) -> ExprBase {2046 ExprBase::ExprBinary(node)2047 }2048}2049impl From<ExprUnary> for ExprBase {2050 fn from(node: ExprUnary) -> ExprBase {2051 ExprBase::ExprUnary(node)2052 }2053}2054impl From<ExprObjExtend> for ExprBase {2055 fn from(node: ExprObjExtend) -> ExprBase {2056 ExprBase::ExprObjExtend(node)2057 }2058}2059impl From<ExprParened> for ExprBase {2060 fn from(node: ExprParened) -> ExprBase {2061 ExprBase::ExprParened(node)2062 }2063}2064impl From<ExprString> for ExprBase {2065 fn from(node: ExprString) -> ExprBase {2066 ExprBase::ExprString(node)2067 }2068}2069impl From<ExprNumber> for ExprBase {2070 fn from(node: ExprNumber) -> ExprBase {2071 ExprBase::ExprNumber(node)2072 }2073}2074impl From<ExprLiteral> for ExprBase {2075 fn from(node: ExprLiteral) -> ExprBase {2076 ExprBase::ExprLiteral(node)2077 }2078}2079impl From<ExprArray> for ExprBase {2080 fn from(node: ExprArray) -> ExprBase {2081 ExprBase::ExprArray(node)2082 }2083}2084impl From<ExprObject> for ExprBase {2085 fn from(node: ExprObject) -> ExprBase {2086 ExprBase::ExprObject(node)2087 }2088}2089impl From<ExprArrayComp> for ExprBase {2090 fn from(node: ExprArrayComp) -> ExprBase {2091 ExprBase::ExprArrayComp(node)2092 }2093}2094impl From<ExprImport> for ExprBase {2095 fn from(node: ExprImport) -> ExprBase {2096 ExprBase::ExprImport(node)2097 }2098}2099impl From<ExprVar> for ExprBase {2100 fn from(node: ExprVar) -> ExprBase {2101 ExprBase::ExprVar(node)2102 }2103}2104impl From<ExprIfThenElse> for ExprBase {2105 fn from(node: ExprIfThenElse) -> ExprBase {2106 ExprBase::ExprIfThenElse(node)2107 }2108}2109impl From<ExprFunction> for ExprBase {2110 fn from(node: ExprFunction) -> ExprBase {2111 ExprBase::ExprFunction(node)2112 }2113}2114impl From<ExprError> for ExprBase {2115 fn from(node: ExprError) -> ExprBase {2116 ExprBase::ExprError(node)2117 }2118}2119impl AstNode for ExprBase {2120 fn can_cast(kind: SyntaxKind) -> bool {2121 match kind {2122 EXPR_BINARY | EXPR_UNARY | EXPR_OBJ_EXTEND | EXPR_PARENED | EXPR_STRING2123 | EXPR_NUMBER | EXPR_LITERAL | EXPR_ARRAY | EXPR_OBJECT | EXPR_ARRAY_COMP2124 | EXPR_IMPORT | EXPR_VAR | EXPR_IF_THEN_ELSE | EXPR_FUNCTION | EXPR_ERROR => true,2125 _ => false,2126 }2127 }2128 fn cast(syntax: SyntaxNode) -> Option<Self> {2129 let res = match syntax.kind() {2130 EXPR_BINARY => ExprBase::ExprBinary(ExprBinary { syntax }),2131 EXPR_UNARY => ExprBase::ExprUnary(ExprUnary { syntax }),2132 EXPR_OBJ_EXTEND => ExprBase::ExprObjExtend(ExprObjExtend { syntax }),2133 EXPR_PARENED => ExprBase::ExprParened(ExprParened { syntax }),2134 EXPR_STRING => ExprBase::ExprString(ExprString { syntax }),2135 EXPR_NUMBER => ExprBase::ExprNumber(ExprNumber { syntax }),2136 EXPR_LITERAL => ExprBase::ExprLiteral(ExprLiteral { syntax }),2137 EXPR_ARRAY => ExprBase::ExprArray(ExprArray { syntax }),2138 EXPR_OBJECT => ExprBase::ExprObject(ExprObject { syntax }),2139 EXPR_ARRAY_COMP => ExprBase::ExprArrayComp(ExprArrayComp { syntax }),2140 EXPR_IMPORT => ExprBase::ExprImport(ExprImport { syntax }),2141 EXPR_VAR => ExprBase::ExprVar(ExprVar { syntax }),2142 EXPR_IF_THEN_ELSE => ExprBase::ExprIfThenElse(ExprIfThenElse { syntax }),2143 EXPR_FUNCTION => ExprBase::ExprFunction(ExprFunction { syntax }),2144 EXPR_ERROR => ExprBase::ExprError(ExprError { syntax }),2145 _ => return None,2146 };2147 Some(res)2148 }2149 fn syntax(&self) -> &SyntaxNode {2150 match self {2151 ExprBase::ExprBinary(it) => &it.syntax,2152 ExprBase::ExprUnary(it) => &it.syntax,2153 ExprBase::ExprObjExtend(it) => &it.syntax,2154 ExprBase::ExprParened(it) => &it.syntax,2155 ExprBase::ExprString(it) => &it.syntax,2156 ExprBase::ExprNumber(it) => &it.syntax,2157 ExprBase::ExprLiteral(it) => &it.syntax,2158 ExprBase::ExprArray(it) => &it.syntax,2159 ExprBase::ExprObject(it) => &it.syntax,2160 ExprBase::ExprArrayComp(it) => &it.syntax,2161 ExprBase::ExprImport(it) => &it.syntax,2162 ExprBase::ExprVar(it) => &it.syntax,2163 ExprBase::ExprIfThenElse(it) => &it.syntax,2164 ExprBase::ExprFunction(it) => &it.syntax,2165 ExprBase::ExprError(it) => &it.syntax,2166 }2167 }2168}2169impl From<MemberBindStmt> for MemberComp {2170 fn from(node: MemberBindStmt) -> MemberComp {2171 MemberComp::MemberBindStmt(node)2172 }2173}2174impl From<MemberFieldNormal> for MemberComp {2175 fn from(node: MemberFieldNormal) -> MemberComp {2176 MemberComp::MemberFieldNormal(node)2177 }2178}2179impl From<MemberFieldMethod> for MemberComp {2180 fn from(node: MemberFieldMethod) -> MemberComp {2181 MemberComp::MemberFieldMethod(node)2182 }2183}2184impl AstNode for MemberComp {2185 fn can_cast(kind: SyntaxKind) -> bool {2186 match kind {2187 MEMBER_BIND_STMT | MEMBER_FIELD_NORMAL | MEMBER_FIELD_METHOD => true,2188 _ => false,2189 }2190 }2191 fn cast(syntax: SyntaxNode) -> Option<Self> {2192 let res = match syntax.kind() {2193 MEMBER_BIND_STMT => MemberComp::MemberBindStmt(MemberBindStmt { syntax }),2194 MEMBER_FIELD_NORMAL => MemberComp::MemberFieldNormal(MemberFieldNormal { syntax }),2195 MEMBER_FIELD_METHOD => MemberComp::MemberFieldMethod(MemberFieldMethod { syntax }),2196 _ => return None,2197 };2198 Some(res)2199 }2200 fn syntax(&self) -> &SyntaxNode {2201 match self {2202 MemberComp::MemberBindStmt(it) => &it.syntax,2203 MemberComp::MemberFieldNormal(it) => &it.syntax,2204 MemberComp::MemberFieldMethod(it) => &it.syntax,2205 }2206 }2207}2208impl From<MemberBindStmt> for Member {2209 fn from(node: MemberBindStmt) -> Member {2210 Member::MemberBindStmt(node)2211 }2212}2213impl From<MemberAssertStmt> for Member {2214 fn from(node: MemberAssertStmt) -> Member {2215 Member::MemberAssertStmt(node)2216 }2217}2218impl From<MemberFieldNormal> for Member {2219 fn from(node: MemberFieldNormal) -> Member {2220 Member::MemberFieldNormal(node)2221 }2222}2223impl From<MemberFieldMethod> for Member {2224 fn from(node: MemberFieldMethod) -> Member {2225 Member::MemberFieldMethod(node)2226 }2227}2228impl AstNode for Member {2229 fn can_cast(kind: SyntaxKind) -> bool {2230 match kind {2231 MEMBER_BIND_STMT | MEMBER_ASSERT_STMT | MEMBER_FIELD_NORMAL | MEMBER_FIELD_METHOD => {2232 true2233 }2234 _ => false,2235 }2236 }2237 fn cast(syntax: SyntaxNode) -> Option<Self> {2238 let res = match syntax.kind() {2239 MEMBER_BIND_STMT => Member::MemberBindStmt(MemberBindStmt { syntax }),2240 MEMBER_ASSERT_STMT => Member::MemberAssertStmt(MemberAssertStmt { syntax }),2241 MEMBER_FIELD_NORMAL => Member::MemberFieldNormal(MemberFieldNormal { syntax }),2242 MEMBER_FIELD_METHOD => Member::MemberFieldMethod(MemberFieldMethod { syntax }),2243 _ => return None,2244 };2245 Some(res)2246 }2247 fn syntax(&self) -> &SyntaxNode {2248 match self {2249 Member::MemberBindStmt(it) => &it.syntax,2250 Member::MemberAssertStmt(it) => &it.syntax,2251 Member::MemberFieldNormal(it) => &it.syntax,2252 Member::MemberFieldMethod(it) => &it.syntax,2253 }2254 }2255}2256impl From<FieldNameFixed> for FieldName {2257 fn from(node: FieldNameFixed) -> FieldName {2258 FieldName::FieldNameFixed(node)2259 }2260}2261impl From<FieldNameDynamic> for FieldName {2262 fn from(node: FieldNameDynamic) -> FieldName {2263 FieldName::FieldNameDynamic(node)2264 }2265}2266impl AstNode for FieldName {2267 fn can_cast(kind: SyntaxKind) -> bool {2268 match kind {2269 FIELD_NAME_FIXED | FIELD_NAME_DYNAMIC => true,2270 _ => false,2271 }2272 }2273 fn cast(syntax: SyntaxNode) -> Option<Self> {2274 let res = match syntax.kind() {2275 FIELD_NAME_FIXED => FieldName::FieldNameFixed(FieldNameFixed { syntax }),2276 FIELD_NAME_DYNAMIC => FieldName::FieldNameDynamic(FieldNameDynamic { syntax }),2277 _ => return None,2278 };2279 Some(res)2280 }2281 fn syntax(&self) -> &SyntaxNode {2282 match self {2283 FieldName::FieldNameFixed(it) => &it.syntax,2284 FieldName::FieldNameDynamic(it) => &it.syntax,2285 }2286 }2287}2288impl From<DestructFull> for Destruct {2289 fn from(node: DestructFull) -> Destruct {2290 Destruct::DestructFull(node)2291 }2292}2293impl From<DestructSkip> for Destruct {2294 fn from(node: DestructSkip) -> Destruct {2295 Destruct::DestructSkip(node)2296 }2297}2298impl From<DestructArray> for Destruct {2299 fn from(node: DestructArray) -> Destruct {2300 Destruct::DestructArray(node)2301 }2302}2303impl From<DestructObject> for Destruct {2304 fn from(node: DestructObject) -> Destruct {2305 Destruct::DestructObject(node)2306 }2307}2308impl AstNode for Destruct {2309 fn can_cast(kind: SyntaxKind) -> bool {2310 match kind {2311 DESTRUCT_FULL | DESTRUCT_SKIP | DESTRUCT_ARRAY | DESTRUCT_OBJECT => true,2312 _ => false,2313 }2314 }2315 fn cast(syntax: SyntaxNode) -> Option<Self> {2316 let res = match syntax.kind() {2317 DESTRUCT_FULL => Destruct::DestructFull(DestructFull { syntax }),2318 DESTRUCT_SKIP => Destruct::DestructSkip(DestructSkip { syntax }),2319 DESTRUCT_ARRAY => Destruct::DestructArray(DestructArray { syntax }),2320 DESTRUCT_OBJECT => Destruct::DestructObject(DestructObject { syntax }),2321 _ => return None,2322 };2323 Some(res)2324 }2325 fn syntax(&self) -> &SyntaxNode {2326 match self {2327 Destruct::DestructFull(it) => &it.syntax,2328 Destruct::DestructSkip(it) => &it.syntax,2329 Destruct::DestructArray(it) => &it.syntax,2330 Destruct::DestructObject(it) => &it.syntax,2331 }2332 }2333}2334impl From<DestructArrayElement> for DestructArrayPart {2335 fn from(node: DestructArrayElement) -> DestructArrayPart {2336 DestructArrayPart::DestructArrayElement(node)2337 }2338}2339impl From<DestructRest> for DestructArrayPart {2340 fn from(node: DestructRest) -> DestructArrayPart {2341 DestructArrayPart::DestructRest(node)2342 }2343}2344impl AstNode for DestructArrayPart {2345 fn can_cast(kind: SyntaxKind) -> bool {2346 match kind {2347 DESTRUCT_ARRAY_ELEMENT | DESTRUCT_REST => true,2348 _ => false,2349 }2350 }2351 fn cast(syntax: SyntaxNode) -> Option<Self> {2352 let res = match syntax.kind() {2353 DESTRUCT_ARRAY_ELEMENT => {2354 DestructArrayPart::DestructArrayElement(DestructArrayElement { syntax })2355 }2356 DESTRUCT_REST => DestructArrayPart::DestructRest(DestructRest { syntax }),2357 _ => return None,2358 };2359 Some(res)2360 }2361 fn syntax(&self) -> &SyntaxNode {2362 match self {2363 DestructArrayPart::DestructArrayElement(it) => &it.syntax,2364 DestructArrayPart::DestructRest(it) => &it.syntax,2365 }2366 }2367}2368impl AstToken for BinaryOperator {2369 fn can_cast(kind: SyntaxKind) -> bool {2370 BinaryOperatorKind::can_cast(kind)2371 }2372 fn cast(syntax: SyntaxToken) -> Option<Self> {2373 let kind = BinaryOperatorKind::cast(syntax.kind())?;2374 Some(BinaryOperator { syntax, kind })2375 }2376 fn syntax(&self) -> &SyntaxToken {2377 &self.syntax2378 }2379}2380impl BinaryOperatorKind {2381 fn can_cast(kind: SyntaxKind) -> bool {2382 match kind {2383 OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE2384 | IN_KW | LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | META_OBJECT_APPLY2385 | ERROR_NO_OPERATOR => true,2386 _ => false,2387 }2388 }2389 pub fn cast(kind: SyntaxKind) -> Option<Self> {2390 let res = match kind {2391 OR => Self::Or,2392 NULL_COAELSE => Self::NullCoaelse,2393 AND => Self::And,2394 BIT_OR => Self::BitOr,2395 BIT_XOR => Self::BitXor,2396 BIT_AND => Self::BitAnd,2397 EQ => Self::Eq,2398 NE => Self::Ne,2399 LT => Self::Lt,2400 GT => Self::Gt,2401 LE => Self::Le,2402 GE => Self::Ge,2403 IN_KW => Self::InKw,2404 LHS => Self::Lhs,2405 RHS => Self::Rhs,2406 PLUS => Self::Plus,2407 MINUS => Self::Minus,2408 MUL => Self::Mul,2409 DIV => Self::Div,2410 MODULO => Self::Modulo,2411 META_OBJECT_APPLY => Self::MetaObjectApply,2412 ERROR_NO_OPERATOR => Self::ErrorNoOperator,2413 _ => return None,2414 };2415 Some(res)2416 }2417}2418impl BinaryOperator {2419 pub fn kind(&self) -> BinaryOperatorKind {2420 self.kind2421 }2422}2423impl std::fmt::Display for BinaryOperator {2424 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2425 std::fmt::Display::fmt(self.syntax(), f)2426 }2427}2428impl AstToken for UnaryOperator {2429 fn can_cast(kind: SyntaxKind) -> bool {2430 UnaryOperatorKind::can_cast(kind)2431 }2432 fn cast(syntax: SyntaxToken) -> Option<Self> {2433 let kind = UnaryOperatorKind::cast(syntax.kind())?;2434 Some(UnaryOperator { syntax, kind })2435 }2436 fn syntax(&self) -> &SyntaxToken {2437 &self.syntax2438 }2439}2440impl UnaryOperatorKind {2441 fn can_cast(kind: SyntaxKind) -> bool {2442 match kind {2443 MINUS | NOT | BIT_NOT => true,2444 _ => false,2445 }2446 }2447 pub fn cast(kind: SyntaxKind) -> Option<Self> {2448 let res = match kind {2449 MINUS => Self::Minus,2450 NOT => Self::Not,2451 BIT_NOT => Self::BitNot,2452 _ => return None,2453 };2454 Some(res)2455 }2456}2457impl UnaryOperator {2458 pub fn kind(&self) -> UnaryOperatorKind {2459 self.kind2460 }2461}2462impl std::fmt::Display for UnaryOperator {2463 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2464 std::fmt::Display::fmt(self.syntax(), f)2465 }2466}2467impl AstToken for Literal {2468 fn can_cast(kind: SyntaxKind) -> bool {2469 LiteralKind::can_cast(kind)2470 }2471 fn cast(syntax: SyntaxToken) -> Option<Self> {2472 let kind = LiteralKind::cast(syntax.kind())?;2473 Some(Literal { syntax, kind })2474 }2475 fn syntax(&self) -> &SyntaxToken {2476 &self.syntax2477 }2478}2479impl LiteralKind {2480 fn can_cast(kind: SyntaxKind) -> bool {2481 match kind {2482 NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | DOLLAR | SUPER_KW => true,2483 _ => false,2484 }2485 }2486 pub fn cast(kind: SyntaxKind) -> Option<Self> {2487 let res = match kind {2488 NULL_KW => Self::NullKw,2489 TRUE_KW => Self::TrueKw,2490 FALSE_KW => Self::FalseKw,2491 SELF_KW => Self::SelfKw,2492 DOLLAR => Self::Dollar,2493 SUPER_KW => Self::SuperKw,2494 _ => return None,2495 };2496 Some(res)2497 }2498}2499impl Literal {2500 pub fn kind(&self) -> LiteralKind {2501 self.kind2502 }2503}2504impl std::fmt::Display for Literal {2505 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2506 std::fmt::Display::fmt(self.syntax(), f)2507 }2508}2509impl AstToken for Text {2510 fn can_cast(kind: SyntaxKind) -> bool {2511 TextKind::can_cast(kind)2512 }2513 fn cast(syntax: SyntaxToken) -> Option<Self> {2514 let kind = TextKind::cast(syntax.kind())?;2515 Some(Text { syntax, kind })2516 }2517 fn syntax(&self) -> &SyntaxToken {2518 &self.syntax2519 }2520}2521impl TextKind {2522 fn can_cast(kind: SyntaxKind) -> bool {2523 match kind {2524 STRING_DOUBLE2525 | ERROR_STRING_DOUBLE_UNTERMINATED2526 | STRING_SINGLE2527 | ERROR_STRING_SINGLE_UNTERMINATED2528 | STRING_DOUBLE_VERBATIM2529 | ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED2530 | STRING_SINGLE_VERBATIM2531 | ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED2532 | ERROR_STRING_VERBATIM_MISSING_QUOTES2533 | STRING_BLOCK2534 | ERROR_STRING_BLOCK_UNEXPECTED_END2535 | ERROR_STRING_BLOCK_MISSING_NEW_LINE2536 | ERROR_STRING_BLOCK_MISSING_TERMINATION2537 | ERROR_STRING_BLOCK_MISSING_INDENT => true,2538 _ => false,2539 }2540 }2541 pub fn cast(kind: SyntaxKind) -> Option<Self> {2542 let res = match kind {2543 STRING_DOUBLE => Self::StringDouble,2544 ERROR_STRING_DOUBLE_UNTERMINATED => Self::ErrorStringDoubleUnterminated,2545 STRING_SINGLE => Self::StringSingle,2546 ERROR_STRING_SINGLE_UNTERMINATED => Self::ErrorStringSingleUnterminated,2547 STRING_DOUBLE_VERBATIM => Self::StringDoubleVerbatim,2548 ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED => {2549 Self::ErrorStringDoubleVerbatimUnterminated2550 }2551 STRING_SINGLE_VERBATIM => Self::StringSingleVerbatim,2552 ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED => {2553 Self::ErrorStringSingleVerbatimUnterminated2554 }2555 ERROR_STRING_VERBATIM_MISSING_QUOTES => Self::ErrorStringVerbatimMissingQuotes,2556 STRING_BLOCK => Self::StringBlock,2557 ERROR_STRING_BLOCK_UNEXPECTED_END => Self::ErrorStringBlockUnexpectedEnd,2558 ERROR_STRING_BLOCK_MISSING_NEW_LINE => Self::ErrorStringBlockMissingNewLine,2559 ERROR_STRING_BLOCK_MISSING_TERMINATION => Self::ErrorStringBlockMissingTermination,2560 ERROR_STRING_BLOCK_MISSING_INDENT => Self::ErrorStringBlockMissingIndent,2561 _ => return None,2562 };2563 Some(res)2564 }2565}2566impl Text {2567 pub fn kind(&self) -> TextKind {2568 self.kind2569 }2570}2571impl std::fmt::Display for Text {2572 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2573 std::fmt::Display::fmt(self.syntax(), f)2574 }2575}2576impl AstToken for Number {2577 fn can_cast(kind: SyntaxKind) -> bool {2578 NumberKind::can_cast(kind)2579 }2580 fn cast(syntax: SyntaxToken) -> Option<Self> {2581 let kind = NumberKind::cast(syntax.kind())?;2582 Some(Number { syntax, kind })2583 }2584 fn syntax(&self) -> &SyntaxToken {2585 &self.syntax2586 }2587}2588impl NumberKind {2589 fn can_cast(kind: SyntaxKind) -> bool {2590 match kind {2591 FLOAT2592 | ERROR_FLOAT_JUNK_AFTER_POINT2593 | ERROR_FLOAT_JUNK_AFTER_EXPONENT2594 | ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => true,2595 _ => false,2596 }2597 }2598 pub fn cast(kind: SyntaxKind) -> Option<Self> {2599 let res = match kind {2600 FLOAT => Self::Float,2601 ERROR_FLOAT_JUNK_AFTER_POINT => Self::ErrorFloatJunkAfterPoint,2602 ERROR_FLOAT_JUNK_AFTER_EXPONENT => Self::ErrorFloatJunkAfterExponent,2603 ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => Self::ErrorFloatJunkAfterExponentSign,2604 _ => return None,2605 };2606 Some(res)2607 }2608}2609impl Number {2610 pub fn kind(&self) -> NumberKind {2611 self.kind2612 }2613}2614impl std::fmt::Display for Number {2615 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2616 std::fmt::Display::fmt(self.syntax(), f)2617 }2618}2619impl AstToken for ImportKind {2620 fn can_cast(kind: SyntaxKind) -> bool {2621 ImportKindKind::can_cast(kind)2622 }2623 fn cast(syntax: SyntaxToken) -> Option<Self> {2624 let kind = ImportKindKind::cast(syntax.kind())?;2625 Some(ImportKind { syntax, kind })2626 }2627 fn syntax(&self) -> &SyntaxToken {2628 &self.syntax2629 }2630}2631impl ImportKindKind {2632 fn can_cast(kind: SyntaxKind) -> bool {2633 match kind {2634 IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW => true,2635 _ => false,2636 }2637 }2638 pub fn cast(kind: SyntaxKind) -> Option<Self> {2639 let res = match kind {2640 IMPORTSTR_KW => Self::ImportstrKw,2641 IMPORTBIN_KW => Self::ImportbinKw,2642 IMPORT_KW => Self::ImportKw,2643 _ => return None,2644 };2645 Some(res)2646 }2647}2648impl ImportKind {2649 pub fn kind(&self) -> ImportKindKind {2650 self.kind2651 }2652}2653impl std::fmt::Display for ImportKind {2654 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2655 std::fmt::Display::fmt(self.syntax(), f)2656 }2657}2658impl AstToken for Trivia {2659 fn can_cast(kind: SyntaxKind) -> bool {2660 TriviaKind::can_cast(kind)2661 }2662 fn cast(syntax: SyntaxToken) -> Option<Self> {2663 let kind = TriviaKind::cast(syntax.kind())?;2664 Some(Trivia { syntax, kind })2665 }2666 fn syntax(&self) -> &SyntaxToken {2667 &self.syntax2668 }2669}2670impl TriviaKind {2671 fn can_cast(kind: SyntaxKind) -> bool {2672 match kind {2673 WHITESPACE2674 | MULTI_LINE_COMMENT2675 | ERROR_COMMENT_TOO_SHORT2676 | ERROR_COMMENT_UNTERMINATED2677 | SINGLE_LINE_HASH_COMMENT2678 | SINGLE_LINE_SLASH_COMMENT => true,2679 _ => false,2680 }2681 }2682 pub fn cast(kind: SyntaxKind) -> Option<Self> {2683 let res = match kind {2684 WHITESPACE => Self::Whitespace,2685 MULTI_LINE_COMMENT => Self::MultiLineComment,2686 ERROR_COMMENT_TOO_SHORT => Self::ErrorCommentTooShort,2687 ERROR_COMMENT_UNTERMINATED => Self::ErrorCommentUnterminated,2688 SINGLE_LINE_HASH_COMMENT => Self::SingleLineHashComment,2689 SINGLE_LINE_SLASH_COMMENT => Self::SingleLineSlashComment,2690 _ => return None,2691 };2692 Some(res)2693 }2694}2695impl Trivia {2696 pub fn kind(&self) -> TriviaKind {2697 self.kind2698 }2699}2700impl std::fmt::Display for Trivia {2701 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2702 std::fmt::Display::fmt(self.syntax(), f)2703 }2704}2705impl AstToken for CustomError {2706 fn can_cast(kind: SyntaxKind) -> bool {2707 CustomErrorKind::can_cast(kind)2708 }2709 fn cast(syntax: SyntaxToken) -> Option<Self> {2710 let kind = CustomErrorKind::cast(syntax.kind())?;2711 Some(CustomError { syntax, kind })2712 }2713 fn syntax(&self) -> &SyntaxToken {2714 &self.syntax2715 }2716}2717impl CustomErrorKind {2718 fn can_cast(kind: SyntaxKind) -> bool {2719 match kind {2720 ERROR_MISSING_TOKEN | ERROR_UNEXPECTED_TOKEN | ERROR_CUSTOM => true,2721 _ => false,2722 }2723 }2724 pub fn cast(kind: SyntaxKind) -> Option<Self> {2725 let res = match kind {2726 ERROR_MISSING_TOKEN => Self::ErrorMissingToken,2727 ERROR_UNEXPECTED_TOKEN => Self::ErrorUnexpectedToken,2728 ERROR_CUSTOM => Self::ErrorCustom,2729 _ => return None,2730 };2731 Some(res)2732 }2733}2734impl CustomError {2735 pub fn kind(&self) -> CustomErrorKind {2736 self.kind2737 }2738}2739impl std::fmt::Display for CustomError {2740 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2741 std::fmt::Display::fmt(self.syntax(), f)2742 }2743}2744impl std::fmt::Display for Suffix {2745 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2746 std::fmt::Display::fmt(self.syntax(), f)2747 }2748}2749impl std::fmt::Display for Bind {2750 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2751 std::fmt::Display::fmt(self.syntax(), f)2752 }2753}2754impl std::fmt::Display for Stmt {2755 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2756 std::fmt::Display::fmt(self.syntax(), f)2757 }2758}2759impl std::fmt::Display for ObjBody {2760 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2761 std::fmt::Display::fmt(self.syntax(), f)2762 }2763}2764impl std::fmt::Display for CompSpec {2765 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2766 std::fmt::Display::fmt(self.syntax(), f)2767 }2768}2769impl std::fmt::Display for ExprBase {2770 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2771 std::fmt::Display::fmt(self.syntax(), f)2772 }2773}2774impl std::fmt::Display for MemberComp {2775 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2776 std::fmt::Display::fmt(self.syntax(), f)2777 }2778}2779impl std::fmt::Display for Member {2780 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2781 std::fmt::Display::fmt(self.syntax(), f)2782 }2783}2784impl std::fmt::Display for FieldName {2785 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2786 std::fmt::Display::fmt(self.syntax(), f)2787 }2788}2789impl std::fmt::Display for Destruct {2790 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2791 std::fmt::Display::fmt(self.syntax(), f)2792 }2793}2794impl std::fmt::Display for DestructArrayPart {2795 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2796 std::fmt::Display::fmt(self.syntax(), f)2797 }2798}2799impl std::fmt::Display for SourceFile {2800 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2801 std::fmt::Display::fmt(self.syntax(), f)2802 }2803}2804impl std::fmt::Display for Expr {2805 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2806 std::fmt::Display::fmt(self.syntax(), f)2807 }2808}2809impl std::fmt::Display for SuffixIndex {2810 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2811 std::fmt::Display::fmt(self.syntax(), f)2812 }2813}2814impl std::fmt::Display for Name {2815 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2816 std::fmt::Display::fmt(self.syntax(), f)2817 }2818}2819impl std::fmt::Display for SuffixIndexExpr {2820 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2821 std::fmt::Display::fmt(self.syntax(), f)2822 }2823}2824impl std::fmt::Display for SuffixSlice {2825 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2826 std::fmt::Display::fmt(self.syntax(), f)2827 }2828}2829impl std::fmt::Display for SliceDesc {2830 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2831 std::fmt::Display::fmt(self.syntax(), f)2832 }2833}2834impl std::fmt::Display for SuffixApply {2835 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2836 std::fmt::Display::fmt(self.syntax(), f)2837 }2838}2839impl std::fmt::Display for ArgsDesc {2840 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2841 std::fmt::Display::fmt(self.syntax(), f)2842 }2843}2844impl std::fmt::Display for StmtLocal {2845 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2846 std::fmt::Display::fmt(self.syntax(), f)2847 }2848}2849impl std::fmt::Display for StmtAssert {2850 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2851 std::fmt::Display::fmt(self.syntax(), f)2852 }2853}2854impl std::fmt::Display for Assertion {2855 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2856 std::fmt::Display::fmt(self.syntax(), f)2857 }2858}2859impl std::fmt::Display for ExprBinary {2860 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2861 std::fmt::Display::fmt(self.syntax(), f)2862 }2863}2864impl std::fmt::Display for ExprUnary {2865 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2866 std::fmt::Display::fmt(self.syntax(), f)2867 }2868}2869impl std::fmt::Display for ExprObjExtend {2870 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2871 std::fmt::Display::fmt(self.syntax(), f)2872 }2873}2874impl std::fmt::Display for ExprParened {2875 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2876 std::fmt::Display::fmt(self.syntax(), f)2877 }2878}2879impl std::fmt::Display for ExprLiteral {2880 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2881 std::fmt::Display::fmt(self.syntax(), f)2882 }2883}2884impl std::fmt::Display for ExprString {2885 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2886 std::fmt::Display::fmt(self.syntax(), f)2887 }2888}2889impl std::fmt::Display for ExprNumber {2890 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2891 std::fmt::Display::fmt(self.syntax(), f)2892 }2893}2894impl std::fmt::Display for ExprArray {2895 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2896 std::fmt::Display::fmt(self.syntax(), f)2897 }2898}2899impl std::fmt::Display for ExprObject {2900 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2901 std::fmt::Display::fmt(self.syntax(), f)2902 }2903}2904impl std::fmt::Display for ExprArrayComp {2905 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2906 std::fmt::Display::fmt(self.syntax(), f)2907 }2908}2909impl std::fmt::Display for ExprImport {2910 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2911 std::fmt::Display::fmt(self.syntax(), f)2912 }2913}2914impl std::fmt::Display for ExprVar {2915 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2916 std::fmt::Display::fmt(self.syntax(), f)2917 }2918}2919impl std::fmt::Display for ExprIfThenElse {2920 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2921 std::fmt::Display::fmt(self.syntax(), f)2922 }2923}2924impl std::fmt::Display for TrueExpr {2925 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2926 std::fmt::Display::fmt(self.syntax(), f)2927 }2928}2929impl std::fmt::Display for FalseExpr {2930 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2931 std::fmt::Display::fmt(self.syntax(), f)2932 }2933}2934impl std::fmt::Display for ExprFunction {2935 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2936 std::fmt::Display::fmt(self.syntax(), f)2937 }2938}2939impl std::fmt::Display for ParamsDesc {2940 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2941 std::fmt::Display::fmt(self.syntax(), f)2942 }2943}2944impl std::fmt::Display for ExprError {2945 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2946 std::fmt::Display::fmt(self.syntax(), f)2947 }2948}2949impl std::fmt::Display for SliceDescEnd {2950 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2951 std::fmt::Display::fmt(self.syntax(), f)2952 }2953}2954impl std::fmt::Display for SliceDescStep {2955 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2956 std::fmt::Display::fmt(self.syntax(), f)2957 }2958}2959impl std::fmt::Display for Arg {2960 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2961 std::fmt::Display::fmt(self.syntax(), f)2962 }2963}2964impl std::fmt::Display for ObjBodyComp {2965 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2966 std::fmt::Display::fmt(self.syntax(), f)2967 }2968}2969impl std::fmt::Display for ObjBodyMemberList {2970 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2971 std::fmt::Display::fmt(self.syntax(), f)2972 }2973}2974impl std::fmt::Display for MemberBindStmt {2975 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2976 std::fmt::Display::fmt(self.syntax(), f)2977 }2978}2979impl std::fmt::Display for ObjLocal {2980 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2981 std::fmt::Display::fmt(self.syntax(), f)2982 }2983}2984impl std::fmt::Display for MemberAssertStmt {2985 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2986 std::fmt::Display::fmt(self.syntax(), f)2987 }2988}2989impl std::fmt::Display for MemberFieldNormal {2990 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2991 std::fmt::Display::fmt(self.syntax(), f)2992 }2993}2994impl std::fmt::Display for Visibility {2995 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2996 std::fmt::Display::fmt(self.syntax(), f)2997 }2998}2999impl std::fmt::Display for MemberFieldMethod {3000 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3001 std::fmt::Display::fmt(self.syntax(), f)3002 }3003}3004impl std::fmt::Display for FieldNameFixed {3005 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3006 std::fmt::Display::fmt(self.syntax(), f)3007 }3008}3009impl std::fmt::Display for FieldNameDynamic {3010 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3011 std::fmt::Display::fmt(self.syntax(), f)3012 }3013}3014impl std::fmt::Display for ForSpec {3015 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3016 std::fmt::Display::fmt(self.syntax(), f)3017 }3018}3019impl std::fmt::Display for IfSpec {3020 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3021 std::fmt::Display::fmt(self.syntax(), f)3022 }3023}3024impl std::fmt::Display for BindDestruct {3025 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3026 std::fmt::Display::fmt(self.syntax(), f)3027 }3028}3029impl std::fmt::Display for BindFunction {3030 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3031 std::fmt::Display::fmt(self.syntax(), f)3032 }3033}3034impl std::fmt::Display for Param {3035 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3036 std::fmt::Display::fmt(self.syntax(), f)3037 }3038}3039impl std::fmt::Display for DestructFull {3040 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3041 std::fmt::Display::fmt(self.syntax(), f)3042 }3043}3044impl std::fmt::Display for DestructSkip {3045 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3046 std::fmt::Display::fmt(self.syntax(), f)3047 }3048}3049impl std::fmt::Display for DestructArray {3050 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3051 std::fmt::Display::fmt(self.syntax(), f)3052 }3053}3054impl std::fmt::Display for DestructObject {3055 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3056 std::fmt::Display::fmt(self.syntax(), f)3057 }3058}3059impl std::fmt::Display for DestructObjectField {3060 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3061 std::fmt::Display::fmt(self.syntax(), f)3062 }3063}3064impl std::fmt::Display for DestructRest {3065 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3066 std::fmt::Display::fmt(self.syntax(), f)3067 }3068}3069impl std::fmt::Display for DestructArrayElement {3070 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3071 std::fmt::Display::fmt(self.syntax(), f)3072 }3073}crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
+++ b/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
@@ -44,8 +44,6 @@
L_BRACE,
R_BRACE,
COLON,
- COLONCOLON,
- COLONCOLONCOLON,
SEMI,
DOT,
DOTDOTDOT,
@@ -142,6 +140,7 @@
OBJ_LOCAL,
MEMBER_ASSERT_STMT,
MEMBER_FIELD_NORMAL,
+ VISIBILITY,
MEMBER_FIELD_METHOD,
FIELD_NAME_FIXED,
FIELD_NAME_DYNAMIC,
@@ -174,7 +173,6 @@
TEXT,
NUMBER,
IMPORT_KIND,
- VISIBILITY,
TRIVIA,
CUSTOM_ERROR,
#[doc(hidden)]
@@ -186,11 +184,10 @@
match self {
OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE
| LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | NOT | BIT_NOT | L_BRACK | R_BRACK
- | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | COLONCOLON | COLONCOLONCOLON
- | SEMI | DOT | DOTDOTDOT | COMMA | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW
- | LOCAL_KW | IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW
- | FUNCTION_KW | ERROR_KW | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW
- | SUPER_KW | FOR_KW | ASSERT_KW => true,
+ | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | SEMI | DOT | DOTDOTDOT | COMMA
+ | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW | LOCAL_KW | IMPORTSTR_KW
+ | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW | FUNCTION_KW | ERROR_KW
+ | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | SUPER_KW | FOR_KW | ASSERT_KW => true,
_ => false,
}
}
@@ -198,7 +195,7 @@
match self {
SUFFIX | BIND | STMT | OBJ_BODY | COMP_SPEC | EXPR_BASE | MEMBER_COMP | MEMBER
| FIELD_NAME | DESTRUCT | DESTRUCT_ARRAY_PART | BINARY_OPERATOR | UNARY_OPERATOR
- | LITERAL | TEXT | NUMBER | IMPORT_KIND | VISIBILITY | TRIVIA | CUSTOM_ERROR => true,
+ | LITERAL | TEXT | NUMBER | IMPORT_KIND | TRIVIA | CUSTOM_ERROR => true,
_ => false,
}
}
@@ -211,6 +208,6 @@
}
}
#[macro_export]
-macro_rules ! T { [||] => { $ crate :: SyntaxKind :: OR } ; [??] => { $ crate :: SyntaxKind :: NULL_COAELSE } ; [&&] => { $ crate :: SyntaxKind :: AND } ; [|] => { $ crate :: SyntaxKind :: BIT_OR } ; [^] => { $ crate :: SyntaxKind :: BIT_XOR } ; [&] => { $ crate :: SyntaxKind :: BIT_AND } ; [==] => { $ crate :: SyntaxKind :: EQ } ; [!=] => { $ crate :: SyntaxKind :: NE } ; [<] => { $ crate :: SyntaxKind :: LT } ; [>] => { $ crate :: SyntaxKind :: GT } ; [<=] => { $ crate :: SyntaxKind :: LE } ; [>=] => { $ crate :: SyntaxKind :: GE } ; [<<] => { $ crate :: SyntaxKind :: LHS } ; [>>] => { $ crate :: SyntaxKind :: RHS } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [*] => { $ crate :: SyntaxKind :: MUL } ; [/] => { $ crate :: SyntaxKind :: DIV } ; [%] => { $ crate :: SyntaxKind :: MODULO } ; [!] => { $ crate :: SyntaxKind :: NOT } ; [~] => { $ crate :: SyntaxKind :: BIT_NOT } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_BRACE } ; ['}'] => { $ crate :: SyntaxKind :: R_BRACE } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLONCOLON } ; [:::] => { $ crate :: SyntaxKind :: COLONCOLONCOLON } ; [;] => { $ crate :: SyntaxKind :: SEMI } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [...] => { $ crate :: SyntaxKind :: DOTDOTDOT } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['$'] => { $ crate :: SyntaxKind :: DOLLAR } ; [=] => { $ crate :: SyntaxKind :: ASSIGN } ; [?] => { $ crate :: SyntaxKind :: QUESTION_MARK } ; [tailstrict] => { $ crate :: SyntaxKind :: TAILSTRICT_KW } ; [local] => { $ crate :: SyntaxKind :: LOCAL_KW } ; [importstr] => { $ crate :: SyntaxKind :: IMPORTSTR_KW } ; [importbin] => { $ crate :: SyntaxKind :: IMPORTBIN_KW } ; [import] => { $ crate :: SyntaxKind :: IMPORT_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [then] => { $ crate :: SyntaxKind :: THEN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [function] => { $ crate :: SyntaxKind :: FUNCTION_KW } ; [error] => { $ crate :: SyntaxKind :: ERROR_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [null] => { $ crate :: SyntaxKind :: NULL_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [assert] => { $ crate :: SyntaxKind :: ASSERT_KW } }
+macro_rules ! T { [||] => { $ crate :: SyntaxKind :: OR } ; [??] => { $ crate :: SyntaxKind :: NULL_COAELSE } ; [&&] => { $ crate :: SyntaxKind :: AND } ; [|] => { $ crate :: SyntaxKind :: BIT_OR } ; [^] => { $ crate :: SyntaxKind :: BIT_XOR } ; [&] => { $ crate :: SyntaxKind :: BIT_AND } ; [==] => { $ crate :: SyntaxKind :: EQ } ; [!=] => { $ crate :: SyntaxKind :: NE } ; [<] => { $ crate :: SyntaxKind :: LT } ; [>] => { $ crate :: SyntaxKind :: GT } ; [<=] => { $ crate :: SyntaxKind :: LE } ; [>=] => { $ crate :: SyntaxKind :: GE } ; [<<] => { $ crate :: SyntaxKind :: LHS } ; [>>] => { $ crate :: SyntaxKind :: RHS } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [*] => { $ crate :: SyntaxKind :: MUL } ; [/] => { $ crate :: SyntaxKind :: DIV } ; [%] => { $ crate :: SyntaxKind :: MODULO } ; [!] => { $ crate :: SyntaxKind :: NOT } ; [~] => { $ crate :: SyntaxKind :: BIT_NOT } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_BRACE } ; ['}'] => { $ crate :: SyntaxKind :: R_BRACE } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [;] => { $ crate :: SyntaxKind :: SEMI } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [...] => { $ crate :: SyntaxKind :: DOTDOTDOT } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['$'] => { $ crate :: SyntaxKind :: DOLLAR } ; [=] => { $ crate :: SyntaxKind :: ASSIGN } ; [?] => { $ crate :: SyntaxKind :: QUESTION_MARK } ; [tailstrict] => { $ crate :: SyntaxKind :: TAILSTRICT_KW } ; [local] => { $ crate :: SyntaxKind :: LOCAL_KW } ; [importstr] => { $ crate :: SyntaxKind :: IMPORTSTR_KW } ; [importbin] => { $ crate :: SyntaxKind :: IMPORTBIN_KW } ; [import] => { $ crate :: SyntaxKind :: IMPORT_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [then] => { $ crate :: SyntaxKind :: THEN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [function] => { $ crate :: SyntaxKind :: FUNCTION_KW } ; [error] => { $ crate :: SyntaxKind :: ERROR_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [null] => { $ crate :: SyntaxKind :: NULL_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [assert] => { $ crate :: SyntaxKind :: ASSERT_KW } }
#[allow(unused_imports)]
pub use T;
crates/jrsonnet-rowan-parser/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/lib.rs
+++ b/crates/jrsonnet-rowan-parser/src/lib.rs
@@ -21,11 +21,6 @@
pub use language::*;
pub use token_set::SyntaxKindSet;
-use self::{
- ast::support,
- generated::nodes::{Expr, ExprObjExtend},
-};
-
pub fn parse(input: &str) -> (SourceFile, Vec<LocatedSyntaxError>) {
let lexemes = lex::lex(input);
let kinds = lexemes
@@ -44,15 +39,4 @@
},
parse.errors,
)
-}
-impl ExprObjExtend {
- pub fn lhs_work(&self) -> Option<Expr> {
- support::child(self.syntax())
- }
- pub fn rhs_work(&self) -> Option<Expr> {
- let mut children = support::children(self.syntax());
- // skip lhs
- children.next()?;
- children.next()
- }
}
crates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/parser.rs
+++ b/crates/jrsonnet-rowan-parser/src/parser.rs
@@ -406,17 +406,27 @@
m.complete(p, FIELD_NAME_FIXED);
} else {
m.forget(p);
- // ::: it split because in TS it is being handled as : ::
- p.error_with_recovery_set(TS![; : :: '('].with(T![:::]));
+ // Recover with ::, :::
+ p.error_with_recovery_set(TS![; : '(']);
}
}
fn visibility(p: &mut Parser) {
- // ::: it split because in TS it is being handled as : ::
- if p.at_ts(TS![: ::].with(T![:::])) {
+ let m = p.start();
+ if !p.at_ts(TS![:]) {
+ p.error_with_recovery_set(TS![=]);
+ }
+ p.bump();
+ 'colons: {
+ if !p.at_ts(TS![:]) {
+ break 'colons;
+ }
p.bump();
- } else {
- p.error_with_recovery_set(TS![=]);
+ if !p.at_ts(TS![:]) {
+ break 'colons;
+ }
+ p.bump();
}
+ m.complete(p, VISIBILITY);
}
fn assertion(p: &mut Parser) {
let m = p.start();
@@ -472,17 +482,17 @@
visibility(p);
expr(p);
true
- // ::: it split because in TS it is being handled as : ::
- } else if p.at_ts(TS![: ::].with(T![:::])) && p.nth_at(1, T![function]) {
- visibility(p);
- p.bump_assert(T![function]);
- params_desc(p);
- expr(p);
- true
} else {
visibility(p);
- expr(p);
- false
+ if p.at(T![function]) {
+ p.bump_assert(T![function]);
+ params_desc(p);
+ expr(p);
+ true
+ } else {
+ expr(p);
+ false
+ }
};
elems += 1;
@@ -648,15 +658,14 @@
fn slice_desc_or_index(p: &mut Parser) -> bool {
let m = p.start();
p.bump();
- // TODO: do not treat :, ::, ::: as full tokens?
// Start
- if !p.at(T![:]) && !p.at(T![::]) {
+ if !p.at(T![:]) {
expr(p);
}
if p.at(T![:]) {
p.bump();
// End
- if !p.at(T![']']) {
+ if !p.at_ts(TS![']' :]) {
expr(p).wrap(p, SLICE_DESC_END, true);
}
if p.at(T![:]) {
@@ -665,12 +674,6 @@
if !p.at(T![']']) {
expr(p).wrap(p, SLICE_DESC_STEP, true);
}
- }
- } else if p.at(T![::]) {
- p.bump();
- // End
- if !p.at(T![']']) {
- expr(p).wrap(p, SLICE_DESC_END, true);
}
} else {
// It was not a slice
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec.snap
@@ -11,7 +11,8 @@
FIELD_NAME_FIXED@1..2
NAME@1..2
IDENT@1..2 "a"
- COLON@2..3 ":"
+ VISIBILITY@2..3
+ COLON@2..3 ":"
EXPR@3..4
EXPR_NUMBER@3..4
FLOAT@3..4 "1"
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_comma.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_comma.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_comma.snap
@@ -11,7 +11,8 @@
FIELD_NAME_FIXED@1..2
NAME@1..2
IDENT@1..2 "a"
- COLON@2..3 ":"
+ VISIBILITY@2..3
+ COLON@2..3 ":"
EXPR@3..4
EXPR_NUMBER@3..4
FLOAT@3..4 "1"
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_asserts.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_asserts.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_asserts.snap
@@ -21,7 +21,8 @@
FIELD_NAME_FIXED@11..12
NAME@11..12
IDENT@11..12 "a"
- COLON@12..13 ":"
+ VISIBILITY@12..13
+ COLON@12..13 ":"
WHITESPACE@13..14 " "
EXPR@14..15
EXPR_NUMBER@14..15
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems.snap
@@ -11,7 +11,8 @@
FIELD_NAME_FIXED@1..2
NAME@1..2
IDENT@1..2 "a"
- COLON@2..3 ":"
+ VISIBILITY@2..3
+ COLON@2..3 ":"
EXPR@3..4
EXPR_NUMBER@3..4
FLOAT@3..4 "1"
@@ -49,7 +50,8 @@
FIELD_NAME_FIXED@25..26
NAME@25..26
IDENT@25..26 "b"
- COLON@26..27 ":"
+ VISIBILITY@26..27
+ COLON@26..27 ":"
EXPR@27..28
EXPR_NUMBER@27..28
FLOAT@27..28 "1"
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems_w.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems_w.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems_w.snap
@@ -11,7 +11,8 @@
FIELD_NAME_FIXED@1..2
NAME@1..2
IDENT@1..2 "a"
- COLON@2..3 ":"
+ VISIBILITY@2..3
+ COLON@2..3 ":"
EXPR@3..4
EXPR_NUMBER@3..4
FLOAT@3..4 "1"
@@ -21,7 +22,8 @@
FIELD_NAME_FIXED@6..7
NAME@6..7
IDENT@6..7 "b"
- COLON@7..8 ":"
+ VISIBILITY@7..8
+ COLON@7..8 ":"
EXPR@8..9
EXPR_NUMBER@8..9
FLOAT@8..9 "1"
@@ -60,7 +62,8 @@
FIELD_NAME_FIXED@31..32
NAME@31..32
IDENT@31..32 "c"
- COLON@32..33 ":"
+ VISIBILITY@32..33
+ COLON@32..33 ":"
EXPR@33..34
EXPR_NUMBER@33..34
FLOAT@33..34 "1"
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_method.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_method.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_method.snap
@@ -19,7 +19,8 @@
NAME@5..6
IDENT@5..6 "x"
R_PAREN@6..7 ")"
- COLON@7..8 ":"
+ VISIBILITY@7..8
+ COLON@7..8 ":"
WHITESPACE@8..9 " "
EXPR@9..10
EXPR_VAR@9..10
@@ -31,7 +32,8 @@
FIELD_NAME_FIXED@13..14
NAME@13..14
IDENT@13..14 "a"
- COLON@14..15 ":"
+ VISIBILITY@14..15
+ COLON@14..15 ":"
WHITESPACE@15..16 " "
FUNCTION_KW@16..24 "function"
PARAMS_DESC@24..27
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__visibilities.snapdiffbeforeafterboth--- /dev/null
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__visibilities.snap
@@ -0,0 +1,51 @@
+---
+source: crates/jrsonnet-rowan-parser/src/tests.rs
+expression: "{\n\tnormal: 1,\n\thide:: 2,\n\tunhide::: 3,\n}\n"
+---
+SOURCE_FILE@0..41
+ EXPR@0..40
+ EXPR_OBJECT@0..40
+ OBJ_BODY_MEMBER_LIST@0..40
+ L_BRACE@0..1 "{"
+ WHITESPACE@1..3 "\n\t"
+ MEMBER_FIELD_NORMAL@3..12
+ FIELD_NAME_FIXED@3..9
+ NAME@3..9
+ IDENT@3..9 "normal"
+ VISIBILITY@9..10
+ COLON@9..10 ":"
+ WHITESPACE@10..11 " "
+ EXPR@11..12
+ EXPR_NUMBER@11..12
+ FLOAT@11..12 "1"
+ COMMA@12..13 ","
+ WHITESPACE@13..15 "\n\t"
+ MEMBER_FIELD_NORMAL@15..23
+ FIELD_NAME_FIXED@15..19
+ NAME@15..19
+ IDENT@15..19 "hide"
+ VISIBILITY@19..21
+ COLON@19..20 ":"
+ COLON@20..21 ":"
+ WHITESPACE@21..22 " "
+ EXPR@22..23
+ EXPR_NUMBER@22..23
+ FLOAT@22..23 "2"
+ COMMA@23..24 ","
+ WHITESPACE@24..26 "\n\t"
+ MEMBER_FIELD_NORMAL@26..37
+ FIELD_NAME_FIXED@26..32
+ NAME@26..32
+ IDENT@26..32 "unhide"
+ VISIBILITY@32..35
+ COLON@32..33 ":"
+ COLON@33..34 ":"
+ COLON@34..35 ":"
+ WHITESPACE@35..36 " "
+ EXPR@36..37
+ EXPR_NUMBER@36..37
+ FLOAT@36..37 "3"
+ COMMA@37..38 ","
+ WHITESPACE@38..39 "\n"
+ R_BRACE@39..40 "}"
+ WHITESPACE@40..41 "\n"
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__wrong_field_end.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__wrong_field_end.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__wrong_field_end.snap
@@ -12,7 +12,8 @@
FIELD_NAME_FIXED@3..4
NAME@3..4
IDENT@3..4 "a"
- COLON@4..5 ":"
+ VISIBILITY@4..5
+ COLON@4..5 ":"
WHITESPACE@5..6 " "
EXPR@6..7
EXPR_NUMBER@6..7
@@ -24,7 +25,8 @@
FIELD_NAME_FIXED@10..11
NAME@10..11
IDENT@10..11 "b"
- COLON@11..12 ":"
+ VISIBILITY@11..12
+ COLON@11..12 ":"
WHITESPACE@12..13 " "
EXPR@13..14
EXPR_NUMBER@13..14
crates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/tests.rs
+++ b/crates/jrsonnet-rowan-parser/src/tests.rs
@@ -208,6 +208,14 @@
Trimmed text block
|||
"#
+
+ visibilities => r#"
+ {
+ normal: 1,
+ hide:: 2,
+ unhide::: 3,
+ }
+ "#
);
#[test]
xtask/src/sourcegen/kinds.rsdiffbeforeafterboth--- a/xtask/src/sourcegen/kinds.rs
+++ b/xtask/src/sourcegen/kinds.rs
@@ -240,8 +240,6 @@
"{" => "L_BRACE";
"}" => "R_BRACE";
":" => "COLON";
- "::" => "COLONCOLON";
- ":::" => "COLONCOLONCOLON";
";" => "SEMI";
"." => "DOT";
"..." => "DOTDOTDOT";