Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Rewrite/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
<EmbeddedServer>true</EmbeddedServer>
</PropertyGroup>

<PropertyGroup Condition="'$(RELEASE_PUBLICATION)'!=''">
<RewriteRemoteVersion>0.15.0</RewriteRemoteVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(RELEASE_PUBLICATION)'==''">
<RewriteRemoteVersion>0.15.0</RewriteRemoteVersion>
<PropertyGroup>
<RewriteRemoteVersion>0.18.1</RewriteRemoteVersion>
</PropertyGroup>

<Import Project="Directory.Build.props.user" Condition="Exists('Directory.Build.props.user')"/>
Expand Down
9 changes: 9 additions & 0 deletions Rewrite/src/Rewrite.Java/JavaVisitor.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expression>(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)!);
Expand Down
131 changes: 131 additions & 0 deletions Rewrite/src/Rewrite.Java/Tree/DeconstructionPattern.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#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<J> nested,
JavaType type
) : J, TypedTree, TypedTree<DeconstructionPattern>, J<DeconstructionPattern>, MutableTree<DeconstructionPattern>
{
[NonSerialized] private WeakReference<PaddingHelper>? _padding;

public PaddingHelper Padding
{
get
{
PaddingHelper? p;
if (_padding == null)
{
p = new PaddingHelper(this);
_padding = new WeakReference<PaddingHelper>(p);
}
else
{
_padding.TryGetTarget(out p);
if (p == null || p.T != this)
{
p = new PaddingHelper(this);
_padding.SetTarget(p);
}
}
return p;
}
}

public J? AcceptJava<P>(JavaVisitor<P> 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<J> _nested = nested;
public IList<J> Nested => _nested.GetElements();

public DeconstructionPattern WithNested(IList<J> newNested)
{
return Padding.WithNested(JContainer<J>.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<J> Nested => T._nested;

public J.DeconstructionPattern WithNested(JContainer<J> 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();
}
}
}
1 change: 1 addition & 0 deletions Rewrite/src/Rewrite.Java/Tree/JContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 13 additions & 11 deletions Rewrite/src/Rewrite.Java/Tree/Space.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -228,15 +228,18 @@ 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,
EMPTY_PREFIX,
ENUM_VALUE_PREFIX,
ENUM_VALUE_SET_PREFIX,
ENUM_VALUE_SUFFIX,
ERRONEOUS_PREFIX,
EXPRESSION_PREFIX,
EXTENDS,
FIELD_ACCESS_NAME,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -302,6 +304,7 @@ public enum Location
PARAMETERIZED_TYPE_PREFIX,
PARENTHESES_PREFIX,
PARENTHESES_SUFFIX,
PERMITS,
PERMITS_SUFFIX,
PRIMITIVE_PREFIX,
RECORD_STATE_VECTOR,
Expand All @@ -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,
Expand Down Expand Up @@ -344,7 +347,6 @@ public enum Location
WILDCARD_BOUND,
WILDCARD_PREFIX,
YIELD_PREFIX,
ERRONEOUS_PREFIX,
}

private static Space Build(string str, IList<Comment> comments)
Expand Down
23 changes: 23 additions & 0 deletions Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)!);
Expand Down Expand Up @@ -3476,6 +3487,18 @@ public Rewrite.Core.Tree Create<T>(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<J>), ReceiveContainer)!,
ctx.ReceiveValue(default(JavaType))!
);
}

if (type is "Rewrite.RewriteCSharp.Tree.J.IntersectionType" or "org.openrewrite.java.tree.J$IntersectionType")
{
return new J.IntersectionType(
Expand Down
11 changes: 11 additions & 0 deletions Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions Rewrite/src/Rewrite.Remote.Codec/Java/JavaReceiver.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)!);
Expand Down Expand Up @@ -1166,6 +1177,18 @@ public Rewrite.Core.Tree Create<T>(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<J>), ReceiveContainer)!,
ctx.ReceiveValue(default(JavaType))!
);
}

if (type is "Rewrite.RewriteJava.Tree.J.IntersectionType" or "org.openrewrite.java.tree.J$IntersectionType")
{
return new J.IntersectionType(
Expand Down
11 changes: 11 additions & 0 deletions Rewrite/src/Rewrite.Remote.Codec/Java/JavaSender.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading
Loading