Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,6 @@ pub struct Class<'a> {
/// class Foo extends Bar {}
/// // ^^^
/// ```
#[visit(as(ClassHeritage))]
pub super_class: Option<Expression<'a>>,
/// Type parameters passed to super class.
///
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_ast/src/ast_kind_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ impl<'a> AstKind<'a> {
Self::AssignmentTargetWithDefault(_) => "AssignmentTargetWithDefault".into(),
Self::SpreadElement(_) => "SpreadElement".into(),
Self::Elision(_) => "Elision".into(),
Self::ExpressionArrayElement(_) => "ExpressionArrayElement".into(),
Self::BindingRestElement(_) => "BindingRestElement".into(),

Self::Function(x) => format!("Function({})", or_anonymous(x.id.as_ref())).into(),
Expand All @@ -314,7 +313,6 @@ impl<'a> AstKind<'a> {
Self::Class(c) => format!("Class({})", or_anonymous(c.id.as_ref())).into(),
Self::TSClassImplements(_) => "TSClassImplements".into(),
Self::ClassBody(_) => "ClassBody".into(),
Self::ClassHeritage(_) => "ClassHeritage".into(),
Self::StaticBlock(_) => "StaticBlock".into(),
Self::PropertyDefinition(_) => "PropertyDefinition".into(),
Self::MethodDefinition(_) => "MethodDefinition".into(),
Expand Down
24 changes: 0 additions & 24 deletions crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub enum AstType {
ArrowFunctionExpression,
YieldExpression,
Class,
ClassHeritage,
ClassBody,
MethodDefinition,
PropertyDefinition,
Expand Down Expand Up @@ -175,7 +174,6 @@ pub enum AstType {
JSXSpreadAttribute,
JSXIdentifier,
JSXText,
ExpressionArrayElement,
}

/// Untyped AST Node Kind
Expand Down Expand Up @@ -263,7 +261,6 @@ pub enum AstKind<'a> {
ArrowFunctionExpression(&'a ArrowFunctionExpression<'a>),
YieldExpression(&'a YieldExpression<'a>),
Class(&'a Class<'a>),
ClassHeritage(&'a Expression<'a>),
ClassBody(&'a ClassBody<'a>),
MethodDefinition(&'a MethodDefinition<'a>),
PropertyDefinition(&'a PropertyDefinition<'a>),
Expand Down Expand Up @@ -348,7 +345,6 @@ pub enum AstKind<'a> {
JSXSpreadAttribute(&'a JSXSpreadAttribute<'a>),
JSXIdentifier(&'a JSXIdentifier<'a>),
JSXText(&'a JSXText<'a>),
ExpressionArrayElement(&'a Expression<'a>),
}

impl<'a> GetSpan for AstKind<'a> {
Expand Down Expand Up @@ -437,7 +433,6 @@ impl<'a> GetSpan for AstKind<'a> {
Self::ArrowFunctionExpression(it) => it.span(),
Self::YieldExpression(it) => it.span(),
Self::Class(it) => it.span(),
Self::ClassHeritage(it) => it.span(),
Self::ClassBody(it) => it.span(),
Self::MethodDefinition(it) => it.span(),
Self::PropertyDefinition(it) => it.span(),
Expand Down Expand Up @@ -522,7 +517,6 @@ impl<'a> GetSpan for AstKind<'a> {
Self::JSXSpreadAttribute(it) => it.span(),
Self::JSXIdentifier(it) => it.span(),
Self::JSXText(it) => it.span(),
Self::ExpressionArrayElement(it) => it.span(),
}
}
}
Expand Down Expand Up @@ -1266,15 +1260,6 @@ impl<'a> AstKind<'a> {
}
}

#[inline]
pub fn as_class_heritage(&self) -> Option<&'a Expression<'a>> {
if let Self::ClassHeritage(v) = self {
Some(*v)
} else {
None
}
}

#[inline]
pub fn as_class_body(&self) -> Option<&'a ClassBody<'a>> {
if let Self::ClassBody(v) = self {
Expand Down Expand Up @@ -2034,13 +2019,4 @@ impl<'a> AstKind<'a> {
None
}
}

#[inline]
pub fn as_expression_array_element(&self) -> Option<&'a Expression<'a>> {
if let Self::ExpressionArrayElement(v) = self {
Some(*v)
} else {
None
}
}
}
28 changes: 2 additions & 26 deletions crates/oxc_ast/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ pub trait Visit<'a>: Sized {
walk_elision(self, it);
}

#[inline]
fn visit_expression_array_element(&mut self, it: &Expression<'a>) {
walk_expression_array_element(self, it);
}

