diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d3d9d60..67c1598a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ env: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 with: diff --git a/Rewrite/dotnet-test.sh b/Rewrite/dotnet-test.sh new file mode 100644 index 00000000..833a0a8b --- /dev/null +++ b/Rewrite/dotnet-test.sh @@ -0,0 +1 @@ +dotnet test Rewrite.Sources.sln --filter "Category!=KnownBug & Category!=Exploratory" \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs b/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs index dfcb1902..7265226f 100644 --- a/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs +++ b/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs @@ -38,8 +38,9 @@ public CSharpPrinter() _delegate = new CSharpJavaPrinter(this); } - // [DebuggerNonUserCode] - // [DebuggerStepperBoundary] +#if DEBUG_VISITOR + [DebuggerStepThrough] +#endif public override J? Visit(Rewrite.Core.Tree? tree, PrintOutputCapture p) { if (!(tree is Cs)) @@ -369,6 +370,23 @@ public override Cs VisitFileScopeNamespaceDeclaration(Cs.FileScopeNamespaceDecla return usingDirective; } + public override Cs VisitLambda(Cs.Lambda lambda, PrintOutputCapture p) + { + var javaLambda = lambda.LambdaExpression; + BeforeSyntax(javaLambda, Space.Location.LAMBDA_PREFIX, p); + VisitSpace(javaLambda.Prefix, Space.Location.LAMBDA_PARAMETERS_PREFIX, p); + VisitMarkers(javaLambda.Markers, p); + // _delegate.VisitContainer(lambda.Modifiers, JContainer.Location.ANY, p); + foreach (var modifier in lambda.Modifiers) + { + _delegate.VisitModifier(modifier, p); + } + + Visit(javaLambda, p); + AfterSyntax(lambda, p); + return lambda; + } + protected override Space VisitSpace(Space space, CsSpace.Location loc, PrintOutputCapture p) { return _delegate.VisitSpace(space, Space.Location.LANGUAGE_EXTENSION, p); @@ -471,9 +489,12 @@ protected void VisitStatement(JRightPadded paddedStat, CsRightPadded. _delegate.PrintStatementTerminator(paddedStat.Element, p); } + private class CSharpJavaPrinter(CSharpPrinter _parent) : JavaPrinter { - [DebuggerHidden] +#if DEBUG_VISITOR + [DebuggerStepThrough] +#endif public override J? Visit(Rewrite.Core.Tree? tree, PrintOutputCapture p) { if (tree is Cs) @@ -844,12 +865,12 @@ public override Markers VisitMarkers(Markers? markers, PrintOutputCapture JAVA_MARKER_WRAPPER = o => "/*~~" + o + (string.IsNullOrEmpty(o) ? "" : "~~") + ">*/"; - private void BeforeSyntax(Cs cs, Space.Location loc, PrintOutputCapture p) + private void BeforeSyntax(J cs, Space.Location loc, PrintOutputCapture p) { BeforeSyntax(cs.Prefix, cs.Markers, loc, p); } - private void BeforeSyntax(Cs cs, CsSpace.Location loc, PrintOutputCapture p) + private void BeforeSyntax(J cs, CsSpace.Location loc, PrintOutputCapture p) { BeforeSyntax(cs.Prefix, cs.Markers, loc, p); } diff --git a/Rewrite/src/Rewrite.CSharp/CSharpVisitor.g.cs b/Rewrite/src/Rewrite.CSharp/CSharpVisitor.g.cs index 86f82b72..7fa657b9 100644 --- a/Rewrite/src/Rewrite.CSharp/CSharpVisitor.g.cs +++ b/Rewrite/src/Rewrite.CSharp/CSharpVisitor.g.cs @@ -314,6 +314,27 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) return propertyDeclaration; } + public virtual J? VisitLambda(Cs.Lambda lambda, P p) + { + lambda = lambda.WithPrefix(VisitSpace(lambda.Prefix, CsSpace.Location.LAMBDA_PREFIX, p)!); + var tempStatement = (Statement) VisitStatement(lambda, p); + if (tempStatement is not Cs.Lambda) + { + return tempStatement; + } + lambda = (Cs.Lambda) tempStatement; + var tempExpression = (Expression) VisitExpression(lambda, p); + if (tempExpression is not Cs.Lambda) + { + return tempExpression; + } + lambda = (Cs.Lambda) tempExpression; + lambda = lambda.WithMarkers(VisitMarkers(lambda.Markers, p)); + lambda = lambda.WithLambdaExpression(VisitAndCast(lambda.LambdaExpression, p)!); + lambda = lambda.WithModifiers(lambda.Modifiers.Map(el => (J.Modifier?)Visit(el, p))); + return lambda; + } + protected virtual JContainer? VisitContainer(JContainer? container, CsContainer.Location loc, P p) where J2 : J { if (container == null) { diff --git a/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs b/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs index 535052ad..33c9f83e 100644 --- a/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs +++ b/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs @@ -411,7 +411,7 @@ public override J VisitIdentifierName(IdentifierNameSyntax node) Core.Tree.RandomId(), prefix, fa.Markers, - new JRightPadded(fa.Target, Format(operatorToken.LeadingTrivia), Markers.EMPTY), + new JRightPadded(fa.Target, fa.Padding.Name.Before, Markers.EMPTY), null, fa.Name, MapArgumentList(node.ArgumentList), @@ -494,7 +494,7 @@ pt.Clazz is J.Identifier i private JContainer MapArgumentList(ArgumentListSyntax argumentList) { return new JContainer( - Format(Trailing(argumentList.OpenParenToken)), + Format(Leading(argumentList.OpenParenToken)), argumentList.Arguments.Select(MapArgument).ToList(), Markers.EMPTY ); @@ -1865,49 +1865,57 @@ private J.ArrayAccess MapArrayAccess(ElementAccessExpressionSyntax node, int ind ); } - public override J? VisitSimpleLambdaExpression(SimpleLambdaExpressionSyntax node) + public override J? VisitRefExpression(RefExpressionSyntax node) { - return new J.Lambda( - Core.Tree.RandomId(), - Format((Leading(node))), - Markers.EMPTY, - new J.Lambda.Parameters( - Core.Tree.RandomId(), - Space.EMPTY, - Markers.EMPTY, - false, - [ - MapParameter(node.Parameter) - ] - ), - Format(Leading(node.ArrowToken)), - Convert(node.Body)!, - MapType(node) - ); + return base.VisitRefExpression(node); } - public override J? VisitRefExpression(RefExpressionSyntax node) + public override J? VisitSimpleLambdaExpression(SimpleLambdaExpressionSyntax node) { - return base.VisitRefExpression(node); + return VisitLambdaExpressionSyntax(node); } public override J? VisitParenthesizedLambdaExpression(ParenthesizedLambdaExpressionSyntax node) { - return new J.Lambda( - Core.Tree.RandomId(), - Format((Leading(node))), - Markers.EMPTY, - new J.Lambda.Parameters( + return VisitLambdaExpressionSyntax(node); + } + + private J? VisitLambdaExpressionSyntax(LambdaExpressionSyntax node) + { + J.Lambda.Parameters parameters = node switch + { + ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpression => new J.Lambda.Parameters( Core.Tree.RandomId(), - Space.EMPTY, + Format(Trailing(node.AsyncKeyword)), Markers.EMPTY, true, - MapParameters(node.ParameterList)!.Elements - ), + MapParameters(parenthesizedLambdaExpression.ParameterList)!.Elements), + SimpleLambdaExpressionSyntax simpleLambdaExpression => new J.Lambda.Parameters( + Core.Tree.RandomId(), + Format(Trailing(node.AsyncKeyword)), + Markers.EMPTY, + false, + [MapParameter(simpleLambdaExpression.Parameter)]), + _ => throw new NotSupportedException($"Unsupported type {node.GetType()}") + }; + + var jLambda = new J.Lambda( + Core.Tree.RandomId(), + Space.EMPTY, + Markers.EMPTY, + parameters, Format(Leading(node.ArrowToken)), Convert(node.Body)!, MapType(node) ); + var csLambda = new Cs.Lambda( + Core.Tree.RandomId(), + Format((Leading(node))), + Markers.EMPTY, + jLambda, + MapModifiers(node.Modifiers) + ); + return csLambda; } public override J? VisitInitializerExpression(InitializerExpressionSyntax node) @@ -2493,7 +2501,7 @@ private JRightPadded MapAnonymousObjectMember(AnonymousObjectMemberDe public override J? VisitGlobalStatement(GlobalStatementSyntax node) { - return base.VisitGlobalStatement(node); + return node.Statement.Accept(this); } public override J? VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) @@ -3703,6 +3711,7 @@ private JRightPadded MapParameter(ParameterSyntax tps) where T : J )).ToList(); } + #if DEBUG_VISITOR [DebuggerStepThrough] #endif diff --git a/Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs index b3c8c20a..e37ce0fc 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs @@ -69,11 +69,16 @@ public AnnotatedStatement WithStatement(Statement newStatement) { return ReferenceEquals(newStatement, statement) ? this : new AnnotatedStatement(id, prefix, markers, attributeLists, newStatement); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is AnnotatedStatement && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs index 5c5e6fc0..d2e1f77c 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs @@ -105,11 +105,16 @@ public Cs.ArrayRankSpecifier WithSizes(JContainer newSizes) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ArrayRankSpecifier && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs index 55a7e9ed..35e7eb48 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs @@ -124,11 +124,16 @@ public Cs.AssignmentOperation WithOperator(JLeftPadded> newAttr } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is AttributeList && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs index 8f9be2bd..aac9df0d 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs @@ -69,11 +69,16 @@ public AwaitExpression WithType(JavaType? newType) { return newType == type ? this : new AwaitExpression(id, prefix, markers, expression, newType); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is AwaitExpression && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs index 9a60409c..5dad4fbd 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs @@ -125,11 +125,16 @@ public Cs.Binary WithOperator(JLeftPadded newOperator) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Binary && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs index de97af34..d4eb47a7 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs @@ -151,11 +151,16 @@ public Cs.BlockScopeNamespaceDeclaration WithMembers(IList> newE } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is CollectionExpression && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs index 9a3c5cd0..1fe88cf7 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs @@ -178,11 +178,16 @@ public Cs.CompilationUnit WithMembers(IList> newMembers) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is CompilationUnit && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs index 1d7c3528..301c1bdc 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs @@ -23,16 +23,23 @@ namespace Rewrite.RewriteCSharp.Tree; [SuppressMessage("ReSharper", "RedundantNameQualifier")] public partial interface Cs : J { + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif bool Core.Tree.IsAcceptable(ITreeVisitor v, P p) { return v.IsAdaptableTo(typeof(CSharpVisitor<>)); } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif R? Core.Tree.Accept(ITreeVisitor v, P p) where R : class { return (R?)AcceptCSharp(v.Adapt>(), p); } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif J? AcceptCSharp

