Skip to content

Commit 2bc5175

Browse files
committed
refactor(transformer/arrow-functions): rename method (#8481)
Follow-on after #8435. Pure refactor. Rename method to `in_class_property_definition_value`. I think that name is more descriptive than `if_ancestor_of_class_property_definition_value`, since the method does not take an `Ancestor` as parameter.
1 parent 53ef263 commit 2bc5175

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/oxc_transformer/src/common/arrow_function_converter.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> {
270270
let previous = *self.arguments_needs_transform_stack.last();
271271
self.arguments_needs_transform_stack.push(previous || arrow.r#async);
272272

273-
if Self::if_ancestor_of_class_property_definition_value(ctx) {
273+
if Self::in_class_property_definition_value(ctx) {
274274
self.this_var_stack.push(None);
275275
self.super_methods_stack.push(FxIndexMap::default());
276276
}
@@ -285,7 +285,7 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> {
285285
ctx: &mut TraverseCtx<'a>,
286286
) {
287287
if self.is_async_only() {
288-
if Self::if_ancestor_of_class_property_definition_value(ctx) {
288+
if Self::in_class_property_definition_value(ctx) {
289289
let this_var = self.this_var_stack.pop();
290290
let super_methods = self.super_methods_stack.pop();
291291
self.insert_variable_statement_at_the_top_of_statements(
@@ -403,7 +403,7 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> {
403403
// TODO: If the async arrow function without `this` or `super` usage, we can skip this step.
404404
if self.is_async_only()
405405
&& arrow.r#async
406-
&& Self::if_ancestor_of_class_property_definition_value(ctx)
406+
&& Self::in_class_property_definition_value(ctx)
407407
{
408408
// Inside class property definition value, since async arrow function will be
409409
// converted to a generator function by `AsyncToGenerator` plugin, ensure
@@ -681,9 +681,9 @@ impl<'a> ArrowFunctionConverter<'a> {
681681
}
682682
}
683683

684-
/// Check whether the ancestor is an [`Ancestor::PropertyDefinitionValue`],
685-
/// return false if it's reached the statement.
686-
fn if_ancestor_of_class_property_definition_value(ctx: &mut TraverseCtx<'a>) -> bool {
684+
/// Check whether currently in a class property initializer.
685+
/// e.g. `x` in `class C { prop = [foo(x)]; }`
686+
fn in_class_property_definition_value(ctx: &mut TraverseCtx<'a>) -> bool {
687687
for ancestor in ctx.ancestors() {
688688
if ancestor.is_parent_of_statement() {
689689
return false;

0 commit comments

Comments
 (0)