Skip to content

Commit 4c246fb

Browse files
authored
feat(ast): Add override field in AccessorProperty (oxc-project#10415)
Fixes oxc-project#10414
1 parent 9a1323f commit 4c246fb

File tree

14 files changed

+57
-9
lines changed

14 files changed

+57
-9
lines changed

crates/oxc_ast/src/ast/js.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2300,7 +2300,7 @@ pub enum AccessorPropertyType {
23002300
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
23012301
#[rustfmt::skip]
23022302
#[estree(
2303-
add_fields(declare = TsFalse, optional = TsFalse, r#override = TsFalse, readonly = TsFalse),
2303+
add_fields(declare = TsFalse, optional = TsFalse, readonly = TsFalse),
23042304
field_order(
23052305
r#type, span, key, value, computed, r#static, decorators, definite, type_annotation,
23062306
accessibility, optional, r#override, readonly, declare)
@@ -2321,6 +2321,9 @@ pub struct AccessorProperty<'a> {
23212321
pub computed: bool,
23222322
/// Property was declared with a `static` modifier
23232323
pub r#static: bool,
2324+
/// Property was declared with a `override` modifier
2325+
#[ts]
2326+
pub r#override: bool,
23242327
/// Property has a `!` after its key.
23252328
#[ts]
23262329
pub definite: bool,

crates/oxc_ast/src/generated/assert_layouts.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,8 @@ const _: () = {
656656
assert!(offset_of!(AccessorProperty, value) == 64);
657657
assert!(offset_of!(AccessorProperty, computed) == 80);
658658
assert!(offset_of!(AccessorProperty, r#static) == 81);
659-
assert!(offset_of!(AccessorProperty, definite) == 82);
659+
assert!(offset_of!(AccessorProperty, r#override) == 82);
660+
assert!(offset_of!(AccessorProperty, definite) == 83);
660661
assert!(offset_of!(AccessorProperty, type_annotation) == 88);
661662
assert!(offset_of!(AccessorProperty, accessibility) == 96);
662663

@@ -2051,7 +2052,8 @@ const _: () = {
20512052
assert!(offset_of!(AccessorProperty, value) == 36);
20522053
assert!(offset_of!(AccessorProperty, computed) == 44);
20532054
assert!(offset_of!(AccessorProperty, r#static) == 45);
2054-
assert!(offset_of!(AccessorProperty, definite) == 46);
2055+
assert!(offset_of!(AccessorProperty, r#override) == 46);
2056+
assert!(offset_of!(AccessorProperty, definite) == 47);
20552057
assert!(offset_of!(AccessorProperty, type_annotation) == 48);
20562058
assert!(offset_of!(AccessorProperty, accessibility) == 52);
20572059

crates/oxc_ast/src/generated/ast_builder.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6693,6 +6693,7 @@ impl<'a> AstBuilder<'a> {
66936693
/// * `value`: Initialized value in the declaration, if present.
66946694
/// * `computed`: Property was declared with a computed key
66956695
/// * `static`: Property was declared with a `static` modifier
6696+
/// * `override`: Property was declared with a `override` modifier
66966697
/// * `definite`: Property has a `!` after its key.
66976698
/// * `type_annotation`: Type annotation on the property.
66986699
/// * `accessibility`: Accessibility modifier.
@@ -6706,6 +6707,7 @@ impl<'a> AstBuilder<'a> {
67066707
value: Option<Expression<'a>>,
67076708
computed: bool,
67086709
r#static: bool,
6710+
r#override: bool,
67096711
definite: bool,
67106712
type_annotation: T1,
67116713
accessibility: Option<TSAccessibility>,
@@ -6721,6 +6723,7 @@ impl<'a> AstBuilder<'a> {
67216723
value,
67226724
computed,
67236725
r#static,
6726+
r#override,
67246727
definite,
67256728
type_annotation,
67266729
accessibility,
@@ -7250,6 +7253,7 @@ impl<'a> AstBuilder<'a> {
72507253
/// * `value`: Initialized value in the declaration, if present.
72517254
/// * `computed`: Property was declared with a computed key
72527255
/// * `static`: Property was declared with a `static` modifier
7256+
/// * `override`: Property was declared with a `override` modifier
72537257
/// * `definite`: Property has a `!` after its key.
72547258
/// * `type_annotation`: Type annotation on the property.
72557259
/// * `accessibility`: Accessibility modifier.
@@ -7263,6 +7267,7 @@ impl<'a> AstBuilder<'a> {
72637267
value: Option<Expression<'a>>,
72647268
computed: bool,
72657269
r#static: bool,
7270+
r#override: bool,
72667271
definite: bool,
72677272
type_annotation: T1,
72687273
accessibility: Option<TSAccessibility>,
@@ -7278,6 +7283,7 @@ impl<'a> AstBuilder<'a> {
72787283
value,
72797284
computed,
72807285
r#static,
7286+
r#override,
72817287
definite,
72827288
type_annotation: type_annotation.into_in(self.allocator),
72837289
accessibility,
@@ -7297,6 +7303,7 @@ impl<'a> AstBuilder<'a> {
72977303
/// * `value`: Initialized value in the declaration, if present.
72987304
/// * `computed`: Property was declared with a computed key
72997305
/// * `static`: Property was declared with a `static` modifier
7306+
/// * `override`: Property was declared with a `override` modifier
73007307
/// * `definite`: Property has a `!` after its key.
73017308
/// * `type_annotation`: Type annotation on the property.
73027309
/// * `accessibility`: Accessibility modifier.
@@ -7310,6 +7317,7 @@ impl<'a> AstBuilder<'a> {
73107317
value: Option<Expression<'a>>,
73117318
computed: bool,
73127319
r#static: bool,
7320+
r#override: bool,
73137321
definite: bool,
73147322
type_annotation: T1,
73157323
accessibility: Option<TSAccessibility>,
@@ -7326,6 +7334,7 @@ impl<'a> AstBuilder<'a> {
73267334
value,
73277335
computed,
73287336
r#static,
7337+
r#override,
73297338
definite,
73307339
type_annotation,
73317340
accessibility,

crates/oxc_ast/src/generated/derive_clone_in.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,6 +4072,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for AccessorProperty<'_> {
40724072
value: CloneIn::clone_in(&self.value, allocator),
40734073
computed: CloneIn::clone_in(&self.computed, allocator),
40744074
r#static: CloneIn::clone_in(&self.r#static, allocator),
4075+
r#override: CloneIn::clone_in(&self.r#override, allocator),
40754076
definite: CloneIn::clone_in(&self.definite, allocator),
40764077
type_annotation: CloneIn::clone_in(&self.type_annotation, allocator),
40774078
accessibility: CloneIn::clone_in(&self.accessibility, allocator),
@@ -4087,6 +4088,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for AccessorProperty<'_> {
40874088
value: CloneIn::clone_in_with_semantic_ids(&self.value, allocator),
40884089
computed: CloneIn::clone_in_with_semantic_ids(&self.computed, allocator),
40894090
r#static: CloneIn::clone_in_with_semantic_ids(&self.r#static, allocator),
4091+
r#override: CloneIn::clone_in_with_semantic_ids(&self.r#override, allocator),
40904092
definite: CloneIn::clone_in_with_semantic_ids(&self.definite, allocator),
40914093
type_annotation: CloneIn::clone_in_with_semantic_ids(&self.type_annotation, allocator),
40924094
accessibility: CloneIn::clone_in_with_semantic_ids(&self.accessibility, allocator),

crates/oxc_ast/src/generated/derive_content_eq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ impl ContentEq for AccessorProperty<'_> {
12521252
&& ContentEq::content_eq(&self.value, &other.value)
12531253
&& ContentEq::content_eq(&self.computed, &other.computed)
12541254
&& ContentEq::content_eq(&self.r#static, &other.r#static)
1255+
&& ContentEq::content_eq(&self.r#override, &other.r#override)
12551256
&& ContentEq::content_eq(&self.definite, &other.definite)
12561257
&& ContentEq::content_eq(&self.type_annotation, &other.type_annotation)
12571258
&& ContentEq::content_eq(&self.accessibility, &other.accessibility)

crates/oxc_ast/src/generated/derive_dummy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ impl<'a> Dummy<'a> for AccessorProperty<'a> {
13451345
value: Dummy::dummy(allocator),
13461346
computed: Dummy::dummy(allocator),
13471347
r#static: Dummy::dummy(allocator),
1348+
r#override: Dummy::dummy(allocator),
13481349
definite: Dummy::dummy(allocator),
13491350
type_annotation: Dummy::dummy(allocator),
13501351
accessibility: Dummy::dummy(allocator),

crates/oxc_ast/src/generated/derive_estree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ impl ESTree for AccessorProperty<'_> {
16311631
state.serialize_ts_field("typeAnnotation", &self.type_annotation);
16321632
state.serialize_ts_field("accessibility", &self.accessibility);
16331633
state.serialize_ts_field("optional", &crate::serialize::TsFalse(self));
1634-
state.serialize_ts_field("override", &crate::serialize::TsFalse(self));
1634+
state.serialize_ts_field("override", &self.r#override);
16351635
state.serialize_ts_field("readonly", &crate::serialize::TsFalse(self));
16361636
state.serialize_ts_field("declare", &crate::serialize::TsFalse(self));
16371637
state.end();

crates/oxc_codegen/src/gen.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,11 @@ impl Gen for AccessorProperty<'_> {
27822782
p.print_str("static");
27832783
p.print_soft_space();
27842784
}
2785+
if self.r#override {
2786+
p.print_space_before_identifier();
2787+
p.print_str("override");
2788+
p.print_soft_space();
2789+
}
27852790
p.print_space_before_identifier();
27862791
p.print_str("accessor");
27872792
if self.computed {

crates/oxc_isolated_declarations/src/class.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ impl<'a> IsolatedDeclarations<'a> {
515515
None,
516516
property.computed,
517517
property.r#static,
518+
property.r#override,
518519
property.definite,
519520
type_annotation,
520521
property.accessibility,

crates/oxc_parser/src/js/class.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ impl<'a> ParserImpl<'a> {
295295
computed,
296296
r#static,
297297
r#abstract,
298+
r#override,
298299
definite,
299300
accessibility,
300301
)
@@ -498,6 +499,7 @@ impl<'a> ParserImpl<'a> {
498499
computed: bool,
499500
r#static: bool,
500501
r#abstract: bool,
502+
r#override: bool,
501503
definite: bool,
502504
accessibility: Option<TSAccessibility>,
503505
) -> Result<ClassElement<'a>> {
@@ -519,6 +521,7 @@ impl<'a> ParserImpl<'a> {
519521
value,
520522
computed,
521523
r#static,
524+
r#override,
522525
definite,
523526
type_annotation,
524527
accessibility,

0 commit comments

Comments
 (0)