mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(linter/consistent-function-scoping): remove Visit::enter_node usage (#8538)
Use `Visit::visit_*` method instead of `Visit::enter_node` / `leave_node`. A step towards solving #8461, but also may improve performance.
This commit is contained in:
parent
30c0689dfc
commit
8dd0013e72
1 changed files with 8 additions and 13 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
use oxc_ast::{AstKind, Visit};
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
|
use oxc_ast::{visit::walk, AstKind, Visit};
|
||||||
use oxc_diagnostics::OxcDiagnostic;
|
use oxc_diagnostics::OxcDiagnostic;
|
||||||
use oxc_macros::declare_oxc_lint;
|
use oxc_macros::declare_oxc_lint;
|
||||||
use oxc_semantic::ReferenceId;
|
use oxc_semantic::{ReferenceId, ScopeFlags};
|
||||||
use oxc_span::{GetSpan, Span};
|
use oxc_span::{GetSpan, Span};
|
||||||
use rustc_hash::FxHashSet;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast_util::{get_function_like_declaration, nth_outermost_paren_parent, outermost_paren_parent},
|
ast_util::{get_function_like_declaration, nth_outermost_paren_parent, outermost_paren_parent},
|
||||||
|
|
@ -283,17 +284,11 @@ impl<'a> Visit<'a> for ReferencesFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_node(&mut self, kind: AstKind<'a>) {
|
fn visit_function(&mut self, func: &oxc_ast::ast::Function<'a>, flags: ScopeFlags) {
|
||||||
if let AstKind::Function(_) = kind {
|
|
||||||
self.in_function += 1;
|
self.in_function += 1;
|
||||||
}
|
walk::walk_function(self, func, flags);
|
||||||
}
|
|
||||||
|
|
||||||
fn leave_node(&mut self, kind: AstKind<'a>) {
|
|
||||||
if let AstKind::Function(_) = kind {
|
|
||||||
self.in_function -= 1;
|
self.in_function -= 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_parent_scope_iife<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) -> bool {
|
fn is_parent_scope_iife<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) -> bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue