-
-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(isolated_declarations): Remove nested AssignmentPatterns from ins…
…ide parameters
- Loading branch information
MichaelMitchell-at
committed
Jul 7, 2024
1 parent
57d821b
commit c77db8e
Showing
5 changed files
with
57 additions
and
24 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
crates/oxc_isolated_declarations/src/formal_parameter_binding_pattern.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use oxc_ast::{ | ||
ast::BindingPatternKind, visit::walk_mut::walk_binding_pattern_kind, AstBuilder, VisitMut, | ||
}; | ||
|
||
pub struct FormalParameterBindingPattern<'a> { | ||
ast: AstBuilder<'a>, | ||
} | ||
|
||
impl<'a> VisitMut<'a> for FormalParameterBindingPattern<'a> { | ||
fn visit_binding_pattern_kind(&mut self, kind: &mut BindingPatternKind<'a>) { | ||
if let BindingPatternKind::AssignmentPattern(assignment) = kind { | ||
*kind = self.ast.copy(&assignment.left.kind); | ||
} | ||
|
||
walk_binding_pattern_kind(self, kind); | ||
} | ||
} | ||
|
||
impl<'a> FormalParameterBindingPattern<'a> { | ||
pub fn remove_assignments_from_kind(ast: AstBuilder<'a>, kind: &mut BindingPatternKind<'a>) { | ||
let mut visitor = FormalParameterBindingPattern { ast }; | ||
visitor.visit_binding_pattern_kind(kind); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters