Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into regexpp
Browse files Browse the repository at this point in the history
  • Loading branch information
leaysgur committed Jul 3, 2024
2 parents 362ed78 + b007553 commit c42a3cc
Show file tree
Hide file tree
Showing 67 changed files with 10,430 additions and 7,005 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/oxlint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oxlint"
version = "0.5.1"
version = "0.5.2"
publish = false
authors.workspace = true
description.workspace = true
Expand Down
16 changes: 15 additions & 1 deletion crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub enum Expression<'a> {
ChainExpression(Box<'a, ChainExpression<'a>>) = 16,
ClassExpression(Box<'a, Class<'a>>) = 17,
ConditionalExpression(Box<'a, ConditionalExpression<'a>>) = 18,
#[visit_args(flags = None)]
FunctionExpression(Box<'a, Function<'a>>) = 19,
ImportExpression(Box<'a, ImportExpression<'a>>) = 20,
LogicalExpression(Box<'a, LogicalExpression<'a>>) = 21,
Expand Down Expand Up @@ -250,6 +251,7 @@ pub enum ArrayExpressionElement<'a> {
/// <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#arrays>
Elision(Elision) = 65,
// `Expression` variants added here by `inherit_variants!` macro
// TODO: support for attributes syntax here so we can use `#[visit_as(ExpressionArrayElement)]`
@inherit Expression
}
}
Expand Down Expand Up @@ -967,6 +969,7 @@ pub struct BlockStatement<'a> {
#[cfg_attr(feature = "serialize", serde(untagged))]
pub enum Declaration<'a> {
VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32,
#[visit_args(flags = None)]
FunctionDeclaration(Box<'a, Function<'a>>) = 33,
ClassDeclaration(Box<'a, Class<'a>>) = 34,
UsingDeclaration(Box<'a, UsingDeclaration<'a>>) = 35,
Expand Down Expand Up @@ -1291,6 +1294,7 @@ pub struct TryStatement<'a> {
pub span: Span,
pub block: Box<'a, BlockStatement<'a>>,
pub handler: Option<Box<'a, CatchClause<'a>>>,
#[visit_as(FinallyClause)]
pub finalizer: Option<Box<'a, BlockStatement<'a>>>,
}

Expand Down Expand Up @@ -1340,6 +1344,7 @@ pub struct BindingPattern<'a> {
feature = "serialize",
tsify(type = "(BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern)")
)]
#[span]
pub kind: BindingPatternKind<'a>,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub optional: bool,
Expand Down Expand Up @@ -1432,7 +1437,7 @@ pub struct BindingRestElement<'a> {
#[visited_node]
#[scope(
// TODO: `ScopeFlags::Function` is not correct if this is a `MethodDefinition`
flags(ScopeFlags::Function),
flags(flags.unwrap_or(ScopeFlags::empty()) | ScopeFlags::Function),
strict_if(self.body.as_ref().is_some_and(|body| body.has_use_strict_directive())),
)]
#[derive(Debug)]
Expand Down Expand Up @@ -1586,6 +1591,7 @@ pub struct Class<'a> {
pub decorators: Vec<'a, Decorator<'a>>,
#[scope(enter_before)]
pub id: Option<BindingIdentifier<'a>>,
#[visit_as(ClassHeritage)]
pub super_class: Option<Expression<'a>>,
pub body: Box<'a, ClassBody<'a>>,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
Expand Down Expand Up @@ -1635,6 +1641,12 @@ pub struct MethodDefinition<'a> {
pub span: Span,
pub decorators: Vec<'a, Decorator<'a>>,
pub key: PropertyKey<'a>,
#[visit_args(flags = Some(match self.kind {
MethodDefinitionKind::Get => ScopeFlags::GetAccessor,
MethodDefinitionKind::Set => ScopeFlags::SetAccessor,
MethodDefinitionKind::Constructor => ScopeFlags::Constructor,
MethodDefinitionKind::Method => ScopeFlags::empty(),
}))]
pub value: Box<'a, Function<'a>>, // FunctionExpression
pub kind: MethodDefinitionKind,
pub computed: bool,
Expand Down Expand Up @@ -1946,9 +1958,11 @@ inherit_variants! {
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(untagged))]
pub enum ExportDefaultDeclarationKind<'a> {
#[visit_args(flags = None)]
FunctionDeclaration(Box<'a, Function<'a>>) = 64,
ClassDeclaration(Box<'a, Class<'a>>) = 65,

#[visit(ignore)]
TSInterfaceDeclaration(Box<'a, TSInterfaceDeclaration<'a>>) = 66,

// `Expression` variants added here by `inherit_variants!` macro
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ pub enum TSTypePredicateName<'a> {
#[visited_node]
#[scope(
flags(ScopeFlags::TsModuleBlock),
strict_if(self.body.as_ref().is_some_and(|body| body.is_strict())),
strict_if(self.body.as_ref().is_some_and(TSModuleDeclarationBody::is_strict)),
)]
#[derive(Debug)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,12 @@ impl MethodDefinitionKind {
}
}

impl MethodDefinitionType {
pub fn is_abstract(&self) -> bool {
matches!(self, Self::TSAbstractMethodDefinition)
}
}

impl<'a> PrivateIdentifier<'a> {
pub fn new(span: Span, name: Atom<'a>) -> Self {
Self { span, name }
Expand Down
12 changes: 6 additions & 6 deletions crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub enum AstType {
LabeledStatement,
ThrowStatement,
TryStatement,
FinallyClause,
CatchClause,
CatchParameter,
DebuggerStatement,
Expand All @@ -85,6 +86,7 @@ pub enum AstType {
ArrowFunctionExpression,
YieldExpression,
Class,
ClassHeritage,
ClassBody,
MethodDefinition,
PropertyDefinition,
Expand Down Expand Up @@ -164,8 +166,6 @@ pub enum AstType {
JSXSpreadAttribute,
JSXIdentifier,
JSXText,
FinallyClause,
ClassHeritage,
ExpressionArrayElement,
}

Expand Down Expand Up @@ -237,6 +237,7 @@ pub enum AstKind<'a> {
LabeledStatement(&'a LabeledStatement<'a>),
ThrowStatement(&'a ThrowStatement<'a>),
TryStatement(&'a TryStatement<'a>),
FinallyClause(&'a BlockStatement<'a>),
CatchClause(&'a CatchClause<'a>),
CatchParameter(&'a CatchParameter<'a>),
DebuggerStatement(&'a DebuggerStatement),
Expand All @@ -251,6 +252,7 @@ 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 @@ -330,8 +332,6 @@ pub enum AstKind<'a> {
JSXSpreadAttribute(&'a JSXSpreadAttribute<'a>),
JSXIdentifier(&'a JSXIdentifier<'a>),
JSXText(&'a JSXText<'a>),
FinallyClause(&'a BlockStatement<'a>),
ClassHeritage(&'a Expression<'a>),
ExpressionArrayElement(&'a Expression<'a>),
}

Expand Down Expand Up @@ -404,6 +404,7 @@ impl<'a> GetSpan for AstKind<'a> {
Self::LabeledStatement(it) => it.span(),
Self::ThrowStatement(it) => it.span(),
Self::TryStatement(it) => it.span(),
Self::FinallyClause(it) => it.span(),
Self::CatchClause(it) => it.span(),
Self::CatchParameter(it) => it.span(),
Self::DebuggerStatement(it) => it.span(),
Expand All @@ -418,6 +419,7 @@ 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 @@ -497,8 +499,6 @@ impl<'a> GetSpan for AstKind<'a> {
Self::JSXSpreadAttribute(it) => it.span(),
Self::JSXIdentifier(it) => it.span(),
Self::JSXText(it) => it.span(),
Self::FinallyClause(it) => it.span(),
Self::ClassHeritage(it) => it.span(),
Self::ExpressionArrayElement(it) => it.span(),
}
}
Expand Down
13 changes: 7 additions & 6 deletions crates/oxc_ast/src/generated/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,13 @@ impl GetSpan for DebuggerStatement {
}
}

impl<'a> GetSpan for BindingPattern<'a> {
#[inline]
fn span(&self) -> Span {
self.kind.span()
}
}

impl<'a> GetSpan for BindingPatternKind<'a> {
fn span(&self) -> Span {
match self {
Expand Down Expand Up @@ -2185,9 +2192,3 @@ impl<'a> GetSpan for JSXText<'a> {
self.span
}
}

impl<'a> GetSpan for BindingPattern<'a> {
fn span(&self) -> Span {
self.kind.span()
}
}
Loading

0 comments on commit c42a3cc

Please sign in to comment.