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/build.gradle.kts b/rewrite-javascript-remote/build.gradle.kts index 75804bc0..06117827 100644 --- a/rewrite-javascript-remote/build.gradle.kts +++ b/rewrite-javascript-remote/build.gradle.kts @@ -3,8 +3,7 @@ plugins { } -//val latest = if (System.getenv("RELEASE_PUBLICATION") != null) "latest.release" else "latest.integration" -val latest = "latest.release"; +val latest = if (project.hasProperty("releasing")) "latest.release" else "latest.integration" dependencies { compileOnly("com.google.auto.service:auto-service-annotations:1.1.1") diff --git a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/Extensions.java b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/Extensions.java index 59b7324e..0fd83737 100644 --- a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/Extensions.java +++ b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/Extensions.java @@ -22,58 +22,58 @@ class Extensions { public static void sendContainer(JContainer container, SenderContext ctx) { - org.openrewrite.remote.java.Extensions.sendContainer(container, ctx); + org.openrewrite.java.remote.Extensions.sendContainer(container, ctx); } public static void sendLeftPadded(JLeftPadded leftPadded, SenderContext ctx) { - org.openrewrite.remote.java.Extensions.sendLeftPadded(leftPadded, ctx); + org.openrewrite.java.remote.Extensions.sendLeftPadded(leftPadded, ctx); } public static void sendRightPadded(JRightPadded rightPadded, SenderContext ctx) { - org.openrewrite.remote.java.Extensions.sendRightPadded(rightPadded, ctx); + org.openrewrite.java.remote.Extensions.sendRightPadded(rightPadded, ctx); } public static void sendSpace(Space space, SenderContext ctx) { - org.openrewrite.remote.java.Extensions.sendSpace(space, ctx); + org.openrewrite.java.remote.Extensions.sendSpace(space, ctx); } public static void sendComment(Comment comment, SenderContext ctx) { - org.openrewrite.remote.java.Extensions.sendComment(comment, ctx); + org.openrewrite.java.remote.Extensions.sendComment(comment, ctx); } public static JContainer receiveContainer(@Nullable JContainer container, @Nullable Class type, ReceiverContext ctx) { - return org.openrewrite.remote.java.Extensions.receiveContainer(container, type, ctx); + return org.openrewrite.java.remote.Extensions.receiveContainer(container, type, ctx); } public static ReceiverContext.DetailsReceiver> leftPaddedValueReceiver(Class valueType) { - return org.openrewrite.remote.java.Extensions.leftPaddedValueReceiver(valueType); + return org.openrewrite.java.remote.Extensions.leftPaddedValueReceiver(valueType); } public static ReceiverContext.DetailsReceiver> leftPaddedNodeReceiver(Class nodeType) { - return org.openrewrite.remote.java.Extensions.leftPaddedNodeReceiver(nodeType); + return org.openrewrite.java.remote.Extensions.leftPaddedNodeReceiver(nodeType); } public static JLeftPadded receiveLeftPaddedTree(@Nullable JLeftPadded leftPadded, @Nullable Class type, ReceiverContext ctx) { - return org.openrewrite.remote.java.Extensions.receiveLeftPaddedTree(leftPadded, type, ctx); + return org.openrewrite.java.remote.Extensions.receiveLeftPaddedTree(leftPadded, type, ctx); } public static ReceiverContext.DetailsReceiver> rightPaddedValueReceiver(Class valueType) { - return org.openrewrite.remote.java.Extensions.rightPaddedValueReceiver(valueType); + return org.openrewrite.java.remote.Extensions.rightPaddedValueReceiver(valueType); } public static ReceiverContext.DetailsReceiver> rightPaddedNodeReceiver(Class nodeType) { - return org.openrewrite.remote.java.Extensions.rightPaddedNodeReceiver(nodeType); + return org.openrewrite.java.remote.Extensions.rightPaddedNodeReceiver(nodeType); } public static JRightPadded receiveRightPaddedTree(@Nullable JRightPadded rightPadded, @Nullable Class type, ReceiverContext ctx) { - return org.openrewrite.remote.java.Extensions.receiveRightPaddedTree(rightPadded, type, ctx); + return org.openrewrite.java.remote.Extensions.receiveRightPaddedTree(rightPadded, type, ctx); } public static Space receiveSpace(@Nullable Space space, Class type, ReceiverContext ctx) { - return org.openrewrite.remote.java.Extensions.receiveSpace(space, type, ctx); + return org.openrewrite.java.remote.Extensions.receiveSpace(space, type, ctx); } public static Comment receiveComment(@Nullable Comment comment, @Nullable Class type, ReceiverContext ctx) { - return org.openrewrite.remote.java.Extensions.receiveComment(comment, type, ctx); + return org.openrewrite.java.remote.Extensions.receiveComment(comment, type, ctx); } } 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 4de6df2b..880a705f 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 @@ -874,7 +874,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)); @@ -1115,7 +1115,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)); @@ -1140,6 +1140,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)); @@ -1350,7 +1361,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; @@ -1373,7 +1384,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))); @@ -2387,7 +2398,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), @@ -2648,7 +2659,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), @@ -2894,7 +2905,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) ); @@ -2927,7 +2938,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)), @@ -3048,27 +3059,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 360bc0e2..7d205085 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 @@ -856,7 +856,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); @@ -1113,7 +1113,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); @@ -1143,13 +1143,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 @@ -1362,7 +1364,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; @@ -1393,7 +1395,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 5866108b..22494d64 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 @@ -207,7 +207,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; } @@ -568,7 +568,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); @@ -744,6 +744,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/build.gradle.kts b/rewrite-javascript/build.gradle.kts index 2f8c4fb7..027ac2bb 100644 --- a/rewrite-javascript/build.gradle.kts +++ b/rewrite-javascript/build.gradle.kts @@ -5,8 +5,7 @@ plugins { } -//val latest = if (System.getenv("RELEASE_PUBLICATION") != null) "latest.release" else "latest.integration" -val latest = "latest.release"; +val latest = if (project.hasProperty("releasing")) "latest.release" else "latest.integration" dependencies { compileOnly("org.openrewrite:rewrite-test") 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 d12a443c..da53cdcb 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); } diff --git a/rewrite-javascript/src/main/resources/javet-jni-classnames.txt b/rewrite-javascript/src/main/resources/javet-jni-classnames.txt deleted file mode 100644 index 6112a172..00000000 --- a/rewrite-javascript/src/main/resources/javet-jni-classnames.txt +++ /dev/null @@ -1,59 +0,0 @@ -com.caoccao.javet.exceptions.JavetCompilationException -com.caoccao.javet.exceptions.JavetConverterException -com.caoccao.javet.exceptions.JavetExecutionException -com.caoccao.javet.exceptions.JavetOutOfMemoryException -com.caoccao.javet.exceptions.JavetScriptingError -com.caoccao.javet.exceptions.JavetTerminatedException -com.caoccao.javet.interop.V8Host -com.caoccao.javet.interop.V8Inspector -com.caoccao.javet.interop.V8Runtime -com.caoccao.javet.interop.callback.JavetCallbackContext -com.caoccao.javet.interop.callback.V8FunctionCallback -com.caoccao.javet.interop.monitoring.V8HeapSpaceStatistics -com.caoccao.javet.interop.monitoring.V8HeapStatistics -com.caoccao.javet.interop.monitoring.V8SharedMemoryStatistics -com.caoccao.javet.interop.options.NodeRuntimeOptions -com.caoccao.javet.interop.options.V8Flags -com.caoccao.javet.interop.options.V8RuntimeOptions -com.caoccao.javet.utils.JavetResourceUtils -com.caoccao.javet.values.V8Value -com.caoccao.javet.values.primitive.V8ValueBigInteger -com.caoccao.javet.values.primitive.V8ValueBoolean -com.caoccao.javet.values.primitive.V8ValueDouble -com.caoccao.javet.values.primitive.V8ValueInteger -com.caoccao.javet.values.primitive.V8ValueLong -com.caoccao.javet.values.primitive.V8ValueNull -com.caoccao.javet.values.primitive.V8ValueString -com.caoccao.javet.values.primitive.V8ValueUndefined -com.caoccao.javet.values.primitive.V8ValueUnknown -com.caoccao.javet.values.primitive.V8ValueZonedDateTime -com.caoccao.javet.values.reference.IV8Module -com.caoccao.javet.values.reference.IV8ValueFunction$ScriptSource -com.caoccao.javet.values.reference.IV8ValueReference -com.caoccao.javet.values.reference.V8Context -com.caoccao.javet.values.reference.V8Module -com.caoccao.javet.values.reference.V8Script -com.caoccao.javet.values.reference.V8ValueArguments -com.caoccao.javet.values.reference.V8ValueArray -com.caoccao.javet.values.reference.V8ValueArrayBuffer -com.caoccao.javet.values.reference.V8ValueDataView -com.caoccao.javet.values.reference.V8ValueError -com.caoccao.javet.values.reference.V8ValueFunction -com.caoccao.javet.values.reference.V8ValueGlobalObject -com.caoccao.javet.values.reference.V8ValueIterator -com.caoccao.javet.values.reference.V8ValueMap -com.caoccao.javet.values.reference.V8ValueObject -com.caoccao.javet.values.reference.V8ValuePromise -com.caoccao.javet.values.reference.V8ValueProxy -com.caoccao.javet.values.reference.V8ValueReference -com.caoccao.javet.values.reference.V8ValueRegExp -com.caoccao.javet.values.reference.V8ValueSet -com.caoccao.javet.values.reference.V8ValueSharedArrayBuffer -com.caoccao.javet.values.reference.V8ValueSymbol -com.caoccao.javet.values.reference.V8ValueSymbolObject -com.caoccao.javet.values.reference.V8ValueTypedArray -com.caoccao.javet.values.reference.V8ValueWeakMap -com.caoccao.javet.values.reference.V8ValueWeakSet -java.lang.String -java.lang.Throwable -java.nio.ByteBuffer diff --git a/rewrite-test-engine-remote/build.gradle.kts b/rewrite-test-engine-remote/build.gradle.kts index 771b8d92..8daada9f 100644 --- a/rewrite-test-engine-remote/build.gradle.kts +++ b/rewrite-test-engine-remote/build.gradle.kts @@ -7,7 +7,7 @@ application { mainClass = "org.openrewrite.remote.java.RemotingServer" } -val latest = if (System.getenv("RELEASE_PUBLICATION") != null) "latest.release" else "latest.integration" +val latest = if (project.hasProperty("releasing")) "latest.release" else "latest.integration" dependencies {