git.delta.rocks / jrsonnet / refs/commits / d34410c49dcf

difftreelog

refactor demote ::, ::: from full tokens to multiple colon tokens

zvspltntYaroslav Bolyukin2026-03-22parent: #93f08ca.patch.diff
in: master

21 files changed

modifiedcrates/jrsonnet-formatter/Cargo.tomldiffbeforeafterboth
11hi-doc.workspace = true11hi-doc.workspace = true
12indoc.workspace = true12indoc.workspace = true
13insta.workspace = true13insta.workspace = true
14jrsonnet-lexer = { version = "0.5.0-pre97", path = "../jrsonnet-lexer" }
14jrsonnet-rowan-parser.workspace = true15jrsonnet-rowan-parser.workspace = true
1516
16[lints]17[lints]
modifiedcrates/jrsonnet-formatter/src/lib.rsdiffbeforeafterboth
8 ConditionResolver, ConditionResolverContext, LineNumber, PrintItems, PrintOptions,8 ConditionResolver, ConditionResolverContext, LineNumber, PrintItems, PrintOptions,
9};9};
10use hi_doc::{Formatting, SnippetBuilder};10use hi_doc::{Formatting, SnippetBuilder};
11use jrsonnet_lexer::collect_lexed_str_block;
11use jrsonnet_rowan_parser::{12use jrsonnet_rowan_parser::{
12 collect_lexed_str_block,
13 nodes::{13 nodes::{
14 Arg, ArgsDesc, Assertion, BinaryOperator, Bind, CompSpec, Destruct, DestructArrayPart,14 Arg, ArgsDesc, Assertion, BinaryOperator, Bind, CompSpec, Destruct, DestructArrayPart,
15 DestructRest, Expr, ExprArray, ExprBase, FieldName, ForSpec, IfSpec, ImportKind, Literal,15 DestructRest, Expr, ExprArray, ExprBase, FieldName, ForSpec, IfSpec, ImportKind, Literal,
790 // pi790 // pi
791 // }791 // }
792 Self::ExprObjExtend(ex) => {792 Self::ExprObjExtend(ex) => {
793 p!(out, {ex.lhs_work()} str(" ") {ex.rhs_work()});793 p!(out, {ex.lhs()} str(" ") {ex.rhs()});
794 }794 }
795 Self::ExprParened(p) => {795 Self::ExprParened(p) => {
796 p!(out, str("(") {p.expr()} str(")"));796 p!(out, str("(") {p.expr()} str(")"));
addedcrates/jrsonnet-formatter/src/snapshots/jrsonnet_formatter__tests__snapshots@visibilities.jsonnet.snapdiffbeforeafterboth

no changes

addedcrates/jrsonnet-formatter/src/tests/visibilities.jsonnetdiffbeforeafterboth

no changes

modifiedcrates/jrsonnet-lexer/src/generated/syntax_kinds.rsdiffbeforeafterboth
72 R_BRACE,72 R_BRACE,
73 #[token(":")]73 #[token(":")]
74 COLON,74 COLON,
75 #[token("::")]
76 COLONCOLON,
77 #[token(":::")]
78 COLONCOLONCOLON,
79 #[token(";")]75 #[token(";")]
80 SEMI,76 SEMI,
81 #[token(".")]77 #[token(".")]
188 match self {184 match self {
189 OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE185 OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE
190 | LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | NOT | BIT_NOT | L_BRACK | R_BRACK186 | LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | NOT | BIT_NOT | L_BRACK | R_BRACK
191 | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | COLONCOLON | COLONCOLONCOLON187 | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | SEMI | DOT | DOTDOTDOT | COMMA
192 | SEMI | DOT | DOTDOTDOT | COMMA | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW188 | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW | LOCAL_KW | IMPORTSTR_KW
193 | LOCAL_KW | IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW189 | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW | FUNCTION_KW | ERROR_KW
194 | FUNCTION_KW | ERROR_KW | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW190 | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | SUPER_KW | FOR_KW | ASSERT_KW => true,
195 | SUPER_KW | FOR_KW | ASSERT_KW => true,
196 _ => false,191 _ => false,
197 }192 }
198 }193 }
205 }200 }
206}201}
207#[macro_export]202#[macro_export]
208macro_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 } }203macro_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 } }
209#[allow(unused_imports)]204#[allow(unused_imports)]
210pub use T;205pub use T;
211206
modifiedcrates/jrsonnet-lexer/src/lib.rsdiffbeforeafterboth
5#[derive(Clone, Copy, Debug)]5#[derive(Clone, Copy, Debug)]
6pub struct Span(pub u32, pub u32);6pub struct Span(pub u32, pub u32);
77
8pub use generated::syntax_kinds::SyntaxKind;
8pub use lex::{Lexeme, Lexer};9pub use lex::{Lexeme, Lexer};
10pub use string_block::{collect_lexed_str_block, CollectStrBlock};
911
modifiedcrates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth
44 UnaryOperator44 UnaryOperator
45 rhs:Expr45 rhs:Expr
46ExprObjExtend =46ExprObjExtend =
47 Expr47 lhs:Expr
48 Expr48 rhs:Expr
49ExprParened =49ExprParened =
50 '('50 '('
51 Expr51 Expr
209| FieldNameDynamic209| FieldNameDynamic
210210
211Visibility =211Visibility =
212 ':::'212 ':' v1:':'? v2:':'?
213| '::'
214| ':'
215213
216Literal =214Literal =
217 'null'215 'null'
modifiedcrates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth
228 pub(crate) syntax: SyntaxNode,228 pub(crate) syntax: SyntaxNode,
229}229}
230impl ExprObjExtend {230impl ExprObjExtend {
231 pub fn expr(&self) -> Option<Expr> {231 pub fn lhs(&self) -> Option<Expr> {
232 support::children(&self.syntax).next()232 support::children(&self.syntax).next()
233 }233 }
234 pub fn rhs(&self) -> Option<Expr> {
235 support::children(&self.syntax).nth(1usize)
236 }
234}237}
235238
236#[derive(Debug, Clone, PartialEq, Eq, Hash)]239#[derive(Debug, Clone, PartialEq, Eq, Hash)]
562 support::token(&self.syntax, T![+])565 support::token(&self.syntax, T![+])
563 }566 }
564 pub fn visibility(&self) -> Option<Visibility> {567 pub fn visibility(&self) -> Option<Visibility> {
565 support::token_child(&self.syntax)568 support::children(&self.syntax).next()
566 }569 }
567 pub fn expr(&self) -> Option<Expr> {570 pub fn expr(&self) -> Option<Expr> {
568 support::children(&self.syntax).next()571 support::children(&self.syntax).next()
569 }572 }
570}573}
574
575#[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}
571584
572#[derive(Debug, Clone, PartialEq, Eq, Hash)]585#[derive(Debug, Clone, PartialEq, Eq, Hash)]
573pub struct MemberFieldMethod {586pub struct MemberFieldMethod {
581 support::children(&self.syntax).next()594 support::children(&self.syntax).next()
582 }595 }
583 pub fn visibility(&self) -> Option<Visibility> {596 pub fn visibility(&self) -> Option<Visibility> {
584 support::token_child(&self.syntax)597 support::children(&self.syntax).next()
585 }598 }
586 pub fn expr(&self) -> Option<Expr> {599 pub fn expr(&self) -> Option<Expr> {
587 support::children(&self.syntax).next()600 support::children(&self.syntax).next()
1001 ImportKw,1014 ImportKw,
1002}1015}
1003
1004#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1005pub struct Visibility {
1006 syntax: SyntaxToken,
1007 kind: VisibilityKind,
1008}
1009
1010#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1011pub enum VisibilityKind {
1012 Coloncoloncolon,
1013 Coloncolon,
1014 Colon,
1015}
10161016
1017#[derive(Debug, Clone, PartialEq, Eq, Hash)]1017#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1018pub struct Trivia {1018pub struct Trivia {
1627 &self.syntax1627 &self.syntax
1628 }1628 }
1629}1629}
1630impl AstNode for Visibility {
1631 fn can_cast(kind: SyntaxKind) -> bool {
1632 kind == VISIBILITY
1633 }
1634 fn cast(syntax: SyntaxNode) -> Option<Self> {
1635 if Self::can_cast(syntax.kind()) {
1636 Some(Self { syntax })
1637 } else {
1638 None
1639 }
1640 }
1641 fn syntax(&self) -> &SyntaxNode {
1642 &self.syntax
1643 }
1644}
1630impl AstNode for MemberFieldMethod {1645impl AstNode for MemberFieldMethod {
1631 fn can_cast(kind: SyntaxKind) -> bool {1646 fn can_cast(kind: SyntaxKind) -> bool {
1632 kind == MEMBER_FIELD_METHOD1647 kind == MEMBER_FIELD_METHOD
2640 std::fmt::Display::fmt(self.syntax(), f)2655 std::fmt::Display::fmt(self.syntax(), f)
2641 }2656 }
2642}2657}
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.syntax
2653 }
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.kind
2675 }
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 {2658impl AstToken for Trivia {
2683 fn can_cast(kind: SyntaxKind) -> bool {2659 fn can_cast(kind: SyntaxKind) -> bool {
2684 TriviaKind::can_cast(kind)2660 TriviaKind::can_cast(kind)
3015 std::fmt::Display::fmt(self.syntax(), f)2991 std::fmt::Display::fmt(self.syntax(), f)
3016 }2992 }
3017}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}
3018impl std::fmt::Display for MemberFieldMethod {2999impl std::fmt::Display for MemberFieldMethod {
3019 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3000 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3020 std::fmt::Display::fmt(self.syntax(), f)3001 std::fmt::Display::fmt(self.syntax(), f)
modifiedcrates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rsdiffbeforeafterboth
44 L_BRACE,44 L_BRACE,
45 R_BRACE,45 R_BRACE,
46 COLON,46 COLON,
47 COLONCOLON,
48 COLONCOLONCOLON,
49 SEMI,47 SEMI,
50 DOT,48 DOT,
51 DOTDOTDOT,49 DOTDOTDOT,
142 OBJ_LOCAL,140 OBJ_LOCAL,
143 MEMBER_ASSERT_STMT,141 MEMBER_ASSERT_STMT,
144 MEMBER_FIELD_NORMAL,142 MEMBER_FIELD_NORMAL,
143 VISIBILITY,
145 MEMBER_FIELD_METHOD,144 MEMBER_FIELD_METHOD,
146 FIELD_NAME_FIXED,145 FIELD_NAME_FIXED,
147 FIELD_NAME_DYNAMIC,146 FIELD_NAME_DYNAMIC,
174 TEXT,173 TEXT,
175 NUMBER,174 NUMBER,
176 IMPORT_KIND,175 IMPORT_KIND,
177 VISIBILITY,
178 TRIVIA,176 TRIVIA,
179 CUSTOM_ERROR,177 CUSTOM_ERROR,
180 #[doc(hidden)]178 #[doc(hidden)]
186 match self {184 match self {
187 OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE185 OR | NULL_COAELSE | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE
188 | LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | NOT | BIT_NOT | L_BRACK | R_BRACK186 | LHS | RHS | PLUS | MINUS | MUL | DIV | MODULO | NOT | BIT_NOT | L_BRACK | R_BRACK
189 | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | COLONCOLON | COLONCOLONCOLON187 | L_PAREN | R_PAREN | L_BRACE | R_BRACE | COLON | SEMI | DOT | DOTDOTDOT | COMMA
190 | SEMI | DOT | DOTDOTDOT | COMMA | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW188 | DOLLAR | ASSIGN | QUESTION_MARK | TAILSTRICT_KW | LOCAL_KW | IMPORTSTR_KW
191 | LOCAL_KW | IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW189 | IMPORTBIN_KW | IMPORT_KW | IF_KW | THEN_KW | ELSE_KW | FUNCTION_KW | ERROR_KW
192 | FUNCTION_KW | ERROR_KW | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW190 | IN_KW | NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | SUPER_KW | FOR_KW | ASSERT_KW => true,
193 | SUPER_KW | FOR_KW | ASSERT_KW => true,
194 _ => false,191 _ => false,
195 }192 }
196 }193 }
197 pub fn is_enum(self) -> bool {194 pub fn is_enum(self) -> bool {
198 match self {195 match self {
199 SUFFIX | BIND | STMT | OBJ_BODY | COMP_SPEC | EXPR_BASE | MEMBER_COMP | MEMBER196 SUFFIX | BIND | STMT | OBJ_BODY | COMP_SPEC | EXPR_BASE | MEMBER_COMP | MEMBER
200 | FIELD_NAME | DESTRUCT | DESTRUCT_ARRAY_PART | BINARY_OPERATOR | UNARY_OPERATOR197 | FIELD_NAME | DESTRUCT | DESTRUCT_ARRAY_PART | BINARY_OPERATOR | UNARY_OPERATOR
201 | LITERAL | TEXT | NUMBER | IMPORT_KIND | VISIBILITY | TRIVIA | CUSTOM_ERROR => true,198 | LITERAL | TEXT | NUMBER | IMPORT_KIND | TRIVIA | CUSTOM_ERROR => true,
202 _ => false,199 _ => false,
203 }200 }
204 }201 }
211 }208 }
212}209}
213#[macro_export]210#[macro_export]
214macro_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 } }211macro_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 } }
215#[allow(unused_imports)]212#[allow(unused_imports)]
216pub use T;213pub use T;
217214
modifiedcrates/jrsonnet-rowan-parser/src/lib.rsdiffbeforeafterboth
21pub use language::*;21pub use language::*;
22pub use token_set::SyntaxKindSet;22pub use token_set::SyntaxKindSet;
23
24use self::{
25 ast::support,
26 generated::nodes::{Expr, ExprObjExtend},
27};
2823
29pub fn parse(input: &str) -> (SourceFile, Vec<LocatedSyntaxError>) {24pub fn parse(input: &str) -> (SourceFile, Vec<LocatedSyntaxError>) {
30 let lexemes = lex::lex(input);25 let lexemes = lex::lex(input);
45 parse.errors,40 parse.errors,
46 )41 )
47}42}
48impl ExprObjExtend {
49 pub fn lhs_work(&self) -> Option<Expr> {
50 support::child(self.syntax())
51 }
52 pub fn rhs_work(&self) -> Option<Expr> {
53 let mut children = support::children(self.syntax());
54 // skip lhs
55 children.next()?;
56 children.next()
57 }
58}
5943
modifiedcrates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth
406 m.complete(p, FIELD_NAME_FIXED);406 m.complete(p, FIELD_NAME_FIXED);
407 } else {407 } else {
408 m.forget(p);408 m.forget(p);
409 // ::: it split because in TS it is being handled as : ::409 // Recover with ::, :::
410 p.error_with_recovery_set(TS![; : :: '('].with(T![:::]));410 p.error_with_recovery_set(TS![; : '(']);
411 }411 }
412}412}
413fn visibility(p: &mut Parser) {413fn visibility(p: &mut Parser) {
414 // ::: it split because in TS it is being handled as : ::414 let m = p.start();
415 if !p.at_ts(TS![:]) {
416 p.error_with_recovery_set(TS![=]);
417 }
418 p.bump();
419 'colons: {
415 if p.at_ts(TS![: ::].with(T![:::])) {420 if !p.at_ts(TS![:]) {
421 break 'colons;
422 }
416 p.bump();423 p.bump();
417 } else {
418 p.error_with_recovery_set(TS![=]);424 if !p.at_ts(TS![:]) {
419 }425 break 'colons;
426 }
427 p.bump();
428 }
429 m.complete(p, VISIBILITY);
420}430}
421fn assertion(p: &mut Parser) {431fn assertion(p: &mut Parser) {
422 let m = p.start();432 let m = p.start();
472 visibility(p);482 visibility(p);
473 expr(p);483 expr(p);
474 true484 true
475 // ::: it split because in TS it is being handled as : ::
476 } else if p.at_ts(TS![: ::].with(T![:::])) && p.nth_at(1, T![function]) {485 } else {
477 visibility(p);486 visibility(p);
487 if p.at(T![function]) {
478 p.bump_assert(T![function]);488 p.bump_assert(T![function]);
479 params_desc(p);489 params_desc(p);
480 expr(p);490 expr(p);
481 true491 true
482 } else {492 } else {
483 visibility(p);
484 expr(p);493 expr(p);
485 false494 false
486 };495 }
496 };
487 elems += 1;497 elems += 1;
488498
489 if params {499 if params {
648fn slice_desc_or_index(p: &mut Parser) -> bool {658fn slice_desc_or_index(p: &mut Parser) -> bool {
649 let m = p.start();659 let m = p.start();
650 p.bump();660 p.bump();
651 // TODO: do not treat :, ::, ::: as full tokens?
652 // Start661 // Start
653 if !p.at(T![:]) && !p.at(T![::]) {662 if !p.at(T![:]) {
654 expr(p);663 expr(p);
655 }664 }
656 if p.at(T![:]) {665 if p.at(T![:]) {
657 p.bump();666 p.bump();
658 // End667 // End
659 if !p.at(T![']']) {668 if !p.at_ts(TS![']' :]) {
660 expr(p).wrap(p, SLICE_DESC_END, true);669 expr(p).wrap(p, SLICE_DESC_END, true);
661 }670 }
662 if p.at(T![:]) {671 if p.at(T![:]) {
666 expr(p).wrap(p, SLICE_DESC_STEP, true);675 expr(p).wrap(p, SLICE_DESC_STEP, true);
667 }676 }
668 }677 }
669 } else if p.at(T![::]) {678 } else {
670 p.bump();
671 // End
672 if !p.at(T![']']) {
673 expr(p).wrap(p, SLICE_DESC_END, true);
674 }
675 } else {
676 // It was not a slice679 // It was not a slice
677 p.expect(T![']']);680 p.expect(T![']']);
678 m.forget(p);681 m.forget(p);
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec.snapdiffbeforeafterboth
11 FIELD_NAME_FIXED@1..211 FIELD_NAME_FIXED@1..2
12 NAME@1..212 NAME@1..2
13 IDENT@1..2 "a"13 IDENT@1..2 "a"
14 COLON@2..3 ":"14 VISIBILITY@2..3
15 COLON@2..3 ":"
15 EXPR@3..416 EXPR@3..4
16 EXPR_NUMBER@3..417 EXPR_NUMBER@3..4
17 FLOAT@3..4 "1"18 FLOAT@3..4 "1"
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_comma.snapdiffbeforeafterboth
11 FIELD_NAME_FIXED@1..211 FIELD_NAME_FIXED@1..2
12 NAME@1..212 NAME@1..2
13 IDENT@1..2 "a"13 IDENT@1..2 "a"
14 COLON@2..3 ":"14 VISIBILITY@2..3
15 COLON@2..3 ":"
15 EXPR@3..416 EXPR@3..4
16 EXPR_NUMBER@3..417 EXPR_NUMBER@3..4
17 FLOAT@3..4 "1"18 FLOAT@3..4 "1"
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_asserts.snapdiffbeforeafterboth
21 FIELD_NAME_FIXED@11..1221 FIELD_NAME_FIXED@11..12
22 NAME@11..1222 NAME@11..12
23 IDENT@11..12 "a"23 IDENT@11..12 "a"
24 COLON@12..13 ":"24 VISIBILITY@12..13
25 COLON@12..13 ":"
25 WHITESPACE@13..14 " "26 WHITESPACE@13..14 " "
26 EXPR@14..1527 EXPR@14..15
27 EXPR_NUMBER@14..1528 EXPR_NUMBER@14..15
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems.snapdiffbeforeafterboth
11 FIELD_NAME_FIXED@1..211 FIELD_NAME_FIXED@1..2
12 NAME@1..212 NAME@1..2
13 IDENT@1..2 "a"13 IDENT@1..2 "a"
14 COLON@2..3 ":"14 VISIBILITY@2..3
15 COLON@2..3 ":"
15 EXPR@3..416 EXPR@3..4
16 EXPR_NUMBER@3..417 EXPR_NUMBER@3..4
17 FLOAT@3..4 "1"18 FLOAT@3..4 "1"
49 FIELD_NAME_FIXED@25..2650 FIELD_NAME_FIXED@25..26
50 NAME@25..2651 NAME@25..26
51 IDENT@25..26 "b"52 IDENT@25..26 "b"
52 COLON@26..27 ":"53 VISIBILITY@26..27
54 COLON@26..27 ":"
53 EXPR@27..2855 EXPR@27..28
54 EXPR_NUMBER@27..2856 EXPR_NUMBER@27..28
55 FLOAT@27..28 "1"57 FLOAT@27..28 "1"
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_compspec_incompatible_with_multiple_elems_w.snapdiffbeforeafterboth
11 FIELD_NAME_FIXED@1..211 FIELD_NAME_FIXED@1..2
12 NAME@1..212 NAME@1..2
13 IDENT@1..2 "a"13 IDENT@1..2 "a"
14 COLON@2..3 ":"14 VISIBILITY@2..3
15 COLON@2..3 ":"
15 EXPR@3..416 EXPR@3..4
16 EXPR_NUMBER@3..417 EXPR_NUMBER@3..4
17 FLOAT@3..4 "1"18 FLOAT@3..4 "1"
21 FIELD_NAME_FIXED@6..722 FIELD_NAME_FIXED@6..7
22 NAME@6..723 NAME@6..7
23 IDENT@6..7 "b"24 IDENT@6..7 "b"
24 COLON@7..8 ":"25 VISIBILITY@7..8
26 COLON@7..8 ":"
25 EXPR@8..927 EXPR@8..9
26 EXPR_NUMBER@8..928 EXPR_NUMBER@8..9
27 FLOAT@8..9 "1"29 FLOAT@8..9 "1"
60 FIELD_NAME_FIXED@31..3262 FIELD_NAME_FIXED@31..32
61 NAME@31..3263 NAME@31..32
62 IDENT@31..32 "c"64 IDENT@31..32 "c"
63 COLON@32..33 ":"65 VISIBILITY@32..33
66 COLON@32..33 ":"
64 EXPR@33..3467 EXPR@33..34
65 EXPR_NUMBER@33..3468 EXPR_NUMBER@33..34
66 FLOAT@33..34 "1"69 FLOAT@33..34 "1"
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__obj_method.snapdiffbeforeafterboth
19 NAME@5..619 NAME@5..6
20 IDENT@5..6 "x"20 IDENT@5..6 "x"
21 R_PAREN@6..7 ")"21 R_PAREN@6..7 ")"
22 COLON@7..8 ":"22 VISIBILITY@7..8
23 COLON@7..8 ":"
23 WHITESPACE@8..9 " "24 WHITESPACE@8..9 " "
24 EXPR@9..1025 EXPR@9..10
25 EXPR_VAR@9..1026 EXPR_VAR@9..10
31 FIELD_NAME_FIXED@13..1432 FIELD_NAME_FIXED@13..14
32 NAME@13..1433 NAME@13..14
33 IDENT@13..14 "a"34 IDENT@13..14 "a"
34 COLON@14..15 ":"35 VISIBILITY@14..15
36 COLON@14..15 ":"
35 WHITESPACE@15..16 " "37 WHITESPACE@15..16 " "
36 FUNCTION_KW@16..24 "function"38 FUNCTION_KW@16..24 "function"
37 PARAMS_DESC@24..2739 PARAMS_DESC@24..27
addedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__visibilities.snapdiffbeforeafterboth

no changes

modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__wrong_field_end.snapdiffbeforeafterboth
12 FIELD_NAME_FIXED@3..412 FIELD_NAME_FIXED@3..4
13 NAME@3..413 NAME@3..4
14 IDENT@3..4 "a"14 IDENT@3..4 "a"
15 COLON@4..5 ":"15 VISIBILITY@4..5
16 COLON@4..5 ":"
16 WHITESPACE@5..6 " "17 WHITESPACE@5..6 " "
17 EXPR@6..718 EXPR@6..7
18 EXPR_NUMBER@6..719 EXPR_NUMBER@6..7
24 FIELD_NAME_FIXED@10..1125 FIELD_NAME_FIXED@10..11
25 NAME@10..1126 NAME@10..11
26 IDENT@10..11 "b"27 IDENT@10..11 "b"
27 COLON@11..12 ":"28 VISIBILITY@11..12
29 COLON@11..12 ":"
28 WHITESPACE@12..13 " "30 WHITESPACE@12..13 " "
29 EXPR@13..1431 EXPR@13..14
30 EXPR_NUMBER@13..1432 EXPR_NUMBER@13..14
modifiedcrates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth
209 |||209 |||
210 "#210 "#
211
212 visibilities => r#"
213 {
214 normal: 1,
215 hide:: 2,
216 unhide::: 3,
217 }
218 "#
211);219);
212220
213#[test]221#[test]
modifiedxtask/src/sourcegen/kinds.rsdiffbeforeafterboth
240 "{" => "L_BRACE";240 "{" => "L_BRACE";
241 "}" => "R_BRACE";241 "}" => "R_BRACE";
242 ":" => "COLON";242 ":" => "COLON";
243 "::" => "COLONCOLON";
244 ":::" => "COLONCOLONCOLON";
245 ";" => "SEMI";243 ";" => "SEMI";
246 "." => "DOT";244 "." => "DOT";
247 "..." => "DOTDOTDOT";245 "..." => "DOTDOTDOT";