From 92cf684c5eae90e107043445f22fc83136215299 Mon Sep 17 00:00:00 2001 From: Andrew Stakhov Date: Thu, 12 Sep 2024 10:49:31 -0400 Subject: [PATCH 1/3] Clean up all warnings, adjust nullability across solution, treat future warnings as errors --- Rewrite/.editorconfig | 19 +++++ Rewrite/ClearBinObjFolders.bat | 4 + Rewrite/Directory.Build.props | 7 +- Rewrite/Directory.Build.targets | 7 +- Rewrite/Rewrite.sln | 47 ++++++++++++ .../src/Rewrite.CSharp.Test.Api/Assertions.cs | 4 +- .../Rewrite.CSharp.Test.Api.csproj | 7 +- Rewrite/src/Rewrite.CSharp/CSharpParser.cs | 2 +- Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs | 9 ++- Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs | 2 +- .../Parser/CSharpParserVisitor.cs | 29 ++++---- Rewrite/src/Rewrite.CSharp/Tree/Cs.cs | 10 ++- .../Rewrite.Core/Config/OptionDescriptor.cs | 4 +- .../Rewrite.Core/Config/RecipeDescriptor.cs | 16 ++-- Rewrite/src/Rewrite.Core/Cursor.cs | 12 +-- Rewrite/src/Rewrite.Core/Extensions.cs | 11 ++- Rewrite/src/Rewrite.Core/ITreeVisitor.cs | 6 +- .../Rewrite.Core/Internal/ExceptionUtils.cs | 18 +++-- Rewrite/src/Rewrite.Core/ListUtils.cs | 7 +- .../Rewrite.Core/Marker/UnknownJavaMarker.cs | 4 +- Rewrite/src/Rewrite.Core/ParseError.cs | 2 +- Rewrite/src/Rewrite.Core/ParseErrorResult.cs | 16 ++-- Rewrite/src/Rewrite.Core/Parser.cs | 4 +- .../src/Rewrite.Core/PrintOutputCapture.cs | 4 +- Rewrite/src/Rewrite.Core/Quark/Quark.cs | 4 +- Rewrite/src/Rewrite.Core/Recipe.cs | 8 +- Rewrite/src/Rewrite.Core/TreeVisitor.cs | 14 ++-- Rewrite/src/Rewrite.Core/Validated.cs | 2 +- Rewrite/src/Rewrite.Java/JavaPrinter.cs | 33 ++++----- Rewrite/src/Rewrite.Java/JavaTypeCache.cs | 4 +- .../Rewrite.Java/JavaTypeSignatureBuilder.cs | 6 +- Rewrite/src/Rewrite.Java/JavaVisitor.cs | 8 +- Rewrite/src/Rewrite.Java/Tree/Extensions.cs | 9 ++- Rewrite/src/Rewrite.Java/Tree/Flag.cs | 5 +- Rewrite/src/Rewrite.Java/Tree/JContainer.cs | 11 ++- Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs | 4 +- Rewrite/src/Rewrite.Java/Tree/JavaType.cs | 73 ++++++++++--------- .../src/Rewrite.Properties/Tree/Properties.cs | 10 ++- Rewrite/src/Rewrite.Test/RewriteTest.cs | 10 +-- Rewrite/src/Rewrite.Test/RewriteTestUtils.cs | 4 +- Rewrite/src/Rewrite.Xml/Tree/Extensions.cs | 12 +-- Rewrite/src/Rewrite.Xml/Tree/Xml.cs | 6 +- Rewrite/src/Rewrite.Xml/XmlPrinter.cs | 6 +- Rewrite/src/Rewrite.Xml/XmlVisitor.cs | 18 ++--- .../CSharpTypeAttributionTests.cs | 1 + .../FindClassDeclarationTests.cs | 21 +++--- .../Rewrite.CSharp.Tests/FindClassTests.cs | 9 ++- 47 files changed, 320 insertions(+), 209 deletions(-) create mode 100644 Rewrite/.editorconfig create mode 100644 Rewrite/ClearBinObjFolders.bat diff --git a/Rewrite/.editorconfig b/Rewrite/.editorconfig new file mode 100644 index 00000000..22d11dec --- /dev/null +++ b/Rewrite/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 4 +tab-width = 4 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{build,config,csproj,js,json,proj,props,targets,xml,ruleset,xsd,yml,yaml}] +indent_size = 2 +tab-width = 2 +max_line_length = 160 + +[*.{cs,cshtml,ascx,aspx}] \ No newline at end of file diff --git a/Rewrite/ClearBinObjFolders.bat b/Rewrite/ClearBinObjFolders.bat new file mode 100644 index 00000000..5535358b --- /dev/null +++ b/Rewrite/ClearBinObjFolders.bat @@ -0,0 +1,4 @@ +FOR /F "tokens=*" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G" +FOR /F "tokens=*" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G" +FOR /F "tokens=*" %%G IN ('DIR /B /AD /S tmp') DO RMDIR /S /Q "%%G" +FOR /F "tokens=*" %%G IN ('DIR /B /AD /S target') DO RMDIR /S /Q "%%G" \ No newline at end of file diff --git a/Rewrite/Directory.Build.props b/Rewrite/Directory.Build.props index b10e0669..2665ac9f 100644 --- a/Rewrite/Directory.Build.props +++ b/Rewrite/Directory.Build.props @@ -1,10 +1,15 @@ + + enable + enable + true + latest + Moderne Inc. openrewrite.png Apache-2.0 0.8.4 - 0.8.0-preview-10 ..\..\..\..\..\moderneinc\rewrite-remote\Rewrite.Remote diff --git a/Rewrite/Directory.Build.targets b/Rewrite/Directory.Build.targets index f2f1b03b..c1dcff04 100644 --- a/Rewrite/Directory.Build.targets +++ b/Rewrite/Directory.Build.targets @@ -2,7 +2,12 @@ - + + + + + + public override J VisitUnknown(J.Unknown unknown, int p) { var parentCursor = Cursor.Parent!; - object container = unknown; + object? container = unknown; while (parentCursor.Value is not Core.Tree) { container = parentCursor.Value; @@ -120,4 +120,4 @@ public override J VisitUnknown(J.Unknown unknown, int p) unknown.Should().BeNull(because: "parser must not produce `J.Unknown` nodes"); return unknown; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.CSharp.Test.Api/Rewrite.CSharp.Test.Api.csproj b/Rewrite/src/Rewrite.CSharp.Test.Api/Rewrite.CSharp.Test.Api.csproj index 31f63ca3..98c45614 100644 --- a/Rewrite/src/Rewrite.CSharp.Test.Api/Rewrite.CSharp.Test.Api.csproj +++ b/Rewrite/src/Rewrite.CSharp.Test.Api/Rewrite.CSharp.Test.Api.csproj @@ -8,7 +8,7 @@ false C# recipe test support for the automated code refactoring framework OpenRewrite. - + @@ -28,17 +28,16 @@ - - + %(RecursiveDir)%(Filename)%(Extension) - + diff --git a/Rewrite/src/Rewrite.CSharp/CSharpParser.cs b/Rewrite/src/Rewrite.CSharp/CSharpParser.cs index f618d879..9b1dc148 100644 --- a/Rewrite/src/Rewrite.CSharp/CSharpParser.cs +++ b/Rewrite/src/Rewrite.CSharp/CSharpParser.cs @@ -72,7 +72,7 @@ public IEnumerable ParseInputs(IEnumerable source var semanticModel = compilation.GetSemanticModel(syntaxTree); var visitor = new CSharpParserVisitor(semanticModel); - cs = visitor.Visit(root) as Cs.CompilationUnit; + cs = visitor.Visit(root) as Cs.CompilationUnit ?? throw new InvalidOperationException("Visitor.Visit returned null instead of Compilation Unit"); } catch (Exception t) { diff --git a/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs b/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs index 8559f53a..9f852e41 100644 --- a/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs +++ b/Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs @@ -115,16 +115,19 @@ public override Markers VisitMarkers(Markers? markers, PrintOutputCapture

p) } } - return markers; + return Markers.EMPTY; } - public Space VisitSpace(Space space, CsSpace.Location loc, PrintOutputCapture

p) + //todo: AS: review if base method can be virtual and this one should just be override + protected override Space VisitSpace(Space space, CsSpace.Location loc, PrintOutputCapture

