From 1fca27cbcf83a4a0630410c4b5fd3987af290bd9 Mon Sep 17 00:00:00 2001 From: Andrii Rodionov Date: Mon, 16 Dec 2024 14:58:31 +0100 Subject: [PATCH] Change type to prevent class cast exception (#171) * Change type to prevent class cast exception * updated after rebase --------- Co-authored-by: Andrii Rodionov --- openrewrite/src/javascript/remote/receiver.ts | 2 +- openrewrite/src/javascript/tree/tree.ts | 12 ++--- .../test/javascript/parser/arrow.test.ts | 9 ++++ .../javascript/remote/JavaScriptReceiver.java | 48 ++++++++----------- .../javascript/remote/JavaScriptSender.java | 12 +++-- .../remote/JavaScriptValidator.java | 10 +++- .../org/openrewrite/javascript/tree/JS.java | 10 ++-- 7 files changed, 55 insertions(+), 48 deletions(-) diff --git a/openrewrite/src/javascript/remote/receiver.ts b/openrewrite/src/javascript/remote/receiver.ts index 3a57947c..9cb8183a 100644 --- a/openrewrite/src/javascript/remote/receiver.ts +++ b/openrewrite/src/javascript/remote/receiver.ts @@ -1553,7 +1553,7 @@ class Factory implements ReceiverFactory { ctx.receiveNodes(null, ctx.receiveTree)!, ctx.receiveNodes(null, ctx.receiveTree)!, ctx.receiveNode(null, ctx.receiveTree), - ctx.receiveNode>(null, receiveContainer)!, + ctx.receiveNode>(null, receiveContainer)!, ctx.receiveNode>(null, receiveLeftPaddedTree) ); } diff --git a/openrewrite/src/javascript/tree/tree.ts b/openrewrite/src/javascript/tree/tree.ts index 35a9f423..7322b8b8 100644 --- a/openrewrite/src/javascript/tree/tree.ts +++ b/openrewrite/src/javascript/tree/tree.ts @@ -1964,7 +1964,7 @@ export namespace MappedType { @LstType("org.openrewrite.javascript.tree.JS$ObjectBindingDeclarations") export class ObjectBindingDeclarations extends JSMixin(Object) implements Expression, TypedTree { - public constructor(id: UUID, prefix: Space, markers: Markers, leadingAnnotations: Java.Annotation[], modifiers: Java.Modifier[], typeExpression: TypeTree | null, bindings: JContainer, initializer: JLeftPadded | null) { + public constructor(id: UUID, prefix: Space, markers: Markers, leadingAnnotations: Java.Annotation[], modifiers: Java.Modifier[], typeExpression: TypeTree | null, bindings: JContainer, initializer: JLeftPadded | null) { super(); this._id = id; this._prefix = prefix; @@ -2036,13 +2036,13 @@ export class ObjectBindingDeclarations extends JSMixin(Object) implements Expres return typeExpression === this._typeExpression ? this : new ObjectBindingDeclarations(this._id, this._prefix, this._markers, this._leadingAnnotations, this._modifiers, typeExpression, this._bindings, this._initializer); } - private readonly _bindings: JContainer; + private readonly _bindings: JContainer; - public get bindings(): BindingElement[] { + public get bindings(): J[] { return this._bindings.elements; } - public withBindings(bindings: BindingElement[]): ObjectBindingDeclarations { + public withBindings(bindings: J[]): ObjectBindingDeclarations { return this.padding.withBindings(JContainer.withElements(this._bindings, bindings)); } @@ -2071,10 +2071,10 @@ export class ObjectBindingDeclarations extends JSMixin(Object) implements Expres get padding() { const t = this; return new class { - public get bindings(): JContainer { + public get bindings(): JContainer { return t._bindings; } - public withBindings(bindings: JContainer): ObjectBindingDeclarations { + public withBindings(bindings: JContainer): ObjectBindingDeclarations { return t._bindings === bindings ? t : new ObjectBindingDeclarations(t._id, t._prefix, t._markers, t._leadingAnnotations, t._modifiers, t._typeExpression, bindings, t._initializer); } public get initializer(): JLeftPadded | null { diff --git a/openrewrite/test/javascript/parser/arrow.test.ts b/openrewrite/test/javascript/parser/arrow.test.ts index c2e6a89d..b4ce0112 100644 --- a/openrewrite/test/javascript/parser/arrow.test.ts +++ b/openrewrite/test/javascript/parser/arrow.test.ts @@ -182,4 +182,13 @@ describe('arrow mapping', () => { ); }); + test('arrow function with empty object binding', () => { + rewriteRun( + //language=typescript + typeScript(` + ({/*a*/}) => ({/*b*/}) + `) + ); + }); + }); diff --git a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java index 075a8ef9..7d9e946c 100644 --- a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java +++ b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java @@ -875,7 +875,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDeclarat classDeclaration = classDeclaration.withPrefix(ctx.receiveNonNullNode(classDeclaration.getPrefix(), JavaScriptReceiver::receiveSpace)); classDeclaration = classDeclaration.withMarkers(ctx.receiveNonNullNode(classDeclaration.getMarkers(), ctx::receiveMarkers)); classDeclaration = classDeclaration.withLeadingAnnotations(ctx.receiveNonNullNodes(classDeclaration.getLeadingAnnotations(), ctx::receiveTree)); - classDeclaration = classDeclaration.withModifiers(ctx.receiveNonNullNodes(classDeclaration.getModifiers(), JavaScriptReceiver::receiveModifier)); + classDeclaration = classDeclaration.withModifiers(ctx.receiveNonNullNodes(classDeclaration.getModifiers(), ctx::receiveTree)); classDeclaration = classDeclaration.getPadding().withKind(ctx.receiveNonNullNode(classDeclaration.getPadding().getKind(), JavaScriptReceiver::receiveClassDeclarationKind)); classDeclaration = classDeclaration.withName(ctx.receiveNonNullNode(classDeclaration.getName(), ctx::receiveTree)); classDeclaration = classDeclaration.getPadding().withTypeParameters(ctx.receiveNode(classDeclaration.getPadding().getTypeParameters(), JavaScriptReceiver::receiveContainer)); @@ -1116,7 +1116,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration methodDecl methodDeclaration = methodDeclaration.withPrefix(ctx.receiveNonNullNode(methodDeclaration.getPrefix(), JavaScriptReceiver::receiveSpace)); methodDeclaration = methodDeclaration.withMarkers(ctx.receiveNonNullNode(methodDeclaration.getMarkers(), ctx::receiveMarkers)); methodDeclaration = methodDeclaration.withLeadingAnnotations(ctx.receiveNonNullNodes(methodDeclaration.getLeadingAnnotations(), ctx::receiveTree)); - methodDeclaration = methodDeclaration.withModifiers(ctx.receiveNonNullNodes(methodDeclaration.getModifiers(), JavaScriptReceiver::receiveModifier)); + methodDeclaration = methodDeclaration.withModifiers(ctx.receiveNonNullNodes(methodDeclaration.getModifiers(), ctx::receiveTree)); methodDeclaration = methodDeclaration.getAnnotations().withTypeParameters(ctx.receiveNode(methodDeclaration.getAnnotations().getTypeParameters(), JavaScriptReceiver::receiveMethodTypeParameters)); methodDeclaration = methodDeclaration.withReturnTypeExpression(ctx.receiveNode(methodDeclaration.getReturnTypeExpression(), ctx::receiveTree)); methodDeclaration = methodDeclaration.getAnnotations().withName(ctx.receiveNonNullNode(methodDeclaration.getAnnotations().getName(), JavaScriptReceiver::receiveMethodIdentifierWithAnnotations)); @@ -1141,6 +1141,17 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation methodInvocat return methodInvocation; } + @Override + public J.Modifier visitModifier(J.Modifier modifier, ReceiverContext ctx) { + modifier = modifier.withId(ctx.receiveNonNullValue(modifier.getId(), UUID.class)); + modifier = modifier.withPrefix(ctx.receiveNonNullNode(modifier.getPrefix(), JavaScriptReceiver::receiveSpace)); + modifier = modifier.withMarkers(ctx.receiveNonNullNode(modifier.getMarkers(), ctx::receiveMarkers)); + modifier = modifier.withKeyword(ctx.receiveValue(modifier.getKeyword(), String.class)); + modifier = modifier.withType(ctx.receiveNonNullValue(modifier.getType(), J.Modifier.Type.class)); + modifier = modifier.withAnnotations(ctx.receiveNonNullNodes(modifier.getAnnotations(), ctx::receiveTree)); + return modifier; + } + @Override public J.MultiCatch visitMultiCatch(J.MultiCatch multiCatch, ReceiverContext ctx) { multiCatch = multiCatch.withId(ctx.receiveNonNullValue(multiCatch.getId(), UUID.class)); @@ -1351,7 +1362,7 @@ public J.TypeParameter visitTypeParameter(J.TypeParameter typeParameter, Receive typeParameter = typeParameter.withPrefix(ctx.receiveNonNullNode(typeParameter.getPrefix(), JavaScriptReceiver::receiveSpace)); typeParameter = typeParameter.withMarkers(ctx.receiveNonNullNode(typeParameter.getMarkers(), ctx::receiveMarkers)); typeParameter = typeParameter.withAnnotations(ctx.receiveNonNullNodes(typeParameter.getAnnotations(), ctx::receiveTree)); - typeParameter = typeParameter.withModifiers(ctx.receiveNonNullNodes(typeParameter.getModifiers(), JavaScriptReceiver::receiveModifier)); + typeParameter = typeParameter.withModifiers(ctx.receiveNonNullNodes(typeParameter.getModifiers(), ctx::receiveTree)); typeParameter = typeParameter.withName(ctx.receiveNonNullNode(typeParameter.getName(), ctx::receiveTree)); typeParameter = typeParameter.getPadding().withBounds(ctx.receiveNode(typeParameter.getPadding().getBounds(), JavaScriptReceiver::receiveContainer)); return typeParameter; @@ -1374,7 +1385,7 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations v variableDeclarations = variableDeclarations.withPrefix(ctx.receiveNonNullNode(variableDeclarations.getPrefix(), JavaScriptReceiver::receiveSpace)); variableDeclarations = variableDeclarations.withMarkers(ctx.receiveNonNullNode(variableDeclarations.getMarkers(), ctx::receiveMarkers)); variableDeclarations = variableDeclarations.withLeadingAnnotations(ctx.receiveNonNullNodes(variableDeclarations.getLeadingAnnotations(), ctx::receiveTree)); - variableDeclarations = variableDeclarations.withModifiers(ctx.receiveNonNullNodes(variableDeclarations.getModifiers(), JavaScriptReceiver::receiveModifier)); + variableDeclarations = variableDeclarations.withModifiers(ctx.receiveNonNullNodes(variableDeclarations.getModifiers(), ctx::receiveTree)); variableDeclarations = variableDeclarations.withTypeExpression(ctx.receiveNode(variableDeclarations.getTypeExpression(), ctx::receiveTree)); variableDeclarations = variableDeclarations.withVarargs(ctx.receiveNode(variableDeclarations.getVarargs(), JavaScriptReceiver::receiveSpace)); variableDeclarations = variableDeclarations.withDimensionsBeforeName(ctx.receiveNonNullNodes(variableDeclarations.getDimensionsBeforeName(), leftPaddedNodeReceiver(org.openrewrite.java.tree.Space.class))); @@ -2388,7 +2399,7 @@ private static J.ClassDeclaration createJClassDeclaration(ReceiverContext ctx) { ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveSpace), ctx.receiveNonNullNode(null, ctx::receiveMarkers), ctx.receiveNonNullNodes(null, ctx::receiveTree), - ctx.receiveNonNullNodes(null, JavaScriptReceiver::receiveModifier), + ctx.receiveNonNullNodes(null, ctx::receiveTree), ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveClassDeclarationKind), ctx.receiveNonNullNode(null, ctx::receiveTree), ctx.receiveNode(null, JavaScriptReceiver::receiveContainer), @@ -2649,7 +2660,7 @@ private static J.MethodDeclaration createJMethodDeclaration(ReceiverContext ctx) ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveSpace), ctx.receiveNonNullNode(null, ctx::receiveMarkers), ctx.receiveNonNullNodes(null, ctx::receiveTree), - ctx.receiveNonNullNodes(null, JavaScriptReceiver::receiveModifier), + ctx.receiveNonNullNodes(null, ctx::receiveTree), ctx.receiveNode(null, JavaScriptReceiver::receiveMethodTypeParameters), ctx.receiveNode(null, ctx::receiveTree), ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveMethodIdentifierWithAnnotations), @@ -2895,7 +2906,7 @@ private static J.TypeParameter createJTypeParameter(ReceiverContext ctx) { ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveSpace), ctx.receiveNonNullNode(null, ctx::receiveMarkers), ctx.receiveNonNullNodes(null, ctx::receiveTree), - ctx.receiveNonNullNodes(null, JavaScriptReceiver::receiveModifier), + ctx.receiveNonNullNodes(null, ctx::receiveTree), ctx.receiveNonNullNode(null, ctx::receiveTree), ctx.receiveNode(null, JavaScriptReceiver::receiveContainer) ); @@ -2928,7 +2939,7 @@ private static J.VariableDeclarations createJVariableDeclarations(ReceiverContex ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveSpace), ctx.receiveNonNullNode(null, ctx::receiveMarkers), ctx.receiveNonNullNodes(null, ctx::receiveTree), - ctx.receiveNonNullNodes(null, JavaScriptReceiver::receiveModifier), + ctx.receiveNonNullNodes(null, ctx::receiveTree), ctx.receiveNode(null, ctx::receiveTree), ctx.receiveNode(null, JavaScriptReceiver::receiveSpace), ctx.receiveNonNullNodes(null, leftPaddedNodeReceiver(org.openrewrite.java.tree.Space.class)), @@ -3049,27 +3060,6 @@ private static J.MethodDeclaration.IdentifierWithAnnotations receiveMethodIdenti return identifierWithAnnotations; } - private static J.Modifier receiveModifier(J.@Nullable Modifier modifier, @Nullable Class type, ReceiverContext ctx) { - if (modifier != null) { - modifier = modifier.withId(ctx.receiveNonNullValue(modifier.getId(), UUID.class)); - modifier = modifier.withPrefix(ctx.receiveNonNullNode(modifier.getPrefix(), JavaScriptReceiver::receiveSpace)); - modifier = modifier.withMarkers(ctx.receiveNonNullNode(modifier.getMarkers(), ctx::receiveMarkers)); - modifier = modifier.withKeyword(ctx.receiveValue(modifier.getKeyword(), String.class)); - modifier = modifier.withType(ctx.receiveNonNullValue(modifier.getType(), J.Modifier.Type.class)); - modifier = modifier.withAnnotations(ctx.receiveNonNullNodes(modifier.getAnnotations(), ctx::receiveTree)); - } else { - modifier = new J.Modifier( - ctx.receiveNonNullValue(null, UUID.class), - ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveSpace), - ctx.receiveNonNullNode(null, ctx::receiveMarkers), - ctx.receiveValue(null, String.class), - ctx.receiveNonNullValue(null, J.Modifier.Type.class), - ctx.receiveNonNullNodes(null, ctx::receiveTree) - ); - } - return modifier; - } - private static J.TypeParameters receiveMethodTypeParameters(J.@Nullable TypeParameters typeParameters, @Nullable Class type, ReceiverContext ctx) { if (typeParameters != null) { typeParameters = typeParameters.withId(ctx.receiveNonNullValue(typeParameters.getId(), UUID.class)); diff --git a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java index 09b7d8cc..cca87cfa 100644 --- a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java +++ b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java @@ -857,7 +857,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDeclarat ctx.sendNode(classDeclaration, J.ClassDeclaration::getPrefix, JavaScriptSender::sendSpace); ctx.sendNode(classDeclaration, J.ClassDeclaration::getMarkers, ctx::sendMarkers); ctx.sendNodes(classDeclaration, J.ClassDeclaration::getLeadingAnnotations, ctx::sendTree, Tree::getId); - ctx.sendNodes(classDeclaration, J.ClassDeclaration::getModifiers, this::sendModifier, Tree::getId); + ctx.sendNodes(classDeclaration, J.ClassDeclaration::getModifiers, ctx::sendTree, Tree::getId); ctx.sendNode(classDeclaration, e -> e.getPadding().getKind(), this::sendClassDeclarationKind); ctx.sendNode(classDeclaration, J.ClassDeclaration::getName, ctx::sendTree); ctx.sendNode(classDeclaration, e -> e.getPadding().getTypeParameters(), JavaScriptSender::sendContainer); @@ -1114,7 +1114,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration methodDecl ctx.sendNode(methodDeclaration, J.MethodDeclaration::getPrefix, JavaScriptSender::sendSpace); ctx.sendNode(methodDeclaration, J.MethodDeclaration::getMarkers, ctx::sendMarkers); ctx.sendNodes(methodDeclaration, J.MethodDeclaration::getLeadingAnnotations, ctx::sendTree, Tree::getId); - ctx.sendNodes(methodDeclaration, J.MethodDeclaration::getModifiers, this::sendModifier, Tree::getId); + ctx.sendNodes(methodDeclaration, J.MethodDeclaration::getModifiers, ctx::sendTree, Tree::getId); ctx.sendNode(methodDeclaration, e -> e.getAnnotations().getTypeParameters(), this::sendMethodTypeParameters); ctx.sendNode(methodDeclaration, J.MethodDeclaration::getReturnTypeExpression, ctx::sendTree); ctx.sendNode(methodDeclaration, e -> e.getAnnotations().getName(), this::sendMethodIdentifierWithAnnotations); @@ -1144,13 +1144,15 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation methodInvocat return methodInvocation; } - private void sendModifier(J.Modifier modifier, SenderContext ctx) { + @Override + public J.Modifier visitModifier(J.Modifier modifier, SenderContext ctx) { ctx.sendValue(modifier, J.Modifier::getId); ctx.sendNode(modifier, J.Modifier::getPrefix, JavaScriptSender::sendSpace); ctx.sendNode(modifier, J.Modifier::getMarkers, ctx::sendMarkers); ctx.sendValue(modifier, J.Modifier::getKeyword); ctx.sendValue(modifier, J.Modifier::getType); ctx.sendNodes(modifier, J.Modifier::getAnnotations, ctx::sendTree, Tree::getId); + return modifier; } @Override @@ -1363,7 +1365,7 @@ public J.TypeParameter visitTypeParameter(J.TypeParameter typeParameter, SenderC ctx.sendNode(typeParameter, J.TypeParameter::getPrefix, JavaScriptSender::sendSpace); ctx.sendNode(typeParameter, J.TypeParameter::getMarkers, ctx::sendMarkers); ctx.sendNodes(typeParameter, J.TypeParameter::getAnnotations, ctx::sendTree, Tree::getId); - ctx.sendNodes(typeParameter, J.TypeParameter::getModifiers, this::sendModifier, Tree::getId); + ctx.sendNodes(typeParameter, J.TypeParameter::getModifiers, ctx::sendTree, Tree::getId); ctx.sendNode(typeParameter, J.TypeParameter::getName, ctx::sendTree); ctx.sendNode(typeParameter, e -> e.getPadding().getBounds(), JavaScriptSender::sendContainer); return typeParameter; @@ -1394,7 +1396,7 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations v ctx.sendNode(variableDeclarations, J.VariableDeclarations::getPrefix, JavaScriptSender::sendSpace); ctx.sendNode(variableDeclarations, J.VariableDeclarations::getMarkers, ctx::sendMarkers); ctx.sendNodes(variableDeclarations, J.VariableDeclarations::getLeadingAnnotations, ctx::sendTree, Tree::getId); - ctx.sendNodes(variableDeclarations, J.VariableDeclarations::getModifiers, this::sendModifier, Tree::getId); + ctx.sendNodes(variableDeclarations, J.VariableDeclarations::getModifiers, ctx::sendTree, Tree::getId); ctx.sendNode(variableDeclarations, J.VariableDeclarations::getTypeExpression, ctx::sendTree); ctx.sendNode(variableDeclarations, J.VariableDeclarations::getVarargs, JavaScriptSender::sendSpace); ctx.sendNodes(variableDeclarations, J.VariableDeclarations::getDimensionsBeforeName, JavaScriptSender::sendLeftPadded, Function.identity()); diff --git a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptValidator.java b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptValidator.java index b78f8fa9..47259c64 100644 --- a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptValidator.java +++ b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptValidator.java @@ -208,7 +208,7 @@ public JS.ObjectBindingDeclarations visitObjectBindingDeclarations(JS.ObjectBind ListUtils.map(objectBindingDeclarations.getLeadingAnnotations(), el -> visitAndValidateNonNull(el, J.Annotation.class, p)); ListUtils.map(objectBindingDeclarations.getModifiers(), el -> visitAndValidateNonNull(el, J.Modifier.class, p)); visitAndValidate(objectBindingDeclarations.getTypeExpression(), TypeTree.class, p); - visitAndValidate(objectBindingDeclarations.getBindings(), JS.BindingElement.class, p); + visitAndValidate(objectBindingDeclarations.getBindings(), J.class, p); visitAndValidate(objectBindingDeclarations.getInitializer(), Expression.class, p); return objectBindingDeclarations; } @@ -569,7 +569,7 @@ public J.Case visitCase(J.Case case_, P p) { public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDeclaration, P p) { ListUtils.map(classDeclaration.getLeadingAnnotations(), el -> visitAndValidateNonNull(el, J.Annotation.class, p)); ListUtils.map(classDeclaration.getModifiers(), el -> visitAndValidateNonNull(el, J.Modifier.class, p)); - visit(classDeclaration.getPadding().getKind(), p); + visitAndValidate(classDeclaration.getPadding().getKind().getAnnotations(), J.Annotation.class, p); visitAndValidateNonNull(classDeclaration.getName(), J.Identifier.class, p); visitAndValidate(classDeclaration.getTypeParameters(), J.TypeParameter.class, p); visitAndValidate(classDeclaration.getPrimaryConstructor(), Statement.class, p); @@ -745,6 +745,12 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation methodInvocat return methodInvocation; } + @Override + public J.Modifier visitModifier(J.Modifier modifier, P p) { + ListUtils.map(modifier.getAnnotations(), el -> visitAndValidateNonNull(el, J.Annotation.class, p)); + return modifier; + } + @Override public J.MultiCatch visitMultiCatch(J.MultiCatch multiCatch, P p) { ListUtils.map(multiCatch.getAlternatives(), el -> visitAndValidateNonNull(el, NameTree.class, p)); diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java index 88671467..b4f5c251 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java @@ -1893,13 +1893,13 @@ final class ObjectBindingDeclarations implements JS, Expression, TypedTree { @Getter TypeTree typeExpression; - JContainer bindings; + JContainer bindings; - public List getBindings() { + public List getBindings() { return bindings.getElements(); } - public ObjectBindingDeclarations withBindings(List bindings) { + public ObjectBindingDeclarations withBindings(List bindings) { return getPadding().withBindings(JContainer.withElements(this.bindings, bindings)); } @@ -1976,11 +1976,11 @@ public ObjectBindingDeclarations.Padding getPadding() { public static class Padding { private final ObjectBindingDeclarations t; - public JContainer getBindings() { + public JContainer getBindings() { return t.bindings; } - public ObjectBindingDeclarations withBindings(JContainer bindings) { + public ObjectBindingDeclarations withBindings(JContainer bindings) { return t.bindings == bindings ? t : new ObjectBindingDeclarations(t.id, t.prefix, t.markers, t.leadingAnnotations, t.modifiers, t.typeExpression, bindings, t.initializer); }