1
+ // NB: `#[visited_node]` and `#[scope]` attributes on AST nodes do not do anything to the code in this file.
2
+ // They are purely markers for codegen used in `oxc_traverse`. See docs in that crate.
3
+
1
4
// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]`
2
5
#![ allow( non_snake_case) ]
3
6
@@ -23,8 +26,9 @@ use serde::Serialize;
23
26
#[ cfg( feature = "serialize" ) ]
24
27
use tsify:: Tsify ;
25
28
26
- #[ visited_node(
27
- scope( ScopeFlags :: Top ) ,
29
+ #[ visited_node]
30
+ #[ scope(
31
+ flags( ScopeFlags :: Top ) ,
28
32
strict_if( self . source_type. is_strict( ) || self . directives. iter( ) . any( Directive :: is_use_strict) ) ,
29
33
) ]
30
34
#[ derive( Debug ) ]
@@ -943,7 +947,8 @@ pub struct Hashbang<'a> {
943
947
}
944
948
945
949
/// Block Statement
946
- #[ visited_node( scope( ScopeFlags :: empty( ) ) ) ]
950
+ #[ visited_node]
951
+ #[ scope]
947
952
#[ derive( Debug ) ]
948
953
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
949
954
#[ cfg_attr( feature = "serialize" , serde( tag = "type" ) ) ]
@@ -1099,10 +1104,8 @@ pub struct WhileStatement<'a> {
1099
1104
}
1100
1105
1101
1106
/// For Statement
1102
- #[ visited_node(
1103
- scope( ScopeFlags :: empty( ) ) ,
1104
- scope_if( self . init. as_ref( ) . is_some_and( ForStatementInit :: is_lexical_declaration) ) ,
1105
- ) ]
1107
+ #[ visited_node]
1108
+ #[ scope( if ( self . init. as_ref( ) . is_some_and( ForStatementInit :: is_lexical_declaration) ) ) ]
1106
1109
#[ derive( Debug ) ]
1107
1110
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
1108
1111
#[ cfg_attr( feature = "serialize" , serde( tag = "type" ) ) ]
@@ -1136,7 +1139,8 @@ pub enum ForStatementInit<'a> {
1136
1139
}
1137
1140
1138
1141
/// For-In Statement
1139
- #[ visited_node( scope( ScopeFlags :: empty( ) ) , scope_if( self . left. is_lexical_declaration( ) ) ) ]
1142
+ #[ visited_node]
1143
+ #[ scope( if ( self . left. is_lexical_declaration( ) ) ) ]
1140
1144
#[ derive( Debug ) ]
1141
1145
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
1142
1146
#[ cfg_attr( feature = "serialize" , serde( tag = "type" ) ) ]
@@ -1168,7 +1172,8 @@ pub enum ForStatementLeft<'a> {
1168
1172
}
1169
1173
}
1170
1174
/// For-Of Statement
1171
- #[ visited_node( scope( ScopeFlags :: empty( ) ) , scope_if( self . left. is_lexical_declaration( ) ) ) ]
1175
+ #[ visited_node]
1176
+ #[ scope( if ( self . left. is_lexical_declaration( ) ) ) ]
1172
1177
#[ derive( Debug ) ]
1173
1178
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
1174
1179
#[ cfg_attr( feature = "serialize" , serde( tag = "type" ) ) ]
@@ -1228,7 +1233,8 @@ pub struct WithStatement<'a> {
1228
1233
}
1229
1234
1230
1235
/// Switch Statement
1231
- #[ visited_node( scope( ScopeFlags :: empty( ) ) ) ]
1236
+ #[ visited_node]
1237
+ #[ scope]
1232
1238
#[ derive( Debug ) ]
1233
1239
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
1234
1240
#[ cfg_attr( feature = "serialize" , serde( tag = "type" ) ) ]
@@ -1288,7 +1294,8 @@ pub struct TryStatement<'a> {
1288
1294
pub finalizer : Option < Box < ' a , BlockStatement < ' a > > > ,
1289
1295
}
1290
1296
1291
- #[ visited_node( scope( ScopeFlags :: empty( ) ) , scope_if( self . param. is_some( ) ) ) ]
1297
+ #[ visited_node]
1298
+ #[ scope( if ( self . param. is_some( ) ) ) ]
1292
1299
#[ derive( Debug ) ]
1293
1300
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
1294
1301
#[ cfg_attr( feature = "serialize" , serde( tag = "type" ) ) ]
@@ -1422,9 +1429,10 @@ pub struct BindingRestElement<'a> {
1422
1429
}
1423
1430
1424
1431
/// Function Definitions
1425
- #[ visited_node(
1432
+ #[ visited_node]
1433
+ #[ scope(
1426
1434
// TODO: `ScopeFlags::Function` is not correct if this is a `MethodDefinition`
1427
- scope ( ScopeFlags :: Function ) ,
1435
+ flags ( ScopeFlags :: Function ) ,
1428
1436
strict_if( self . body. as_ref( ) . is_some_and( |body| body. has_use_strict_directive( ) ) ) ,
1429
1437
) ]
1430
1438
#[ derive( Debug ) ]
@@ -1530,8 +1538,9 @@ pub struct FunctionBody<'a> {
1530
1538
}
1531
1539
1532
1540
/// Arrow Function Definitions
1533
- #[ visited_node(
1534
- scope( ScopeFlags :: Function | ScopeFlags :: Arrow ) ,
1541
+ #[ visited_node]
1542
+ #[ scope(
1543
+ flags( ScopeFlags :: Function | ScopeFlags :: Arrow ) ,
1535
1544
strict_if( self . body. has_use_strict_directive( ) ) ,
1536
1545
) ]
1537
1546
#[ derive( Debug ) ]
@@ -1565,7 +1574,8 @@ pub struct YieldExpression<'a> {
1565
1574
}
1566
1575
1567
1576
/// Class Definitions
1568
- #[ visited_node( scope( ScopeFlags :: StrictMode ) ) ]
1577
+ #[ visited_node]
1578
+ #[ scope( flags( ScopeFlags :: StrictMode ) ) ]
1569
1579
#[ derive( Debug ) ]
1570
1580
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
1571
1581
#[ cfg_attr( feature = "serialize" , serde( rename_all = "camelCase" ) ) ]
@@ -1690,7 +1700,8 @@ pub struct PrivateIdentifier<'a> {
1690
1700
pub name : Atom < ' a > ,
1691
1701
}
1692
1702
1693
- #[ visited_node( scope( ScopeFlags :: ClassStaticBlock ) ) ]
1703
+ #[ visited_node]
1704
+ #[ scope( flags( ScopeFlags :: ClassStaticBlock ) ) ]
1694
1705
#[ derive( Debug ) ]
1695
1706
#[ cfg_attr( feature = "serialize" , derive( Serialize , Tsify ) ) ]
1696
1707
#[ cfg_attr( feature = "serialize" , serde( tag = "type" ) ) ]
0 commit comments