p) { return VisitSpace(space, Space.Location.LANGUAGE_EXTENSION, p); } public override Space VisitSpace(Space? space, Space.Location? loc, PrintOutputCapture

p) { + if (space == null) + return Space.EMPTY; p.Append(space.Whitespace); foreach (var comment in space.Comments) { @@ -274,4 +277,4 @@ public override J VisitClassDeclaration(J.ClassDeclaration classDecl, PrintOutpu return classDecl; } } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs b/Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs index 622a122f..e4dcc097 100644 --- a/Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs +++ b/Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs @@ -360,7 +360,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) return right; } - protected Space VisitSpace(Space space, CsSpace.Location loc, P p) + protected virtual Space VisitSpace(Space space, CsSpace.Location loc, P p) { return VisitSpace(space, Space.Location.LANGUAGE_EXTENSION, p); } diff --git a/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs b/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs index 79a8f936..8c1ce172 100644 --- a/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs +++ b/Rewrite/src/Rewrite.CSharp/Parser/CSharpParserVisitor.cs @@ -267,7 +267,7 @@ public override Statement VisitParameter(ParameterSyntax p) null ) : null*/ Convert(p.Type), - null, + null!, [], [ new JRightPadded( @@ -858,7 +858,8 @@ private J.AssignmentOperation.Type MapAssignmentOperator(SyntaxToken op) node.OperatorToken.Kind() switch { SyntaxKind.QuestionQuestionToken => Cs.Binary.OperatorType.NullCoalescing, - SyntaxKind.AsKeyword => Cs.Binary.OperatorType.As + SyntaxKind.AsKeyword => Cs.Binary.OperatorType.As, + _ => throw new ArgumentOutOfRangeException() }, Markers.EMPTY), Convert(node.Right)!, @@ -978,7 +979,7 @@ private static J.Binary.Type MapBinaryExpressionOperator(SyntaxToken operatorTok [], [], null, - null, + null!, [], [] ), @@ -999,7 +1000,7 @@ private static J.Binary.Type MapBinaryExpressionOperator(SyntaxToken operatorTok [], [], Convert(node.Type), - null, + null!, [], node.Identifier.IsKind(SyntaxKind.None) ? [] @@ -1878,7 +1879,7 @@ private J.ArrayAccess MapArrayAccess(ElementAccessExpressionSyntax node, int ind [], [], null, - null, + null!, [], [ node.NameEquals != null @@ -1916,7 +1917,7 @@ private J.ArrayAccess MapArrayAccess(ElementAccessExpressionSyntax node, int ind var identifierOrFieldAccess = Convert(expression)!; var identifier = identifierOrFieldAccess is J.Identifier i ? i - : (identifierOrFieldAccess as J.FieldAccess).Name; + : (identifierOrFieldAccess as J.FieldAccess)?.Name ?? throw new InvalidOperationException("Can't determine identifier"); return new JRightPadded( new J.VariableDeclarations.NamedVariable( Core.Tree.RandomId(), @@ -2390,7 +2391,7 @@ private JRightPadded MapAnonymousObjectMember(AnonymousObjectMemberDe [], usingModifier != null ? [usingModifier, .. MapModifiers(node.Modifiers)] : MapModifiers(node.Modifiers), Visit(node.Declaration.Type) as TypeTree, - null, + null!, [], node.Declaration.Variables.Select(MapVariable).ToList() ); @@ -2415,7 +2416,7 @@ private JRightPadded MapAnonymousObjectMember(AnonymousObjectMemberDe [], [], Visit(node.Type) as TypeTree, - null, + null!, [], node.Variables.Select(MapVariable).ToList() ); @@ -2642,7 +2643,7 @@ private IList> MapArrayDimensions(BracketedArgumentListSyntax [], [], Convert(node.Type), - null, + null!, [], [ new JRightPadded( @@ -2704,14 +2705,14 @@ private IList> MapArrayDimensions(BracketedArgumentListSyntax : [], Markers.EMPTY ); - var s = Convert(node.Statement); - + var s = Convert(node.Statement) ?? throw new InvalidOperationException("Statement is empty after conversion"); + return new J.Try( Core.Tree.RandomId(), Format(Leading(node)), Markers.EMPTY, jContainer, - s is not J.Block block + s is not J.Block block ? new J.Block( Core.Tree.RandomId(), Space.EMPTY, @@ -3546,7 +3547,7 @@ private JRightPadded MapParameter(ParameterSyntax tps) where T : J private List? MapAttributes(SyntaxList m) { - return m.Count == 0 ? null : m.Select(Convert).ToList(); + return m.Count == 0 ? null : m.Select(x => Convert(x)!).ToList(); } private JavaType MapType(ExpressionSyntax ins) @@ -3643,4 +3644,4 @@ private static Space Format(SyntaxTriviaList trivia) // FIXME optimize return Space.Format(trivia.ToString()); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Cs.cs b/Rewrite/src/Rewrite.CSharp/Tree/Cs.cs index 721345d4..c3628579 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/Cs.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/Cs.cs @@ -28,7 +28,7 @@ bool Core.Tree.IsAcceptable(ITreeVisitor v, P p) { return v.DefaultValue(this, p); } - +#pragma warning disable CS0108 public class CompilationUnit( Guid id, Space prefix, @@ -44,6 +44,7 @@ public class CompilationUnit( IList> members, Space eof ) : Cs, MutableSourceFile, JavaSourceFile, MutableTree +#pragma warning restore CS0108 { [NonSerialized] private WeakReference? _padding; @@ -93,6 +94,7 @@ public CompilationUnit WithPrefix(Space newPrefix) public CompilationUnit WithMarkers(Markers newMarkers) { + // todo: AS: review if this should be reference equality or value equality check return ReferenceEquals(newMarkers, markers) ? this : new CompilationUnit(id, prefix, newMarkers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); } @@ -362,7 +364,7 @@ public override int GetHashCode() return Id.GetHashCode(); } } - +#pragma warning disable CS0108 public class AssignmentOperation( Guid id, Space prefix, @@ -372,6 +374,7 @@ public class AssignmentOperation( Expression assignment, JavaType? type ) : Cs, Statement, Expression, TypedTree, MutableTree +#pragma warning restore CS0108 { [NonSerialized] private WeakReference? _padding; @@ -643,7 +646,7 @@ public override int GetHashCode() return Id.GetHashCode(); } } - +#pragma warning disable CS0108 public class Binary( Guid id, Space prefix, @@ -653,6 +656,7 @@ public class Binary( Expression right, JavaType? type ) : Cs, Expression, TypedTree, MutableTree +#pragma warning restore CS0108 { [NonSerialized] private WeakReference? _padding; diff --git a/Rewrite/src/Rewrite.Core/Config/OptionDescriptor.cs b/Rewrite/src/Rewrite.Core/Config/OptionDescriptor.cs index 58d3d112..aa8c819a 100644 --- a/Rewrite/src/Rewrite.Core/Config/OptionDescriptor.cs +++ b/Rewrite/src/Rewrite.Core/Config/OptionDescriptor.cs @@ -43,7 +43,7 @@ public override bool Equals(object? obj) DisplayName == other.DisplayName && Description == other.Description && Example == other.Example && - Valid?.SequenceEqual(other.Valid) == true && + Valid.SafeSequenceEqual(other.Valid) && Required == other.Required && Equals(Value, other.Value); } @@ -55,4 +55,4 @@ public override int GetHashCode() { return HashCode.Combine(Name, Type, DisplayName, Description, Example, Valid, Required, Value); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/Config/RecipeDescriptor.cs b/Rewrite/src/Rewrite.Core/Config/RecipeDescriptor.cs index 1a6cf522..86c47b44 100644 --- a/Rewrite/src/Rewrite.Core/Config/RecipeDescriptor.cs +++ b/Rewrite/src/Rewrite.Core/Config/RecipeDescriptor.cs @@ -41,7 +41,7 @@ public RecipeDescriptor(string name, string displayName, string description, Has } // Override Equals and GetHashCode to handle equality based on Name and Options - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is RecipeDescriptor other) { @@ -58,18 +58,18 @@ public override int GetHashCode() // With pattern for immutability public RecipeDescriptor With( - string name = null, - string displayName = null, - string description = null, - HashSet tags = null, + string? name = null, + string? displayName = null, + string? description = null, + HashSet? tags = null, TimeSpan? estimatedEffortPerOccurrence = null, - List options = null, - List recipeList = null, + List? options = null, + List? recipeList = null, // List dataTables = null, // List maintainers = null, // List contributors = null, // List examples = null, - Uri source = null) + Uri? source = null) { return new RecipeDescriptor( name ?? this.Name, diff --git a/Rewrite/src/Rewrite.Core/Cursor.cs b/Rewrite/src/Rewrite.Core/Cursor.cs index f86da34e..735edcbb 100644 --- a/Rewrite/src/Rewrite.Core/Cursor.cs +++ b/Rewrite/src/Rewrite.Core/Cursor.cs @@ -1,6 +1,6 @@ namespace Rewrite.Core; -public record Cursor(Cursor? Parent, object Value) +public record Cursor(Cursor? Parent, object? Value) { public const string ROOT_VALUE = "root"; @@ -28,9 +28,9 @@ public Cursor GetRoot() return c; } - public T GetValue() + public T? GetValue() where T : class { - return (T)Value; + return Value as T; } public Cursor GetParentOrThrow(int levels = 1) { @@ -62,7 +62,7 @@ public T FirstEnclosingOrThrow() return default; } - public Cursor DropParentUntil(Func predicate) + public Cursor DropParentUntil(Func predicate) { var c = this; while (c != null) @@ -87,7 +87,7 @@ public void PutMessage(string key, object value) public T? GetMessage(string key, T? defaultValue = default) { - return _messages is null ? defaultValue : + return _messages is null ? defaultValue : _messages.TryGetValue(key, out var value) ? (T?)value : defaultValue; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/Extensions.cs b/Rewrite/src/Rewrite.Core/Extensions.cs index 51605011..3f5e7b5d 100644 --- a/Rewrite/src/Rewrite.Core/Extensions.cs +++ b/Rewrite/src/Rewrite.Core/Extensions.cs @@ -1,3 +1,12 @@ namespace Rewrite.Core; -public static class Extensions; \ No newline at end of file +public static class Extensions +{ + [Pure] + internal static bool SafeSequenceEqual(this IEnumerable? first, IEnumerable? second) + { + if (ReferenceEquals(first, second)) return true; // they are either pointing to same collection or both are null + if (first == null || second == null) return false; + return first.SequenceEqual(second); + } +} diff --git a/Rewrite/src/Rewrite.Core/ITreeVisitor.cs b/Rewrite/src/Rewrite.Core/ITreeVisitor.cs index 9a44990c..34a8466c 100644 --- a/Rewrite/src/Rewrite.Core/ITreeVisitor.cs +++ b/Rewrite/src/Rewrite.Core/ITreeVisitor.cs @@ -1,3 +1,5 @@ +using Rewrite.Core.Marker; + namespace Rewrite.Core; public interface ITreeVisitor where T : class, Tree @@ -22,8 +24,8 @@ V Adapt() where R : class, Tree where V : class, ITreeVisitor T? Visit(Tree? tree, P p); T? Visit(Tree? tree, P p, Cursor parent); T? PostVisit(Tree tree, P p); - Marker.Markers VisitMarkers(Marker.Markers? markers, P p); - M VisitMarker(M marker, P p) where M : Marker.Marker; + Markers? VisitMarkers(Marker.Markers? markers, P p); + TMarker VisitMarker(TMarker marker, P p) where TMarker : Marker.Marker; } internal class NoopVisitor : TreeVisitor diff --git a/Rewrite/src/Rewrite.Core/Internal/ExceptionUtils.cs b/Rewrite/src/Rewrite.Core/Internal/ExceptionUtils.cs index 5dc40a25..4565314e 100644 --- a/Rewrite/src/Rewrite.Core/Internal/ExceptionUtils.cs +++ b/Rewrite/src/Rewrite.Core/Internal/ExceptionUtils.cs @@ -1,16 +1,20 @@ +using System.Diagnostics; + namespace Rewrite.Core.Internal; -public class ExceptionUtils +public static class ExceptionUtils { - public static string SanitizeStackTrace(Exception t, Type until) + public static string SanitizeStackTrace(this Exception exception, Type until) { - var cause = t; var sanitized = ""; - sanitized = string.Join("\n", sanitized, cause.GetType().Name + ": " + cause.Message); + sanitized = string.Join("\n", sanitized, exception.GetType().Name + ": " + exception.Message); var i = 0; - foreach (var stackTraceElement in cause.StackTrace.TakeWhile(stackTraceElement => - !stackTraceElement.Equals(until.Name))) + foreach (var stackTraceElement in new StackTrace(exception).GetFrames() + .Select(x => x.GetMethod()?.DeclaringType) + .Where(x => x != null) + .Cast() + .TakeWhile(originatingClass => originatingClass != until)) { if (i++ >= 16) { @@ -23,4 +27,4 @@ public static string SanitizeStackTrace(Exception t, Type until) return sanitized; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/ListUtils.cs b/Rewrite/src/Rewrite.Core/ListUtils.cs index cae253fd..84f46f13 100644 --- a/Rewrite/src/Rewrite.Core/ListUtils.cs +++ b/Rewrite/src/Rewrite.Core/ListUtils.cs @@ -4,9 +4,10 @@ namespace Rewrite.Core; public static class ListUtils { - public static IList Map(IList? list, Func map) + // todo: AS: this method is used in contexts where tree is changed in immutable way. this immutability is broken by how this method tries to optimize as it sometimes reuses same list when a copy should have been made. since this collection is writable, it's possible that changes mutation in one set affects it in other place, which is not the intent of immutable copy + public static IList Map(this IList list, Func map) { - if (list == null || list.Count == 0) + if (list.Count == 0) { return list; } @@ -47,4 +48,4 @@ public static IList Concat(IList? ls, T? t) newLs.Add(t); return newLs; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/Marker/UnknownJavaMarker.cs b/Rewrite/src/Rewrite.Core/Marker/UnknownJavaMarker.cs index 5c12ce61..6ac7507d 100644 --- a/Rewrite/src/Rewrite.Core/Marker/UnknownJavaMarker.cs +++ b/Rewrite/src/Rewrite.Core/Marker/UnknownJavaMarker.cs @@ -1,9 +1,9 @@ namespace Rewrite.Core.Marker; -public record UnknownJavaMarker(Guid Id, IDictionary Data) : Marker +public record UnknownJavaMarker(Guid Id, IDictionary Data) : Marker { public bool Equals(Marker? other) { return other is UnknownJavaMarker && other.Id.Equals(Id); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/ParseError.cs b/Rewrite/src/Rewrite.Core/ParseError.cs index a802dec6..38031ee2 100644 --- a/Rewrite/src/Rewrite.Core/ParseError.cs +++ b/Rewrite/src/Rewrite.Core/ParseError.cs @@ -145,7 +145,7 @@ public static ParseError Build(Parser parser, using var readableStream = new StreamReader(stream, Encoding.UTF8); return new ParseError( Tree.RandomId(), - new Markers(Tree.RandomId(), [ParseExceptionResult.build(parser, t)]), + new Markers(Tree.RandomId(), [ParseExceptionResult.Build(parser, t)]), input.GetRelativePath(relativeTo), null, // FIXME: need real file attr parser.GetCharset(ctx), diff --git a/Rewrite/src/Rewrite.Core/ParseErrorResult.cs b/Rewrite/src/Rewrite.Core/ParseErrorResult.cs index 3b5d2677..392bd9c5 100644 --- a/Rewrite/src/Rewrite.Core/ParseErrorResult.cs +++ b/Rewrite/src/Rewrite.Core/ParseErrorResult.cs @@ -55,28 +55,26 @@ public ParseExceptionResult WithTreeType(string? newTreeType) /** * The type of tree element that was being parsed when the failure occurred. */ - public static ParseExceptionResult build(Type parserClass, - Exception t, - string message) + public static ParseExceptionResult Build(Type parserClass, Exception t, string? message) { var simpleName = t.GetType().Name; return new ParseExceptionResult( Tree.RandomId(), parserClass.Name, !string.IsNullOrEmpty(simpleName) ? simpleName : t.GetType().Name, - (message != null ? message : "") + ExceptionUtils.SanitizeStackTrace(t, parserClass), + (message ?? "") + t.SanitizeStackTrace(parserClass), null ); } - public static ParseExceptionResult build(Parser parser, Exception t, string? message) + public static ParseExceptionResult Build(Parser parser, Exception t, string? message) { - return build(parser.GetType(), t, message); + return Build(parser.GetType(), t, message); } - public static ParseExceptionResult build(Parser parser, Exception t) + public static ParseExceptionResult Build(Parser parser, Exception t) { - return build(parser.GetType(), t, null); + return Build(parser.GetType(), t, null); } public bool Equals(Marker.Marker? other) @@ -88,4 +86,4 @@ public override int GetHashCode() { return Id.GetHashCode(); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/Parser.cs b/Rewrite/src/Rewrite.Core/Parser.cs index ec13662a..390a9247 100644 --- a/Rewrite/src/Rewrite.Core/Parser.cs +++ b/Rewrite/src/Rewrite.Core/Parser.cs @@ -6,7 +6,7 @@ abstract class Builder { public abstract Builder Clone(); - public Type SourceFileType { get; set; } + public Type? SourceFileType { get; set; } public abstract Parser Build(); } @@ -33,4 +33,4 @@ string GetCharset(ExecutionContext ctx) // FIXME implement return "UTF-8"; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/PrintOutputCapture.cs b/Rewrite/src/Rewrite.Core/PrintOutputCapture.cs index ad2bbcf4..bc3ae57e 100644 --- a/Rewrite/src/Rewrite.Core/PrintOutputCapture.cs +++ b/Rewrite/src/Rewrite.Core/PrintOutputCapture.cs @@ -38,7 +38,7 @@ public PrintOutputCapture

Append(char c) public PrintOutputCapture

Clone() { - return new PrintOutputCapture

(p, markerPrinter); + return new PrintOutputCapture

(Context, MarkerPrinter); } public interface IMarkerPrinter @@ -68,4 +68,4 @@ string AfterSyntax(Marker.Marker marker, Cursor cursor, Func com return ""; } } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/Quark/Quark.cs b/Rewrite/src/Rewrite.Core/Quark/Quark.cs index 2e56e313..4b5a399f 100644 --- a/Rewrite/src/Rewrite.Core/Quark/Quark.cs +++ b/Rewrite/src/Rewrite.Core/Quark/Quark.cs @@ -11,13 +11,13 @@ public bool Equals(Tree? other) } public Guid Id { get; } - public Markers Markers { get; } + public Markers Markers { get; } = Markers.EMPTY; public bool IsAcceptable(ITreeVisitor v, P p) where R : class, Tree { throw new NotImplementedException(); } - public string SourcePath { get; } + public string SourcePath { get; } = null!; public string? CharsetName { get; } public bool CharsetBomMarked { get; } public Checksum? Checksum { get; } diff --git a/Rewrite/src/Rewrite.Core/Recipe.cs b/Rewrite/src/Rewrite.Core/Recipe.cs index 6f977bd2..e3f99425 100644 --- a/Rewrite/src/Rewrite.Core/Recipe.cs +++ b/Rewrite/src/Rewrite.Core/Recipe.cs @@ -11,11 +11,11 @@ public RecipeDescriptor Descriptor { get { - return _descriptor ?? (_descriptor = new RecipeDescriptor(GetType().FullName, GetType().FullName, "", + return _descriptor ??= new RecipeDescriptor(GetType().FullName!, GetType().FullName!, "", new HashSet(), null, GetType().GetConstructors()[0].GetParameters().Select(parameterInfo => { - return new OptionDescriptor(parameterInfo.Name, parameterInfo.ParameterType.FullName, null, + return new OptionDescriptor(parameterInfo.Name!, parameterInfo.ParameterType.FullName!, null, null, null, null, @@ -27,7 +27,7 @@ public RecipeDescriptor Descriptor }).ToList(), [], new Uri($"recipe://{GetType().FullName}") - )); + ); } set => _descriptor = value; @@ -72,7 +72,7 @@ public Validated Validate(ExecutionContext ctx) public Validated Validate() { - var validated = Validated.None(); + var validated = Validated.None(); // Class clazz = this.getClass(); // List requiredFields = NullUtils.findNonNullFields(clazz); // for (Field field : requiredFields) { diff --git a/Rewrite/src/Rewrite.Core/TreeVisitor.cs b/Rewrite/src/Rewrite.Core/TreeVisitor.cs index be00714b..8c359b06 100644 --- a/Rewrite/src/Rewrite.Core/TreeVisitor.cs +++ b/Rewrite/src/Rewrite.Core/TreeVisitor.cs @@ -1,9 +1,11 @@ +using Rewrite.Core.Marker; + namespace Rewrite.Core; public abstract class TreeVisitor : ITreeVisitor where T : class, Tree { - public Cursor Cursor { get; set; } + public Cursor Cursor { get; set; } = null!; public bool IsAdaptableTo(Type adaptTo) { @@ -95,20 +97,22 @@ public void Visit(IList? nodes, P p) where T2 : T return (T2?)Visit(tree, p); } - public virtual Marker.Markers VisitMarkers(Marker.Markers? markers, P p) + [Pure] + public virtual Markers VisitMarkers(Marker.Markers? markers, P p) { if (markers == null || ReferenceEquals(markers, Marker.Markers.EMPTY)) { return Marker.Markers.EMPTY; } - else if (markers.MarkerList.Count == 0) + + if (markers.MarkerList.Count == 0) { return markers; } return markers with { - MarkerList = ListUtils.Map(markers.MarkerList, m => VisitMarker(m, p)) + MarkerList = ListUtils.Map(markers.MarkerList, m => VisitMarker(m, p))! }; } @@ -122,4 +126,4 @@ public virtual M VisitMarker(M marker, P p) where M : Marker.Marker Cursor = parent; return Visit(tree, p); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Core/Validated.cs b/Rewrite/src/Rewrite.Core/Validated.cs index c1f50263..152ec320 100644 --- a/Rewrite/src/Rewrite.Core/Validated.cs +++ b/Rewrite/src/Rewrite.Core/Validated.cs @@ -2,7 +2,7 @@ namespace Rewrite.Core; public interface Validated { - static Validated None() + static Validated None() { return new ValidatedNone(); } diff --git a/Rewrite/src/Rewrite.Java/JavaPrinter.cs b/Rewrite/src/Rewrite.Java/JavaPrinter.cs index f602ffe2..b1135922 100644 --- a/Rewrite/src/Rewrite.Java/JavaPrinter.cs +++ b/Rewrite/src/Rewrite.Java/JavaPrinter.cs @@ -38,7 +38,7 @@ protected void VisitContainer(string before, JContainer? container, JConta p.Append(after ?? ""); } - public override Space VisitSpace(Space? space, Space.Location? loc, PrintOutputCapture

p) + public override Space VisitSpace(Space space, Space.Location? loc, PrintOutputCapture

p) { p.Append(space.Whitespace); @@ -86,7 +86,7 @@ protected void VisitRightPadded(JRightPadded? rightPadded, JRightPadded.Lo } } - protected void VisitModifier(J.Modifier mod, PrintOutputCapture

p) + public override J VisitModifier(J.Modifier mod, PrintOutputCapture

p) { Visit(mod.Annotations, p); var keyword = ""; @@ -139,6 +139,7 @@ protected void VisitModifier(J.Modifier mod, PrintOutputCapture

p) BeforeSyntax(mod, Space.Location.MODIFIER_PREFIX, p); p.Append(keyword); AfterSyntax(mod, p); + return mod; } @@ -202,9 +203,9 @@ private void PrintDimensions(J.ArrayType arrayType, PrintOutputCapture

p) { BeforeSyntax(arrayType, Space.Location.ARRAY_TYPE_PREFIX, p); Visit(arrayType.Annotations, p); - VisitSpace(arrayType.Dimension.Before, Space.Location.DIMENSION_PREFIX, p); + VisitSpace(arrayType.Dimension?.Before ?? Space.EMPTY, Space.Location.DIMENSION_PREFIX, p); p.Append('['); - VisitSpace(arrayType.Dimension.Element, Space.Location.DIMENSION, p); + VisitSpace(arrayType.Dimension?.Element ?? Space.EMPTY, Space.Location.DIMENSION, p); p.Append(']'); if (arrayType.ElementType is J.ArrayType) { @@ -431,11 +432,11 @@ s is J.VariableDeclarations || // This section may need to change depending on the actual representation of these objects if (Cursor.Value is J.Case) { - object aSwitch = Cursor + var aSwitch = Cursor .DropParentUntil(c => c is J.Switch || c is J.SwitchExpression || - c == Cursor.ROOT_VALUE) + c?.ToString() == Cursor.ROOT_VALUE) .Value; if (aSwitch is J.SwitchExpression) @@ -499,7 +500,7 @@ public override J VisitCatch(J.Try.Catch catch_, PrintOutputCapture

p) AfterSyntax(catch_, p); return catch_; } - + public override J VisitClassDeclaration(J.ClassDeclaration classDecl, PrintOutputCapture

p) { string kind = ""; @@ -755,7 +756,7 @@ public override J VisitLambda(J.Lambda lambda, PrintOutputCapture

p) public override J VisitLiteral(J.Literal literal, PrintOutputCapture

p) { BeforeSyntax(literal, Space.Location.LITERAL_PREFIX, p); - IList unicodeEscapes = literal.UnicodeEscapes; + var unicodeEscapes = literal.UnicodeEscapes; if (unicodeEscapes == null) { p.Append(literal.ValueSource); @@ -763,8 +764,7 @@ public override J VisitLiteral(J.Literal literal, PrintOutputCapture

p) else if (literal.ValueSource != null) { var surrogateEnum = unicodeEscapes.GetEnumerator(); - J.Literal.UnicodeEscape surrogate = surrogateEnum.MoveNext() ? - surrogateEnum.Current : null; + var surrogate = surrogateEnum.MoveNext() ? surrogateEnum.Current : null; int i = 0; if (surrogate != null && surrogate.ValueSourceIndex == 0) { @@ -804,7 +804,7 @@ public override J VisitMemberReference(J.MemberReference memberRef, PrintOutputC AfterSyntax(memberRef, p); return memberRef; } - + public override J VisitMethodDeclaration(J.MethodDeclaration method, PrintOutputCapture

p) { BeforeSyntax(method, Space.Location.METHOD_DECLARATION_PREFIX, p); @@ -837,7 +837,7 @@ public override J VisitMethodDeclaration(J.MethodDeclaration method, PrintOutput AfterSyntax(method, p); return method; } - + public override J VisitMethodInvocation(J.MethodInvocation method, PrintOutputCapture

p) { BeforeSyntax(method, Space.Location.METHOD_INVOCATION_PREFIX, p); @@ -956,13 +956,6 @@ public override J VisitParameterizedType(J.ParameterizedType type, PrintOutputCa public override J VisitPrimitive(J.Primitive primitive, PrintOutputCapture

p) { - if (true) - { - BeforeSyntax(primitive, Space.Location.PRIMITIVE_PREFIX, p); - p.Append("foo"); - AfterSyntax(primitive, p); - return primitive; - } string keyword; switch (primitive.Type.Kind) { @@ -1291,4 +1284,4 @@ protected void AfterSyntax(Markers markers, PrintOutputCapture

p) p.Append(p.MarkerPrinter.AfterSyntax(marker, new Cursor(Cursor, marker), MARKER_WRAPPER)); } } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Java/JavaTypeCache.cs b/Rewrite/src/Rewrite.Java/JavaTypeCache.cs index 0a498bc7..59019a2b 100644 --- a/Rewrite/src/Rewrite.Java/JavaTypeCache.cs +++ b/Rewrite/src/Rewrite.Java/JavaTypeCache.cs @@ -9,6 +9,6 @@ internal class JavaTypeCache public JavaType? this[string typeName] { get => _cache.TryGetValue(typeName, out var type) ? type : null; - set => _cache[typeName] = value; + set => _cache[typeName] = value ?? JavaType.Unknown.Instance; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Java/JavaTypeSignatureBuilder.cs b/Rewrite/src/Rewrite.Java/JavaTypeSignatureBuilder.cs index 0e48c97b..52f07175 100644 --- a/Rewrite/src/Rewrite.Java/JavaTypeSignatureBuilder.cs +++ b/Rewrite/src/Rewrite.Java/JavaTypeSignatureBuilder.cs @@ -2,8 +2,6 @@ namespace Rewrite.RewriteJava; using System; -using System; - ///

/// In addition to the signature formats described below, implementations should provide a way of retrieving method /// and variable signatures, but they may have different numbers of input arguments depending on the implementation. @@ -23,7 +21,7 @@ public interface JavaTypeSignatureBuilder /// A type object. /// The type signature. If is null, the signature is {undefined}. string Signature(T type); - + /// /// Formats an array type. /// @@ -64,4 +62,4 @@ public interface JavaTypeSignatureBuilder /// A primitive type. /// Formatted like Integer. string PrimitiveSignature(T type); -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Java/JavaVisitor.cs b/Rewrite/src/Rewrite.Java/JavaVisitor.cs index 97a8248c..fc45747a 100644 --- a/Rewrite/src/Rewrite.Java/JavaVisitor.cs +++ b/Rewrite/src/Rewrite.Java/JavaVisitor.cs @@ -78,7 +78,7 @@ public virtual J VisitStatement(Statement statement, P p) { arrayType = (J.ArrayType) tempExpression; arrayType = arrayType.WithMarkers(VisitMarkers(arrayType.Markers, p)); arrayType = arrayType.WithElementType(VisitAndCast(arrayType.ElementType, p)!); - arrayType = arrayType.WithAnnotations(ListUtils.Map(arrayType.Annotations, el => (J.Annotation?)Visit(el, p))); + arrayType = arrayType.WithAnnotations(arrayType.Annotations?.Map(el => (J.Annotation?)Visit(el, p))); arrayType = arrayType.WithDimension(arrayType.Dimension?.WithBefore(VisitSpace(arrayType.Dimension.Before, Space.Location.DIMENSION_PREFIX, p)).WithElement(VisitSpace(arrayType.Dimension.Element, Space.Location.DIMENSION, p))); return arrayType; } @@ -953,7 +953,7 @@ public virtual J VisitStatement(Statement statement, P p) { variableDeclarations = variableDeclarations.WithLeadingAnnotations(ListUtils.Map(variableDeclarations.LeadingAnnotations, el => (J.Annotation?)Visit(el, p))); variableDeclarations = variableDeclarations.WithModifiers(ListUtils.Map(variableDeclarations.Modifiers, el => (J.Modifier?)Visit(el, p))); variableDeclarations = variableDeclarations.WithTypeExpression(VisitAndCast(variableDeclarations.TypeExpression, p)); - variableDeclarations = variableDeclarations.WithVarargs(VisitSpace(variableDeclarations.Varargs, Space.Location.VARARGS, p)); + variableDeclarations = variableDeclarations.WithVarargs(VisitSpace(variableDeclarations.Varargs!, Space.Location.VARARGS, p)); variableDeclarations = variableDeclarations.WithDimensionsBeforeName(ListUtils.Map(variableDeclarations.DimensionsBeforeName, el => el.WithBefore(VisitSpace(el.Before, Space.Location.DIMENSION_PREFIX, p)).WithElement(VisitSpace(el.Element, Space.Location.DIMENSION, p)))); variableDeclarations = variableDeclarations.Padding.WithVariables(ListUtils.Map(variableDeclarations.Padding.Variables, el => VisitRightPadded(el, JRightPadded.Location.NAMED_VARIABLE, p))); return variableDeclarations; @@ -1040,7 +1040,7 @@ public virtual J VisitStatement(Statement statement, P p) { return source; } - public virtual JContainer VisitContainer(JContainer? container, JContainer.Location loc, P p) + public virtual JContainer? VisitContainer(JContainer? container, JContainer.Location loc, P p) { if (container == null) { return null; @@ -1109,7 +1109,7 @@ public virtual JContainer VisitContainer(JContainer? container, JContai return right; } - public virtual Space VisitSpace(Space? space, Space.Location? loc, P p) + public virtual Space VisitSpace(Space space, Space.Location? loc, P p) { // FIXME add Javadoc support return space; diff --git a/Rewrite/src/Rewrite.Java/Tree/Extensions.cs b/Rewrite/src/Rewrite.Java/Tree/Extensions.cs index 607bef02..5d42715a 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Extensions.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Extensions.cs @@ -27,8 +27,8 @@ public static class Extensions public static JavaType? GetJavaType(J.IntersectionType expr) { return new JavaType.Intersection(expr.Bounds - .Where(b => b != null) .Select(b => b.Type) + .Cast() .ToList()); } @@ -42,11 +42,12 @@ public static class Extensions return expr.MethodType?.ReturnType; } - public static JavaType? GetJavaType(J.MultiCatch expr) + public static JavaType GetJavaType(J.MultiCatch expr) { return new JavaType.MultiCatch(expr.Alternatives - .Where(b => b != null) .Select(alt => alt.Type) + .Where(x => x != null) + .Cast() .ToList()); } @@ -465,4 +466,4 @@ public static J.Unknown WithJavaType(J.Unknown expr, JavaType newType) { return expr; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Java/Tree/Flag.cs b/Rewrite/src/Rewrite.Java/Tree/Flag.cs index f472c61c..3275dc52 100644 --- a/Rewrite/src/Rewrite.Java/Tree/Flag.cs +++ b/Rewrite/src/Rewrite.Java/Tree/Flag.cs @@ -1,5 +1,4 @@ namespace Rewrite.RewriteJava.Tree; - public enum Flag : long { Public = 1, @@ -26,7 +25,7 @@ public enum Flag : long internal static class FlagExtensions { - + public static ISet BitMapToFlags(long flagsBitMap) { var flags = new HashSet(); @@ -54,4 +53,4 @@ public static bool HasFlags(long flagsBitMap, params Flag[] flags) return false; return true; } -} \ 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 28c9b459..dea25cce 100644 --- a/Rewrite/src/Rewrite.Java/Tree/JContainer.cs +++ b/Rewrite/src/Rewrite.Java/Tree/JContainer.cs @@ -1,6 +1,5 @@ using System.Diagnostics.CodeAnalysis; using Rewrite.Core.Marker; - namespace Rewrite.RewriteJava.Tree; [SuppressMessage("ReSharper", "InconsistentNaming")] @@ -75,14 +74,14 @@ public static JContainer WithElements(JContainer before, IList? return before.Padding.WithElements(JRightPadded.WithElements(before.Elements, elements)); } - public static JContainer Build(Space before, IList> elements, Markers markers) + public static JContainer Build(Space before, IList> elements, Markers markers) { - return new JContainer(before, elements, markers); + return new JContainer(before, elements, markers); } - public static JContainer Build(List> elements) + public static JContainer Build(List> elements) { - return new JContainer(Space.EMPTY, elements, Markers.EMPTY); + return new JContainer(Space.EMPTY, elements, Markers.EMPTY); } public sealed record PaddingHelper(JContainer c) @@ -132,4 +131,4 @@ public record Location(Space.Location BeforeLocation, JRightPadded.Location Elem public static readonly Location TYPE_BOUNDS = new(Space.Location.TYPE_BOUNDS, JRightPadded.Location.TYPE_BOUND); public static readonly Location TYPE_PARAMETERS = new(Space.Location.TYPE_PARAMETERS, JRightPadded.Location.TYPE_PARAMETER); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs b/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs index 42abe5e9..ea7fa129 100644 --- a/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs +++ b/Rewrite/src/Rewrite.Java/Tree/JRightPadded.cs @@ -94,7 +94,7 @@ public static IList> WithElements(IList> b foreach (var t in elements) { - after.Add(beforeById.TryGetValue(t.Id, out JRightPadded found) + after.Add(beforeById.TryGetValue(t.Id, out var found) ? found.WithElement(t) : new JRightPadded(t, Space.EMPTY, Markers.EMPTY)); } @@ -173,4 +173,4 @@ public static JRightPadded WithElement(JRightPadded right, T element) { return right.WithElement(element); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Java/Tree/JavaType.cs b/Rewrite/src/Rewrite.Java/Tree/JavaType.cs index 1d7cb602..08146cab 100644 --- a/Rewrite/src/Rewrite.Java/Tree/JavaType.cs +++ b/Rewrite/src/Rewrite.Java/Tree/JavaType.cs @@ -67,7 +67,7 @@ public Intersection(IList? bounds) this._bounds = bounds ?? EMPTY_JAVA_TYPE_ARRAY; } - public IList Bounds => _bounds; + public IList Bounds => _bounds; } public abstract class FullyQualified : JavaType @@ -151,11 +151,14 @@ private IEnumerator GetVisibleMembers(string packageName) } private class FullyQualifiedEnumerator( +#pragma warning disable // TODO: needs to be fully implemented FullyQualified fq, + string packageName, Func flagsFn, Func> baseFn, Func> recursiveFn) : IEnumerator + { public bool MoveNext() { @@ -167,7 +170,7 @@ public void Reset() throw new NotImplementedException(); } - public E Current { get; } + public E Current { get; } = default!; object IEnumerator.Current => Current; @@ -187,6 +190,7 @@ public enum TypeKind Value } } +#pragma warning restore public class Class : FullyQualified { @@ -194,6 +198,7 @@ internal Class() { } + public Class( int? managedReference, long flagsBitMap, @@ -239,29 +244,29 @@ private Class( FlagsBitMap = flagsBitMap; FullyQualifiedName = fullyQualifiedName; Kind = kind; - TypeParameters = typeParameters; + TypeParameters = typeParameters ?? EMPTY_JAVA_TYPE_ARRAY; Supertype = supertype; OwningClass = owningClass; - Annotations = annotations; - Interfaces = interfaces; - Members = members; - Methods = methods; + Annotations = annotations ?? EMPTY_FULLY_QUALIFIED_ARRAY; + Interfaces = interfaces ?? EMPTY_FULLY_QUALIFIED_ARRAY; + Members = members ?? EMPTY_VARIABLE_ARRAY; + Methods = methods ?? EMPTY_METHOD_ARRAY; } public int? ManagedReference { get; internal set; } public long FlagsBitMap { get; internal set; } - public override string FullyQualifiedName { get; internal set; } + public override string FullyQualifiedName { get; internal set; } = null!; public override TypeKind Kind { get; internal set; } - public override IList TypeParameters { get; internal set; } + public override IList TypeParameters { get; internal set; } = EMPTY_JAVA_TYPE_ARRAY; public override FullyQualified? Supertype { get; internal set; } public override FullyQualified? OwningClass { get; internal set; } - public override IList Annotations { get; internal set; } + public override IList Annotations { get; internal set; } = EMPTY_FULLY_QUALIFIED_ARRAY; - public override IList Interfaces { get; internal set; } - public override IList Members { get; internal set; } - public override IList Methods { get; internal set; } + public override IList Interfaces { get; internal set; } = EMPTY_FULLY_QUALIFIED_ARRAY; + public override IList Members { get; internal set; } = EMPTY_VARIABLE_ARRAY; + public override IList Methods { get; internal set; } = EMPTY_METHOD_ARRAY; public override ISet GetFlags() => FlagExtensions.BitMapToFlags(FlagsBitMap); @@ -382,7 +387,7 @@ public override FullyQualified WithFullyQualifiedName(string fullyQualifiedName) return new Parameterized(ManagedReference, newType, TypeParameters); } - public override IList Annotations { get; internal set; } + public override IList Annotations { get; internal set; } = EMPTY_FULLY_QUALIFIED_ARRAY; public override bool HasFlags(params Flag[] test) { @@ -394,11 +399,11 @@ public override ISet GetFlags() return Type!.GetFlags(); } - public override IList Interfaces { get; internal set; } + public override IList Interfaces { get; internal set; } = EMPTY_FULLY_QUALIFIED_ARRAY; public override TypeKind Kind { get; internal set; } - public override IList Members { get; internal set; } - public override IList Methods { get; internal set; } - public override IList TypeParameters { get; internal set; } + public override IList Members { get; internal set; } = EMPTY_VARIABLE_ARRAY; + public override IList Methods { get; internal set; } = EMPTY_METHOD_ARRAY; + public override IList TypeParameters { get; internal set; } = EMPTY_JAVA_TYPE_ARRAY; public override FullyQualified? Supertype { get; internal set; } public override FullyQualified? OwningClass { get; internal set; } } @@ -427,7 +432,7 @@ public enum VarianceType CONTRAVARIANT } - public IList Bounds { get; internal set; } + public IList Bounds { get; internal set; } = EMPTY_JAVA_TYPE_ARRAY; public GenericTypeVariable WithBounds(IList? bounds) { @@ -444,7 +449,7 @@ public GenericTypeVariable WithBounds(IList? bounds) public VarianceType Variance { get; internal set; } - public string Name { get; internal set; } + public string Name { get; internal set; } = null!; } public sealed class Array : JavaType @@ -462,9 +467,9 @@ public Array(int? managedReference, JavaType? elementType, IList internal int? ManagedReference { get; set; } - public JavaType ElementType { get; internal set; } + public JavaType ElementType { get; internal set; } = Unknown.Instance; - public IList Annotations { get; internal set; } + public IList Annotations { get; internal set; } = EMPTY_FULLY_QUALIFIED_ARRAY; public void UnsafeSet(JavaType elementType, IList? annotations) { @@ -542,26 +547,26 @@ public bool HasFlags(params Flag[] flags) public ISet GetFlags() => FlagExtensions.BitMapToFlags(FlagsBitMap); - public FullyQualified DeclaringType { get; internal set; } + public FullyQualified DeclaringType { get; internal set; } = Unknown.Instance; - public string Name { get; internal set; } + public string Name { get; internal set; } = null!; - public JavaType ReturnType { get; internal set; } + public JavaType ReturnType { get; internal set; } = Unknown.Instance; - public IList ParameterNames { get; internal set; } + public IList ParameterNames { get; internal set; } = []; - public IList ParameterTypes { get; internal set; } + public IList ParameterTypes { get; internal set; } = EMPTY_JAVA_TYPE_ARRAY; public bool isConstructor() { return "".Equals(Name); } - public IList ThrownExceptions { get; set; } + public IList ThrownExceptions { get; set; } = []; - public IList Annotations { get; internal set; } + public IList Annotations { get; internal set; } = []; - public IList? DefaultValue { get; internal set; } + public IList? DefaultValue { get; internal set; } = []; } public sealed class Variable : JavaType @@ -592,11 +597,11 @@ public Variable(int? managedReference, public bool HasFlags(params Flag[] flags) => FlagExtensions.HasFlags(FlagsBitMap, flags); - public string Name { get; internal set; } + public string Name { get; internal set; } = null!; public JavaType? Owner { get; internal set; } - public JavaType Type { get; internal set; } + public JavaType Type { get; internal set; } = Unknown.Instance; public Variable WithType(JavaType? javaType) { @@ -606,7 +611,7 @@ public Variable WithType(JavaType? javaType) : new Variable(ManagedReference, FlagsBitMap, Name, Owner, jType, Annotations); } - public IList Annotations { get; internal set; } + public IList Annotations { get; internal set; } = EMPTY_FULLY_QUALIFIED_ARRAY; public void UnsafeSet(JavaType? owner, JavaType? type, IList? annotations) { @@ -715,4 +720,4 @@ public override bool IsAssignableTo(string fullyQualifiedName) return false; } } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Properties/Tree/Properties.cs b/Rewrite/src/Rewrite.Properties/Tree/Properties.cs index 82f4ceeb..8fec08b5 100644 --- a/Rewrite/src/Rewrite.Properties/Tree/Properties.cs +++ b/Rewrite/src/Rewrite.Properties/Tree/Properties.cs @@ -259,11 +259,17 @@ public Value WithText(string newText) return newText == text ? this : new Value(id, prefix, markers, newText); } - public bool Equals(Rewrite.Core.Tree? other) + private bool Equals(Value other) { - return other is Value && other.Id == Id; + return Id.Equals(other.Id); } + public override bool Equals(object? obj) + { + return ReferenceEquals(this, obj) || obj is Value other && Equals(other); + } + + public override int GetHashCode() { return Id.GetHashCode(); diff --git a/Rewrite/src/Rewrite.Test/RewriteTest.cs b/Rewrite/src/Rewrite.Test/RewriteTest.cs index d8f4623e..c0c93ec8 100644 --- a/Rewrite/src/Rewrite.Test/RewriteTest.cs +++ b/Rewrite/src/Rewrite.Test/RewriteTest.cs @@ -119,7 +119,7 @@ public void RewriteRun(Action spec, SourceSpec[] sourceSpecs) continue; } - var beforeTrimmed = sourceSpec.NoTrim ? sourceSpec.Before : TrimIndentPreserveCrLf(sourceSpec.Before); + var beforeTrimmed = sourceSpec.NoTrim ? sourceSpec.Before : TrimIndentPreserveCrLf(sourceSpec.Before) ?? ""; var sourcePath = sourceSpec.SourcePath != null ? Path.Combine(sourceSpec.Dir, sourceSpec.SourcePath) @@ -202,7 +202,7 @@ public void RewriteRun(Action spec, SourceSpec[] sourceSpecs) } } - var mapped = nextSpec.BeforeRecipe(sourceFile); + var mapped = nextSpec.BeforeRecipe(sourceFile!); specBySourceFile[mapped] = nextSpec; } } @@ -243,7 +243,7 @@ public void RewriteRun(Action spec, SourceSpec[] sourceSpecs) } // TODO figure out how to do this without reflection - var afterRecipe = sourceSpec.GetType().GetProperty("AfterRecipe").GetValue(sourceSpec); + var afterRecipe = sourceSpec.GetType()?.GetProperty("AfterRecipe")?.GetValue(sourceSpec); if (afterRecipe != null) { var methodInfo = afterRecipe.GetType().GetMethod("Invoke"); @@ -274,7 +274,7 @@ public virtual ExecutionContext DefaultExecutionContext(SourceSpec[] sourceSpecs return new InMemoryExecutionContext(e => Assert.Fail("The recipe threw an exception: " + e)); } - public virtual void Defaults(RecipeSpec spec) + protected virtual void Defaults(RecipeSpec spec) { spec.Recipe = Recipe.Noop(); } @@ -287,4 +287,4 @@ public static string ReadFully(Stream stream, Encoding encoding) using var reader = new StreamReader(stream, encoding); return reader.ReadToEnd(); } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Test/RewriteTestUtils.cs b/Rewrite/src/Rewrite.Test/RewriteTestUtils.cs index 1397bdcc..d8747340 100644 --- a/Rewrite/src/Rewrite.Test/RewriteTestUtils.cs +++ b/Rewrite/src/Rewrite.Test/RewriteTestUtils.cs @@ -19,7 +19,7 @@ public static bool GroupSourceSpecsByParser(List parserBuilders, foreach (var parser in parserBuilders) { - if (parser.SourceFileType.Equals(sourceSpec.SourceFileType)) + if (parser.SourceFileType?.Equals(sourceSpec.SourceFileType) ?? false) { if (!sourceSpecsByParser.ContainsKey(parser)) sourceSpecsByParser[parser] = []; @@ -30,4 +30,4 @@ public static bool GroupSourceSpecsByParser(List parserBuilders, return false; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Xml/Tree/Extensions.cs b/Rewrite/src/Rewrite.Xml/Tree/Extensions.cs index f7f96378..53c71f56 100644 --- a/Rewrite/src/Rewrite.Xml/Tree/Extensions.cs +++ b/Rewrite/src/Rewrite.Xml/Tree/Extensions.cs @@ -10,22 +10,24 @@ public static Xml.Document WithEof(this Xml.Document document, string eof) return eof == document.Eof ? document : new Xml.Document(document.Id, document.SourcePath, document.Prefix, document.Markers, document.CharsetName, document.CharsetBomMarked, document.Checksum, document.FileAttributes, document.Prolog, document.Root, eof); } - public static Xml.Tag WithContent(this Xml.Tag tag, IList? content) + public static Xml.Tag WithContent(this Xml.Tag tag, IList? content) { - if (tag.Content == content) { + if (ReferenceEquals(tag.Content, content)) { return tag; } + content ??= []; + tag = new Xml.Tag(tag.Id, tag.Prefix, tag.Markers, tag.Name, tag.Attributes, content, tag.ClosingTag, tag.BeforeTagDelimiterPrefix); if (tag.ClosingTag == null) { - if (content != null && content.Count > 0) { + if (tag.Content != null && tag.Content.Count > 0) { // TODO test this string indentedClosingTagPrefix = tag.Prefix.Substring(Math.Max(0, tag.Prefix.LastIndexOf('\n'))); if (tag.Content[0] is Xml.CharData) { return tag.WithClosingTag(new Xml.Tag.Closing(Core.Tree.RandomId(), - content[0].GetPrefix().Contains('\n') ? + tag.Content[0].GetPrefix().Contains('\n') ? indentedClosingTagPrefix : "", Markers.EMPTY, tag.Name, "")); @@ -78,4 +80,4 @@ public static string GetPrefix(this Xml.Ident ident) { return ident.Prefix; } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Xml/Tree/Xml.cs b/Rewrite/src/Rewrite.Xml/Tree/Xml.cs index fd4f06bf..41e0c3ff 100644 --- a/Rewrite/src/Rewrite.Xml/Tree/Xml.cs +++ b/Rewrite/src/Rewrite.Xml/Tree/Xml.cs @@ -347,7 +347,7 @@ public sealed class Tag( Markers markers, string name, IList attributes, - IList? content, + IList content, Tag.Closing? closingTag, string beforeTagDelimiterPrefix ) : Xml, Content, MutableTree @@ -392,9 +392,9 @@ public Tag WithAttributes(IList newAttributes) return newAttributes == attributes ? this : new Tag(id, prefix, markers, name, newAttributes, content, closingTag, beforeTagDelimiterPrefix); } - public IList? Content => content; + public IList Content => content; - public Tag WithContent(IList? newContent) + public Tag WithContent(IList newContent) { return newContent == content ? this : new Tag(id, prefix, markers, name, attributes, newContent, closingTag, beforeTagDelimiterPrefix); } diff --git a/Rewrite/src/Rewrite.Xml/XmlPrinter.cs b/Rewrite/src/Rewrite.Xml/XmlPrinter.cs index feb0e487..5f0fcc79 100644 --- a/Rewrite/src/Rewrite.Xml/XmlPrinter.cs +++ b/Rewrite/src/Rewrite.Xml/XmlPrinter.cs @@ -9,7 +9,7 @@ public class XmlPrinter

: XmlVisitor> public override Tree.Xml VisitDocument(Tree.Xml.Document document, PrintOutputCapture

p) { BeforeSyntax(document, p); - document = (Tree.Xml.Document)base.VisitDocument(document, p); + document = (Tree.Xml.Document)base.VisitDocument(document, p)!; AfterSyntax(document, p); p.Append(document.Eof); return document; @@ -18,7 +18,7 @@ public override Tree.Xml VisitDocument(Tree.Xml.Document document, PrintOutputCa public override Tree.Xml VisitProlog(Tree.Xml.Prolog prolog, PrintOutputCapture

p) { BeforeSyntax(prolog, p); - prolog = (Tree.Xml.Prolog)base.VisitProlog(prolog, p); + prolog = (Tree.Xml.Prolog)base.VisitProlog(prolog, p)!; AfterSyntax(prolog, p); return prolog; } @@ -206,4 +206,4 @@ private void AfterSyntax(Tree.Xml x, PrintOutputCapture

p) p.Append(p.MarkerPrinter.AfterSyntax(marker, new Cursor(Cursor, marker), XmlMarkerWrapper)); } } -} \ No newline at end of file +} diff --git a/Rewrite/src/Rewrite.Xml/XmlVisitor.cs b/Rewrite/src/Rewrite.Xml/XmlVisitor.cs index dfa672ac..971582b6 100644 --- a/Rewrite/src/Rewrite.Xml/XmlVisitor.cs +++ b/Rewrite/src/Rewrite.Xml/XmlVisitor.cs @@ -26,15 +26,15 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) { prolog = prolog.WithMarkers(VisitMarkers(prolog.Markers, p)); prolog = prolog.WithXmlDecl(VisitAndCast(prolog.XmlDecl, p)); - prolog = prolog.WithMisc(ListUtils.Map(prolog.Misc, el => (Misc?)Visit(el, p))); - prolog = prolog.WithJspDirectives(ListUtils.Map(prolog.JspDirectives, el => (Xml.JspDirective?)Visit(el, p))); + prolog = prolog.WithMisc(prolog.Misc.Map(el => (Misc?)Visit(el, p))); + prolog = prolog.WithJspDirectives(prolog.JspDirectives.Map(el => (Xml.JspDirective?)Visit(el, p))); return prolog; } public virtual Xml? VisitXmlDecl(Xml.XmlDecl xmlDecl, P p) { xmlDecl = xmlDecl.WithMarkers(VisitMarkers(xmlDecl.Markers, p)); - xmlDecl = xmlDecl.WithAttributes(ListUtils.Map(xmlDecl.Attributes, el => (Xml.Attribute?)Visit(el, p))); + xmlDecl = xmlDecl.WithAttributes(xmlDecl.Attributes.Map(el => (Xml.Attribute?)Visit(el, p))); return xmlDecl; } @@ -48,8 +48,8 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) public virtual Xml? VisitTag(Xml.Tag tag, P p) { tag = tag.WithMarkers(VisitMarkers(tag.Markers, p)); - tag = tag.WithAttributes(ListUtils.Map(tag.Attributes, el => (Xml.Attribute?)Visit(el, p))); - tag = tag.WithContent(ListUtils.Map(tag.Content, el => (Content?)Visit(el, p))); + tag = tag.WithAttributes(tag.Attributes.Map(el => (Xml.Attribute?)Visit(el, p))); + tag = tag.WithContent(tag.Content.Map(el => (Content?)Visit(el, p))); tag = tag.WithClosingTag(VisitAndCast(tag.ClosingTag, p)); return tag; } @@ -91,7 +91,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) docTypeDecl = docTypeDecl.WithMarkers(VisitMarkers(docTypeDecl.Markers, p)); docTypeDecl = docTypeDecl.WithName(VisitAndCast(docTypeDecl.Name, p)!); docTypeDecl = docTypeDecl.WithExternalId(VisitAndCast(docTypeDecl.ExternalId, p)); - docTypeDecl = docTypeDecl.WithInternalSubset(ListUtils.Map(docTypeDecl.InternalSubset, el => (Xml.Ident?)Visit(el, p))); + docTypeDecl = docTypeDecl.WithInternalSubset(docTypeDecl.InternalSubset.Map(el => (Xml.Ident?)Visit(el, p))); docTypeDecl = docTypeDecl.WithSubsets(VisitAndCast(docTypeDecl.Subsets, p)); return docTypeDecl; } @@ -99,14 +99,14 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) public virtual Xml? VisitDocTypeDeclExternalSubsets(Xml.DocTypeDecl.ExternalSubsets externalSubsets, P p) { externalSubsets = externalSubsets.WithMarkers(VisitMarkers(externalSubsets.Markers, p)); - externalSubsets = externalSubsets.WithElements(ListUtils.Map(externalSubsets.Elements, el => (Xml.Element?)Visit(el, p))); + externalSubsets = externalSubsets.WithElements(externalSubsets.Elements.Map(el => (Xml.Element?)Visit(el, p))); return externalSubsets; } public virtual Xml? VisitElement(Xml.Element element, P p) { element = element.WithMarkers(VisitMarkers(element.Markers, p)); - element = element.WithSubset(ListUtils.Map(element.Subset, el => (Xml.Ident?)Visit(el, p))); + element = element.WithSubset(element.Subset.Map(el => (Xml.Ident?)Visit(el, p))); return element; } @@ -119,7 +119,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) public virtual Xml? VisitJspDirective(Xml.JspDirective jspDirective, P p) { jspDirective = jspDirective.WithMarkers(VisitMarkers(jspDirective.Markers, p)); - jspDirective = jspDirective.WithAttributes(ListUtils.Map(jspDirective.Attributes, el => (Xml.Attribute?)Visit(el, p))); + jspDirective = jspDirective.WithAttributes(jspDirective.Attributes.Map(el => (Xml.Attribute?)Visit(el, p))); return jspDirective; } diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/CSharpTypeAttributionTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/CSharpTypeAttributionTests.cs index 95b645e7..45763c44 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/CSharpTypeAttributionTests.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/CSharpTypeAttributionTests.cs @@ -1,4 +1,5 @@ using FluentAssertions; +using Rewrite.RewriteCSharp.Test; using Rewrite.RewriteCSharp.Test.Api; using Rewrite.RewriteCSharp.Tree; using Rewrite.RewriteJava; diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/FindClassDeclarationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/FindClassDeclarationTests.cs index 675f0eb7..1633224b 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/FindClassDeclarationTests.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/FindClassDeclarationTests.cs @@ -1,4 +1,5 @@ using Rewrite.Recipes; +using Rewrite.RewriteCSharp.Test; using Rewrite.RewriteCSharp.Test.Api; using Rewrite.RewriteJava; using Rewrite.Test; @@ -10,7 +11,7 @@ namespace Rewrite.CSharp.Tests; [Collection("C# remoting")] public class FindClassDeclarationTests : RewriteTest { - public override void Defaults(RecipeSpec spec) + protected override void Defaults(RecipeSpec spec) { spec.Recipe = new FindClass(null); } @@ -31,7 +32,7 @@ public class Foo; ) ); } - + [Fact] public void ClassWithoutBody() { @@ -48,9 +49,9 @@ class Foo; ) ); } - - - + + + [Fact] public void ClassWithEmptyPrimaryCtorWithoutBody() { @@ -67,7 +68,7 @@ class Foo(); ) ); } - + [Fact] public void ClassWithEmptyPrimaryCtorWithEmptyBody() { @@ -77,20 +78,20 @@ public void ClassWithEmptyPrimaryCtorWithEmptyBody() // comment class Foo() { - + } ", @" // comment /*~~>*/class Foo() { - + } " ) ); } - + [Fact(Skip = "For now we dont extract types")] public void ClassWithoutBody2() { @@ -103,4 +104,4 @@ class Foo(int test); ) ); } -} \ No newline at end of file +} diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/FindClassTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/FindClassTests.cs index eb855298..442ab386 100644 --- a/Rewrite/tests/Rewrite.CSharp.Tests/FindClassTests.cs +++ b/Rewrite/tests/Rewrite.CSharp.Tests/FindClassTests.cs @@ -1,4 +1,5 @@ using Rewrite.Recipes; +using Rewrite.RewriteCSharp.Test; using Rewrite.RewriteCSharp.Test.Api; using Rewrite.RewriteJava; using Rewrite.Test; @@ -10,7 +11,7 @@ namespace Rewrite.CSharp.Tests; [Collection("C# remoting")] public class FindClassTests : RewriteTest { - public override void Defaults(RecipeSpec spec) + protected override void Defaults(RecipeSpec spec) { spec.Recipe = new FindClass(null); } @@ -29,7 +30,7 @@ public class Foo; ) ); } - + [Fact] public void FindInterfaceTest() { @@ -44,7 +45,7 @@ public interface Foo{} ) ); } - + [Fact] public void FindRecordTest() { @@ -82,4 +83,4 @@ public interface Baz; ) ); } -} \ No newline at end of file +} From a3b5719390fb9e9f0a2463cf2347171781a642fa Mon Sep 17 00:00:00 2001 From: Andrew Stakhov Date: Thu, 12 Sep 2024 10:49:31 -0400 Subject: [PATCH 2/3] Fix up solution for CI build --- Rewrite/Rewrite.Sources.sln | 117 ++++++++++++++++++ Rewrite/Rewrite.sln | 23 ---- .../{CSharpVisitor.cs => CSharpVisitor.g.cs} | 14 ++- .../Rewrite.CSharp/Tree/{Cs.cs => Cs.g.cs} | 56 +++++---- 4 files changed, 158 insertions(+), 52 deletions(-) create mode 100644 Rewrite/Rewrite.Sources.sln rename Rewrite/src/Rewrite.CSharp/{CSharpVisitor.cs => CSharpVisitor.g.cs} (96%) rename Rewrite/src/Rewrite.CSharp/Tree/{Cs.cs => Cs.g.cs} (98%) diff --git a/Rewrite/Rewrite.Sources.sln b/Rewrite/Rewrite.Sources.sln new file mode 100644 index 00000000..197ba57e --- /dev/null +++ b/Rewrite/Rewrite.Sources.sln @@ -0,0 +1,117 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Core", "src\Rewrite.Core\Rewrite.Core.csproj", "{FB30394C-7930-4BFF-97E2-400CFADE92C2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Properties", "src\Rewrite.Properties\Rewrite.Properties.csproj", "{C7E280C5-E841-4690-8AA3-653ECBC7C78B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Yaml", "src\Rewrite.Yaml\Rewrite.Yaml.csproj", "{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Xml", "src\Rewrite.Xml\Rewrite.Xml.csproj", "{D38BB305-3276-4AE1-87B1-C19C7A9F3840}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Json", "src\Rewrite.Json\Rewrite.Json.csproj", "{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Java", "src\Rewrite.Java\Rewrite.Java.csproj", "{06BCC1C7-9D8C-4D3B-934D-072C35A5C984}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp", "src\Rewrite.CSharp\Rewrite.CSharp.csproj", "{25208A27-E598-4BE3-9CD9-0618A6B9598F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Tests", "tests\Rewrite.CSharp.Tests\Rewrite.CSharp.Tests.csproj", "{25EEACCB-9BAE-4361-A980-9E9CDA37602E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Test", "src\Rewrite.Test\Rewrite.Test.csproj", "{D3F48947-C702-4D1A-B6EE-96B89D13953D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Test.Api", "src\Rewrite.CSharp.Test.Api\Rewrite.CSharp.Test.Api.csproj", "{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C7A4A8F9-0343-4A3E-AB77-101C458C23B5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7B268266-B9CD-4D85-ABC5-3B2C4611FD74}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_solution", "_solution", "{B5C675AF-506B-47E6-AB10-4E7BC36531D2}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + README.md = README.md + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Test", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.CSharp.Test\Rewrite.CSharp.Test.csproj", "{E3A7B93C-310E-4109-8F80-C469215FB93B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "commercial", "commercial", "{45B6292D-DC7E-46A7-A86E-7455BBEAED70}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Remote", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.Remote\Rewrite.Remote.csproj", "{0E364862-1ACA-4C94-8EA0-23724FF67AA2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.MSBuild", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.MSBuild\Rewrite.MSBuild.csproj", "{DE03049F-95A3-483F-939C-C2325548D590}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FB30394C-7930-4BFF-97E2-400CFADE92C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FB30394C-7930-4BFF-97E2-400CFADE92C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FB30394C-7930-4BFF-97E2-400CFADE92C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FB30394C-7930-4BFF-97E2-400CFADE92C2}.Release|Any CPU.Build.0 = Release|Any CPU + {C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Release|Any CPU.Build.0 = Release|Any CPU + {F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Release|Any CPU.Build.0 = Release|Any CPU + {D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Release|Any CPU.Build.0 = Release|Any CPU + {5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Release|Any CPU.Build.0 = Release|Any CPU + {06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Release|Any CPU.Build.0 = Release|Any CPU + {25208A27-E598-4BE3-9CD9-0618A6B9598F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25208A27-E598-4BE3-9CD9-0618A6B9598F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25208A27-E598-4BE3-9CD9-0618A6B9598F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25208A27-E598-4BE3-9CD9-0618A6B9598F}.Release|Any CPU.Build.0 = Release|Any CPU + {25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Release|Any CPU.Build.0 = Release|Any CPU + {D3F48947-C702-4D1A-B6EE-96B89D13953D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3F48947-C702-4D1A-B6EE-96B89D13953D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3F48947-C702-4D1A-B6EE-96B89D13953D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3F48947-C702-4D1A-B6EE-96B89D13953D}.Release|Any CPU.Build.0 = Release|Any CPU + {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.Build.0 = Release|Any CPU + {E3A7B93C-310E-4109-8F80-C469215FB93B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3A7B93C-310E-4109-8F80-C469215FB93B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3A7B93C-310E-4109-8F80-C469215FB93B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3A7B93C-310E-4109-8F80-C469215FB93B}.Release|Any CPU.Build.0 = Release|Any CPU + {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Release|Any CPU.Build.0 = Release|Any CPU + {DE03049F-95A3-483F-939C-C2325548D590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE03049F-95A3-483F-939C-C2325548D590}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE03049F-95A3-483F-939C-C2325548D590}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE03049F-95A3-483F-939C-C2325548D590}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {25EEACCB-9BAE-4361-A980-9E9CDA37602E} = {7B268266-B9CD-4D85-ABC5-3B2C4611FD74} + {FB30394C-7930-4BFF-97E2-400CFADE92C2} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {25208A27-E598-4BE3-9CD9-0618A6B9598F} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {06BCC1C7-9D8C-4D3B-934D-072C35A5C984} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {C7E280C5-E841-4690-8AA3-653ECBC7C78B} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {D3F48947-C702-4D1A-B6EE-96B89D13953D} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {D38BB305-3276-4AE1-87B1-C19C7A9F3840} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {F7F4F27F-2CAE-422B-B6CE-25A88C3603A1} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} + {0E364862-1ACA-4C94-8EA0-23724FF67AA2} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70} + {DE03049F-95A3-483F-939C-C2325548D590} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70} + {E3A7B93C-310E-4109-8F80-C469215FB93B} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70} + EndGlobalSection +EndGlobal diff --git a/Rewrite/Rewrite.sln b/Rewrite/Rewrite.sln index 197ba57e..fd0f3cc8 100644 --- a/Rewrite/Rewrite.sln +++ b/Rewrite/Rewrite.sln @@ -32,14 +32,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_solution", "_solution", "{ README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Test", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.CSharp.Test\Rewrite.CSharp.Test.csproj", "{E3A7B93C-310E-4109-8F80-C469215FB93B}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "commercial", "commercial", "{45B6292D-DC7E-46A7-A86E-7455BBEAED70}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Remote", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.Remote\Rewrite.Remote.csproj", "{0E364862-1ACA-4C94-8EA0-23724FF67AA2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.MSBuild", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.MSBuild\Rewrite.MSBuild.csproj", "{DE03049F-95A3-483F-939C-C2325548D590}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,18 +78,6 @@ Global {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.Build.0 = Release|Any CPU - {E3A7B93C-310E-4109-8F80-C469215FB93B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E3A7B93C-310E-4109-8F80-C469215FB93B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E3A7B93C-310E-4109-8F80-C469215FB93B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E3A7B93C-310E-4109-8F80-C469215FB93B}.Release|Any CPU.Build.0 = Release|Any CPU - {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Release|Any CPU.Build.0 = Release|Any CPU - {DE03049F-95A3-483F-939C-C2325548D590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DE03049F-95A3-483F-939C-C2325548D590}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DE03049F-95A3-483F-939C-C2325548D590}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DE03049F-95A3-483F-939C-C2325548D590}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {25EEACCB-9BAE-4361-A980-9E9CDA37602E} = {7B268266-B9CD-4D85-ABC5-3B2C4611FD74} @@ -110,8 +90,5 @@ Global {D3F48947-C702-4D1A-B6EE-96B89D13953D} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} {D38BB305-3276-4AE1-87B1-C19C7A9F3840} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} {F7F4F27F-2CAE-422B-B6CE-25A88C3603A1} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5} - {0E364862-1ACA-4C94-8EA0-23724FF67AA2} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70} - {DE03049F-95A3-483F-939C-C2325548D590} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70} - {E3A7B93C-310E-4109-8F80-C469215FB93B} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70} EndGlobalSection EndGlobal diff --git a/Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs b/Rewrite/src/Rewrite.CSharp/CSharpVisitor.g.cs similarity index 96% rename from Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs rename to Rewrite/src/Rewrite.CSharp/CSharpVisitor.g.cs index e4dcc097..9195fcae 100644 --- a/Rewrite/src/Rewrite.CSharp/CSharpVisitor.cs +++ b/Rewrite/src/Rewrite.CSharp/CSharpVisitor.g.cs @@ -1,3 +1,11 @@ +//------------------------------------------------------------------------------ +// +// 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.CodeAnalysis; using Rewrite.Core; using Rewrite.RewriteCSharp.Tree; @@ -291,7 +299,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) return propertyDeclaration; } - protected JContainer? VisitContainer(JContainer? container, CsContainer.Location loc, P p) where J2 : J + protected virtual JContainer? VisitContainer(JContainer? container, CsContainer.Location loc, P p) where J2 : J { if (container == null) { return null; @@ -309,7 +317,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) JContainer.Build(before!, js, container.Markers); } - protected JLeftPadded? VisitLeftPadded(JLeftPadded? left, CsLeftPadded.Location loc, P p) + protected virtual JLeftPadded? VisitLeftPadded(JLeftPadded? left, CsLeftPadded.Location loc, P p) { if (left == null) { @@ -334,7 +342,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p) return t == null ? null : new JLeftPadded(before, t, left.Markers); } - protected JRightPadded? VisitRightPadded(JRightPadded? right, CsRightPadded.Location loc, P p) + protected virtual JRightPadded? VisitRightPadded(JRightPadded? right, CsRightPadded.Location loc, P p) { if (right == null) { diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Cs.cs b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs similarity index 98% rename from Rewrite/src/Rewrite.CSharp/Tree/Cs.cs rename to Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs index c3628579..2552c042 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/Cs.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs @@ -1,3 +1,11 @@ +//------------------------------------------------------------------------------ +// +// 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.CodeAnalysis; using Rewrite.Core; using Rewrite.Core.Marker; @@ -12,7 +20,7 @@ namespace Rewrite.RewriteCSharp.Tree; [SuppressMessage("ReSharper", "RedundantExtendsListEntry")] [SuppressMessage("ReSharper", "UnusedMember.Global")] [SuppressMessage("ReSharper", "RedundantNameQualifier")] -public interface Cs : J +public partial interface Cs : J { bool Core.Tree.IsAcceptable(ITreeVisitor v, P p) { @@ -28,8 +36,8 @@ bool Core.Tree.IsAcceptable(ITreeVisitor v, P p) { return v.DefaultValue(this, p); } -#pragma warning disable CS0108 - public class CompilationUnit( + + public partial class CompilationUnit( Guid id, Space prefix, Markers markers, @@ -44,7 +52,6 @@ public class CompilationUnit( IList> members, Space eof ) : Cs, MutableSourceFile, JavaSourceFile, MutableTree -#pragma warning restore CS0108 { [NonSerialized] private WeakReference? _padding; @@ -94,7 +101,6 @@ public CompilationUnit WithPrefix(Space newPrefix) public CompilationUnit WithMarkers(Markers newMarkers) { - // todo: AS: review if this should be reference equality or value equality check return ReferenceEquals(newMarkers, markers) ? this : new CompilationUnit(id, prefix, newMarkers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); } @@ -212,7 +218,7 @@ public override int GetHashCode() } } - public class AnnotatedStatement( + public partial class AnnotatedStatement( Guid id, Space prefix, Markers markers, @@ -271,7 +277,7 @@ public override int GetHashCode() } } - public class ArrayRankSpecifier( + public partial class ArrayRankSpecifier( Guid id, Space prefix, Markers markers, @@ -364,8 +370,8 @@ public override int GetHashCode() return Id.GetHashCode(); } } -#pragma warning disable CS0108 - public class AssignmentOperation( + + public partial class AssignmentOperation( Guid id, Space prefix, Markers markers, @@ -374,7 +380,6 @@ public class AssignmentOperation( Expression assignment, JavaType? type ) : Cs, Statement, Expression, TypedTree, MutableTree -#pragma warning restore CS0108 { [NonSerialized] private WeakReference? _padding; @@ -484,7 +489,7 @@ public override int GetHashCode() } } - public class AttributeList( + public partial class AttributeList( Guid id, Space prefix, Markers markers, @@ -588,7 +593,7 @@ public override int GetHashCode() } } - public class AwaitExpression( + public partial class AwaitExpression( Guid id, Space prefix, Markers markers, @@ -646,8 +651,8 @@ public override int GetHashCode() return Id.GetHashCode(); } } -#pragma warning disable CS0108 - public class Binary( + + public partial class Binary( Guid id, Space prefix, Markers markers, @@ -656,7 +661,6 @@ public class Binary( Expression right, JavaType? type ) : Cs, Expression, TypedTree, MutableTree -#pragma warning restore CS0108 { [NonSerialized] private WeakReference? _padding; @@ -767,7 +771,7 @@ public override int GetHashCode() } } - public class BlockScopeNamespaceDeclaration( + public partial class BlockScopeNamespaceDeclaration( Guid id, Space prefix, Markers markers, @@ -911,7 +915,7 @@ public override int GetHashCode() } } - public class CollectionExpression( + public partial class CollectionExpression( Guid id, Space prefix, Markers markers, @@ -1007,7 +1011,7 @@ public override int GetHashCode() } } - public class ExpressionStatement( + public partial class ExpressionStatement( Guid id, Space prefix, Markers markers, @@ -1058,7 +1062,7 @@ public override int GetHashCode() } } - public class ExternAlias( + public partial class ExternAlias( Guid id, Space prefix, Markers markers, @@ -1146,7 +1150,7 @@ public override int GetHashCode() } } - public class FileScopeNamespaceDeclaration( + public partial class FileScopeNamespaceDeclaration( Guid id, Space prefix, Markers markers, @@ -1282,7 +1286,7 @@ public override int GetHashCode() } } - public class InterpolatedString( + public partial class InterpolatedString( Guid id, Space prefix, Markers markers, @@ -1392,7 +1396,7 @@ public override int GetHashCode() } } - public class Interpolation( + public partial class Interpolation( Guid id, Space prefix, Markers markers, @@ -1518,7 +1522,7 @@ public override int GetHashCode() } } - public class NullSafeExpression( + public partial class NullSafeExpression( Guid id, Space prefix, Markers markers, @@ -1612,7 +1616,7 @@ public override int GetHashCode() } } - public class StatementExpression( + public partial class StatementExpression( Guid id, Space prefix, Markers markers, @@ -1669,7 +1673,7 @@ public override int GetHashCode() } } - public class UsingDirective( + public partial class UsingDirective( Guid id, Space prefix, Markers markers, @@ -1813,7 +1817,7 @@ public override int GetHashCode() } } - public class PropertyDeclaration( + public partial class PropertyDeclaration( Guid id, Space prefix, Markers markers, From 0977165934d46665a7db48e2f2220a0f12ea5a58 Mon Sep 17 00:00:00 2001 From: Andrew Stakhov Date: Wed, 18 Sep 2024 20:17:36 -0400 Subject: [PATCH 3/3] Commit regenerated sources from code generator --- Rewrite/Rewrite.Sources.sln.DotSettings.user | 4 + .../Tree/AnnotatedStatement.g.cs | 78 + .../Tree/ArrayRankSpecifier.g.cs | 114 + .../Tree/AssignmentOperation.g.cs | 133 ++ .../Rewrite.CSharp/Tree/AttributeList.g.cs | 123 ++ .../Rewrite.CSharp/Tree/AwaitExpression.g.cs | 78 + Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs | 134 ++ .../Tree/BlockScopeNamespaceDeclaration.g.cs | 160 ++ .../Tree/CollectionExpression.g.cs | 115 + .../Rewrite.CSharp/Tree/CompilationUnit.g.cs | 192 ++ Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs | 1924 ----------------- .../Tree/ExpressionStatement.g.cs | 71 + .../src/Rewrite.CSharp/Tree/ExternAlias.g.cs | 108 + .../Tree/FileScopeNamespaceDeclaration.g.cs | 153 ++ .../Tree/InterpolatedString.g.cs | 128 ++ .../Rewrite.CSharp/Tree/Interpolation.g.cs | 144 ++ .../Tree/NullSafeExpression.g.cs | 114 + .../Tree/PropertyDeclaration.g.cs | 158 ++ .../Tree/StatementExpression.g.cs | 77 + .../Rewrite.CSharp/Tree/UsingDirective.g.cs | 160 ++ 20 files changed, 2244 insertions(+), 1924 deletions(-) create mode 100644 Rewrite/Rewrite.Sources.sln.DotSettings.user create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/AttributeList.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/CollectionExpression.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/InterpolatedString.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs create mode 100644 Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs diff --git a/Rewrite/Rewrite.Sources.sln.DotSettings.user b/Rewrite/Rewrite.Sources.sln.DotSettings.user new file mode 100644 index 00000000..43ed04f2 --- /dev/null +++ b/Rewrite/Rewrite.Sources.sln.DotSettings.user @@ -0,0 +1,4 @@ + + <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;tests&gt;\&lt;Rewrite.CSharp.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Project Location="C:\projects\openrewrite\rewrite-csharp\Rewrite\tests\Rewrite.CSharp.Tests" Presentation="&lt;tests&gt;\&lt;Rewrite.CSharp.Tests&gt;" /> +</SessionState> \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs new file mode 100644 index 00000000..d3a2dcd0 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/AnnotatedStatement.g.cs @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class AnnotatedStatement( + Guid id, + Space prefix, + Markers markers, + IList attributeLists, + Statement statement + ) : Cs, Statement, MutableTree + { + public J? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitAnnotatedStatement(this, p); + } + + public Guid Id => id; + + public AnnotatedStatement WithId(Guid newId) + { + return newId == id ? this : new AnnotatedStatement(newId, prefix, markers, attributeLists, statement); + } + public Space Prefix => prefix; + + public AnnotatedStatement WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new AnnotatedStatement(id, newPrefix, markers, attributeLists, statement); + } + public Markers Markers => markers; + + public AnnotatedStatement WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new AnnotatedStatement(id, prefix, newMarkers, attributeLists, statement); + } + public IList AttributeLists => attributeLists; + + public AnnotatedStatement WithAttributeLists(IList newAttributeLists) + { + return newAttributeLists == attributeLists ? this : new AnnotatedStatement(id, prefix, markers, newAttributeLists, statement); + } + public Statement Statement => statement; + + public AnnotatedStatement WithStatement(Statement newStatement) + { + return ReferenceEquals(newStatement, statement) ? this : new AnnotatedStatement(id, prefix, markers, attributeLists, newStatement); + } + public bool Equals(Rewrite.Core.Tree? other) + { + return other is AnnotatedStatement && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs new file mode 100644 index 00000000..4a5e88b4 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/ArrayRankSpecifier.g.cs @@ -0,0 +1,114 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class ArrayRankSpecifier( + Guid id, + Space prefix, + Markers markers, + JContainer sizes + ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitArrayRankSpecifier(this, p); + } + + public JavaType? Type => Extensions.GetJavaType(this); + + public ArrayRankSpecifier WithType(JavaType newType) + { + return Extensions.WithJavaType(this, newType); + } + public Guid Id => id; + + public ArrayRankSpecifier WithId(Guid newId) + { + return newId == id ? this : new ArrayRankSpecifier(newId, prefix, markers, _sizes); + } + public Space Prefix => prefix; + + public ArrayRankSpecifier WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new ArrayRankSpecifier(id, newPrefix, markers, _sizes); + } + public Markers Markers => markers; + + public ArrayRankSpecifier WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new ArrayRankSpecifier(id, prefix, newMarkers, _sizes); + } + private readonly JContainer _sizes = sizes; + public IList Sizes => _sizes.GetElements(); + + public ArrayRankSpecifier WithSizes(IList newSizes) + { + return Padding.WithSizes(JContainer.WithElements(_sizes, newSizes)); + } + public sealed record PaddingHelper(Cs.ArrayRankSpecifier T) + { + public JContainer Sizes => T._sizes; + + public Cs.ArrayRankSpecifier WithSizes(JContainer newSizes) + { + return T._sizes == newSizes ? T : new Cs.ArrayRankSpecifier(T.Id, T.Prefix, T.Markers, newSizes); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is ArrayRankSpecifier && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs new file mode 100644 index 00000000..ea50d913 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/AssignmentOperation.g.cs @@ -0,0 +1,133 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class AssignmentOperation( + Guid id, + Space prefix, + Markers markers, + Expression variable, + JLeftPadded @operator, + Expression assignment, + JavaType? type + ) : Cs, Statement, Expression, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitAssignmentOperation(this, p); + } + + public Guid Id => id; + + public AssignmentOperation WithId(Guid newId) + { + return newId == id ? this : new AssignmentOperation(newId, prefix, markers, variable, _operator, assignment, type); + } + public Space Prefix => prefix; + + public AssignmentOperation WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new AssignmentOperation(id, newPrefix, markers, variable, _operator, assignment, type); + } + public Markers Markers => markers; + + public AssignmentOperation WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new AssignmentOperation(id, prefix, newMarkers, variable, _operator, assignment, type); + } + public Expression Variable => variable; + + public AssignmentOperation WithVariable(Expression newVariable) + { + return ReferenceEquals(newVariable, variable) ? this : new AssignmentOperation(id, prefix, markers, newVariable, _operator, assignment, type); + } + private readonly JLeftPadded _operator = @operator; + public OperatorType Operator => _operator.Element; + + public AssignmentOperation WithOperator(OperatorType newOperator) + { + return Padding.WithOperator(_operator.WithElement(newOperator)); + } + public Expression Assignment => assignment; + + public AssignmentOperation WithAssignment(Expression newAssignment) + { + return ReferenceEquals(newAssignment, assignment) ? this : new AssignmentOperation(id, prefix, markers, variable, _operator, newAssignment, type); + } + public JavaType? Type => type; + + public AssignmentOperation WithType(JavaType? newType) + { + return newType == type ? this : new AssignmentOperation(id, prefix, markers, variable, _operator, assignment, newType); + } + public enum OperatorType + { + NullCoalescing, + } + public sealed record PaddingHelper(Cs.AssignmentOperation T) + { + public JLeftPadded Operator => T._operator; + + public Cs.AssignmentOperation WithOperator(JLeftPadded newOperator) + { + return T._operator == newOperator ? T : new Cs.AssignmentOperation(T.Id, T.Prefix, T.Markers, T.Variable, newOperator, T.Assignment, T.Type); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is AssignmentOperation && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/AttributeList.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/AttributeList.g.cs new file mode 100644 index 00000000..51b31b81 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/AttributeList.g.cs @@ -0,0 +1,123 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class AttributeList( + Guid id, + Space prefix, + Markers markers, + JRightPadded? target, + IList> attributes + ) : Cs, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitAttributeList(this, p); + } + + public Guid Id => id; + + public AttributeList WithId(Guid newId) + { + return newId == id ? this : new AttributeList(newId, prefix, markers, _target, _attributes); + } + public Space Prefix => prefix; + + public AttributeList WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new AttributeList(id, newPrefix, markers, _target, _attributes); + } + public Markers Markers => markers; + + public AttributeList WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new AttributeList(id, prefix, newMarkers, _target, _attributes); + } + private readonly JRightPadded? _target = target; + public J.Identifier? Target => _target?.Element; + + public AttributeList WithTarget(J.Identifier? newTarget) + { + return Padding.WithTarget(JRightPadded.WithElement(_target, newTarget)); + } + private readonly IList> _attributes = attributes; + public IList Attributes => _attributes.Elements(); + + public AttributeList WithAttributes(IList newAttributes) + { + return Padding.WithAttributes(_attributes.WithElements(newAttributes)); + } + public sealed record PaddingHelper(Cs.AttributeList T) + { + public JRightPadded? Target => T._target; + + public Cs.AttributeList WithTarget(JRightPadded? newTarget) + { + return T._target == newTarget ? T : new Cs.AttributeList(T.Id, T.Prefix, T.Markers, newTarget, T._attributes); + } + + public IList> Attributes => T._attributes; + + public Cs.AttributeList WithAttributes(IList> newAttributes) + { + return T._attributes == newAttributes ? T : new Cs.AttributeList(T.Id, T.Prefix, T.Markers, T._target, newAttributes); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is AttributeList && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs new file mode 100644 index 00000000..2d629eaa --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/AwaitExpression.g.cs @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class AwaitExpression( + Guid id, + Space prefix, + Markers markers, + Expression expression, + JavaType? type + ) : Cs, Expression, MutableTree + { + public J? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitAwaitExpression(this, p); + } + + public Guid Id => id; + + public AwaitExpression WithId(Guid newId) + { + return newId == id ? this : new AwaitExpression(newId, prefix, markers, expression, type); + } + public Space Prefix => prefix; + + public AwaitExpression WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new AwaitExpression(id, newPrefix, markers, expression, type); + } + public Markers Markers => markers; + + public AwaitExpression WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new AwaitExpression(id, prefix, newMarkers, expression, type); + } + public Expression Expression => expression; + + public AwaitExpression WithExpression(Expression newExpression) + { + return ReferenceEquals(newExpression, expression) ? this : new AwaitExpression(id, prefix, markers, newExpression, type); + } + public JavaType? Type => type; + + public AwaitExpression WithType(JavaType? newType) + { + return newType == type ? this : new AwaitExpression(id, prefix, markers, expression, newType); + } + public bool Equals(Rewrite.Core.Tree? other) + { + return other is AwaitExpression && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs new file mode 100644 index 00000000..3f6500cf --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/Binary.g.cs @@ -0,0 +1,134 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class Binary( + Guid id, + Space prefix, + Markers markers, + Expression left, + JLeftPadded @operator, + Expression right, + JavaType? type + ) : Cs, Expression, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitBinary(this, p); + } + + public Guid Id => id; + + public Binary WithId(Guid newId) + { + return newId == id ? this : new Binary(newId, prefix, markers, left, _operator, right, type); + } + public Space Prefix => prefix; + + public Binary WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new Binary(id, newPrefix, markers, left, _operator, right, type); + } + public Markers Markers => markers; + + public Binary WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new Binary(id, prefix, newMarkers, left, _operator, right, type); + } + public Expression Left => left; + + public Binary WithLeft(Expression newLeft) + { + return ReferenceEquals(newLeft, left) ? this : new Binary(id, prefix, markers, newLeft, _operator, right, type); + } + private readonly JLeftPadded _operator = @operator; + public OperatorType Operator => _operator.Element; + + public Binary WithOperator(OperatorType newOperator) + { + return Padding.WithOperator(_operator.WithElement(newOperator)); + } + public Expression Right => right; + + public Binary WithRight(Expression newRight) + { + return ReferenceEquals(newRight, right) ? this : new Binary(id, prefix, markers, left, _operator, newRight, type); + } + public JavaType? Type => type; + + public Binary WithType(JavaType? newType) + { + return newType == type ? this : new Binary(id, prefix, markers, left, _operator, right, newType); + } + public enum OperatorType + { + As, + NullCoalescing, + } + public sealed record PaddingHelper(Cs.Binary T) + { + public JLeftPadded Operator => T._operator; + + public Cs.Binary WithOperator(JLeftPadded newOperator) + { + return T._operator == newOperator ? T : new Cs.Binary(T.Id, T.Prefix, T.Markers, T.Left, newOperator, T.Right, T.Type); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is Binary && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs new file mode 100644 index 00000000..2c3f381c --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/BlockScopeNamespaceDeclaration.g.cs @@ -0,0 +1,160 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class BlockScopeNamespaceDeclaration( + Guid id, + Space prefix, + Markers markers, + JRightPadded name, + IList> externs, + IList> usings, + IList> members, + Space end + ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitBlockScopeNamespaceDeclaration(this, p); + } + + public Guid Id => id; + + public BlockScopeNamespaceDeclaration WithId(Guid newId) + { + return newId == id ? this : new BlockScopeNamespaceDeclaration(newId, prefix, markers, _name, _externs, _usings, _members, end); + } + public Space Prefix => prefix; + + public BlockScopeNamespaceDeclaration WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new BlockScopeNamespaceDeclaration(id, newPrefix, markers, _name, _externs, _usings, _members, end); + } + public Markers Markers => markers; + + public BlockScopeNamespaceDeclaration WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new BlockScopeNamespaceDeclaration(id, prefix, newMarkers, _name, _externs, _usings, _members, end); + } + private readonly JRightPadded _name = name; + public Expression Name => _name.Element; + + public BlockScopeNamespaceDeclaration WithName(Expression newName) + { + return Padding.WithName(_name.WithElement(newName)); + } + private readonly IList> _externs = externs; + public IList Externs => _externs.Elements(); + + public BlockScopeNamespaceDeclaration WithExterns(IList newExterns) + { + return Padding.WithExterns(_externs.WithElements(newExterns)); + } + private readonly IList> _usings = usings; + public IList Usings => _usings.Elements(); + + public BlockScopeNamespaceDeclaration WithUsings(IList newUsings) + { + return Padding.WithUsings(_usings.WithElements(newUsings)); + } + private readonly IList> _members = members; + public IList Members => _members.Elements(); + + public BlockScopeNamespaceDeclaration WithMembers(IList newMembers) + { + return Padding.WithMembers(_members.WithElements(newMembers)); + } + public Space End => end; + + public BlockScopeNamespaceDeclaration WithEnd(Space newEnd) + { + return newEnd == end ? this : new BlockScopeNamespaceDeclaration(id, prefix, markers, _name, _externs, _usings, _members, newEnd); + } + public sealed record PaddingHelper(Cs.BlockScopeNamespaceDeclaration T) + { + public JRightPadded Name => T._name; + + public Cs.BlockScopeNamespaceDeclaration WithName(JRightPadded newName) + { + return T._name == newName ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, newName, T._externs, T._usings, T._members, T.End); + } + + public IList> Externs => T._externs; + + public Cs.BlockScopeNamespaceDeclaration WithExterns(IList> newExterns) + { + return T._externs == newExterns ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, newExterns, T._usings, T._members, T.End); + } + + public IList> Usings => T._usings; + + public Cs.BlockScopeNamespaceDeclaration WithUsings(IList> newUsings) + { + return T._usings == newUsings ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, newUsings, T._members, T.End); + } + + public IList> Members => T._members; + + public Cs.BlockScopeNamespaceDeclaration WithMembers(IList> newMembers) + { + return T._members == newMembers ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, T._usings, newMembers, T.End); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is BlockScopeNamespaceDeclaration && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CollectionExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/CollectionExpression.g.cs new file mode 100644 index 00000000..8312178a --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/CollectionExpression.g.cs @@ -0,0 +1,115 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class CollectionExpression( + Guid id, + Space prefix, + Markers markers, + IList> elements, + JavaType type + ) : Cs, Expression, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitCollectionExpression(this, p); + } + + public Guid Id => id; + + public CollectionExpression WithId(Guid newId) + { + return newId == id ? this : new CollectionExpression(newId, prefix, markers, _elements, type); + } + public Space Prefix => prefix; + + public CollectionExpression WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new CollectionExpression(id, newPrefix, markers, _elements, type); + } + public Markers Markers => markers; + + public CollectionExpression WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new CollectionExpression(id, prefix, newMarkers, _elements, type); + } + private readonly IList> _elements = elements; + public IList Elements => _elements.Elements(); + + public CollectionExpression WithElements(IList newElements) + { + return Padding.WithElements(_elements.WithElements(newElements)); + } + public JavaType Type => type; + + public CollectionExpression WithType(JavaType newType) + { + return newType == type ? this : new CollectionExpression(id, prefix, markers, _elements, newType); + } + public sealed record PaddingHelper(Cs.CollectionExpression T) + { + public IList> Elements => T._elements; + + public Cs.CollectionExpression WithElements(IList> newElements) + { + return T._elements == newElements ? T : new Cs.CollectionExpression(T.Id, T.Prefix, T.Markers, newElements, T.Type); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is CollectionExpression && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs new file mode 100644 index 00000000..fe438441 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/CompilationUnit.g.cs @@ -0,0 +1,192 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class CompilationUnit( + Guid id, + Space prefix, + Markers markers, + string sourcePath, + FileAttributes? fileAttributes, + string? charsetName, + bool charsetBomMarked, + Checksum? checksum, + IList> externs, + IList> usings, + IList attributeLists, + IList> members, + Space eof + ) : Cs, MutableSourceFile, JavaSourceFile, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitCompilationUnit(this, p); + } + + public Guid Id => id; + + public CompilationUnit WithId(Guid newId) + { + return newId == id ? this : new CompilationUnit(newId, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); + } + public Space Prefix => prefix; + + public CompilationUnit WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new CompilationUnit(id, newPrefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); + } + public Markers Markers => markers; + + public CompilationUnit WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new CompilationUnit(id, prefix, newMarkers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); + } + public string SourcePath => sourcePath; + + public CompilationUnit WithSourcePath(string newSourcePath) + { + return newSourcePath == sourcePath ? this : new CompilationUnit(id, prefix, markers, newSourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); + } + public FileAttributes? FileAttributes => fileAttributes; + + public CompilationUnit WithFileAttributes(FileAttributes? newFileAttributes) + { + return newFileAttributes == fileAttributes ? this : new CompilationUnit(id, prefix, markers, sourcePath, newFileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); + } + public string? CharsetName => charsetName; + + public CompilationUnit WithCharsetName(string? newCharsetName) + { + return newCharsetName == charsetName ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, newCharsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); + } + public bool CharsetBomMarked => charsetBomMarked; + + public CompilationUnit WithCharsetBomMarked(bool newCharsetBomMarked) + { + return newCharsetBomMarked == charsetBomMarked ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, newCharsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); + } + public Checksum? Checksum => checksum; + + public CompilationUnit WithChecksum(Checksum? newChecksum) + { + return newChecksum == checksum ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, newChecksum, _externs, _usings, attributeLists, _members, eof); + } + private readonly IList> _externs = externs; + public IList Externs => _externs.Elements(); + + public CompilationUnit WithExterns(IList newExterns) + { + return Padding.WithExterns(_externs.WithElements(newExterns)); + } + private readonly IList> _usings = usings; + public IList Usings => _usings.Elements(); + + public CompilationUnit WithUsings(IList newUsings) + { + return Padding.WithUsings(_usings.WithElements(newUsings)); + } + public IList AttributeLists => attributeLists; + + public CompilationUnit WithAttributeLists(IList newAttributeLists) + { + return newAttributeLists == attributeLists ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, newAttributeLists, _members, eof); + } + private readonly IList> _members = members; + public IList Members => _members.Elements(); + + public CompilationUnit WithMembers(IList newMembers) + { + return Padding.WithMembers(_members.WithElements(newMembers)); + } + public Space Eof => eof; + + public CompilationUnit WithEof(Space newEof) + { + return newEof == eof ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, newEof); + } + public sealed record PaddingHelper(Cs.CompilationUnit T) + { + public IList> Externs => T._externs; + + public Cs.CompilationUnit WithExterns(IList> newExterns) + { + return T._externs == newExterns ? T : new Cs.CompilationUnit(T.Id, T.Prefix, T.Markers, T.SourcePath, T.FileAttributes, T.CharsetName, T.CharsetBomMarked, T.Checksum, newExterns, T._usings, T.AttributeLists, T._members, T.Eof); + } + + public IList> Usings => T._usings; + + public Cs.CompilationUnit WithUsings(IList> newUsings) + { + return T._usings == newUsings ? T : new Cs.CompilationUnit(T.Id, T.Prefix, T.Markers, T.SourcePath, T.FileAttributes, T.CharsetName, T.CharsetBomMarked, T.Checksum, T._externs, newUsings, T.AttributeLists, T._members, T.Eof); + } + + public IList> Members => T._members; + + public Cs.CompilationUnit WithMembers(IList> newMembers) + { + return T._members == newMembers ? T : new Cs.CompilationUnit(T.Id, T.Prefix, T.Markers, T.SourcePath, T.FileAttributes, T.CharsetName, T.CharsetBomMarked, T.Checksum, T._externs, T._usings, T.AttributeLists, newMembers, T.Eof); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is CompilationUnit && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + public ITreeVisitor> Printer

(Cursor cursor) + { + return IPrinterFactory.Current()!.CreatePrinter

(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs index 2552c042..03248a88 100644 --- a/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs +++ b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs @@ -37,1928 +37,4 @@ bool Core.Tree.IsAcceptable(ITreeVisitor v, P p) return v.DefaultValue(this, p); } - public partial class CompilationUnit( - Guid id, - Space prefix, - Markers markers, - string sourcePath, - FileAttributes? fileAttributes, - string? charsetName, - bool charsetBomMarked, - Checksum? checksum, - IList> externs, - IList> usings, - IList attributeLists, - IList> members, - Space eof - ) : Cs, MutableSourceFile, JavaSourceFile, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitCompilationUnit(this, p); - } - - public Guid Id => id; - - public CompilationUnit WithId(Guid newId) - { - return newId == id ? this : new CompilationUnit(newId, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); - } - - public Space Prefix => prefix; - - public CompilationUnit WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new CompilationUnit(id, newPrefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); - } - - public Markers Markers => markers; - - public CompilationUnit WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new CompilationUnit(id, prefix, newMarkers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); - } - - public string SourcePath => sourcePath; - - public CompilationUnit WithSourcePath(string newSourcePath) - { - return newSourcePath == sourcePath ? this : new CompilationUnit(id, prefix, markers, newSourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); - } - - public FileAttributes? FileAttributes => fileAttributes; - - public CompilationUnit WithFileAttributes(FileAttributes? newFileAttributes) - { - return newFileAttributes == fileAttributes ? this : new CompilationUnit(id, prefix, markers, sourcePath, newFileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); - } - - public string? CharsetName => charsetName; - - public CompilationUnit WithCharsetName(string? newCharsetName) - { - return newCharsetName == charsetName ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, newCharsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); - } - - public bool CharsetBomMarked => charsetBomMarked; - - public CompilationUnit WithCharsetBomMarked(bool newCharsetBomMarked) - { - return newCharsetBomMarked == charsetBomMarked ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, newCharsetBomMarked, checksum, _externs, _usings, attributeLists, _members, eof); - } - - public Checksum? Checksum => checksum; - - public CompilationUnit WithChecksum(Checksum? newChecksum) - { - return newChecksum == checksum ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, newChecksum, _externs, _usings, attributeLists, _members, eof); - } - - private readonly IList> _externs = externs; - public IList Externs => _externs.Elements(); - - public CompilationUnit WithExterns(IList newExterns) - { - return Padding.WithExterns(_externs.WithElements(newExterns)); - } - - private readonly IList> _usings = usings; - public IList Usings => _usings.Elements(); - - public CompilationUnit WithUsings(IList newUsings) - { - return Padding.WithUsings(_usings.WithElements(newUsings)); - } - - public IList AttributeLists => attributeLists; - - public CompilationUnit WithAttributeLists(IList newAttributeLists) - { - return newAttributeLists == attributeLists ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, newAttributeLists, _members, eof); - } - - private readonly IList> _members = members; - public IList Members => _members.Elements(); - - public CompilationUnit WithMembers(IList newMembers) - { - return Padding.WithMembers(_members.WithElements(newMembers)); - } - - public Space Eof => eof; - - public CompilationUnit WithEof(Space newEof) - { - return newEof == eof ? this : new CompilationUnit(id, prefix, markers, sourcePath, fileAttributes, charsetName, charsetBomMarked, checksum, _externs, _usings, attributeLists, _members, newEof); - } - - public sealed record PaddingHelper(Cs.CompilationUnit T) - { - public IList> Externs => T._externs; - - public Cs.CompilationUnit WithExterns(IList> newExterns) - { - return T._externs == newExterns ? T : new Cs.CompilationUnit(T.Id, T.Prefix, T.Markers, T.SourcePath, T.FileAttributes, T.CharsetName, T.CharsetBomMarked, T.Checksum, newExterns, T._usings, T.AttributeLists, T._members, T.Eof); - } - - public IList> Usings => T._usings; - - public Cs.CompilationUnit WithUsings(IList> newUsings) - { - return T._usings == newUsings ? T : new Cs.CompilationUnit(T.Id, T.Prefix, T.Markers, T.SourcePath, T.FileAttributes, T.CharsetName, T.CharsetBomMarked, T.Checksum, T._externs, newUsings, T.AttributeLists, T._members, T.Eof); - } - - public IList> Members => T._members; - - public Cs.CompilationUnit WithMembers(IList> newMembers) - { - return T._members == newMembers ? T : new Cs.CompilationUnit(T.Id, T.Prefix, T.Markers, T.SourcePath, T.FileAttributes, T.CharsetName, T.CharsetBomMarked, T.Checksum, T._externs, T._usings, T.AttributeLists, newMembers, T.Eof); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is CompilationUnit && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - - public ITreeVisitor> Printer

(Cursor cursor) - { - return IPrinterFactory.Current()!.CreatePrinter

(); - } - } - - public partial class AnnotatedStatement( - Guid id, - Space prefix, - Markers markers, - IList attributeLists, - Statement statement - ) : Cs, Statement, MutableTree - { - public J? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitAnnotatedStatement(this, p); - } - - public Guid Id => id; - - public AnnotatedStatement WithId(Guid newId) - { - return newId == id ? this : new AnnotatedStatement(newId, prefix, markers, attributeLists, statement); - } - - public Space Prefix => prefix; - - public AnnotatedStatement WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new AnnotatedStatement(id, newPrefix, markers, attributeLists, statement); - } - - public Markers Markers => markers; - - public AnnotatedStatement WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new AnnotatedStatement(id, prefix, newMarkers, attributeLists, statement); - } - - public IList AttributeLists => attributeLists; - - public AnnotatedStatement WithAttributeLists(IList newAttributeLists) - { - return newAttributeLists == attributeLists ? this : new AnnotatedStatement(id, prefix, markers, newAttributeLists, statement); - } - - public Statement Statement => statement; - - public AnnotatedStatement WithStatement(Statement newStatement) - { - return ReferenceEquals(newStatement, statement) ? this : new AnnotatedStatement(id, prefix, markers, attributeLists, newStatement); - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is AnnotatedStatement && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class ArrayRankSpecifier( - Guid id, - Space prefix, - Markers markers, - JContainer sizes - ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitArrayRankSpecifier(this, p); - } - - public JavaType? Type => Extensions.GetJavaType(this); - - public ArrayRankSpecifier WithType(JavaType newType) - { - return Extensions.WithJavaType(this, newType); - } - public Guid Id => id; - - public ArrayRankSpecifier WithId(Guid newId) - { - return newId == id ? this : new ArrayRankSpecifier(newId, prefix, markers, _sizes); - } - - public Space Prefix => prefix; - - public ArrayRankSpecifier WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new ArrayRankSpecifier(id, newPrefix, markers, _sizes); - } - - public Markers Markers => markers; - - public ArrayRankSpecifier WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new ArrayRankSpecifier(id, prefix, newMarkers, _sizes); - } - - private readonly JContainer _sizes = sizes; - public IList Sizes => _sizes.GetElements(); - - public ArrayRankSpecifier WithSizes(IList newSizes) - { - return Padding.WithSizes(JContainer.WithElements(_sizes, newSizes)); - } - - public sealed record PaddingHelper(Cs.ArrayRankSpecifier T) - { - public JContainer Sizes => T._sizes; - - public Cs.ArrayRankSpecifier WithSizes(JContainer newSizes) - { - return T._sizes == newSizes ? T : new Cs.ArrayRankSpecifier(T.Id, T.Prefix, T.Markers, newSizes); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is ArrayRankSpecifier && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class AssignmentOperation( - Guid id, - Space prefix, - Markers markers, - Expression variable, - JLeftPadded @operator, - Expression assignment, - JavaType? type - ) : Cs, Statement, Expression, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitAssignmentOperation(this, p); - } - - public Guid Id => id; - - public AssignmentOperation WithId(Guid newId) - { - return newId == id ? this : new AssignmentOperation(newId, prefix, markers, variable, _operator, assignment, type); - } - - public Space Prefix => prefix; - - public AssignmentOperation WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new AssignmentOperation(id, newPrefix, markers, variable, _operator, assignment, type); - } - - public Markers Markers => markers; - - public AssignmentOperation WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new AssignmentOperation(id, prefix, newMarkers, variable, _operator, assignment, type); - } - - public Expression Variable => variable; - - public AssignmentOperation WithVariable(Expression newVariable) - { - return ReferenceEquals(newVariable, variable) ? this : new AssignmentOperation(id, prefix, markers, newVariable, _operator, assignment, type); - } - - private readonly JLeftPadded _operator = @operator; - public OperatorType Operator => _operator.Element; - - public AssignmentOperation WithOperator(OperatorType newOperator) - { - return Padding.WithOperator(_operator.WithElement(newOperator)); - } - - public Expression Assignment => assignment; - - public AssignmentOperation WithAssignment(Expression newAssignment) - { - return ReferenceEquals(newAssignment, assignment) ? this : new AssignmentOperation(id, prefix, markers, variable, _operator, newAssignment, type); - } - - public JavaType? Type => type; - - public AssignmentOperation WithType(JavaType? newType) - { - return newType == type ? this : new AssignmentOperation(id, prefix, markers, variable, _operator, assignment, newType); - } - - public enum OperatorType - { - NullCoalescing, - - } - - public sealed record PaddingHelper(Cs.AssignmentOperation T) - { - public JLeftPadded Operator => T._operator; - - public Cs.AssignmentOperation WithOperator(JLeftPadded newOperator) - { - return T._operator == newOperator ? T : new Cs.AssignmentOperation(T.Id, T.Prefix, T.Markers, T.Variable, newOperator, T.Assignment, T.Type); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is AssignmentOperation && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class AttributeList( - Guid id, - Space prefix, - Markers markers, - JRightPadded? target, - IList> attributes - ) : Cs, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitAttributeList(this, p); - } - - public Guid Id => id; - - public AttributeList WithId(Guid newId) - { - return newId == id ? this : new AttributeList(newId, prefix, markers, _target, _attributes); - } - - public Space Prefix => prefix; - - public AttributeList WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new AttributeList(id, newPrefix, markers, _target, _attributes); - } - - public Markers Markers => markers; - - public AttributeList WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new AttributeList(id, prefix, newMarkers, _target, _attributes); - } - - private readonly JRightPadded? _target = target; - public J.Identifier? Target => _target?.Element; - - public AttributeList WithTarget(J.Identifier? newTarget) - { - return Padding.WithTarget(JRightPadded.WithElement(_target, newTarget)); - } - - private readonly IList> _attributes = attributes; - public IList Attributes => _attributes.Elements(); - - public AttributeList WithAttributes(IList newAttributes) - { - return Padding.WithAttributes(_attributes.WithElements(newAttributes)); - } - - public sealed record PaddingHelper(Cs.AttributeList T) - { - public JRightPadded? Target => T._target; - - public Cs.AttributeList WithTarget(JRightPadded? newTarget) - { - return T._target == newTarget ? T : new Cs.AttributeList(T.Id, T.Prefix, T.Markers, newTarget, T._attributes); - } - - public IList> Attributes => T._attributes; - - public Cs.AttributeList WithAttributes(IList> newAttributes) - { - return T._attributes == newAttributes ? T : new Cs.AttributeList(T.Id, T.Prefix, T.Markers, T._target, newAttributes); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is AttributeList && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class AwaitExpression( - Guid id, - Space prefix, - Markers markers, - Expression expression, - JavaType? type - ) : Cs, Expression, MutableTree - { - public J? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitAwaitExpression(this, p); - } - - public Guid Id => id; - - public AwaitExpression WithId(Guid newId) - { - return newId == id ? this : new AwaitExpression(newId, prefix, markers, expression, type); - } - - public Space Prefix => prefix; - - public AwaitExpression WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new AwaitExpression(id, newPrefix, markers, expression, type); - } - - public Markers Markers => markers; - - public AwaitExpression WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new AwaitExpression(id, prefix, newMarkers, expression, type); - } - - public Expression Expression => expression; - - public AwaitExpression WithExpression(Expression newExpression) - { - return ReferenceEquals(newExpression, expression) ? this : new AwaitExpression(id, prefix, markers, newExpression, type); - } - - public JavaType? Type => type; - - public AwaitExpression WithType(JavaType? newType) - { - return newType == type ? this : new AwaitExpression(id, prefix, markers, expression, newType); - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is AwaitExpression && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class Binary( - Guid id, - Space prefix, - Markers markers, - Expression left, - JLeftPadded @operator, - Expression right, - JavaType? type - ) : Cs, Expression, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitBinary(this, p); - } - - public Guid Id => id; - - public Binary WithId(Guid newId) - { - return newId == id ? this : new Binary(newId, prefix, markers, left, _operator, right, type); - } - - public Space Prefix => prefix; - - public Binary WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new Binary(id, newPrefix, markers, left, _operator, right, type); - } - - public Markers Markers => markers; - - public Binary WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new Binary(id, prefix, newMarkers, left, _operator, right, type); - } - - public Expression Left => left; - - public Binary WithLeft(Expression newLeft) - { - return ReferenceEquals(newLeft, left) ? this : new Binary(id, prefix, markers, newLeft, _operator, right, type); - } - - private readonly JLeftPadded _operator = @operator; - public OperatorType Operator => _operator.Element; - - public Binary WithOperator(OperatorType newOperator) - { - return Padding.WithOperator(_operator.WithElement(newOperator)); - } - - public Expression Right => right; - - public Binary WithRight(Expression newRight) - { - return ReferenceEquals(newRight, right) ? this : new Binary(id, prefix, markers, left, _operator, newRight, type); - } - - public JavaType? Type => type; - - public Binary WithType(JavaType? newType) - { - return newType == type ? this : new Binary(id, prefix, markers, left, _operator, right, newType); - } - - public enum OperatorType - { - As, - NullCoalescing, - - } - - public sealed record PaddingHelper(Cs.Binary T) - { - public JLeftPadded Operator => T._operator; - - public Cs.Binary WithOperator(JLeftPadded newOperator) - { - return T._operator == newOperator ? T : new Cs.Binary(T.Id, T.Prefix, T.Markers, T.Left, newOperator, T.Right, T.Type); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is Binary && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class BlockScopeNamespaceDeclaration( - Guid id, - Space prefix, - Markers markers, - JRightPadded name, - IList> externs, - IList> usings, - IList> members, - Space end - ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitBlockScopeNamespaceDeclaration(this, p); - } - - public Guid Id => id; - - public BlockScopeNamespaceDeclaration WithId(Guid newId) - { - return newId == id ? this : new BlockScopeNamespaceDeclaration(newId, prefix, markers, _name, _externs, _usings, _members, end); - } - - public Space Prefix => prefix; - - public BlockScopeNamespaceDeclaration WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new BlockScopeNamespaceDeclaration(id, newPrefix, markers, _name, _externs, _usings, _members, end); - } - - public Markers Markers => markers; - - public BlockScopeNamespaceDeclaration WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new BlockScopeNamespaceDeclaration(id, prefix, newMarkers, _name, _externs, _usings, _members, end); - } - - private readonly JRightPadded _name = name; - public Expression Name => _name.Element; - - public BlockScopeNamespaceDeclaration WithName(Expression newName) - { - return Padding.WithName(_name.WithElement(newName)); - } - - private readonly IList> _externs = externs; - public IList Externs => _externs.Elements(); - - public BlockScopeNamespaceDeclaration WithExterns(IList newExterns) - { - return Padding.WithExterns(_externs.WithElements(newExterns)); - } - - private readonly IList> _usings = usings; - public IList Usings => _usings.Elements(); - - public BlockScopeNamespaceDeclaration WithUsings(IList newUsings) - { - return Padding.WithUsings(_usings.WithElements(newUsings)); - } - - private readonly IList> _members = members; - public IList Members => _members.Elements(); - - public BlockScopeNamespaceDeclaration WithMembers(IList newMembers) - { - return Padding.WithMembers(_members.WithElements(newMembers)); - } - - public Space End => end; - - public BlockScopeNamespaceDeclaration WithEnd(Space newEnd) - { - return newEnd == end ? this : new BlockScopeNamespaceDeclaration(id, prefix, markers, _name, _externs, _usings, _members, newEnd); - } - - public sealed record PaddingHelper(Cs.BlockScopeNamespaceDeclaration T) - { - public JRightPadded Name => T._name; - - public Cs.BlockScopeNamespaceDeclaration WithName(JRightPadded newName) - { - return T._name == newName ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, newName, T._externs, T._usings, T._members, T.End); - } - - public IList> Externs => T._externs; - - public Cs.BlockScopeNamespaceDeclaration WithExterns(IList> newExterns) - { - return T._externs == newExterns ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, newExterns, T._usings, T._members, T.End); - } - - public IList> Usings => T._usings; - - public Cs.BlockScopeNamespaceDeclaration WithUsings(IList> newUsings) - { - return T._usings == newUsings ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, newUsings, T._members, T.End); - } - - public IList> Members => T._members; - - public Cs.BlockScopeNamespaceDeclaration WithMembers(IList> newMembers) - { - return T._members == newMembers ? T : new Cs.BlockScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, T._usings, newMembers, T.End); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is BlockScopeNamespaceDeclaration && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class CollectionExpression( - Guid id, - Space prefix, - Markers markers, - IList> elements, - JavaType type - ) : Cs, Expression, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitCollectionExpression(this, p); - } - - public Guid Id => id; - - public CollectionExpression WithId(Guid newId) - { - return newId == id ? this : new CollectionExpression(newId, prefix, markers, _elements, type); - } - - public Space Prefix => prefix; - - public CollectionExpression WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new CollectionExpression(id, newPrefix, markers, _elements, type); - } - - public Markers Markers => markers; - - public CollectionExpression WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new CollectionExpression(id, prefix, newMarkers, _elements, type); - } - - private readonly IList> _elements = elements; - public IList Elements => _elements.Elements(); - - public CollectionExpression WithElements(IList newElements) - { - return Padding.WithElements(_elements.WithElements(newElements)); - } - - public JavaType Type => type; - - public CollectionExpression WithType(JavaType newType) - { - return newType == type ? this : new CollectionExpression(id, prefix, markers, _elements, newType); - } - - public sealed record PaddingHelper(Cs.CollectionExpression T) - { - public IList> Elements => T._elements; - - public Cs.CollectionExpression WithElements(IList> newElements) - { - return T._elements == newElements ? T : new Cs.CollectionExpression(T.Id, T.Prefix, T.Markers, newElements, T.Type); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is CollectionExpression && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class ExpressionStatement( - Guid id, - Space prefix, - Markers markers, - Expression expression - ) : Cs, Statement, MutableTree - { - public J? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitExpressionStatement(this, p); - } - - public Guid Id => id; - - public ExpressionStatement WithId(Guid newId) - { - return newId == id ? this : new ExpressionStatement(newId, prefix, markers, expression); - } - - public Space Prefix => prefix; - - public ExpressionStatement WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new ExpressionStatement(id, newPrefix, markers, expression); - } - - public Markers Markers => markers; - - public ExpressionStatement WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new ExpressionStatement(id, prefix, newMarkers, expression); - } - - public Expression Expression => expression; - - public ExpressionStatement WithExpression(Expression newExpression) - { - return ReferenceEquals(newExpression, expression) ? this : new ExpressionStatement(id, prefix, markers, newExpression); - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is ExpressionStatement && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class ExternAlias( - Guid id, - Space prefix, - Markers markers, - JLeftPadded identifier - ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitExternAlias(this, p); - } - - public Guid Id => id; - - public ExternAlias WithId(Guid newId) - { - return newId == id ? this : new ExternAlias(newId, prefix, markers, _identifier); - } - - public Space Prefix => prefix; - - public ExternAlias WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new ExternAlias(id, newPrefix, markers, _identifier); - } - - public Markers Markers => markers; - - public ExternAlias WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new ExternAlias(id, prefix, newMarkers, _identifier); - } - - private readonly JLeftPadded _identifier = identifier; - public J.Identifier Identifier => _identifier.Element; - - public ExternAlias WithIdentifier(J.Identifier newIdentifier) - { - return Padding.WithIdentifier(_identifier.WithElement(newIdentifier)); - } - - public sealed record PaddingHelper(Cs.ExternAlias T) - { - public JLeftPadded Identifier => T._identifier; - - public Cs.ExternAlias WithIdentifier(JLeftPadded newIdentifier) - { - return T._identifier == newIdentifier ? T : new Cs.ExternAlias(T.Id, T.Prefix, T.Markers, newIdentifier); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is ExternAlias && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class FileScopeNamespaceDeclaration( - Guid id, - Space prefix, - Markers markers, - JRightPadded name, - IList> externs, - IList> usings, - IList> members - ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitFileScopeNamespaceDeclaration(this, p); - } - - public Guid Id => id; - - public FileScopeNamespaceDeclaration WithId(Guid newId) - { - return newId == id ? this : new FileScopeNamespaceDeclaration(newId, prefix, markers, _name, _externs, _usings, _members); - } - - public Space Prefix => prefix; - - public FileScopeNamespaceDeclaration WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new FileScopeNamespaceDeclaration(id, newPrefix, markers, _name, _externs, _usings, _members); - } - - public Markers Markers => markers; - - public FileScopeNamespaceDeclaration WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new FileScopeNamespaceDeclaration(id, prefix, newMarkers, _name, _externs, _usings, _members); - } - - private readonly JRightPadded _name = name; - public Expression Name => _name.Element; - - public FileScopeNamespaceDeclaration WithName(Expression newName) - { - return Padding.WithName(_name.WithElement(newName)); - } - - private readonly IList> _externs = externs; - public IList Externs => _externs.Elements(); - - public FileScopeNamespaceDeclaration WithExterns(IList newExterns) - { - return Padding.WithExterns(_externs.WithElements(newExterns)); - } - - private readonly IList> _usings = usings; - public IList Usings => _usings.Elements(); - - public FileScopeNamespaceDeclaration WithUsings(IList newUsings) - { - return Padding.WithUsings(_usings.WithElements(newUsings)); - } - - private readonly IList> _members = members; - public IList Members => _members.Elements(); - - public FileScopeNamespaceDeclaration WithMembers(IList newMembers) - { - return Padding.WithMembers(_members.WithElements(newMembers)); - } - - public sealed record PaddingHelper(Cs.FileScopeNamespaceDeclaration T) - { - public JRightPadded Name => T._name; - - public Cs.FileScopeNamespaceDeclaration WithName(JRightPadded newName) - { - return T._name == newName ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, newName, T._externs, T._usings, T._members); - } - - public IList> Externs => T._externs; - - public Cs.FileScopeNamespaceDeclaration WithExterns(IList> newExterns) - { - return T._externs == newExterns ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, newExterns, T._usings, T._members); - } - - public IList> Usings => T._usings; - - public Cs.FileScopeNamespaceDeclaration WithUsings(IList> newUsings) - { - return T._usings == newUsings ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, newUsings, T._members); - } - - public IList> Members => T._members; - - public Cs.FileScopeNamespaceDeclaration WithMembers(IList> newMembers) - { - return T._members == newMembers ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, T._usings, newMembers); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is FileScopeNamespaceDeclaration && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class InterpolatedString( - Guid id, - Space prefix, - Markers markers, - string start, - IList> parts, - string end - ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitInterpolatedString(this, p); - } - - public JavaType? Type => Extensions.GetJavaType(this); - - public InterpolatedString WithType(JavaType newType) - { - return Extensions.WithJavaType(this, newType); - } - public Guid Id => id; - - public InterpolatedString WithId(Guid newId) - { - return newId == id ? this : new InterpolatedString(newId, prefix, markers, start, _parts, end); - } - - public Space Prefix => prefix; - - public InterpolatedString WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new InterpolatedString(id, newPrefix, markers, start, _parts, end); - } - - public Markers Markers => markers; - - public InterpolatedString WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new InterpolatedString(id, prefix, newMarkers, start, _parts, end); - } - - public string Start => start; - - public InterpolatedString WithStart(string newStart) - { - return newStart == start ? this : new InterpolatedString(id, prefix, markers, newStart, _parts, end); - } - - private readonly IList> _parts = parts; - public IList Parts => _parts.Elements(); - - public InterpolatedString WithParts(IList newParts) - { - return Padding.WithParts(_parts.WithElements(newParts)); - } - - public string End => end; - - public InterpolatedString WithEnd(string newEnd) - { - return newEnd == end ? this : new InterpolatedString(id, prefix, markers, start, _parts, newEnd); - } - - public sealed record PaddingHelper(Cs.InterpolatedString T) - { - public IList> Parts => T._parts; - - public Cs.InterpolatedString WithParts(IList> newParts) - { - return T._parts == newParts ? T : new Cs.InterpolatedString(T.Id, T.Prefix, T.Markers, T.Start, newParts, T.End); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is InterpolatedString && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class Interpolation( - Guid id, - Space prefix, - Markers markers, - JRightPadded expression, - JRightPadded? alignment, - JRightPadded? format - ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitInterpolation(this, p); - } - - public JavaType? Type => Extensions.GetJavaType(this); - - public Interpolation WithType(JavaType newType) - { - return Extensions.WithJavaType(this, newType); - } - public Guid Id => id; - - public Interpolation WithId(Guid newId) - { - return newId == id ? this : new Interpolation(newId, prefix, markers, _expression, _alignment, _format); - } - - public Space Prefix => prefix; - - public Interpolation WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new Interpolation(id, newPrefix, markers, _expression, _alignment, _format); - } - - public Markers Markers => markers; - - public Interpolation WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new Interpolation(id, prefix, newMarkers, _expression, _alignment, _format); - } - - private readonly JRightPadded _expression = expression; - public Expression Expression => _expression.Element; - - public Interpolation WithExpression(Expression newExpression) - { - return Padding.WithExpression(_expression.WithElement(newExpression)); - } - - private readonly JRightPadded? _alignment = alignment; - public Expression? Alignment => _alignment?.Element; - - public Interpolation WithAlignment(Expression? newAlignment) - { - return Padding.WithAlignment(JRightPadded.WithElement(_alignment, newAlignment)); - } - - private readonly JRightPadded? _format = format; - public Expression? Format => _format?.Element; - - public Interpolation WithFormat(Expression? newFormat) - { - return Padding.WithFormat(JRightPadded.WithElement(_format, newFormat)); - } - - public sealed record PaddingHelper(Cs.Interpolation T) - { - public JRightPadded Expression => T._expression; - - public Cs.Interpolation WithExpression(JRightPadded newExpression) - { - return T._expression == newExpression ? T : new Cs.Interpolation(T.Id, T.Prefix, T.Markers, newExpression, T._alignment, T._format); - } - - public JRightPadded? Alignment => T._alignment; - - public Cs.Interpolation WithAlignment(JRightPadded? newAlignment) - { - return T._alignment == newAlignment ? T : new Cs.Interpolation(T.Id, T.Prefix, T.Markers, T._expression, newAlignment, T._format); - } - - public JRightPadded? Format => T._format; - - public Cs.Interpolation WithFormat(JRightPadded? newFormat) - { - return T._format == newFormat ? T : new Cs.Interpolation(T.Id, T.Prefix, T.Markers, T._expression, T._alignment, newFormat); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is Interpolation && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class NullSafeExpression( - Guid id, - Space prefix, - Markers markers, - JRightPadded expression - ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitNullSafeExpression(this, p); - } - - public JavaType? Type => Extensions.GetJavaType(this); - - public NullSafeExpression WithType(JavaType newType) - { - return Extensions.WithJavaType(this, newType); - } - public Guid Id => id; - - public NullSafeExpression WithId(Guid newId) - { - return newId == id ? this : new NullSafeExpression(newId, prefix, markers, _expression); - } - - public Space Prefix => prefix; - - public NullSafeExpression WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new NullSafeExpression(id, newPrefix, markers, _expression); - } - - public Markers Markers => markers; - - public NullSafeExpression WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new NullSafeExpression(id, prefix, newMarkers, _expression); - } - - private readonly JRightPadded _expression = expression; - public Expression Expression => _expression.Element; - - public NullSafeExpression WithExpression(Expression newExpression) - { - return Padding.WithExpression(_expression.WithElement(newExpression)); - } - - public sealed record PaddingHelper(Cs.NullSafeExpression T) - { - public JRightPadded Expression => T._expression; - - public Cs.NullSafeExpression WithExpression(JRightPadded newExpression) - { - return T._expression == newExpression ? T : new Cs.NullSafeExpression(T.Id, T.Prefix, T.Markers, newExpression); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is NullSafeExpression && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class StatementExpression( - Guid id, - Space prefix, - Markers markers, - Statement statement - ) : Cs, Expression, MutableTree - { - public J? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitStatementExpression(this, p); - } - - public JavaType? Type => Extensions.GetJavaType(this); - - public StatementExpression WithType(JavaType newType) - { - return Extensions.WithJavaType(this, newType); - } - public Guid Id => id; - - public StatementExpression WithId(Guid newId) - { - return newId == id ? this : new StatementExpression(newId, prefix, markers, statement); - } - - public Space Prefix => prefix; - - public StatementExpression WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new StatementExpression(id, newPrefix, markers, statement); - } - - public Markers Markers => markers; - - public StatementExpression WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new StatementExpression(id, prefix, newMarkers, statement); - } - - public Statement Statement => statement; - - public StatementExpression WithStatement(Statement newStatement) - { - return ReferenceEquals(newStatement, statement) ? this : new StatementExpression(id, prefix, markers, newStatement); - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is StatementExpression && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class UsingDirective( - Guid id, - Space prefix, - Markers markers, - JRightPadded global, - JLeftPadded @static, - JLeftPadded @unsafe, - JRightPadded? alias, - TypeTree namespaceOrType - ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitUsingDirective(this, p); - } - - public Guid Id => id; - - public UsingDirective WithId(Guid newId) - { - return newId == id ? this : new UsingDirective(newId, prefix, markers, _global, _static, _unsafe, _alias, namespaceOrType); - } - - public Space Prefix => prefix; - - public UsingDirective WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new UsingDirective(id, newPrefix, markers, _global, _static, _unsafe, _alias, namespaceOrType); - } - - public Markers Markers => markers; - - public UsingDirective WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new UsingDirective(id, prefix, newMarkers, _global, _static, _unsafe, _alias, namespaceOrType); - } - - private readonly JRightPadded _global = global; - public bool Global => _global.Element; - - public UsingDirective WithGlobal(bool newGlobal) - { - return Padding.WithGlobal(_global.WithElement(newGlobal)); - } - - private readonly JLeftPadded _static = @static; - public bool Static => _static.Element; - - public UsingDirective WithStatic(bool newStatic) - { - return Padding.WithStatic(_static.WithElement(newStatic)); - } - - private readonly JLeftPadded _unsafe = @unsafe; - public bool Unsafe => _unsafe.Element; - - public UsingDirective WithUnsafe(bool newUnsafe) - { - return Padding.WithUnsafe(_unsafe.WithElement(newUnsafe)); - } - - private readonly JRightPadded? _alias = alias; - public J.Identifier? Alias => _alias?.Element; - - public UsingDirective WithAlias(J.Identifier? newAlias) - { - return Padding.WithAlias(JRightPadded.WithElement(_alias, newAlias)); - } - - public TypeTree NamespaceOrType => namespaceOrType; - - public UsingDirective WithNamespaceOrType(TypeTree newNamespaceOrType) - { - return ReferenceEquals(newNamespaceOrType, namespaceOrType) ? this : new UsingDirective(id, prefix, markers, _global, _static, _unsafe, _alias, newNamespaceOrType); - } - - public sealed record PaddingHelper(Cs.UsingDirective T) - { - public JRightPadded Global => T._global; - - public Cs.UsingDirective WithGlobal(JRightPadded newGlobal) - { - return T._global == newGlobal ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, newGlobal, T._static, T._unsafe, T._alias, T.NamespaceOrType); - } - - public JLeftPadded Static => T._static; - - public Cs.UsingDirective WithStatic(JLeftPadded newStatic) - { - return T._static == newStatic ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, T._global, newStatic, T._unsafe, T._alias, T.NamespaceOrType); - } - - public JLeftPadded Unsafe => T._unsafe; - - public Cs.UsingDirective WithUnsafe(JLeftPadded newUnsafe) - { - return T._unsafe == newUnsafe ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, T._global, T._static, newUnsafe, T._alias, T.NamespaceOrType); - } - - public JRightPadded? Alias => T._alias; - - public Cs.UsingDirective WithAlias(JRightPadded? newAlias) - { - return T._alias == newAlias ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, T._global, T._static, T._unsafe, newAlias, T.NamespaceOrType); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is UsingDirective && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - - public partial class PropertyDeclaration( - Guid id, - Space prefix, - Markers markers, - IList attributeLists, - IList modifiers, - TypeTree typeExpression, - JRightPadded? interfaceSpecifier, - J.Identifier name, - J.Block accessors, - JLeftPadded? initializer - ) : Cs, Statement, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) - { - return v.VisitPropertyDeclaration(this, p); - } - - public Guid Id => id; - - public PropertyDeclaration WithId(Guid newId) - { - return newId == id ? this : new PropertyDeclaration(newId, prefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); - } - - public Space Prefix => prefix; - - public PropertyDeclaration WithPrefix(Space newPrefix) - { - return newPrefix == prefix ? this : new PropertyDeclaration(id, newPrefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); - } - - public Markers Markers => markers; - - public PropertyDeclaration WithMarkers(Markers newMarkers) - { - return ReferenceEquals(newMarkers, markers) ? this : new PropertyDeclaration(id, prefix, newMarkers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); - } - - public IList AttributeLists => attributeLists; - - public PropertyDeclaration WithAttributeLists(IList newAttributeLists) - { - return newAttributeLists == attributeLists ? this : new PropertyDeclaration(id, prefix, markers, newAttributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); - } - - public IList Modifiers => modifiers; - - public PropertyDeclaration WithModifiers(IList newModifiers) - { - return newModifiers == modifiers ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, newModifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); - } - - public TypeTree TypeExpression => typeExpression; - - public PropertyDeclaration WithTypeExpression(TypeTree newTypeExpression) - { - return ReferenceEquals(newTypeExpression, typeExpression) ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, modifiers, newTypeExpression, _interfaceSpecifier, name, accessors, _initializer); - } - - private readonly JRightPadded? _interfaceSpecifier = interfaceSpecifier; - public NameTree? InterfaceSpecifier => _interfaceSpecifier?.Element; - - public PropertyDeclaration WithInterfaceSpecifier(NameTree? newInterfaceSpecifier) - { - return Padding.WithInterfaceSpecifier(JRightPadded.WithElement(_interfaceSpecifier, newInterfaceSpecifier)); - } - - public J.Identifier Name => name; - - public PropertyDeclaration WithName(J.Identifier newName) - { - return ReferenceEquals(newName, name) ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, newName, accessors, _initializer); - } - - public J.Block Accessors => accessors; - - public PropertyDeclaration WithAccessors(J.Block newAccessors) - { - return ReferenceEquals(newAccessors, accessors) ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, newAccessors, _initializer); - } - - private readonly JLeftPadded? _initializer = initializer; - public Expression? Initializer => _initializer?.Element; - - public PropertyDeclaration WithInitializer(Expression? newInitializer) - { - return Padding.WithInitializer(JLeftPadded.WithElement(_initializer, newInitializer)); - } - - public sealed record PaddingHelper(Cs.PropertyDeclaration T) - { - public JRightPadded? InterfaceSpecifier => T._interfaceSpecifier; - - public Cs.PropertyDeclaration WithInterfaceSpecifier(JRightPadded? newInterfaceSpecifier) - { - return T._interfaceSpecifier == newInterfaceSpecifier ? T : new Cs.PropertyDeclaration(T.Id, T.Prefix, T.Markers, T.AttributeLists, T.Modifiers, T.TypeExpression, newInterfaceSpecifier, T.Name, T.Accessors, T._initializer); - } - - public JLeftPadded? Initializer => T._initializer; - - public Cs.PropertyDeclaration WithInitializer(JLeftPadded? newInitializer) - { - return T._initializer == newInitializer ? T : new Cs.PropertyDeclaration(T.Id, T.Prefix, T.Markers, T.AttributeLists, T.Modifiers, T.TypeExpression, T._interfaceSpecifier, T.Name, T.Accessors, newInitializer); - } - - } - - public bool Equals(Rewrite.Core.Tree? other) - { - return other is PropertyDeclaration && other.Id == Id; - } - - public override int GetHashCode() - { - return Id.GetHashCode(); - } - } - } diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs new file mode 100644 index 00000000..1a90bb2c --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/ExpressionStatement.g.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class ExpressionStatement( + Guid id, + Space prefix, + Markers markers, + Expression expression + ) : Cs, Statement, MutableTree + { + public J? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitExpressionStatement(this, p); + } + + public Guid Id => id; + + public ExpressionStatement WithId(Guid newId) + { + return newId == id ? this : new ExpressionStatement(newId, prefix, markers, expression); + } + public Space Prefix => prefix; + + public ExpressionStatement WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new ExpressionStatement(id, newPrefix, markers, expression); + } + public Markers Markers => markers; + + public ExpressionStatement WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new ExpressionStatement(id, prefix, newMarkers, expression); + } + public Expression Expression => expression; + + public ExpressionStatement WithExpression(Expression newExpression) + { + return ReferenceEquals(newExpression, expression) ? this : new ExpressionStatement(id, prefix, markers, newExpression); + } + public bool Equals(Rewrite.Core.Tree? other) + { + return other is ExpressionStatement && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs new file mode 100644 index 00000000..95058c36 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/ExternAlias.g.cs @@ -0,0 +1,108 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class ExternAlias( + Guid id, + Space prefix, + Markers markers, + JLeftPadded identifier + ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitExternAlias(this, p); + } + + public Guid Id => id; + + public ExternAlias WithId(Guid newId) + { + return newId == id ? this : new ExternAlias(newId, prefix, markers, _identifier); + } + public Space Prefix => prefix; + + public ExternAlias WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new ExternAlias(id, newPrefix, markers, _identifier); + } + public Markers Markers => markers; + + public ExternAlias WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new ExternAlias(id, prefix, newMarkers, _identifier); + } + private readonly JLeftPadded _identifier = identifier; + public J.Identifier Identifier => _identifier.Element; + + public ExternAlias WithIdentifier(J.Identifier newIdentifier) + { + return Padding.WithIdentifier(_identifier.WithElement(newIdentifier)); + } + public sealed record PaddingHelper(Cs.ExternAlias T) + { + public JLeftPadded Identifier => T._identifier; + + public Cs.ExternAlias WithIdentifier(JLeftPadded newIdentifier) + { + return T._identifier == newIdentifier ? T : new Cs.ExternAlias(T.Id, T.Prefix, T.Markers, newIdentifier); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is ExternAlias && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs new file mode 100644 index 00000000..734d48ef --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/FileScopeNamespaceDeclaration.g.cs @@ -0,0 +1,153 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class FileScopeNamespaceDeclaration( + Guid id, + Space prefix, + Markers markers, + JRightPadded name, + IList> externs, + IList> usings, + IList> members + ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitFileScopeNamespaceDeclaration(this, p); + } + + public Guid Id => id; + + public FileScopeNamespaceDeclaration WithId(Guid newId) + { + return newId == id ? this : new FileScopeNamespaceDeclaration(newId, prefix, markers, _name, _externs, _usings, _members); + } + public Space Prefix => prefix; + + public FileScopeNamespaceDeclaration WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new FileScopeNamespaceDeclaration(id, newPrefix, markers, _name, _externs, _usings, _members); + } + public Markers Markers => markers; + + public FileScopeNamespaceDeclaration WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new FileScopeNamespaceDeclaration(id, prefix, newMarkers, _name, _externs, _usings, _members); + } + private readonly JRightPadded _name = name; + public Expression Name => _name.Element; + + public FileScopeNamespaceDeclaration WithName(Expression newName) + { + return Padding.WithName(_name.WithElement(newName)); + } + private readonly IList> _externs = externs; + public IList Externs => _externs.Elements(); + + public FileScopeNamespaceDeclaration WithExterns(IList newExterns) + { + return Padding.WithExterns(_externs.WithElements(newExterns)); + } + private readonly IList> _usings = usings; + public IList Usings => _usings.Elements(); + + public FileScopeNamespaceDeclaration WithUsings(IList newUsings) + { + return Padding.WithUsings(_usings.WithElements(newUsings)); + } + private readonly IList> _members = members; + public IList Members => _members.Elements(); + + public FileScopeNamespaceDeclaration WithMembers(IList newMembers) + { + return Padding.WithMembers(_members.WithElements(newMembers)); + } + public sealed record PaddingHelper(Cs.FileScopeNamespaceDeclaration T) + { + public JRightPadded Name => T._name; + + public Cs.FileScopeNamespaceDeclaration WithName(JRightPadded newName) + { + return T._name == newName ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, newName, T._externs, T._usings, T._members); + } + + public IList> Externs => T._externs; + + public Cs.FileScopeNamespaceDeclaration WithExterns(IList> newExterns) + { + return T._externs == newExterns ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, newExterns, T._usings, T._members); + } + + public IList> Usings => T._usings; + + public Cs.FileScopeNamespaceDeclaration WithUsings(IList> newUsings) + { + return T._usings == newUsings ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, newUsings, T._members); + } + + public IList> Members => T._members; + + public Cs.FileScopeNamespaceDeclaration WithMembers(IList> newMembers) + { + return T._members == newMembers ? T : new Cs.FileScopeNamespaceDeclaration(T.Id, T.Prefix, T.Markers, T._name, T._externs, T._usings, newMembers); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is FileScopeNamespaceDeclaration && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/InterpolatedString.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/InterpolatedString.g.cs new file mode 100644 index 00000000..06066475 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/InterpolatedString.g.cs @@ -0,0 +1,128 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class InterpolatedString( + Guid id, + Space prefix, + Markers markers, + string start, + IList> parts, + string end + ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitInterpolatedString(this, p); + } + + public JavaType? Type => Extensions.GetJavaType(this); + + public InterpolatedString WithType(JavaType newType) + { + return Extensions.WithJavaType(this, newType); + } + public Guid Id => id; + + public InterpolatedString WithId(Guid newId) + { + return newId == id ? this : new InterpolatedString(newId, prefix, markers, start, _parts, end); + } + public Space Prefix => prefix; + + public InterpolatedString WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new InterpolatedString(id, newPrefix, markers, start, _parts, end); + } + public Markers Markers => markers; + + public InterpolatedString WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new InterpolatedString(id, prefix, newMarkers, start, _parts, end); + } + public string Start => start; + + public InterpolatedString WithStart(string newStart) + { + return newStart == start ? this : new InterpolatedString(id, prefix, markers, newStart, _parts, end); + } + private readonly IList> _parts = parts; + public IList Parts => _parts.Elements(); + + public InterpolatedString WithParts(IList newParts) + { + return Padding.WithParts(_parts.WithElements(newParts)); + } + public string End => end; + + public InterpolatedString WithEnd(string newEnd) + { + return newEnd == end ? this : new InterpolatedString(id, prefix, markers, start, _parts, newEnd); + } + public sealed record PaddingHelper(Cs.InterpolatedString T) + { + public IList> Parts => T._parts; + + public Cs.InterpolatedString WithParts(IList> newParts) + { + return T._parts == newParts ? T : new Cs.InterpolatedString(T.Id, T.Prefix, T.Markers, T.Start, newParts, T.End); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is InterpolatedString && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs new file mode 100644 index 00000000..bf4da2c5 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/Interpolation.g.cs @@ -0,0 +1,144 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class Interpolation( + Guid id, + Space prefix, + Markers markers, + JRightPadded expression, + JRightPadded? alignment, + JRightPadded? format + ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitInterpolation(this, p); + } + + public JavaType? Type => Extensions.GetJavaType(this); + + public Interpolation WithType(JavaType newType) + { + return Extensions.WithJavaType(this, newType); + } + public Guid Id => id; + + public Interpolation WithId(Guid newId) + { + return newId == id ? this : new Interpolation(newId, prefix, markers, _expression, _alignment, _format); + } + public Space Prefix => prefix; + + public Interpolation WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new Interpolation(id, newPrefix, markers, _expression, _alignment, _format); + } + public Markers Markers => markers; + + public Interpolation WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new Interpolation(id, prefix, newMarkers, _expression, _alignment, _format); + } + private readonly JRightPadded _expression = expression; + public Expression Expression => _expression.Element; + + public Interpolation WithExpression(Expression newExpression) + { + return Padding.WithExpression(_expression.WithElement(newExpression)); + } + private readonly JRightPadded? _alignment = alignment; + public Expression? Alignment => _alignment?.Element; + + public Interpolation WithAlignment(Expression? newAlignment) + { + return Padding.WithAlignment(JRightPadded.WithElement(_alignment, newAlignment)); + } + private readonly JRightPadded? _format = format; + public Expression? Format => _format?.Element; + + public Interpolation WithFormat(Expression? newFormat) + { + return Padding.WithFormat(JRightPadded.WithElement(_format, newFormat)); + } + public sealed record PaddingHelper(Cs.Interpolation T) + { + public JRightPadded Expression => T._expression; + + public Cs.Interpolation WithExpression(JRightPadded newExpression) + { + return T._expression == newExpression ? T : new Cs.Interpolation(T.Id, T.Prefix, T.Markers, newExpression, T._alignment, T._format); + } + + public JRightPadded? Alignment => T._alignment; + + public Cs.Interpolation WithAlignment(JRightPadded? newAlignment) + { + return T._alignment == newAlignment ? T : new Cs.Interpolation(T.Id, T.Prefix, T.Markers, T._expression, newAlignment, T._format); + } + + public JRightPadded? Format => T._format; + + public Cs.Interpolation WithFormat(JRightPadded? newFormat) + { + return T._format == newFormat ? T : new Cs.Interpolation(T.Id, T.Prefix, T.Markers, T._expression, T._alignment, newFormat); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is Interpolation && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs new file mode 100644 index 00000000..52b2a539 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/NullSafeExpression.g.cs @@ -0,0 +1,114 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class NullSafeExpression( + Guid id, + Space prefix, + Markers markers, + JRightPadded expression + ) : Cs, Expression, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitNullSafeExpression(this, p); + } + + public JavaType? Type => Extensions.GetJavaType(this); + + public NullSafeExpression WithType(JavaType newType) + { + return Extensions.WithJavaType(this, newType); + } + public Guid Id => id; + + public NullSafeExpression WithId(Guid newId) + { + return newId == id ? this : new NullSafeExpression(newId, prefix, markers, _expression); + } + public Space Prefix => prefix; + + public NullSafeExpression WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new NullSafeExpression(id, newPrefix, markers, _expression); + } + public Markers Markers => markers; + + public NullSafeExpression WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new NullSafeExpression(id, prefix, newMarkers, _expression); + } + private readonly JRightPadded _expression = expression; + public Expression Expression => _expression.Element; + + public NullSafeExpression WithExpression(Expression newExpression) + { + return Padding.WithExpression(_expression.WithElement(newExpression)); + } + public sealed record PaddingHelper(Cs.NullSafeExpression T) + { + public JRightPadded Expression => T._expression; + + public Cs.NullSafeExpression WithExpression(JRightPadded newExpression) + { + return T._expression == newExpression ? T : new Cs.NullSafeExpression(T.Id, T.Prefix, T.Markers, newExpression); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is NullSafeExpression && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs new file mode 100644 index 00000000..fe24280d --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/PropertyDeclaration.g.cs @@ -0,0 +1,158 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class PropertyDeclaration( + Guid id, + Space prefix, + Markers markers, + IList attributeLists, + IList modifiers, + TypeTree typeExpression, + JRightPadded? interfaceSpecifier, + J.Identifier name, + J.Block accessors, + JLeftPadded? initializer + ) : Cs, Statement, TypedTree, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitPropertyDeclaration(this, p); + } + + public Guid Id => id; + + public PropertyDeclaration WithId(Guid newId) + { + return newId == id ? this : new PropertyDeclaration(newId, prefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); + } + public Space Prefix => prefix; + + public PropertyDeclaration WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new PropertyDeclaration(id, newPrefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); + } + public Markers Markers => markers; + + public PropertyDeclaration WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new PropertyDeclaration(id, prefix, newMarkers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); + } + public IList AttributeLists => attributeLists; + + public PropertyDeclaration WithAttributeLists(IList newAttributeLists) + { + return newAttributeLists == attributeLists ? this : new PropertyDeclaration(id, prefix, markers, newAttributeLists, modifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); + } + public IList Modifiers => modifiers; + + public PropertyDeclaration WithModifiers(IList newModifiers) + { + return newModifiers == modifiers ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, newModifiers, typeExpression, _interfaceSpecifier, name, accessors, _initializer); + } + public TypeTree TypeExpression => typeExpression; + + public PropertyDeclaration WithTypeExpression(TypeTree newTypeExpression) + { + return ReferenceEquals(newTypeExpression, typeExpression) ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, modifiers, newTypeExpression, _interfaceSpecifier, name, accessors, _initializer); + } + private readonly JRightPadded? _interfaceSpecifier = interfaceSpecifier; + public NameTree? InterfaceSpecifier => _interfaceSpecifier?.Element; + + public PropertyDeclaration WithInterfaceSpecifier(NameTree? newInterfaceSpecifier) + { + return Padding.WithInterfaceSpecifier(JRightPadded.WithElement(_interfaceSpecifier, newInterfaceSpecifier)); + } + public J.Identifier Name => name; + + public PropertyDeclaration WithName(J.Identifier newName) + { + return ReferenceEquals(newName, name) ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, newName, accessors, _initializer); + } + public J.Block Accessors => accessors; + + public PropertyDeclaration WithAccessors(J.Block newAccessors) + { + return ReferenceEquals(newAccessors, accessors) ? this : new PropertyDeclaration(id, prefix, markers, attributeLists, modifiers, typeExpression, _interfaceSpecifier, name, newAccessors, _initializer); + } + private readonly JLeftPadded? _initializer = initializer; + public Expression? Initializer => _initializer?.Element; + + public PropertyDeclaration WithInitializer(Expression? newInitializer) + { + return Padding.WithInitializer(JLeftPadded.WithElement(_initializer, newInitializer)); + } + public sealed record PaddingHelper(Cs.PropertyDeclaration T) + { + public JRightPadded? InterfaceSpecifier => T._interfaceSpecifier; + + public Cs.PropertyDeclaration WithInterfaceSpecifier(JRightPadded? newInterfaceSpecifier) + { + return T._interfaceSpecifier == newInterfaceSpecifier ? T : new Cs.PropertyDeclaration(T.Id, T.Prefix, T.Markers, T.AttributeLists, T.Modifiers, T.TypeExpression, newInterfaceSpecifier, T.Name, T.Accessors, T._initializer); + } + + public JLeftPadded? Initializer => T._initializer; + + public Cs.PropertyDeclaration WithInitializer(JLeftPadded? newInitializer) + { + return T._initializer == newInitializer ? T : new Cs.PropertyDeclaration(T.Id, T.Prefix, T.Markers, T.AttributeLists, T.Modifiers, T.TypeExpression, T._interfaceSpecifier, T.Name, T.Accessors, newInitializer); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is PropertyDeclaration && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs new file mode 100644 index 00000000..8d8af3a3 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/StatementExpression.g.cs @@ -0,0 +1,77 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class StatementExpression( + Guid id, + Space prefix, + Markers markers, + Statement statement + ) : Cs, Expression, MutableTree + { + public J? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitStatementExpression(this, p); + } + + public JavaType? Type => Extensions.GetJavaType(this); + + public StatementExpression WithType(JavaType newType) + { + return Extensions.WithJavaType(this, newType); + } + public Guid Id => id; + + public StatementExpression WithId(Guid newId) + { + return newId == id ? this : new StatementExpression(newId, prefix, markers, statement); + } + public Space Prefix => prefix; + + public StatementExpression WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new StatementExpression(id, newPrefix, markers, statement); + } + public Markers Markers => markers; + + public StatementExpression WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new StatementExpression(id, prefix, newMarkers, statement); + } + public Statement Statement => statement; + + public StatementExpression WithStatement(Statement newStatement) + { + return ReferenceEquals(newStatement, statement) ? this : new StatementExpression(id, prefix, markers, newStatement); + } + public bool Equals(Rewrite.Core.Tree? other) + { + return other is StatementExpression && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs new file mode 100644 index 00000000..be3a2761 --- /dev/null +++ b/Rewrite/src/Rewrite.CSharp/Tree/UsingDirective.g.cs @@ -0,0 +1,160 @@ +//------------------------------------------------------------------------------ +// +// 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.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 +{ + public partial class UsingDirective( + Guid id, + Space prefix, + Markers markers, + JRightPadded global, + JLeftPadded @static, + JLeftPadded @unsafe, + JRightPadded? alias, + TypeTree namespaceOrType + ) : Cs, Statement, 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? AcceptCSharp

(CSharpVisitor

v, P p) + { + return v.VisitUsingDirective(this, p); + } + + public Guid Id => id; + + public UsingDirective WithId(Guid newId) + { + return newId == id ? this : new UsingDirective(newId, prefix, markers, _global, _static, _unsafe, _alias, namespaceOrType); + } + public Space Prefix => prefix; + + public UsingDirective WithPrefix(Space newPrefix) + { + return newPrefix == prefix ? this : new UsingDirective(id, newPrefix, markers, _global, _static, _unsafe, _alias, namespaceOrType); + } + public Markers Markers => markers; + + public UsingDirective WithMarkers(Markers newMarkers) + { + return ReferenceEquals(newMarkers, markers) ? this : new UsingDirective(id, prefix, newMarkers, _global, _static, _unsafe, _alias, namespaceOrType); + } + private readonly JRightPadded _global = global; + public bool Global => _global.Element; + + public UsingDirective WithGlobal(bool newGlobal) + { + return Padding.WithGlobal(_global.WithElement(newGlobal)); + } + private readonly JLeftPadded _static = @static; + public bool Static => _static.Element; + + public UsingDirective WithStatic(bool newStatic) + { + return Padding.WithStatic(_static.WithElement(newStatic)); + } + private readonly JLeftPadded _unsafe = @unsafe; + public bool Unsafe => _unsafe.Element; + + public UsingDirective WithUnsafe(bool newUnsafe) + { + return Padding.WithUnsafe(_unsafe.WithElement(newUnsafe)); + } + private readonly JRightPadded? _alias = alias; + public J.Identifier? Alias => _alias?.Element; + + public UsingDirective WithAlias(J.Identifier? newAlias) + { + return Padding.WithAlias(JRightPadded.WithElement(_alias, newAlias)); + } + public TypeTree NamespaceOrType => namespaceOrType; + + public UsingDirective WithNamespaceOrType(TypeTree newNamespaceOrType) + { + return ReferenceEquals(newNamespaceOrType, namespaceOrType) ? this : new UsingDirective(id, prefix, markers, _global, _static, _unsafe, _alias, newNamespaceOrType); + } + public sealed record PaddingHelper(Cs.UsingDirective T) + { + public JRightPadded Global => T._global; + + public Cs.UsingDirective WithGlobal(JRightPadded newGlobal) + { + return T._global == newGlobal ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, newGlobal, T._static, T._unsafe, T._alias, T.NamespaceOrType); + } + + public JLeftPadded Static => T._static; + + public Cs.UsingDirective WithStatic(JLeftPadded newStatic) + { + return T._static == newStatic ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, T._global, newStatic, T._unsafe, T._alias, T.NamespaceOrType); + } + + public JLeftPadded Unsafe => T._unsafe; + + public Cs.UsingDirective WithUnsafe(JLeftPadded newUnsafe) + { + return T._unsafe == newUnsafe ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, T._global, T._static, newUnsafe, T._alias, T.NamespaceOrType); + } + + public JRightPadded? Alias => T._alias; + + public Cs.UsingDirective WithAlias(JRightPadded? newAlias) + { + return T._alias == newAlias ? T : new Cs.UsingDirective(T.Id, T.Prefix, T.Markers, T._global, T._static, T._unsafe, newAlias, T.NamespaceOrType); + } + + } + + public bool Equals(Rewrite.Core.Tree? other) + { + return other is UsingDirective && other.Id == Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file