diff --git a/Rewrite/Directory.Build.props b/Rewrite/Directory.Build.props index 56f5f432..5edac13b 100644 --- a/Rewrite/Directory.Build.props +++ b/Rewrite/Directory.Build.props @@ -18,11 +18,8 @@ true - - 0.15.0 - - - 0.15.0 + + 0.18.1 diff --git a/Rewrite/src/Rewrite.Java/JavaVisitor.g.cs b/Rewrite/src/Rewrite.Java/JavaVisitor.g.cs index 4d9b7207..d8cf3c6b 100644 --- a/Rewrite/src/Rewrite.Java/JavaVisitor.g.cs +++ b/Rewrite/src/Rewrite.Java/JavaVisitor.g.cs @@ -482,6 +482,15 @@ public virtual J VisitStatement(Statement statement, P p) { return instanceOf; } + public virtual J? VisitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, P p) + { + deconstructionPattern = deconstructionPattern.WithPrefix(VisitSpace(deconstructionPattern.Prefix, Space.Location.DECONSTRUCTION_PATTERN_PREFIX, p)!); + deconstructionPattern = deconstructionPattern.WithMarkers(VisitMarkers(deconstructionPattern.Markers, p)); + deconstructionPattern = deconstructionPattern.WithDeconstructor(VisitAndCast(deconstructionPattern.Deconstructor, p)!); + deconstructionPattern = deconstructionPattern.Padding.WithNested(VisitContainer(deconstructionPattern.Padding.Nested, JContainer.Location.DECONSTRUCTION_PATTERN_NESTED, p)!); + return deconstructionPattern; + } + public virtual J? VisitIntersectionType(J.IntersectionType intersectionType, P p) { intersectionType = intersectionType.WithPrefix(VisitSpace(intersectionType.Prefix, Space.Location.INTERSECTION_TYPE_PREFIX, p)!); diff --git a/Rewrite/src/Rewrite.Java/Tree/DeconstructionPattern.g.cs b/Rewrite/src/Rewrite.Java/Tree/DeconstructionPattern.g.cs new file mode 100644 index 00000000..fd8ec3e0 --- /dev/null +++ b/Rewrite/src/Rewrite.Java/Tree/DeconstructionPattern.g.cs @@ -0,0 +1,131 @@ +//------------------------------------------------------------------------------ +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +#nullable enable +#pragma warning disable CS0108 // 'member1' hides inherited member 'member2'. Use the new keyword if hiding was intended. +#pragma warning disable CS8767 // Nullability of reference types in type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes). +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using Rewrite.Core; +using Rewrite.Core.Marker; +using FileAttributes = Rewrite.Core.FileAttributes; + +namespace Rewrite.RewriteJava.Tree; + +[SuppressMessage("ReSharper", "InconsistentNaming")] +[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")] +[SuppressMessage("ReSharper", "InvertIf")] +[SuppressMessage("ReSharper", "RedundantExtendsListEntry")] +[SuppressMessage("ReSharper", "UnusedMember.Global")] +[SuppressMessage("ReSharper", "RedundantNameQualifier")] +public partial interface J : Rewrite.Core.Tree +{ + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif + public partial class DeconstructionPattern( + Guid id, + Space prefix, + Markers markers, + Expression deconstructor, + JContainer nested, + JavaType type + ) : J, TypedTree, TypedTree, J, MutableTree + { + [NonSerialized] private WeakReference? _padding; + + public PaddingHelper Padding + { + get + { + PaddingHelper? p; + if (_padding == null) + { + p = new PaddingHelper(this); + _padding = new WeakReference(p); + } + else + { + _padding.TryGetTarget(out p); + if (p == null || p.T != this) + { + p = new PaddingHelper(this); + _padding.SetTarget(p); + } + } + return p; + } + } + + public J? AcceptJava

(JavaVisitor

v, P p) + { + return v.VisitDeconstructionPattern(this, p); + } + + public Guid Id => id; + + public DeconstructionPattern WithId(Guid newId) + { + return newId == id ? this : new DeconstructionPattern(newId, prefix, markers, deconstructor, _nested, type); + } + public Space Prefix => prefix; + + public DeconstructionPattern WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new DeconstructionPattern(id, newPrefix, markers, deconstructor, _nested, type); + } + public Markers Markers => markers; + + public DeconstructionPattern WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new DeconstructionPattern(id, prefix, newMarkers, deconstructor, _nested, type); + } + public Expression Deconstructor => deconstructor; + + public DeconstructionPattern WithDeconstructor(Expression newDeconstructor) + { + return ReferenceEquals(newDeconstructor, deconstructor) ? this : new DeconstructionPattern(id, prefix, markers, newDeconstructor, _nested, type); + } + private readonly JContainer _nested = nested; + public IList Nested => _nested.GetElements(); + + public DeconstructionPattern WithNested(IList newNested) + { + return Padding.WithNested(JContainer.WithElements(_nested, newNested)); + } + public JavaType Type => type; + + public DeconstructionPattern WithType(JavaType newType) + { + return newType == type ? this : new DeconstructionPattern(id, prefix, markers, deconstructor, _nested, newType); + } + public sealed record PaddingHelper(J.DeconstructionPattern T) + { + public JContainer Nested => T._nested; + + public J.DeconstructionPattern WithNested(JContainer newNested) + { + return T._nested == newNested ? T : new J.DeconstructionPattern(T.Id, T.Prefix, T.Markers, T.Deconstructor, newNested, T.Type); + } + + } + + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif + public bool Equals(Rewrite.Core.Tree? other) + { + return other is DeconstructionPattern && other.Id == Id; + } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.Java/Tree/JContainer.cs b/Rewrite/src/Rewrite.Java/Tree/JContainer.cs index ea9d96eb..51d23ac1 100644 --- a/Rewrite/src/Rewrite.Java/Tree/JContainer.cs +++ b/Rewrite/src/Rewrite.Java/Tree/JContainer.cs @@ -150,6 +150,7 @@ public record Location(Space.Location BeforeLocation, JRightPadded.Location Elem public static readonly Location ANNOTATION_ARGUMENTS = new(Space.Location.ANNOTATION_ARGUMENTS, JRightPadded.Location.ANNOTATION_ARGUMENT); public static readonly Location CASE = new(Space.Location.CASE, JRightPadded.Location.CASE); public static readonly Location CASE_CASE_LABELS = new(Space.Location.CASE_CASE_LABELS, JRightPadded.Location.CASE_CASE_LABELS); + public static readonly Location DECONSTRUCTION_PATTERN_NESTED = new(Space.Location.DECONSTRUCTION_PATTERN_NESTED, JRightPadded.Location.DECONSTRUCTION_PATTERN_NESTED); public static readonly Location IMPLEMENTS = new(Space.Location.IMPLEMENTS, JRightPadded.Location.IMPLEMENTS); public static readonly Location PERMITS = new(Space.Location.PERMITS, JRightPadded.Location.PERMITS); public static readonly Location LANGUAGE_EXTENSION = new(Space.Location.LANGUAGE_EXTENSION, JRightPadded.Location.LANGUAGE_EXTENSION); diff --git a/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs b/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs index e3fc0334..bb3b9fde 100644 --- a/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs +++ b/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs @@ -146,6 +146,7 @@ public record Location(Space.Location AfterLocation) public static readonly Location CASE_CASE_LABELS = new(Space.Location.CASE_CASE_LABELS); public static readonly Location CASE_BODY = new(Space.Location.CASE_BODY); public static readonly Location CATCH_ALTERNATIVE = new(Space.Location.CATCH_ALTERNATIVE_SUFFIX); + public static readonly Location DECONSTRUCTION_PATTERN_NESTED = new(Space.Location.DECONSTRUCTION_PATTERN_NESTED); public static readonly Location DIMENSION = new(Space.Location.DIMENSION_SUFFIX); public static readonly Location ENUM_VALUE = new(Space.Location.ENUM_VALUE_SUFFIX); public static readonly Location FOR_BODY = new(Space.Location.FOR_BODY_SUFFIX); diff --git a/Rewrite/src/Rewrite.Java/Tree/Space.cs b/Rewrite/src/Rewrite.Java/Tree/Space.cs index e35a5835..f4549197 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Space.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Space.cs @@ -193,21 +193,21 @@ public static Space Format(string formatting, int beginIndex, int toIndex) public enum Location { - ANY, ANNOTATED_TYPE_PREFIX, + ANNOTATIONS, ANNOTATION_ARGUMENTS, ANNOTATION_ARGUMENT_SUFFIX, - ANNOTATIONS, ANNOTATION_PREFIX, + ANY, ARRAY_ACCESS_PREFIX, ARRAY_INDEX_SUFFIX, ARRAY_TYPE_PREFIX, - ASSERT_PREFIX, ASSERT_DETAIL, ASSERT_DETAIL_PREFIX, + ASSERT_PREFIX, ASSIGNMENT, - ASSIGNMENT_OPERATION_PREFIX, ASSIGNMENT_OPERATION_OPERATOR, + ASSIGNMENT_OPERATION_PREFIX, ASSIGNMENT_PREFIX, BINARY_OPERATOR, BINARY_PREFIX, @@ -216,9 +216,9 @@ public enum Location BLOCK_STATEMENT_SUFFIX, BREAK_PREFIX, CASE, - CASE_PREFIX, CASE_BODY, CASE_CASE_LABELS, + CASE_PREFIX, CASE_SUFFIX, CATCH_ALTERNATIVE_SUFFIX, CATCH_PREFIX, @@ -228,8 +228,10 @@ public enum Location COMPILATION_UNIT_PREFIX, CONTINUE_PREFIX, CONTROL_PARENTHESES_PREFIX, - DIMENSION_PREFIX, + DECONSTRUCTION_PATTERN_NESTED, + DECONSTRUCTION_PATTERN_PREFIX, DIMENSION, + DIMENSION_PREFIX, DIMENSION_SUFFIX, DO_WHILE_PREFIX, ELSE_PREFIX, @@ -237,6 +239,7 @@ public enum Location ENUM_VALUE_PREFIX, ENUM_VALUE_SET_PREFIX, ENUM_VALUE_SUFFIX, + ERRONEOUS_PREFIX, EXPRESSION_PREFIX, EXTENDS, FIELD_ACCESS_NAME, @@ -256,9 +259,8 @@ public enum Location IF_PREFIX, IF_THEN_SUFFIX, IMPLEMENTS, - IMPORT_ALIAS_PREFIX, - PERMITS, IMPLEMENTS_SUFFIX, + IMPORT_ALIAS_PREFIX, IMPORT_PREFIX, IMPORT_SUFFIX, INSTANCEOF_PREFIX, @@ -275,9 +277,9 @@ public enum Location MEMBER_REFERENCE_CONTAINING, MEMBER_REFERENCE_NAME, MEMBER_REFERENCE_PREFIX, + METHOD_DECLARATION_DEFAULT_VALUE, METHOD_DECLARATION_PARAMETERS, METHOD_DECLARATION_PARAMETER_SUFFIX, - METHOD_DECLARATION_DEFAULT_VALUE, METHOD_DECLARATION_PREFIX, METHOD_INVOCATION_ARGUMENTS, METHOD_INVOCATION_ARGUMENT_SUFFIX, @@ -302,6 +304,7 @@ public enum Location PARAMETERIZED_TYPE_PREFIX, PARENTHESES_PREFIX, PARENTHESES_SUFFIX, + PERMITS, PERMITS_SUFFIX, PRIMITIVE_PREFIX, RECORD_STATE_VECTOR, @@ -310,8 +313,8 @@ public enum Location STATEMENT_PREFIX, STATIC_IMPORT, STATIC_INIT_SUFFIX, - SWITCH_PREFIX, SWITCH_EXPRESSION_PREFIX, + SWITCH_PREFIX, SYNCHRONIZED_PREFIX, TERNARY_FALSE, TERNARY_PREFIX, @@ -344,7 +347,6 @@ public enum Location WILDCARD_BOUND, WILDCARD_PREFIX, YIELD_PREFIX, - ERRONEOUS_PREFIX, } private static Space Build(string str, IList comments) diff --git a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs index e8520eec..07661740 100644 --- a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs +++ b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs @@ -1480,6 +1480,17 @@ public override J VisitInstanceOf(J.InstanceOf instanceOf, ReceiverContext ctx) return instanceOf; } + public override J VisitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, ReceiverContext ctx) + { + deconstructionPattern = deconstructionPattern.WithId(ctx.ReceiveValue(deconstructionPattern.Id)!); + deconstructionPattern = deconstructionPattern.WithPrefix(ctx.ReceiveNode(deconstructionPattern.Prefix, ReceiveSpace)!); + deconstructionPattern = deconstructionPattern.WithMarkers(ctx.ReceiveNode(deconstructionPattern.Markers, ctx.ReceiveMarkers)!); + deconstructionPattern = deconstructionPattern.WithDeconstructor(ctx.ReceiveNode(deconstructionPattern.Deconstructor, ctx.ReceiveTree)!); + deconstructionPattern = deconstructionPattern.Padding.WithNested(ctx.ReceiveNode(deconstructionPattern.Padding.Nested, ReceiveContainer)!); + deconstructionPattern = deconstructionPattern.WithType(ctx.ReceiveValue(deconstructionPattern.Type)!); + return deconstructionPattern; + } + public override J VisitIntersectionType(J.IntersectionType intersectionType, ReceiverContext ctx) { intersectionType = intersectionType.WithId(ctx.ReceiveValue(intersectionType.Id)!); @@ -3476,6 +3487,18 @@ public Rewrite.Core.Tree Create(string type, ReceiverContext ctx) where T : R ); } + if (type is "Rewrite.RewriteCSharp.Tree.J.DeconstructionPattern" or "org.openrewrite.java.tree.J$DeconstructionPattern") + { + return new J.DeconstructionPattern( + ctx.ReceiveValue(default(Guid))!, + ctx.ReceiveNode(default(Space), ReceiveSpace)!, + ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!, + ctx.ReceiveNode(default(Expression), ctx.ReceiveTree)!, + ctx.ReceiveNode(default(JContainer), ReceiveContainer)!, + ctx.ReceiveValue(default(JavaType))! + ); + } + if (type is "Rewrite.RewriteCSharp.Tree.J.IntersectionType" or "org.openrewrite.java.tree.J$IntersectionType") { return new J.IntersectionType( diff --git a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs index 6f438a30..296e9ae5 100644 --- a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs +++ b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs @@ -1471,6 +1471,17 @@ public override J VisitInstanceOf(J.InstanceOf instanceOf, SenderContext ctx) return instanceOf; } + public override J VisitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, SenderContext ctx) + { + ctx.SendValue(deconstructionPattern, v => v.Id); + ctx.SendNode(deconstructionPattern, v => v.Prefix, SendSpace); + ctx.SendNode(deconstructionPattern, v => v.Markers, ctx.SendMarkers); + ctx.SendNode(deconstructionPattern, v => v.Deconstructor, ctx.SendTree); + ctx.SendNode(deconstructionPattern, v => v.Padding.Nested, SendContainer); + ctx.SendTypedValue(deconstructionPattern, v => v.Type); + return deconstructionPattern; + } + public override J VisitIntersectionType(J.IntersectionType intersectionType, SenderContext ctx) { ctx.SendValue(intersectionType, v => v.Id); diff --git a/Rewrite/src/Rewrite.Remote.Codec/Java/JavaReceiver.g.cs b/Rewrite/src/Rewrite.Remote.Codec/Java/JavaReceiver.g.cs index 11ee0e93..8d110879 100644 --- a/Rewrite/src/Rewrite.Remote.Codec/Java/JavaReceiver.g.cs +++ b/Rewrite/src/Rewrite.Remote.Codec/Java/JavaReceiver.g.cs @@ -377,6 +377,17 @@ public override J VisitInstanceOf(J.InstanceOf instanceOf, ReceiverContext ctx) return instanceOf; } + public override J VisitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, ReceiverContext ctx) + { + deconstructionPattern = deconstructionPattern.WithId(ctx.ReceiveValue(deconstructionPattern.Id)!); + deconstructionPattern = deconstructionPattern.WithPrefix(ctx.ReceiveNode(deconstructionPattern.Prefix, ReceiveSpace)!); + deconstructionPattern = deconstructionPattern.WithMarkers(ctx.ReceiveNode(deconstructionPattern.Markers, ctx.ReceiveMarkers)!); + deconstructionPattern = deconstructionPattern.WithDeconstructor(ctx.ReceiveNode(deconstructionPattern.Deconstructor, ctx.ReceiveTree)!); + deconstructionPattern = deconstructionPattern.Padding.WithNested(ctx.ReceiveNode(deconstructionPattern.Padding.Nested, ReceiveContainer)!); + deconstructionPattern = deconstructionPattern.WithType(ctx.ReceiveValue(deconstructionPattern.Type)!); + return deconstructionPattern; + } + public override J VisitIntersectionType(J.IntersectionType intersectionType, ReceiverContext ctx) { intersectionType = intersectionType.WithId(ctx.ReceiveValue(intersectionType.Id)!); @@ -1166,6 +1177,18 @@ public Rewrite.Core.Tree Create(string type, ReceiverContext ctx) where T : R ); } + if (type is "Rewrite.RewriteJava.Tree.J.DeconstructionPattern" or "org.openrewrite.java.tree.J$DeconstructionPattern") + { + return new J.DeconstructionPattern( + ctx.ReceiveValue(default(Guid))!, + ctx.ReceiveNode(default(Space), ReceiveSpace)!, + ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!, + ctx.ReceiveNode(default(Expression), ctx.ReceiveTree)!, + ctx.ReceiveNode(default(JContainer), ReceiveContainer)!, + ctx.ReceiveValue(default(JavaType))! + ); + } + if (type is "Rewrite.RewriteJava.Tree.J.IntersectionType" or "org.openrewrite.java.tree.J$IntersectionType") { return new J.IntersectionType( diff --git a/Rewrite/src/Rewrite.Remote.Codec/Java/JavaSender.g.cs b/Rewrite/src/Rewrite.Remote.Codec/Java/JavaSender.g.cs index 87089c66..5f845440 100644 --- a/Rewrite/src/Rewrite.Remote.Codec/Java/JavaSender.g.cs +++ b/Rewrite/src/Rewrite.Remote.Codec/Java/JavaSender.g.cs @@ -368,6 +368,17 @@ public override J VisitInstanceOf(J.InstanceOf instanceOf, SenderContext ctx) return instanceOf; } + public override J VisitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, SenderContext ctx) + { + ctx.SendValue(deconstructionPattern, v => v.Id); + ctx.SendNode(deconstructionPattern, v => v.Prefix, SendSpace); + ctx.SendNode(deconstructionPattern, v => v.Markers, ctx.SendMarkers); + ctx.SendNode(deconstructionPattern, v => v.Deconstructor, ctx.SendTree); + ctx.SendNode(deconstructionPattern, v => v.Padding.Nested, SendContainer); + ctx.SendTypedValue(deconstructionPattern, v => v.Type); + return deconstructionPattern; + } + public override J VisitIntersectionType(J.IntersectionType intersectionType, SenderContext ctx) { ctx.SendValue(intersectionType, v => v.Id); diff --git a/Rewrite/src/Rewrite.Server/Program.cs b/Rewrite/src/Rewrite.Server/Program.cs index c152602f..44c97397 100644 --- a/Rewrite/src/Rewrite.Server/Program.cs +++ b/Rewrite/src/Rewrite.Server/Program.cs @@ -1,4 +1,5 @@ using Microsoft.CodeAnalysis; +using Rewrite.Remote.Server; using Parser = CommandLine.Parser; namespace Rewrite.Server; @@ -24,8 +25,8 @@ public static void Main(string[] args) var options = result.Value; - var server = new Server(options); - + var server = new Remote.Server.Server(options); + server.Listen().Wait(); } } diff --git a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java index fe7edf50..0b8f24a6 100644 --- a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java +++ b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java @@ -1497,6 +1497,17 @@ public J.InstanceOf visitInstanceOf(J.InstanceOf instanceOf, ReceiverContext ctx return instanceOf; } + @Override + public J.DeconstructionPattern visitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, ReceiverContext ctx) { + deconstructionPattern = deconstructionPattern.withId(ctx.receiveNonNullValue(deconstructionPattern.getId(), UUID.class)); + deconstructionPattern = deconstructionPattern.withPrefix(ctx.receiveNonNullNode(deconstructionPattern.getPrefix(), CSharpReceiver::receiveSpace)); + deconstructionPattern = deconstructionPattern.withMarkers(ctx.receiveNonNullNode(deconstructionPattern.getMarkers(), ctx::receiveMarkers)); + deconstructionPattern = deconstructionPattern.withDeconstructor(ctx.receiveNonNullNode(deconstructionPattern.getDeconstructor(), ctx::receiveTree)); + deconstructionPattern = deconstructionPattern.getPadding().withNested(ctx.receiveNonNullNode(deconstructionPattern.getPadding().getNested(), CSharpReceiver::receiveContainer)); + deconstructionPattern = deconstructionPattern.withType(ctx.receiveValue(deconstructionPattern.getType(), JavaType.class)); + return deconstructionPattern; + } + @Override public J.IntersectionType visitIntersectionType(J.IntersectionType intersectionType, ReceiverContext ctx) { intersectionType = intersectionType.withId(ctx.receiveNonNullValue(intersectionType.getId(), UUID.class)); @@ -2050,6 +2061,7 @@ protected Function computeValue(Class type) { if (type == J.If.Else.class) return Factory::createJIfElse; if (type == J.Import.class) return Factory::createJImport; if (type == J.InstanceOf.class) return Factory::createJInstanceOf; + if (type == J.DeconstructionPattern.class) return Factory::createJDeconstructionPattern; if (type == J.IntersectionType.class) return Factory::createJIntersectionType; if (type == J.Label.class) return Factory::createJLabel; if (type == J.Lambda.class) return Factory::createJLambda; @@ -3533,6 +3545,17 @@ private static J.InstanceOf createJInstanceOf(ReceiverContext ctx) { ); } + private static J.DeconstructionPattern createJDeconstructionPattern(ReceiverContext ctx) { + return new J.DeconstructionPattern( + ctx.receiveNonNullValue(null, UUID.class), + ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace), + ctx.receiveNonNullNode(null, ctx::receiveMarkers), + ctx.receiveNonNullNode(null, ctx::receiveTree), + ctx.receiveNonNullNode(null, CSharpReceiver::receiveContainer), + ctx.receiveValue(null, JavaType.class) + ); + } + private static J.IntersectionType createJIntersectionType(ReceiverContext ctx) { return new J.IntersectionType( ctx.receiveNonNullValue(null, UUID.class), diff --git a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java index 0ce0c9d5..ca50933a 100644 --- a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java +++ b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java @@ -1487,6 +1487,17 @@ public J.InstanceOf visitInstanceOf(J.InstanceOf instanceOf, SenderContext ctx) return instanceOf; } + @Override + public J.DeconstructionPattern visitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, SenderContext ctx) { + ctx.sendValue(deconstructionPattern, J.DeconstructionPattern::getId); + ctx.sendNode(deconstructionPattern, J.DeconstructionPattern::getPrefix, CSharpSender::sendSpace); + ctx.sendNode(deconstructionPattern, J.DeconstructionPattern::getMarkers, ctx::sendMarkers); + ctx.sendNode(deconstructionPattern, J.DeconstructionPattern::getDeconstructor, ctx::sendTree); + ctx.sendNode(deconstructionPattern, e -> e.getPadding().getNested(), CSharpSender::sendContainer); + ctx.sendTypedValue(deconstructionPattern, J.DeconstructionPattern::getType); + return deconstructionPattern; + } + @Override public J.IntersectionType visitIntersectionType(J.IntersectionType intersectionType, SenderContext ctx) { ctx.sendValue(intersectionType, J.IntersectionType::getId); diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java index 50f51f4f..e83d576d 100644 --- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java +++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java @@ -685,6 +685,11 @@ public J.InstanceOf visitInstanceOf(J.InstanceOf instanceOf, P p) { return (J.InstanceOf) super.visitInstanceOf(instanceOf, p); } + @Override + public J.DeconstructionPattern visitDeconstructionPattern(J.DeconstructionPattern deconstructionPattern, P p) { + return (J.DeconstructionPattern) super.visitDeconstructionPattern(deconstructionPattern, p); + } + @Override public J.IntersectionType visitIntersectionType(J.IntersectionType intersectionType, P p) { return (J.IntersectionType) super.visitIntersectionType(intersectionType, p);