#[inline]
fn visit_arrow_function_expression(&mut self, it: &ArrowFunctionExpression<'a>) {
walk_arrow_function_expression(self, it);
Expand Down Expand Up @@ -801,11 +796,6 @@ pub trait Visit<'a>: Sized {
walk_class(self, it);
}

#[inline]
fn visit_class_heritage(&mut self, it: &Expression<'a>) {
walk_class_heritage(self, it);
}

#[inline]
fn visit_ts_class_implementses(&mut self, it: &Vec<'a, TSClassImplements<'a>>) {
walk_ts_class_implementses(self, it);
Expand Down Expand Up @@ -1670,7 +1660,7 @@ pub mod walk {
ArrayExpressionElement::SpreadElement(it) => visitor.visit_spread_element(it),
ArrayExpressionElement::Elision(it) => visitor.visit_elision(it),
match_expression!(ArrayExpressionElement) => {
visitor.visit_expression_array_element(it.to_expression())
visitor.visit_expression(it.to_expression())
}
}
visitor.leave_node(kind);
Expand All @@ -1691,13 +1681,6 @@ pub mod walk {
visitor.leave_node(kind);
}

pub fn walk_expression_array_element<'a, V: Visit<'a>>(visitor: &mut V, it: &Expression<'a>) {
let kind = AstKind::ExpressionArrayElement(visitor.alloc(it));
visitor.enter_node(kind);
visitor.visit_expression(it);
visitor.leave_node(kind);
}

#[inline]
pub fn walk_arrow_function_expression<'a, V: Visit<'a>>(
visitor: &mut V,
Expand Down Expand Up @@ -2950,7 +2933,7 @@ pub mod walk {
visitor.visit_ts_type_parameter_declaration(type_parameters);
}
if let Some(super_class) = &it.super_class {
visitor.visit_class_heritage(super_class);
visitor.visit_expression(super_class);
}
if let Some(super_type_parameters) = &it.super_type_parameters {
visitor.visit_ts_type_parameter_instantiation(super_type_parameters);
Expand All @@ -2963,13 +2946,6 @@ pub mod walk {
visitor.leave_node(kind);
}

pub fn walk_class_heritage<'a, V: Visit<'a>>(visitor: &mut V, it: &Expression<'a>) {
let kind = AstKind::ClassHeritage(visitor.alloc(it));
visitor.enter_node(kind);
visitor.visit_expression(it);
visitor.leave_node(kind);
}

#[inline]
pub fn walk_ts_class_implementses<'a, V: Visit<'a>>(
visitor: &mut V,
Expand Down
31 changes: 2 additions & 29 deletions crates/oxc_ast/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ pub trait VisitMut<'a>: Sized {
walk_elision(self, it);
}

#[inline]
fn visit_expression_array_element(&mut self, it: &mut Expression<'a>) {
walk_expression_array_element(self, it);
}

#[inline]
fn visit_arrow_function_expression(&mut self, it: &mut ArrowFunctionExpression<'a>) {
walk_arrow_function_expression(self, it);
Expand Down Expand Up @@ -796,11 +791,6 @@ pub trait VisitMut<'a>: Sized {
walk_class(self, it);
}

#[inline]
fn visit_class_heritage(&mut self, it: &mut Expression<'a>) {
walk_class_heritage(self, it);
}

#[inline]
fn visit_ts_class_implementses(&mut self, it: &mut Vec<'a, TSClassImplements<'a>>) {
walk_ts_class_implementses(self, it);
Expand Down Expand Up @@ -1689,7 +1679,7 @@ pub mod walk_mut {
ArrayExpressionElement::SpreadElement(it) => visitor.visit_spread_element(it),
ArrayExpressionElement::Elision(it) => visitor.visit_elision(it),
match_expression!(ArrayExpressionElement) => {
visitor.visit_expression_array_element(it.to_expression_mut())
visitor.visit_expression(it.to_expression_mut())
}
}
visitor.leave_node(kind);
Expand All @@ -1710,16 +1700,6 @@ pub mod walk_mut {
visitor.leave_node(kind);
}

pub fn walk_expression_array_element<'a, V: VisitMut<'a>>(
visitor: &mut V,
it: &mut Expression<'a>,
) {
let kind = AstType::ExpressionArrayElement;
visitor.enter_node(kind);
visitor.visit_expression(it);
visitor.leave_node(kind);
}

#[inline]
pub fn walk_arrow_function_expression<'a, V: VisitMut<'a>>(
visitor: &mut V,
Expand Down Expand Up @@ -3077,7 +3057,7 @@ pub mod walk_mut {
visitor.visit_ts_type_parameter_declaration(type_parameters);
}
if let Some(super_class) = &mut it.super_class {
visitor.visit_class_heritage(super_class);
visitor.visit_expression(super_class);
}
if let Some(super_type_parameters) = &mut it.super_type_parameters {
visitor.visit_ts_type_parameter_instantiation(super_type_parameters);
Expand All @@ -3090,13 +3070,6 @@ pub mod walk_mut {
visitor.leave_node(kind);
}

pub fn walk_class_heritage<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut Expression<'a>) {
let kind = AstType::ClassHeritage;
visitor.enter_node(kind);
visitor.visit_expression(it);
visitor.leave_node(kind);
}

#[inline]
pub fn walk_ts_class_implementses<'a, V: VisitMut<'a>>(
visitor: &mut V,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl<'s, 'a> Symbol<'s, 'a> {
// e.g. `const x = [function foo() {}]`
// Only considered used if the array containing the symbol is used.
| AstKind::ArrayExpressionElement(_)
| AstKind::ExpressionArrayElement(_)
| AstKind::ArrayExpression(_)
// a ? b : function foo() {}
// Only considered used if the function is the test or the selected branch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ impl<'s, 'a> Symbol<'s, 'a> {
return true;
}
AstKind::VariableDeclaration(_)
| AstKind::ExpressionArrayElement(_)
| AstKind::ArrayExpressionElement(_)
| AstKind::ArrayExpression(_)
| AstKind::ParenthesizedExpression(_)
Expand Down
7 changes: 1 addition & 6 deletions crates/oxc_linter/src/rules/jest/valid_expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,7 @@ fn get_parent_with_ignore<'a, 'b>(
let mut node = node;
loop {
let parent = ctx.nodes().parent_node(node.id())?;
if !matches!(
parent.kind(),
AstKind::Argument(_)
| AstKind::ExpressionArrayElement(_)
| AstKind::ArrayExpressionElement(_)
) {
if !matches!(parent.kind(), AstKind::Argument(_) | AstKind::ArrayExpressionElement(_)) {
// we don't want to report `Promise.all([invalidExpectCall_1, invalidExpectCall_2])` twice.
// so we need mark whether the node is the first item of an array.
// if it not the first item, we ignore it in `find_promise_call_expression_node`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Rule for PreferEventTarget {
};

match parent.kind() {
AstKind::ClassHeritage(_) => {}
AstKind::Class(_) => {}
AstKind::NewExpression(new_expr) => {
let Expression::Identifier(callee_ident) = &new_expr.callee else {
return;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_ts_type_parameter_declaration(type_parameters);
}
if let Some(super_class) = &class.super_class {
self.visit_class_heritage(super_class);
self.visit_expression(super_class);
}
if let Some(super_type_parameters) = &class.super_type_parameters {
self.visit_ts_type_parameter_instantiation(super_type_parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SCOPES
"flags": "ReferenceFlags(Read)",
"id": 0,
"name": "A",
"node_id": 13
"node_id": 12
}
]
},
Expand All @@ -67,7 +67,7 @@ SCOPES
"flags": "ReferenceFlags(Type)",
"id": 1,
"name": "T",
"node_id": 17
"node_id": 16
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SCOPES
"flags": "ReferenceFlags(Read)",
"id": 0,
"name": "A",
"node_id": 7
"node_id": 6
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SCOPES
"flags": "ReferenceFlags(Type)",
"id": 1,
"name": "A",
"node_id": 11
"node_id": 10
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SCOPES
"flags": "ReferenceFlags(Read)",
"id": 0,
"name": "A",
"node_id": 9
"node_id": 8
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SCOPES
"flags": "ReferenceFlags(Read)",
"id": 0,
"name": "A",
"node_id": 7
"node_id": 6
}
]
}
Expand Down
6 changes: 0 additions & 6 deletions tasks/ast_tools/src/generators/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ pub fn blacklist((ident, _): &(Ident, Type)) -> bool {
!BLACK_LIST.contains(&ident.to_string().as_str())
}

pub fn aliased_nodes() -> [(Ident, Type); 1] {
use syn::parse_quote as pq;
[(pq!(ExpressionArrayElement), pq!(Expression<'a>))]
}

pub fn process_types(def: &TypeDef, _: &LateCtx) -> Vec<(Ident, Type)> {
let aliases = match def {
TypeDef::Enum(enum_) => enum_
Expand Down Expand Up @@ -140,7 +135,6 @@ impl Generator for AstKindGenerator {
)
.flat_map(|it| process_types(it, ctx))
.filter(blacklist)
.chain(aliased_nodes())
.collect();

let types: Vec<Variant> =
Expand Down
Loading