(CSharpVisitor

v, P p) { return v.DefaultValue(this, p); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CsSpace.cs b/Rewrite/src/Rewrite.CSharp/Tree/CsSpace.cs index 40d9c620..09889085 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/CsSpace.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/CsSpace.cs @@ -60,5 +60,6 @@ public record Location public static readonly Location USING_DIRECTIVE_PREFIX = new(); public static readonly Location USING_DIRECTIVE_STATIC = new(); public static readonly Location USING_DIRECTIVE_UNSAFE = new(); + public static readonly Location LAMBDA_PREFIX = new(); } } diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs index 8d4c4197..43db066c 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs @@ -62,11 +62,16 @@ public ExpressionStatement WithExpression(Expression newExpression) { return ReferenceEquals(newExpression, expression) ? this : new ExpressionStatement(id, prefix, markers, newExpression); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ExpressionStatement && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs b/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs index 00df79ed..3c11d697 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs @@ -5,6 +5,10 @@ namespace Rewrite.RewriteCSharp.Tree; internal static class Extensions { + public static JavaType? GetJavaType(Cs.Lambda expr) + { + return expr.LambdaExpression.Type; + } public static JavaType? GetJavaType(Cs.ArrayRankSpecifier expr) { return expr.Sizes.Count == 0 ? null : expr.Sizes[0].Type; @@ -20,6 +24,17 @@ internal static class Extensions return expr.Expression.Type; } + public static Cs.Lambda WithJavaType(Cs.Lambda expr, JavaType newType) + { + return new Cs.Lambda( + expr.Id, + expr.Prefix, + expr.Markers, + expr.LambdaExpression.WithType(newType), + expr.Modifiers + ); + } + public static Cs.ArrayRankSpecifier WithJavaType(Cs.ArrayRankSpecifier expr, JavaType newType) { throw new NotImplementedException(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs index 77c08f78..4310ab37 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs @@ -99,11 +99,16 @@ public Cs.ExternAlias WithIdentifier(JLeftPadded newIdentifier) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ExternAlias && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs index 1219164c..8c22dd74 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs @@ -144,11 +144,16 @@ public Cs.FileScopeNamespaceDeclaration WithMembers(IList> newParts) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is InterpolatedString && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs index 2c4ad89f..45402899 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs @@ -135,11 +135,16 @@ public Cs.Interpolation WithFormat(JRightPadded? newFormat) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Interpolation && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Lambda.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Lambda.g.cs new file mode 100644 index 00000000..1261a4f8 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/Lambda.g.cs @@ -0,0 +1,93 @@ +//------------------------------------------------------------------------------ +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +#nullable enable +#pragma warning disable CS0108 +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using Rewrite.Core; +using Rewrite.Core.Marker; +using FileAttributes = Rewrite.Core.FileAttributes; +using Rewrite.RewriteJava.Tree; + +namespace Rewrite.RewriteCSharp.Tree; + +[SuppressMessage("ReSharper", "InconsistentNaming")] +[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")] +[SuppressMessage("ReSharper", "InvertIf")] +[SuppressMessage("ReSharper", "RedundantExtendsListEntry")] +[SuppressMessage("ReSharper", "UnusedMember.Global")] +[SuppressMessage("ReSharper", "RedundantNameQualifier")] +public partial interface Cs : J +{ + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif + public partial class Lambda( + Guid id, + Space prefix, + Markers markers, + J.Lambda lambdaExpression, + IList modifiers + ) : Cs, Statement, Expression, MutableTree + { + public J? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitLambda(this, p); + } + + public JavaType? Type => Extensions.GetJavaType(this); + + public Lambda WithType(JavaType newType) + { + return Extensions.WithJavaType(this, newType); + } + public Guid Id => id; + + public Lambda WithId(Guid newId) + { + return newId == id ? this : new Lambda(newId, prefix, markers, lambdaExpression, modifiers); + } + public Space Prefix => prefix; + + public Lambda WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new Lambda(id, newPrefix, markers, lambdaExpression, modifiers); + } + public Markers Markers => markers; + + public Lambda WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new Lambda(id, prefix, newMarkers, lambdaExpression, modifiers); + } + public J.Lambda LambdaExpression => lambdaExpression; + + public Lambda WithLambdaExpression(J.Lambda newLambdaExpression) + { + return ReferenceEquals(newLambdaExpression, lambdaExpression) ? this : new Lambda(id, prefix, markers, newLambdaExpression, modifiers); + } + public IList Modifiers => modifiers; + + public Lambda WithModifiers(IList newModifiers) + { + return newModifiers == modifiers ? this : new Lambda(id, prefix, markers, lambdaExpression, newModifiers); + } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif + public bool Equals(Rewrite.Core.Tree? other) + { + return other is Lambda && 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.CSharp/Tree/NamedArgument.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/NamedArgument.g.cs index 3ffa90df..3be5c279 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/NamedArgument.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/NamedArgument.g.cs @@ -112,11 +112,16 @@ public Cs.NamedArgument WithNameColumn(JRightPadded? newNameColumn } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is NamedArgument && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs index 96c0be61..3597d481 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs @@ -105,11 +105,16 @@ public Cs.NullSafeExpression WithExpression(JRightPadded newExpressi } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is NullSafeExpression && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs index d4f7c9f2..8346bbae 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs @@ -149,11 +149,16 @@ public Cs.PropertyDeclaration WithInitializer(JLeftPadded? newInitia } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is PropertyDeclaration && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs index 431b8c08..99398536 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs @@ -68,11 +68,16 @@ public StatementExpression WithStatement(Statement newStatement) { return ReferenceEquals(newStatement, statement) ? this : new StatementExpression(id, prefix, markers, newStatement); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is StatementExpression && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs index 59b438e0..7dbede96 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs @@ -151,11 +151,16 @@ public Cs.UsingDirective WithAlias(JRightPadded? newAlias) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is UsingDirective && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Core/Cursor.cs b/Rewrite/src/Rewrite.Core/Cursor.cs index 0113406a..54e7faf9 100644 --- a/Rewrite/src/Rewrite.Core/Cursor.cs +++ b/Rewrite/src/Rewrite.Core/Cursor.cs @@ -1,5 +1,10 @@ +using System.Diagnostics; + namespace Rewrite.Core; +#if DEBUG_VISITOR +[DebuggerStepThrough] +#endif public class Cursor { private readonly Cursor? _parent; diff --git a/Rewrite/src/Rewrite.Core/TreeVisitor.cs b/Rewrite/src/Rewrite.Core/TreeVisitor.cs index 86e3201e..848de047 100644 --- a/Rewrite/src/Rewrite.Core/TreeVisitor.cs +++ b/Rewrite/src/Rewrite.Core/TreeVisitor.cs @@ -2,7 +2,9 @@ using Rewrite.Core.Marker; namespace Rewrite.Core; - +#if DEBUG_VISITOR +[DebuggerStepThrough] +#endif public abstract class TreeVisitor : ITreeVisitor where T : class, Tree { diff --git a/Rewrite/src/Rewrite.Java/Tree/AnnotatedType.g.cs b/Rewrite/src/Rewrite.Java/Tree/AnnotatedType.g.cs index 26126936..a7fddf7e 100644 --- a/Rewrite/src/Rewrite.Java/Tree/AnnotatedType.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/AnnotatedType.g.cs @@ -74,11 +74,16 @@ public AnnotatedType WithTypeExpression(TypeTree newTypeExpression) { return ReferenceEquals(newTypeExpression, typeExpression) ? this : new AnnotatedType(id, prefix, markers, annotations, newTypeExpression); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is AnnotatedType && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Annotation.g.cs b/Rewrite/src/Rewrite.Java/Tree/Annotation.g.cs index b4e9e574..fde66b24 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Annotation.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Annotation.g.cs @@ -111,11 +111,16 @@ public J.Annotation WithArguments(JContainer? newArguments) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Annotation && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ArrayAccess.g.cs b/Rewrite/src/Rewrite.Java/Tree/ArrayAccess.g.cs index 8a11d5b5..f9858177 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ArrayAccess.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ArrayAccess.g.cs @@ -75,11 +75,16 @@ public ArrayAccess WithType(JavaType? newType) { return newType == type ? this : new ArrayAccess(id, prefix, markers, indexed, dimension, newType); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ArrayAccess && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ArrayDimension.g.cs b/Rewrite/src/Rewrite.Java/Tree/ArrayDimension.g.cs index 36136b25..2134be0e 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ArrayDimension.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ArrayDimension.g.cs @@ -98,11 +98,16 @@ public J.ArrayDimension WithIndex(JRightPadded newIndex) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ArrayDimension && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ArrayType.g.cs b/Rewrite/src/Rewrite.Java/Tree/ArrayType.g.cs index ca594459..de0a96c8 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ArrayType.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ArrayType.g.cs @@ -82,11 +82,16 @@ public ArrayType WithType(JavaType newType) { return newType == type ? this : new ArrayType(id, prefix, markers, elementType, annotations, dimension, newType); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ArrayType && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Assert.g.cs b/Rewrite/src/Rewrite.Java/Tree/Assert.g.cs index 240bc507..941277c4 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Assert.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Assert.g.cs @@ -68,11 +68,16 @@ public Assert WithDetail(JLeftPadded? newDetail) { return newDetail == detail ? this : new Assert(id, prefix, markers, condition, newDetail); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Assert && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Assignment.g.cs b/Rewrite/src/Rewrite.Java/Tree/Assignment.g.cs index 9fc787ee..9903b1fb 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Assignment.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Assignment.g.cs @@ -112,11 +112,16 @@ public J.Assignment WithExpression(JLeftPadded newExpression) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Assignment && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/AssignmentOperation.g.cs b/Rewrite/src/Rewrite.Java/Tree/AssignmentOperation.g.cs index 7fe3c686..ee3a522f 100644 --- a/Rewrite/src/Rewrite.Java/Tree/AssignmentOperation.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/AssignmentOperation.g.cs @@ -136,11 +136,16 @@ public J.AssignmentOperation WithOperator(JLeftPadded newOperator) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Binary && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Block.g.cs b/Rewrite/src/Rewrite.Java/Tree/Block.g.cs index ba0b8601..fe707e44 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Block.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Block.g.cs @@ -120,11 +120,16 @@ public J.Block WithStatements(IList> newStatements) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Block && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Break.g.cs b/Rewrite/src/Rewrite.Java/Tree/Break.g.cs index 4ae0c3ab..39af8e9b 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Break.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Break.g.cs @@ -61,11 +61,16 @@ public Break WithLabel(J.Identifier? newLabel) { return ReferenceEquals(newLabel, label) ? this : new Break(id, prefix, markers, newLabel); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Break && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Case.g.cs b/Rewrite/src/Rewrite.Java/Tree/Case.g.cs index 9090880b..3978d204 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Case.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Case.g.cs @@ -140,11 +140,16 @@ public J.Case WithBody(JRightPadded? newBody) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Case && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ClassDeclaration.g.cs b/Rewrite/src/Rewrite.Java/Tree/ClassDeclaration.g.cs index 5a50f66a..58abba79 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ClassDeclaration.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ClassDeclaration.g.cs @@ -216,11 +216,16 @@ public enum Type Record, Value, } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Kind && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); @@ -272,11 +277,16 @@ public J.ClassDeclaration WithPermits(JContainer? newPermits) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ClassDeclaration && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/CompilationUnit.g.cs b/Rewrite/src/Rewrite.Java/Tree/CompilationUnit.g.cs index ebb0a5de..3d4aedb8 100644 --- a/Rewrite/src/Rewrite.Java/Tree/CompilationUnit.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/CompilationUnit.g.cs @@ -162,11 +162,16 @@ public J.CompilationUnit WithImports(IList> newImports) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is CompilationUnit && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Continue.g.cs b/Rewrite/src/Rewrite.Java/Tree/Continue.g.cs index 8b6520b1..3d22beac 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Continue.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Continue.g.cs @@ -61,11 +61,16 @@ public Continue WithLabel(J.Identifier? newLabel) { return ReferenceEquals(newLabel, label) ? this : new Continue(id, prefix, markers, newLabel); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Continue && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ControlParentheses.g.cs b/Rewrite/src/Rewrite.Java/Tree/ControlParentheses.g.cs index feceecd3..10fa070f 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ControlParentheses.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ControlParentheses.g.cs @@ -104,11 +104,16 @@ public J.ControlParentheses WithTree(JRightPadded newTree) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is J.ControlParentheses && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/DoWhileLoop.g.cs b/Rewrite/src/Rewrite.Java/Tree/DoWhileLoop.g.cs index 858088f1..8fcac094 100644 --- a/Rewrite/src/Rewrite.Java/Tree/DoWhileLoop.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/DoWhileLoop.g.cs @@ -113,11 +113,16 @@ public J.DoWhileLoop WithWhileCondition(JLeftPadded> newEnums) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is EnumValueSet && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/FieldAccess.g.cs b/Rewrite/src/Rewrite.Java/Tree/FieldAccess.g.cs index d559e0d0..a4f7e715 100644 --- a/Rewrite/src/Rewrite.Java/Tree/FieldAccess.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/FieldAccess.g.cs @@ -112,11 +112,16 @@ public J.FieldAccess WithName(JLeftPadded newName) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is FieldAccess && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ForEachLoop.g.cs b/Rewrite/src/Rewrite.Java/Tree/ForEachLoop.g.cs index c190e4d3..679b9b5d 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ForEachLoop.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ForEachLoop.g.cs @@ -185,11 +185,16 @@ public J.ForEachLoop.Control WithIterable(JRightPadded newIterable) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Control && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); @@ -206,11 +211,16 @@ public J.ForEachLoop WithBody(JRightPadded newBody) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ForEachLoop && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ForLoop.g.cs b/Rewrite/src/Rewrite.Java/Tree/ForLoop.g.cs index e4569ae6..6fb5883d 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ForLoop.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ForLoop.g.cs @@ -200,11 +200,16 @@ public J.ForLoop.Control WithUpdate(IList> newUpdate) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Control && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); @@ -221,11 +226,16 @@ public J.ForLoop WithBody(JRightPadded newBody) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ForLoop && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Identifier.g.cs b/Rewrite/src/Rewrite.Java/Tree/Identifier.g.cs index 97196bb5..00673428 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Identifier.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Identifier.g.cs @@ -82,11 +82,16 @@ public Identifier WithFieldType(JavaType.Variable? newFieldType) { return newFieldType == fieldType ? this : new Identifier(id, prefix, markers, annotations, simpleName, type, newFieldType); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Identifier && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/If.g.cs b/Rewrite/src/Rewrite.Java/Tree/If.g.cs index 9bb18fff..6f71c3fa 100644 --- a/Rewrite/src/Rewrite.Java/Tree/If.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/If.g.cs @@ -177,11 +177,16 @@ public J.If.Else WithBody(JRightPadded newBody) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Else && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); @@ -198,11 +203,16 @@ public J.If WithThenPart(JRightPadded newThenPart) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is If && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Import.g.cs b/Rewrite/src/Rewrite.Java/Tree/Import.g.cs index ee000c7e..a347cf0d 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Import.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Import.g.cs @@ -120,11 +120,16 @@ public J.Import WithAlias(JLeftPadded? newAlias) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Import && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/InstanceOf.g.cs b/Rewrite/src/Rewrite.Java/Tree/InstanceOf.g.cs index cd4c876f..cd7aa22b 100644 --- a/Rewrite/src/Rewrite.Java/Tree/InstanceOf.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/InstanceOf.g.cs @@ -119,11 +119,16 @@ public J.InstanceOf WithExpression(JRightPadded newExpression) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is InstanceOf && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/IntersectionType.g.cs b/Rewrite/src/Rewrite.Java/Tree/IntersectionType.g.cs index 936cbcb7..2a5a606c 100644 --- a/Rewrite/src/Rewrite.Java/Tree/IntersectionType.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/IntersectionType.g.cs @@ -104,11 +104,16 @@ public J.IntersectionType WithBounds(JContainer newBounds) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is IntersectionType && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/J.g.cs b/Rewrite/src/Rewrite.Java/Tree/J.g.cs index 15044fc6..afd4a752 100644 --- a/Rewrite/src/Rewrite.Java/Tree/J.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/J.g.cs @@ -24,16 +24,23 @@ public partial interface J : Rewrite.Core.Tree { Space Prefix { get; } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif bool Core.Tree.IsAcceptable(ITreeVisitor v, P p) { return v.IsAdaptableTo(typeof(JavaVisitor<>)); } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif R? Core.Tree.Accept(ITreeVisitor v, P p) where R : class { return (R?)AcceptJava(v.Adapt>(), p); } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif J? AcceptJava

(JavaVisitor

v, P p) { return v.DefaultValue(this, p); diff --git a/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs b/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs index b35743d4..38aa3e0f 100644 --- a/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs +++ b/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs @@ -131,6 +131,10 @@ public JRightPadded Cast() where TNew : T public static class JRightPadded { + public static JRightPadded Create(T t) + { + return new JRightPadded(t, Space.EMPTY, Markers.EMPTY); + } public record Location(Space.Location AfterLocation) { public static readonly Location ANY = new(Space.Location.ANY); diff --git a/Rewrite/src/Rewrite.Java/Tree/Label.g.cs b/Rewrite/src/Rewrite.Java/Tree/Label.g.cs index cd0e10cb..acc22cba 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Label.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Label.g.cs @@ -105,11 +105,16 @@ public J.Label WithName(JRightPadded newName) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Label && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Lambda.g.cs b/Rewrite/src/Rewrite.Java/Tree/Lambda.g.cs index 077657cc..e4267a49 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Lambda.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Lambda.g.cs @@ -165,21 +165,31 @@ public J.Lambda.Parameters WithElements(IList> newElements) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Parameters && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); } } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Lambda && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Literal.g.cs b/Rewrite/src/Rewrite.Java/Tree/Literal.g.cs index 3e1b3b6e..7542db3b 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Literal.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Literal.g.cs @@ -100,11 +100,16 @@ public UnicodeEscape WithCodePoint(string newCodePoint) return newCodePoint == codePoint ? this : new UnicodeEscape(valueSourceIndex, newCodePoint); } } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Literal && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/MemberReference.g.cs b/Rewrite/src/Rewrite.Java/Tree/MemberReference.g.cs index 86eb3807..54fd9ded 100644 --- a/Rewrite/src/Rewrite.Java/Tree/MemberReference.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/MemberReference.g.cs @@ -149,11 +149,16 @@ public J.MemberReference WithReference(JLeftPadded newReference) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is MemberReference && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/MethodDeclaration.g.cs b/Rewrite/src/Rewrite.Java/Tree/MethodDeclaration.g.cs index f41c5f1a..98835b0e 100644 --- a/Rewrite/src/Rewrite.Java/Tree/MethodDeclaration.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/MethodDeclaration.g.cs @@ -263,11 +263,16 @@ public J.MethodDeclaration WithDefaultValue(JLeftPadded? newDefaultV } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is MethodDeclaration && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/MethodInvocation.g.cs b/Rewrite/src/Rewrite.Java/Tree/MethodInvocation.g.cs index 7dcda7ab..8b7cbc55 100644 --- a/Rewrite/src/Rewrite.Java/Tree/MethodInvocation.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/MethodInvocation.g.cs @@ -148,11 +148,16 @@ public J.MethodInvocation WithArguments(JContainer newArguments) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is MethodInvocation && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Modifier.g.cs b/Rewrite/src/Rewrite.Java/Tree/Modifier.g.cs index dcb908ad..e31fb60b 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Modifier.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Modifier.g.cs @@ -96,11 +96,16 @@ public enum Type Inline, LanguageExtension, } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Modifier && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/MultiCatch.g.cs b/Rewrite/src/Rewrite.Java/Tree/MultiCatch.g.cs index 0758d754..483863d6 100644 --- a/Rewrite/src/Rewrite.Java/Tree/MultiCatch.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/MultiCatch.g.cs @@ -98,11 +98,16 @@ public J.MultiCatch WithAlternatives(IList> newAlternativ } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is MultiCatch && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/NewArray.g.cs b/Rewrite/src/Rewrite.Java/Tree/NewArray.g.cs index cde9ef43..0a152294 100644 --- a/Rewrite/src/Rewrite.Java/Tree/NewArray.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/NewArray.g.cs @@ -119,11 +119,16 @@ public J.NewArray WithInitializer(JContainer? newInitializer) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is NewArray && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/NewClass.g.cs b/Rewrite/src/Rewrite.Java/Tree/NewClass.g.cs index 7e2d2c42..8dce4ed8 100644 --- a/Rewrite/src/Rewrite.Java/Tree/NewClass.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/NewClass.g.cs @@ -147,11 +147,16 @@ public J.NewClass WithArguments(JContainer newArguments) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is NewClass && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/NullableType.g.cs b/Rewrite/src/Rewrite.Java/Tree/NullableType.g.cs index 0bce00e4..c7f02ddd 100644 --- a/Rewrite/src/Rewrite.Java/Tree/NullableType.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/NullableType.g.cs @@ -111,11 +111,16 @@ public J.NullableType WithTypeTree(JRightPadded newTypeTree) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is NullableType && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Package.g.cs b/Rewrite/src/Rewrite.Java/Tree/Package.g.cs index d68583c3..2f6d4287 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Package.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Package.g.cs @@ -68,11 +68,16 @@ public Package WithAnnotations(IList newAnnotations) { return newAnnotations == annotations ? this : new Package(id, prefix, markers, expression, newAnnotations); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Package && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ParameterizedType.g.cs b/Rewrite/src/Rewrite.Java/Tree/ParameterizedType.g.cs index 325217c0..70c85253 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ParameterizedType.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ParameterizedType.g.cs @@ -112,11 +112,16 @@ public J.ParameterizedType WithTypeParameters(JContainer? newTypePar } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ParameterizedType && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Parentheses.g.cs b/Rewrite/src/Rewrite.Java/Tree/Parentheses.g.cs index b0bc7e53..a4674c46 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Parentheses.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Parentheses.g.cs @@ -104,11 +104,16 @@ public J.Parentheses WithTree(JRightPadded newTree) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is J.Parentheses && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/ParenthesizedTypeTree.g.cs b/Rewrite/src/Rewrite.Java/Tree/ParenthesizedTypeTree.g.cs index 1458c412..5a575592 100644 --- a/Rewrite/src/Rewrite.Java/Tree/ParenthesizedTypeTree.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/ParenthesizedTypeTree.g.cs @@ -74,11 +74,16 @@ public ParenthesizedTypeTree WithParenthesizedType(J.Parentheses newPa { return ReferenceEquals(newParenthesizedType, parenthesizedType) ? this : new ParenthesizedTypeTree(id, prefix, markers, annotations, newParenthesizedType); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is ParenthesizedTypeTree && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Primitive.g.cs b/Rewrite/src/Rewrite.Java/Tree/Primitive.g.cs index 390e9f6f..6078f327 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Primitive.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Primitive.g.cs @@ -61,11 +61,16 @@ public Primitive WithType(JavaType.Primitive newType) { return newType == type ? this : new Primitive(id, prefix, markers, newType); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Primitive && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Return.g.cs b/Rewrite/src/Rewrite.Java/Tree/Return.g.cs index 7998ba19..d03ab47b 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Return.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Return.g.cs @@ -61,11 +61,16 @@ public Return WithExpression(Expression? newExpression) { return ReferenceEquals(newExpression, expression) ? this : new Return(id, prefix, markers, newExpression); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Return && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Switch.g.cs b/Rewrite/src/Rewrite.Java/Tree/Switch.g.cs index d04b78aa..5775b422 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Switch.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Switch.g.cs @@ -68,11 +68,16 @@ public Switch WithCases(J.Block newCases) { return ReferenceEquals(newCases, cases) ? this : new Switch(id, prefix, markers, selector, newCases); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Switch && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/SwitchExpression.g.cs b/Rewrite/src/Rewrite.Java/Tree/SwitchExpression.g.cs index 52fe2dea..6291faad 100644 --- a/Rewrite/src/Rewrite.Java/Tree/SwitchExpression.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/SwitchExpression.g.cs @@ -74,11 +74,16 @@ public SwitchExpression WithCases(J.Block newCases) { return ReferenceEquals(newCases, cases) ? this : new SwitchExpression(id, prefix, markers, selector, newCases); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is SwitchExpression && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Synchronized.g.cs b/Rewrite/src/Rewrite.Java/Tree/Synchronized.g.cs index 3c142b74..0acb4bb4 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Synchronized.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Synchronized.g.cs @@ -68,11 +68,16 @@ public Synchronized WithBody(J.Block newBody) { return ReferenceEquals(newBody, body) ? this : new Synchronized(id, prefix, markers, @lock, newBody); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Synchronized && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Ternary.g.cs b/Rewrite/src/Rewrite.Java/Tree/Ternary.g.cs index 5d01bcc2..4a62ed8c 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Ternary.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Ternary.g.cs @@ -127,11 +127,16 @@ public J.Ternary WithFalsePart(JLeftPadded newFalsePart) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Ternary && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Throw.g.cs b/Rewrite/src/Rewrite.Java/Tree/Throw.g.cs index 5badb55f..76e7bcc1 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Throw.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Throw.g.cs @@ -61,11 +61,16 @@ public Throw WithException(Expression newException) { return ReferenceEquals(newException, exception) ? this : new Throw(id, prefix, markers, newException); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Throw && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Try.g.cs b/Rewrite/src/Rewrite.Java/Tree/Try.g.cs index 0ae848f4..e9c24c44 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Try.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Try.g.cs @@ -155,11 +155,16 @@ public Resource WithTerminatedWithSemicolon(bool newTerminatedWithSemicolon) { return newTerminatedWithSemicolon == terminatedWithSemicolon ? this : new Resource(id, prefix, markers, variableDeclarations, newTerminatedWithSemicolon); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Resource && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); @@ -211,11 +216,16 @@ public Catch WithBody(J.Block newBody) { return ReferenceEquals(newBody, body) ? this : new Catch(id, prefix, markers, parameter, newBody); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Catch && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); @@ -239,11 +249,16 @@ public J.Try WithFinally(JLeftPadded? newFinally) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Try && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/TypeCast.g.cs b/Rewrite/src/Rewrite.Java/Tree/TypeCast.g.cs index 19b80ba6..fed6a61f 100644 --- a/Rewrite/src/Rewrite.Java/Tree/TypeCast.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/TypeCast.g.cs @@ -74,11 +74,16 @@ public TypeCast WithExpression(Expression newExpression) { return ReferenceEquals(newExpression, expression) ? this : new TypeCast(id, prefix, markers, clazz, newExpression); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is TypeCast && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/TypeParameter.g.cs b/Rewrite/src/Rewrite.Java/Tree/TypeParameter.g.cs index 39a075ba..a191b484 100644 --- a/Rewrite/src/Rewrite.Java/Tree/TypeParameter.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/TypeParameter.g.cs @@ -119,11 +119,16 @@ public J.TypeParameter WithBounds(JContainer? newBounds) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is TypeParameter && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/TypeParameters.g.cs b/Rewrite/src/Rewrite.Java/Tree/TypeParameters.g.cs index cd94601e..06664980 100644 --- a/Rewrite/src/Rewrite.Java/Tree/TypeParameters.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/TypeParameters.g.cs @@ -105,11 +105,16 @@ public J.TypeParameters WithParameters(IList> newP } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is TypeParameters && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Unary.g.cs b/Rewrite/src/Rewrite.Java/Tree/Unary.g.cs index 91432d3a..d6143f44 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Unary.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Unary.g.cs @@ -123,11 +123,16 @@ public J.Unary WithOperator(JLeftPadded newOperator) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Unary && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Unknown.g.cs b/Rewrite/src/Rewrite.Java/Tree/Unknown.g.cs index 62373d14..41a66426 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Unknown.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Unknown.g.cs @@ -106,21 +106,31 @@ public Source WithText(string newText) { return newText == text ? this : new Source(id, prefix, markers, newText); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Source && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); } } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Unknown && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/VariableDeclarations.g.cs b/Rewrite/src/Rewrite.Java/Tree/VariableDeclarations.g.cs index f8d30d4f..274608cf 100644 --- a/Rewrite/src/Rewrite.Java/Tree/VariableDeclarations.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/VariableDeclarations.g.cs @@ -219,11 +219,16 @@ public J.VariableDeclarations.NamedVariable WithInitializer(JLeftPadded newBody) } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is WhileLoop && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Wildcard.g.cs b/Rewrite/src/Rewrite.Java/Tree/Wildcard.g.cs index 1c68f8ab..a14d11c7 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Wildcard.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Wildcard.g.cs @@ -116,11 +116,16 @@ public J.Wildcard WithWildcardBound(JLeftPadded? newWildcardBo } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Wildcard && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Java/Tree/Yield.g.cs b/Rewrite/src/Rewrite.Java/Tree/Yield.g.cs index 26ec611d..5c122388 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Yield.g.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Yield.g.cs @@ -68,11 +68,16 @@ public Yield WithValue(Expression newValue) { return ReferenceEquals(newValue, value) ? this : new Yield(id, prefix, markers, @implicit, newValue); } + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public bool Equals(Rewrite.Core.Tree? other) { return other is Yield && other.Id == Id; } - + #if DEBUG_VISITOR + [DebuggerStepThrough] + #endif public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/GlobalImports.cs b/Rewrite/tests/Rewrite.CSharp.Tests/GlobalImports.cs index ff3b0905..2ab8f3cf 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/GlobalImports.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/GlobalImports.cs @@ -1,3 +1,4 @@ global using Rewrite.RewriteCSharp.Tree; global using Rewrite.RewriteJava.Tree; global using Rewrite.Core; +global using Rewrite.RewriteCSharp.Test.Api; diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs index 2a5d1946..2ace599d 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs @@ -43,4 +43,5 @@ async System.Threading.Tasks.Task M() ) ); } + } diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/GlobalTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/GlobalTests.cs new file mode 100644 index 00000000..4116fe25 --- /dev/null +++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/GlobalTests.cs @@ -0,0 +1,16 @@ +namespace Rewrite.CSharp.Tests.Tree; +using static Assertions; +[Collection(Collections.PrinterAccess)] +public class GlobalTests : RewriteTest +{ + [Fact] + void TopLevelProgram() + { + RewriteRun( + CSharp( + """ + var x = "hi"; + """ + )); + } +} diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs index 8f618b20..17e68f68 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs @@ -99,4 +99,11 @@ class Test { ); } + [Fact] + [KnownBug] + private void AsyncLambda() + { + RewriteRun(CSharp("Task.Run(async () => {});")); + } + } diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs index 267297e9..abc9ab50 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs @@ -10,7 +10,6 @@ namespace Rewrite.CSharp.Tests.Tree; public class MemberAccessTests : RewriteTest { [Fact] - [KnownBug] public void MultilineLinq() { var src = CSharp( @@ -19,13 +18,11 @@ public class Foo { void Test() { - "blah".Skip() + /*1*/ "blah".Skip()/*2*/ .ToList(); } } """); - var cu = src.Parse().First(); - var result = cu.Print(); RewriteRun(src); } diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs index ae189acc..516c718e 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using Rewrite.RewriteCSharp.Test.Api; using Rewrite.Test; @@ -113,5 +114,24 @@ public static Func Something() """ ) ); + + } + + [Fact] + public void ArgumentOnNewLine() + { + RewriteRun( + CSharp( + """ + public class T + { + void Main() + { + /*1*/ Something( + /*2*/ there); + } + } + """) + ); } } 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 00d6ef95..f809fe0c 100644 --- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java +++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java @@ -13,6 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* + * -------------------THIS FILE IS AUTO GENERATED-------------------------- + * Changes to this file may cause incorrect behavior and will be lost if + * the code is regenerated. +*/ + package org.openrewrite.csharp; import org.jspecify.annotations.Nullable; @@ -123,6 +130,11 @@ public Cs.PropertyDeclaration visitPropertyDeclaration(Cs.PropertyDeclaration pr return (Cs.PropertyDeclaration) super.visitPropertyDeclaration(propertyDeclaration, p); } + @Override + public Cs.Lambda visitLambda(Cs.Lambda lambda, P p) { + return (Cs.Lambda) super.visitLambda(lambda, p); + } + @Override public J.AnnotatedType visitAnnotatedType(J.AnnotatedType annotatedType, P p) { return (J.AnnotatedType) super.visitAnnotatedType(annotatedType, p); diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java index 3b165a4c..c41637be 100644 --- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java +++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java @@ -299,6 +299,24 @@ public J visitUsingDirective(Cs.UsingDirective usingDirective, PrintOutputCaptur return usingDirective; } + @Override + public Cs visitLambda(Cs.Lambda lambda, PrintOutputCapture

p) + { + J.Lambda javaLambda = lambda.getLambdaExpression(); + beforeSyntax(javaLambda, Space.Location.LAMBDA_PREFIX, p); + visitSpace(javaLambda.getPrefix(), Space.Location.LAMBDA_PARAMETERS_PREFIX, p); + visitMarkers(javaLambda.getMarkers(), p); + // _delegate.VisitContainer(lambda.Modifiers, JContainer.Location.ANY, p); + for(J.Modifier modifier : lambda.getModifiers()) + { + delegate.visitModifier(modifier, p); + } + + visit(javaLambda, p); + afterSyntax(lambda, p); + return lambda; + } + @Override public Space visitSpace(Space space, CsSpace.Location loc, PrintOutputCapture

p) { return delegate.visitSpace(space, Space.Location.LANGUAGE_EXTENSION, p); @@ -719,12 +737,12 @@ public M visitMarker(Marker marker, PrintOutputCapture

p) private static final UnaryOperator JAVA_MARKER_WRAPPER = out -> "/*~~" + out + (out.isEmpty() ? "" : "~~") + ">*/"; - private void beforeSyntax(Cs cs, Space.Location loc, PrintOutputCapture

p) { - beforeSyntax(cs.getPrefix(), cs.getMarkers(), loc, p); + private void beforeSyntax(J j, Space.Location loc, PrintOutputCapture

p) { + beforeSyntax(j.getPrefix(), j.getMarkers(), loc, p); } - private void beforeSyntax(Cs cs, CsSpace.Location loc, PrintOutputCapture

p) { - beforeSyntax(cs.getPrefix(), cs.getMarkers(), loc, p); + private void beforeSyntax(J j, CsSpace.Location loc, PrintOutputCapture

p) { + beforeSyntax(j.getPrefix(), j.getMarkers(), loc, p); } private void beforeSyntax(Space prefix, Markers markers, CsSpace.@Nullable Location loc, PrintOutputCapture

p) { diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java index 2e0bb3cb..122d11b3 100644 --- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java +++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java @@ -13,6 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* + * -------------------THIS FILE IS AUTO GENERATED-------------------------- + * Changes to this file may cause incorrect behavior and will be lost if + * the code is regenerated. +*/ + package org.openrewrite.csharp; import org.jspecify.annotations.Nullable; @@ -304,6 +311,26 @@ public J visitPropertyDeclaration(Cs.PropertyDeclaration propertyDeclaration, P return propertyDeclaration; } + public J visitLambda(Cs.Lambda lambda, P p) { + lambda = lambda.withPrefix(visitSpace(lambda.getPrefix(), CsSpace.Location.LAMBDA_PREFIX, p)); + Statement tempStatement = (Statement) visitStatement(lambda, p); + if (!(tempStatement instanceof Cs.Lambda)) + { + return tempStatement; + } + lambda = (Cs.Lambda) tempStatement; + Expression tempExpression = (Expression) visitExpression(lambda, p); + if (!(tempExpression instanceof Cs.Lambda)) + { + return tempExpression; + } + lambda = (Cs.Lambda) tempExpression; + lambda = lambda.withMarkers(visitMarkers(lambda.getMarkers(), p)); + lambda = lambda.withLambdaExpression(visitAndCast(lambda.getLambdaExpression(), p)); + lambda = lambda.withModifiers(ListUtils.map(lambda.getModifiers(), el -> (J.Modifier)visit(el, p))); + return lambda; + } + public JContainer visitContainer(@Nullable JContainer container, CsContainer.Location loc, P p) { if (container == null) { diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java index 8330876d..fd0c71b6 100644 --- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java +++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java @@ -1883,4 +1883,65 @@ public PropertyDeclaration withInitializer(@Nullable JLeftPadded ini } } } + + + + + @Getter + @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @RequiredArgsConstructor + final class Lambda implements Cs, Statement, Expression { + @Override + public

J acceptCSharp(CSharpVisitor

v, P p) { + return v.visitLambda(this, p); + } + + @With + @Getter + @EqualsAndHashCode.Include + UUID id; + + @With + @Getter + Space prefix; + + @With + @Getter + Markers markers; + + @With + @Getter + J.Lambda lambdaExpression; + + @With + @Getter + List modifiers; + + @Override + public CoordinateBuilder.Statement getCoordinates() { + return new CoordinateBuilder.Statement(this); + } + + @Override + public @Nullable JavaType getType() { + return lambdaExpression.getType(); + } + + @Override + public Cs.Lambda withType(@Nullable JavaType type) { + return this.getType() == type ? this : new Cs.Lambda( + id, + prefix, + markers, + lambdaExpression.withType(type), + modifiers); + } + + @Override + public String toString() { + return withPrefix(Space.EMPTY).printTrimmed(new CSharpPrinter<>()); + } + } + } diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/CsSpace.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/CsSpace.java index 821d9975..daa1d624 100644 --- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/CsSpace.java +++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/CsSpace.java @@ -67,5 +67,6 @@ public enum Location { USING_DIRECTIVE_STATIC, USING_DIRECTIVE_UNSAFE, NAMED_ARGUMENT_NAME_COLUMN_SUFFIX, + LAMBDA_PREFIX } }