1
1
use oxc_ast:: { ast:: BindingIdentifier , AstKind } ;
2
- use oxc_semantic:: { AstNode , IsGlobalReference , NodeId , SymbolId } ;
2
+ use oxc_semantic:: { IsGlobalReference , Node , NodeId , SymbolId } ;
3
3
use oxc_span:: { GetSpan , Span } ;
4
4
use oxc_syntax:: operator:: { AssignmentOperator , BinaryOperator , LogicalOperator , UnaryOperator } ;
5
5
@@ -181,9 +181,9 @@ impl<'a, 'b> IsConstant<'a, 'b> for SpreadElement<'a> {
181
181
/// Return the innermost `Function` or `ArrowFunctionExpression` Node
182
182
/// enclosing the specified node
183
183
pub fn get_enclosing_function < ' a , ' b > (
184
- node : & ' b AstNode < ' a > ,
184
+ node : & ' b Node < ' a > ,
185
185
ctx : & ' b LintContext < ' a > ,
186
- ) -> Option < & ' b AstNode < ' a > > {
186
+ ) -> Option < & ' b Node < ' a > > {
187
187
let mut current_node = node;
188
188
loop {
189
189
if matches ! ( current_node. kind( ) , AstKind :: Program ( _) ) {
@@ -204,7 +204,7 @@ pub fn is_nth_argument<'a>(call: &CallExpression<'a>, arg: &Argument<'a>, n: usi
204
204
}
205
205
206
206
/// Jump to the outer most of chained parentheses if any
207
- pub fn outermost_paren < ' a , ' b > ( node : & ' b AstNode < ' a > , ctx : & ' b LintContext < ' a > ) -> & ' b AstNode < ' a > {
207
+ pub fn outermost_paren < ' a , ' b > ( node : & ' b Node < ' a > , ctx : & ' b LintContext < ' a > ) -> & ' b Node < ' a > {
208
208
let mut node = node;
209
209
210
210
loop {
@@ -222,20 +222,20 @@ pub fn outermost_paren<'a, 'b>(node: &'b AstNode<'a>, ctx: &'b LintContext<'a>)
222
222
}
223
223
224
224
pub fn outermost_paren_parent < ' a , ' b > (
225
- node : & ' b AstNode < ' a > ,
225
+ node : & ' b Node < ' a > ,
226
226
ctx : & ' b LintContext < ' a > ,
227
- ) -> Option < & ' b AstNode < ' a > > {
227
+ ) -> Option < & ' b Node < ' a > > {
228
228
ctx. nodes ( )
229
229
. iter_parents ( node. id ( ) )
230
230
. skip ( 1 )
231
231
. find ( |parent| !matches ! ( parent. kind( ) , AstKind :: ParenthesizedExpression ( _) ) )
232
232
}
233
233
234
234
pub fn nth_outermost_paren_parent < ' a , ' b > (
235
- node : & ' b AstNode < ' a > ,
235
+ node : & ' b Node < ' a > ,
236
236
ctx : & ' b LintContext < ' a > ,
237
237
n : usize ,
238
- ) -> Option < & ' b AstNode < ' a > > {
238
+ ) -> Option < & ' b Node < ' a > > {
239
239
ctx. nodes ( )
240
240
. iter_parents ( node. id ( ) )
241
241
. skip ( 1 )
@@ -247,7 +247,7 @@ pub fn nth_outermost_paren_parent<'a, 'b>(
247
247
pub fn iter_outer_expressions < ' a , ' ctx > (
248
248
ctx : & ' ctx LintContext < ' a > ,
249
249
node_id : NodeId ,
250
- ) -> impl Iterator < Item = & ' ctx AstNode < ' a > > + ' ctx {
250
+ ) -> impl Iterator < Item = & ' ctx Node < ' a > > + ' ctx {
251
251
ctx. nodes ( ) . iter_parents ( node_id) . skip ( 1 ) . filter ( |parent| {
252
252
!matches ! (
253
253
parent. kind( ) ,
@@ -264,7 +264,7 @@ pub fn iter_outer_expressions<'a, 'ctx>(
264
264
pub fn get_declaration_of_variable < ' a , ' b > (
265
265
ident : & IdentifierReference ,
266
266
ctx : & ' b LintContext < ' a > ,
267
- ) -> Option < & ' b AstNode < ' a > > {
267
+ ) -> Option < & ' b Node < ' a > > {
268
268
let symbol_id = get_symbol_id_of_variable ( ident, ctx) ?;
269
269
let symbol_table = ctx. semantic ( ) . symbols ( ) ;
270
270
Some ( ctx. nodes ( ) . get_node ( symbol_table. get_declaration ( symbol_id) ) )
@@ -391,7 +391,7 @@ pub fn is_global_require_call(call_expr: &CallExpression, ctx: &LintContext) ->
391
391
call_expr. callee . is_global_reference_name ( "require" , ctx. symbols ( ) )
392
392
}
393
393
394
- pub fn is_function_node ( node : & AstNode ) -> bool {
394
+ pub fn is_function_node ( node : & Node ) -> bool {
395
395
match node. kind ( ) {
396
396
AstKind :: Function ( f) if f. is_function_declaration ( ) => true ,
397
397
AstKind :: Function ( f) if f. is_expression ( ) => true ,
@@ -401,7 +401,7 @@ pub fn is_function_node(node: &AstNode) -> bool {
401
401
}
402
402
403
403
pub fn get_function_like_declaration < ' b > (
404
- node : & AstNode < ' b > ,
404
+ node : & Node < ' b > ,
405
405
ctx : & LintContext < ' b > ,
406
406
) -> Option < & ' b BindingIdentifier < ' b > > {
407
407
let parent = outermost_paren_parent ( node, ctx) ?;
0 commit comments