Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit a6b05f1

Browse files
committed
adopt new rewrite changes
1 parent cd45431 commit a6b05f1

File tree

10 files changed

+206
-3
lines changed

10 files changed

+206
-3
lines changed

openrewrite/src/java/remote/receiver.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as extensions from "./remote_extensions";
22
import {Checksum, Cursor, FileAttributes, ListUtils, Tree} from '../../core';
33
import {DetailsReceiver, Receiver, ReceiverContext, ReceiverFactory, ValueType} from '@openrewrite/rewrite-remote';
44
import {JavaVisitor} from '..';
5-
import {J, Comment, Expression, JavaSourceFile, JavaType, JContainer, JLeftPadded, JRightPadded, Loop, MethodCall, NameTree, Space, Statement, TextComment, TypedTree, TypeTree, AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown, Erroneous} from '../tree';
5+
import {J, Comment, Expression, JavaSourceFile, JavaType, JContainer, JLeftPadded, JRightPadded, Loop, MethodCall, NameTree, Space, Statement, TextComment, TypedTree, TypeTree, AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, DeconstructionPattern, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown, Erroneous} from '../tree';
66
import * as Java from "../../java/tree";
77

88
export class JavaReceiver implements Receiver<J> {
@@ -328,6 +328,16 @@ class Visitor extends JavaVisitor<ReceiverContext> {
328328
return instanceOf;
329329
}
330330

331+
public visitDeconstructionPattern(deconstructionPattern: DeconstructionPattern, ctx: ReceiverContext): J {
332+
deconstructionPattern = deconstructionPattern.withId(ctx.receiveValue(deconstructionPattern.id, ValueType.UUID)!);
333+
deconstructionPattern = deconstructionPattern.withPrefix(ctx.receiveNode(deconstructionPattern.prefix, receiveSpace)!);
334+
deconstructionPattern = deconstructionPattern.withMarkers(ctx.receiveNode(deconstructionPattern.markers, ctx.receiveMarkers)!);
335+
deconstructionPattern = deconstructionPattern.withDeconstructor(ctx.receiveNode(deconstructionPattern.deconstructor, ctx.receiveTree)!);
336+
deconstructionPattern = deconstructionPattern.padding.withNested(ctx.receiveNode(deconstructionPattern.padding.nested, receiveContainer)!);
337+
deconstructionPattern = deconstructionPattern.withType(ctx.receiveValue(deconstructionPattern.type, ValueType.Object)!);
338+
return deconstructionPattern;
339+
}
340+
331341
public visitIntersectionType(intersectionType: IntersectionType, ctx: ReceiverContext): J {
332342
intersectionType = intersectionType.withId(ctx.receiveValue(intersectionType.id, ValueType.UUID)!);
333343
intersectionType = intersectionType.withPrefix(ctx.receiveNode(intersectionType.prefix, receiveSpace)!);
@@ -1054,6 +1064,17 @@ class Factory implements ReceiverFactory {
10541064
);
10551065
}
10561066

1067+
if (type === "org.openrewrite.java.tree.J$DeconstructionPattern") {
1068+
return new DeconstructionPattern(
1069+
ctx.receiveValue(null, ValueType.UUID)!,
1070+
ctx.receiveNode(null, receiveSpace)!,
1071+
ctx.receiveNode(null, ctx.receiveMarkers)!,
1072+
ctx.receiveNode<Expression>(null, ctx.receiveTree)!,
1073+
ctx.receiveNode<JContainer<J>>(null, receiveContainer)!,
1074+
ctx.receiveValue(null, ValueType.Object)!
1075+
);
1076+
}
1077+
10571078
if (type === "org.openrewrite.java.tree.J$IntersectionType") {
10581079
return new IntersectionType(
10591080
ctx.receiveValue(null, ValueType.UUID)!,

openrewrite/src/java/remote/sender.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as extensions from "./remote_extensions";
22
import {Cursor, ListUtils, Tree} from '../../core';
33
import {Sender, SenderContext, ValueType} from '@openrewrite/rewrite-remote';
44
import {JavaVisitor} from '..';
5-
import {J, Comment, Expression, JavaSourceFile, JavaType, JContainer, JLeftPadded, JRightPadded, Loop, MethodCall, NameTree, Space, Statement, TextComment, TypedTree, TypeTree, AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown, Erroneous} from '../tree';
5+
import {J, Comment, Expression, JavaSourceFile, JavaType, JContainer, JLeftPadded, JRightPadded, Loop, MethodCall, NameTree, Space, Statement, TextComment, TypedTree, TypeTree, AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, DeconstructionPattern, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown, Erroneous} from '../tree';
66
import * as Java from "../../java/tree";
77

88
export class JavaSender implements Sender<J> {
@@ -323,6 +323,16 @@ class Visitor extends JavaVisitor<SenderContext> {
323323
return instanceOf;
324324
}
325325

326+
public visitDeconstructionPattern(deconstructionPattern: DeconstructionPattern, ctx: SenderContext): J {
327+
ctx.sendValue(deconstructionPattern, v => v.id, ValueType.UUID);
328+
ctx.sendNode(deconstructionPattern, v => v.prefix, Visitor.sendSpace);
329+
ctx.sendNode(deconstructionPattern, v => v.markers, ctx.sendMarkers);
330+
ctx.sendNode(deconstructionPattern, v => v.deconstructor, ctx.sendTree);
331+
ctx.sendNode(deconstructionPattern, v => v.padding.nested, Visitor.sendContainer(ValueType.Tree));
332+
ctx.sendTypedValue(deconstructionPattern, v => v.type, ValueType.Object);
333+
return deconstructionPattern;
334+
}
335+
326336
public visitIntersectionType(intersectionType: IntersectionType, ctx: SenderContext): J {
327337
ctx.sendValue(intersectionType, v => v.id, ValueType.UUID);
328338
ctx.sendNode(intersectionType, v => v.prefix, Visitor.sendSpace);

openrewrite/src/java/tree/support_types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ export namespace Space {
692692
WILDCARD_PREFIX,
693693
YIELD_PREFIX,
694694
ERRONEOUS_PREFIX,
695+
DECONSTRUCTION_PATTERN_PREFIX,
695696
}
696697
}
697698

@@ -798,6 +799,7 @@ export namespace JContainer {
798799
TRY_RESOURCES,
799800
TYPE_BOUNDS,
800801
TYPE_PARAMETERS,
802+
DECONSTRUCTION_PATTERN_NESTED,
801803
}
802804

803805
export namespace Location {

openrewrite/src/java/tree/tree.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,6 +2792,96 @@ export class InstanceOf extends JMixin(Object) implements Expression, TypedTree
27922792

27932793
}
27942794

2795+
@LstType("org.openrewrite.java.tree.J$DeconstructionPattern")
2796+
export class DeconstructionPattern extends JMixin(Object) implements TypedTree {
2797+
public constructor(id: UUID, prefix: Space, markers: Markers, deconstructor: Expression, nested: JContainer<J>, _type: JavaType) {
2798+
super();
2799+
this._id = id;
2800+
this._prefix = prefix;
2801+
this._markers = markers;
2802+
this._deconstructor = deconstructor;
2803+
this._nested = nested;
2804+
this._type = _type;
2805+
}
2806+
2807+
private readonly _id: UUID;
2808+
2809+
public get id(): UUID {
2810+
return this._id;
2811+
}
2812+
2813+
public withId(id: UUID): DeconstructionPattern {
2814+
return id === this._id ? this : new DeconstructionPattern(id, this._prefix, this._markers, this._deconstructor, this._nested, this._type);
2815+
}
2816+
2817+
private readonly _prefix: Space;
2818+
2819+
public get prefix(): Space {
2820+
return this._prefix;
2821+
}
2822+
2823+
public withPrefix(prefix: Space): DeconstructionPattern {
2824+
return prefix === this._prefix ? this : new DeconstructionPattern(this._id, prefix, this._markers, this._deconstructor, this._nested, this._type);
2825+
}
2826+
2827+
private readonly _markers: Markers;
2828+
2829+
public get markers(): Markers {
2830+
return this._markers;
2831+
}
2832+
2833+
public withMarkers(markers: Markers): DeconstructionPattern {
2834+
return markers === this._markers ? this : new DeconstructionPattern(this._id, this._prefix, markers, this._deconstructor, this._nested, this._type);
2835+
}
2836+
2837+
private readonly _deconstructor: Expression;
2838+
2839+
public get deconstructor(): Expression {
2840+
return this._deconstructor;
2841+
}
2842+
2843+
public withDeconstructor(deconstructor: Expression): DeconstructionPattern {
2844+
return deconstructor === this._deconstructor ? this : new DeconstructionPattern(this._id, this._prefix, this._markers, deconstructor, this._nested, this._type);
2845+
}
2846+
2847+
private readonly _nested: JContainer<J>;
2848+
2849+
public get nested(): J[] {
2850+
return this._nested.elements;
2851+
}
2852+
2853+
public withNested(nested: J[]): DeconstructionPattern {
2854+
return this.padding.withNested(JContainer.withElements(this._nested, nested));
2855+
}
2856+
2857+
private readonly _type: JavaType;
2858+
2859+
public get type(): JavaType {
2860+
return this._type;
2861+
}
2862+
2863+
public withType(_type: JavaType): DeconstructionPattern {
2864+
return _type === this._type ? this : new DeconstructionPattern(this._id, this._prefix, this._markers, this._deconstructor, this._nested, _type);
2865+
}
2866+
2867+
public acceptJava<P>(v: JavaVisitor<P>, p: P): J | null {
2868+
return v.visitDeconstructionPattern(this, p);
2869+
}
2870+
2871+
get padding() {
2872+
const t = this;
2873+
return new class {
2874+
public get nested(): JContainer<J> {
2875+
return t._nested;
2876+
}
2877+
public withNested(nested: JContainer<J>): DeconstructionPattern {
2878+
return t._nested === nested ? t : new DeconstructionPattern(t._id, t._prefix, t._markers, t._deconstructor, nested, t._type);
2879+
}
2880+
}
2881+
}
2882+
2883+
}
2884+
27952885
@LstType("org.openrewrite.java.tree.J$IntersectionType")
27962886
export class IntersectionType extends JMixin(Object) implements TypeTree, Expression {
27972887
public constructor(id: UUID, prefix: Space, markers: Markers, bounds: JContainer<TypeTree>) {

openrewrite/src/java/visitor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as extensions from "./extensions";
22
import {ListUtils, SourceFile, Tree, TreeVisitor} from "../core";
33
import {J, isJava, Comment, Expression, JavaSourceFile, JavaType, JContainer, JLeftPadded, JRightPadded, Loop, MethodCall, NameTree, Space, Statement, TextComment, TypedTree, TypeTree} from "./tree";
4-
import {AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown, Erroneous} from "./tree";
4+
import {AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, DeconstructionPattern, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown, Erroneous} from "./tree";
55

66
export class JavaVisitor<P> extends TreeVisitor<J, P> {
77
isAcceptable(sourceFile: SourceFile, p: P): boolean {
@@ -437,6 +437,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
437437
return instanceOf;
438438
}
439439

440+
public visitDeconstructionPattern(deconstructionPattern: DeconstructionPattern, p: P): J | null {
441+
deconstructionPattern = deconstructionPattern.withPrefix(this.visitSpace(deconstructionPattern.prefix, Space.Location.DECONSTRUCTION_PATTERN_PREFIX, p)!);
442+
deconstructionPattern = deconstructionPattern.withMarkers(this.visitMarkers(deconstructionPattern.markers, p));
443+
deconstructionPattern = deconstructionPattern.withDeconstructor(this.visitAndCast(deconstructionPattern.deconstructor, p)!);
444+
deconstructionPattern = deconstructionPattern.padding.withNested(this.visitContainer(deconstructionPattern.padding.nested, JContainer.Location.DECONSTRUCTION_PATTERN_NESTED, p)!);
445+
return deconstructionPattern;
446+
}
447+
440448
public visitIntersectionType(intersectionType: IntersectionType, p: P): J | null {
441449
intersectionType = intersectionType.withPrefix(this.visitSpace(intersectionType.prefix, Space.Location.INTERSECTION_TYPE_PREFIX, p)!);
442450
let tempExpression = this.visitExpression(intersectionType, p) as Expression;

openrewrite/src/javascript/remote/receiver.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,16 @@ class Visitor extends JavaScriptVisitor<ReceiverContext> {
10141014
return instanceOf;
10151015
}
10161016

1017+
public visitDeconstructionPattern(deconstructionPattern: Java.DeconstructionPattern, ctx: ReceiverContext): J {
1018+
deconstructionPattern = deconstructionPattern.withId(ctx.receiveValue(deconstructionPattern.id, ValueType.UUID)!);
1019+
deconstructionPattern = deconstructionPattern.withPrefix(ctx.receiveNode(deconstructionPattern.prefix, receiveSpace)!);
1020+
deconstructionPattern = deconstructionPattern.withMarkers(ctx.receiveNode(deconstructionPattern.markers, ctx.receiveMarkers)!);
1021+
deconstructionPattern = deconstructionPattern.withDeconstructor(ctx.receiveNode(deconstructionPattern.deconstructor, ctx.receiveTree)!);
1022+
deconstructionPattern = deconstructionPattern.padding.withNested(ctx.receiveNode(deconstructionPattern.padding.nested, receiveContainer)!);
1023+
deconstructionPattern = deconstructionPattern.withType(ctx.receiveValue(deconstructionPattern.type, ValueType.Object)!);
1024+
return deconstructionPattern;
1025+
}
1026+
10171027
public visitIntersectionType(intersectionType: Java.IntersectionType, ctx: ReceiverContext): J {
10181028
intersectionType = intersectionType.withId(ctx.receiveValue(intersectionType.id, ValueType.UUID)!);
10191029
intersectionType = intersectionType.withPrefix(ctx.receiveNode(intersectionType.prefix, receiveSpace)!);
@@ -2493,6 +2503,17 @@ class Factory implements ReceiverFactory {
24932503
);
24942504
}
24952505

2506+
if (type === "org.openrewrite.java.tree.J$DeconstructionPattern") {
2507+
return new Java.DeconstructionPattern(
2508+
ctx.receiveValue(null, ValueType.UUID)!,
2509+
ctx.receiveNode(null, receiveSpace)!,
2510+
ctx.receiveNode(null, ctx.receiveMarkers)!,
2511+
ctx.receiveNode<Expression>(null, ctx.receiveTree)!,
2512+
ctx.receiveNode<JContainer<J>>(null, receiveContainer)!,
2513+
ctx.receiveValue(null, ValueType.Object)!
2514+
);
2515+
}
2516+
24962517
if (type === "org.openrewrite.java.tree.J$IntersectionType") {
24972518
return new Java.IntersectionType(
24982519
ctx.receiveValue(null, ValueType.UUID)!,

openrewrite/src/javascript/remote/sender.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,16 @@ class Visitor extends JavaScriptVisitor<SenderContext> {
10091009
return instanceOf;
10101010
}
10111011

1012+
public visitDeconstructionPattern(deconstructionPattern: Java.DeconstructionPattern, ctx: SenderContext): J {
1013+
ctx.sendValue(deconstructionPattern, v => v.id, ValueType.UUID);
1014+
ctx.sendNode(deconstructionPattern, v => v.prefix, Visitor.sendSpace);
1015+
ctx.sendNode(deconstructionPattern, v => v.markers, ctx.sendMarkers);
1016+
ctx.sendNode(deconstructionPattern, v => v.deconstructor, ctx.sendTree);
1017+
ctx.sendNode(deconstructionPattern, v => v.padding.nested, Visitor.sendContainer(ValueType.Tree));
1018+
ctx.sendTypedValue(deconstructionPattern, v => v.type, ValueType.Object);
1019+
return deconstructionPattern;
1020+
}
1021+
10121022
public visitIntersectionType(intersectionType: Java.IntersectionType, ctx: SenderContext): J {
10131023
ctx.sendValue(intersectionType, v => v.id, ValueType.UUID);
10141024
ctx.sendNode(intersectionType, v => v.prefix, Visitor.sendSpace);

0 commit comments

Comments
 (0)