Skip to content

Commit

Permalink
Merge branch 'main' into msal
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Dec 17, 2024
2 parents 8a328d0 + ae0385f commit 0558ebe
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 126 deletions.
2 changes: 1 addition & 1 deletion openrewrite/src/javascript/remote/receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ class Factory implements ReceiverFactory {
ctx.receiveNodes<Java.Annotation>(null, ctx.receiveTree)!,
ctx.receiveNodes<Java.Modifier>(null, ctx.receiveTree)!,
ctx.receiveNode<TypeTree>(null, ctx.receiveTree),
ctx.receiveNode<JContainer<BindingElement>>(null, receiveContainer)!,
ctx.receiveNode<JContainer<J>>(null, receiveContainer)!,
ctx.receiveNode<JLeftPadded<Expression>>(null, receiveLeftPaddedTree)
);
}
Expand Down
12 changes: 6 additions & 6 deletions openrewrite/src/javascript/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BindingElement>, initializer: JLeftPadded<Expression> | null) {
public constructor(id: UUID, prefix: Space, markers: Markers, leadingAnnotations: Java.Annotation[], modifiers: Java.Modifier[], typeExpression: TypeTree | null, bindings: JContainer<J>, initializer: JLeftPadded<Expression> | null) {
super();
this._id = id;
this._prefix = prefix;
Expand Down Expand Up @@ -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<BindingElement>;
private readonly _bindings: JContainer<J>;

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));
}

Expand Down Expand Up @@ -2071,10 +2071,10 @@ export class ObjectBindingDeclarations extends JSMixin(Object) implements Expres
get padding() {
const t = this;
return new class {
public get bindings(): JContainer<BindingElement> {
public get bindings(): JContainer<J> {
return t._bindings;
}
public withBindings(bindings: JContainer<BindingElement>): ObjectBindingDeclarations {
public withBindings(bindings: JContainer<J>): 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<Expression> | null {
Expand Down
9 changes: 9 additions & 0 deletions openrewrite/test/javascript/parser/arrow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,13 @@ describe('arrow mapping', () => {
);
});

test('arrow function with empty object binding', () => {
rewriteRun(
//language=typescript
typeScript(`
({/*a*/}) => ({/*b*/})
`)
);
});

});
3 changes: 1 addition & 2 deletions rewrite-javascript-remote/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,58 @@

class Extensions {
public static <T extends J> void sendContainer(JContainer<T> container, SenderContext ctx) {
org.openrewrite.remote.java.Extensions.sendContainer(container, ctx);
org.openrewrite.java.remote.Extensions.sendContainer(container, ctx);
}

public static <T> void sendLeftPadded(JLeftPadded<T> leftPadded, SenderContext ctx) {
org.openrewrite.remote.java.Extensions.sendLeftPadded(leftPadded, ctx);
org.openrewrite.java.remote.Extensions.sendLeftPadded(leftPadded, ctx);
}

public static <T> void sendRightPadded(JRightPadded<T> 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 <T extends J> JContainer<T> receiveContainer(@Nullable JContainer<T> 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 <T> ReceiverContext.DetailsReceiver<JLeftPadded<T>> leftPaddedValueReceiver(Class<T> valueType) {
return org.openrewrite.remote.java.Extensions.leftPaddedValueReceiver(valueType);
return org.openrewrite.java.remote.Extensions.leftPaddedValueReceiver(valueType);
}

public static <T> ReceiverContext.DetailsReceiver<JLeftPadded<T>> leftPaddedNodeReceiver(Class<T> nodeType) {
return org.openrewrite.remote.java.Extensions.leftPaddedNodeReceiver(nodeType);
return org.openrewrite.java.remote.Extensions.leftPaddedNodeReceiver(nodeType);
}

public static <T extends J> JLeftPadded<T> receiveLeftPaddedTree(@Nullable JLeftPadded<T> 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 <T> ReceiverContext.DetailsReceiver<JRightPadded<T>> rightPaddedValueReceiver(Class<T> valueType) {
return org.openrewrite.remote.java.Extensions.rightPaddedValueReceiver(valueType);
return org.openrewrite.java.remote.Extensions.rightPaddedValueReceiver(valueType);
}

public static <T> ReceiverContext.DetailsReceiver<JRightPadded<T>> rightPaddedNodeReceiver(Class<T> nodeType) {
return org.openrewrite.remote.java.Extensions.rightPaddedNodeReceiver(nodeType);
return org.openrewrite.java.remote.Extensions.rightPaddedNodeReceiver(nodeType);
}

public static <T extends J> JRightPadded<T> receiveRightPaddedTree(@Nullable JRightPadded<T> 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<Comment> type, ReceiverContext ctx) {
return org.openrewrite.remote.java.Extensions.receiveComment(comment, type, ctx);
return org.openrewrite.java.remote.Extensions.receiveComment(comment, type, ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand All @@ -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)));
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
);
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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));
Expand Down
Loading

0 comments on commit 0558ebe

Please sign in to comment.