? _padding;
@@ -61,53 +62,59 @@ public PaddingHelper Padding
public J? AcceptCSharp(CSharpVisitor
v, P p)
{
- return v.VisitNamedArgument(this, p);
+ return v.VisitArgument(this, p);
}
public JavaType? Type => Extensions.GetJavaType(this);
- public NamedArgument WithType(JavaType newType)
+ public Argument WithType(JavaType newType)
{
return Extensions.WithJavaType(this, newType);
}
public Guid Id => id;
- public NamedArgument WithId(Guid newId)
+ public Argument WithId(Guid newId)
{
- return newId == id ? this : new NamedArgument(newId, prefix, markers, _nameColumn, expression);
+ return newId == id ? this : new Argument(newId, prefix, markers, _nameColumn, refKindKeyword, expression);
}
public Space Prefix => prefix;
- public NamedArgument WithPrefix(Space newPrefix)
+ public Argument WithPrefix(Space newPrefix)
{
- return newPrefix == prefix ? this : new NamedArgument(id, newPrefix, markers, _nameColumn, expression);
+ return newPrefix == prefix ? this : new Argument(id, newPrefix, markers, _nameColumn, refKindKeyword, expression);
}
public Markers Markers => markers;
- public NamedArgument WithMarkers(Markers newMarkers)
+ public Argument WithMarkers(Markers newMarkers)
{
- return ReferenceEquals(newMarkers, markers) ? this : new NamedArgument(id, prefix, newMarkers, _nameColumn, expression);
+ return ReferenceEquals(newMarkers, markers) ? this : new Argument(id, prefix, newMarkers, _nameColumn, refKindKeyword, expression);
}
private readonly JRightPadded? _nameColumn = nameColumn;
public J.Identifier? NameColumn => _nameColumn?.Element;
- public NamedArgument WithNameColumn(J.Identifier? newNameColumn)
+ public Argument WithNameColumn(J.Identifier? newNameColumn)
{
return Padding.WithNameColumn(JRightPadded.WithElement(_nameColumn, newNameColumn));
}
+ public Cs.Keyword? RefKindKeyword => refKindKeyword;
+
+ public Argument WithRefKindKeyword(Cs.Keyword? newRefKindKeyword)
+ {
+ return ReferenceEquals(newRefKindKeyword, refKindKeyword) ? this : new Argument(id, prefix, markers, _nameColumn, newRefKindKeyword, expression);
+ }
public Expression Expression => expression;
- public NamedArgument WithExpression(Expression newExpression)
+ public Argument WithExpression(Expression newExpression)
{
- return ReferenceEquals(newExpression, expression) ? this : new NamedArgument(id, prefix, markers, _nameColumn, newExpression);
+ return ReferenceEquals(newExpression, expression) ? this : new Argument(id, prefix, markers, _nameColumn, refKindKeyword, newExpression);
}
- public sealed record PaddingHelper(Cs.NamedArgument T)
+ public sealed record PaddingHelper(Cs.Argument T)
{
public JRightPadded? NameColumn => T._nameColumn;
- public Cs.NamedArgument WithNameColumn(JRightPadded? newNameColumn)
+ public Cs.Argument WithNameColumn(JRightPadded? newNameColumn)
{
- return T._nameColumn == newNameColumn ? T : new Cs.NamedArgument(T.Id, T.Prefix, T.Markers, newNameColumn, T.Expression);
+ return T._nameColumn == newNameColumn ? T : new Cs.Argument(T.Id, T.Prefix, T.Markers, newNameColumn, T.RefKindKeyword, T.Expression);
}
}
@@ -117,7 +124,7 @@ public Cs.NamedArgument WithNameColumn(JRightPadded? newNameColumn
#endif
public bool Equals(Rewrite.Core.Tree? other)
{
- return other is NamedArgument && other.Id == Id;
+ return other is Argument && other.Id == Id;
}
#if DEBUG_VISITOR
[DebuggerStepThrough]
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Constructor.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Constructor.g.cs
new file mode 100644
index 0000000..3eda848
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/Constructor.g.cs
@@ -0,0 +1,87 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class Constructor(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ ConstructorInitializer? initializer,
+ J.MethodDeclaration constructorCore
+ ) : Cs, Statement, MutableTree
+ {
+ public J? AcceptCSharp(CSharpVisitor
v, P p)
+ {
+ return v.VisitConstructor(this, p);
+ }
+
+ public Guid Id => id;
+
+ public Constructor WithId(Guid newId)
+ {
+ return newId == id ? this : new Constructor(newId, prefix, markers, initializer, constructorCore);
+ }
+ public Space Prefix => prefix;
+
+ public Constructor WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new Constructor(id, newPrefix, markers, initializer, constructorCore);
+ }
+ public Markers Markers => markers;
+
+ public Constructor WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new Constructor(id, prefix, newMarkers, initializer, constructorCore);
+ }
+ public Cs.ConstructorInitializer? Initializer => initializer;
+
+ public Constructor WithInitializer(Cs.ConstructorInitializer? newInitializer)
+ {
+ return ReferenceEquals(newInitializer, initializer) ? this : new Constructor(id, prefix, markers, newInitializer, constructorCore);
+ }
+ public J.MethodDeclaration ConstructorCore => constructorCore;
+
+ public Constructor WithConstructorCore(J.MethodDeclaration newConstructorCore)
+ {
+ return ReferenceEquals(newConstructorCore, constructorCore) ? this : new Constructor(id, prefix, markers, initializer, newConstructorCore);
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is Constructor && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ConstructorInitializer.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ConstructorInitializer.g.cs
new file mode 100644
index 0000000..0eafe11
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/ConstructorInitializer.g.cs
@@ -0,0 +1,124 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class ConstructorInitializer(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ Keyword keyword,
+ JContainer arguments
+ ) : 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.VisitConstructorInitializer(this, p);
+ }
+
+ public Guid Id => id;
+
+ public ConstructorInitializer WithId(Guid newId)
+ {
+ return newId == id ? this : new ConstructorInitializer(newId, prefix, markers, keyword, _arguments);
+ }
+ public Space Prefix => prefix;
+
+ public ConstructorInitializer WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new ConstructorInitializer(id, newPrefix, markers, keyword, _arguments);
+ }
+ public Markers Markers => markers;
+
+ public ConstructorInitializer WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new ConstructorInitializer(id, prefix, newMarkers, keyword, _arguments);
+ }
+ public Cs.Keyword Keyword => keyword;
+
+ public ConstructorInitializer WithKeyword(Cs.Keyword newKeyword)
+ {
+ return ReferenceEquals(newKeyword, keyword) ? this : new ConstructorInitializer(id, prefix, markers, newKeyword, _arguments);
+ }
+ private readonly JContainer _arguments = arguments;
+ public IList Arguments => _arguments.GetElements();
+
+ public ConstructorInitializer WithArguments(IList newArguments)
+ {
+ return Padding.WithArguments(JContainer.WithElements(_arguments, newArguments));
+ }
+ public sealed record PaddingHelper(Cs.ConstructorInitializer T)
+ {
+ public JContainer Arguments => T._arguments;
+
+ public Cs.ConstructorInitializer WithArguments(JContainer newArguments)
+ {
+ return T._arguments == newArguments ? T : new Cs.ConstructorInitializer(T.Id, T.Prefix, T.Markers, T.Keyword, newArguments);
+ }
+
+ }
+
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is ConstructorInitializer && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs
index 301c1bd..a644494 100644
--- a/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs
+++ b/Rewrite/src/Rewrite.CSharp/Tree/Cs.g.cs
@@ -45,4 +45,12 @@ bool Core.Tree.IsAcceptable(ITreeVisitor v, P p)
return v.DefaultValue(this, p);
}
+ public enum KeywordKind
+ {
+ Ref,
+ Out,
+ Await,
+ Base,
+ This,
+ }
}
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CsContainer.cs b/Rewrite/src/Rewrite.CSharp/Tree/CsContainer.cs
deleted file mode 100644
index 4e6030a..0000000
--- a/Rewrite/src/Rewrite.CSharp/Tree/CsContainer.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace Rewrite.RewriteCSharp.Tree;
-
-public interface CsContainer
-{
- public record Location(CsSpace.Location BeforeLocation, CsRightPadded.Location ElementLocation)
- {
- public static readonly Location USING_STATEMENT_EXPRESSION = new(CsSpace.Location.USING_STATEMENT_EXPRESSION, CsRightPadded.Location.USING_STATEMENT_EXPRESSION);
- public static readonly Location METHOD_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES = new(CsSpace.Location.METHOD_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES, CsRightPadded.Location.METHOD_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES);
- public static readonly Location ALLOWS_CONSTRAINT_CLAUSE_EXPRESSIONS = new(CsSpace.Location.ALLOWS_CONSTRAINT_CLAUSE_EXPRESSIONS, CsRightPadded.Location.ALLOWS_CONSTRAINT_CLAUSE_EXPRESSIONS);
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER_CONSTRAINTS = new(CsSpace.Location.TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER_CONSTRAINTS, CsRightPadded.Location.TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER_CONSTRAINTS);
- public static readonly Location ALLOWS_CONSTRAINT_EXPRESSIONS = new(CsSpace.Location.ALLOWS_CONSTRAINT_EXPRESSIONS, CsRightPadded.Location.ALLOWS_CONSTRAINT_EXPRESSIONS);
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_CONSTRAINTS = new(CsSpace.Location.TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_CONSTRAINTS, CsRightPadded.Location.TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_CONSTRAINTS);
- public static readonly Location CLASS_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES = new(CsSpace.Location.CLASS_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES, CsRightPadded.Location.CLASS_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES);
- public static readonly Location ARRAY_RANK_SPECIFIER_SIZES = new(CsSpace.Location.ARRAY_RANK_SPECIFIER_SIZES, CsRightPadded.Location.ARRAY_RANK_SPECIFIER_SIZE);
- public static readonly Location PROPERTY_DECLARATION_ACCESSORS = new(CsSpace.Location.PROPERTY_DECLARATION_ACCESSORS, CsRightPadded.Location.PROPERTY_DECLARATION_ACCESSORS);
- }
-}
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CsLeftPadded.cs b/Rewrite/src/Rewrite.CSharp/Tree/CsLeftPadded.cs
deleted file mode 100644
index c73544d..0000000
--- a/Rewrite/src/Rewrite.CSharp/Tree/CsLeftPadded.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace Rewrite.RewriteCSharp.Tree;
-
-public interface CsLeftPadded
-{
- public record Location(CsSpace.Location BeforeLocation)
- {
- public static readonly Location ASSIGNMENT_OPERATION_OPERATOR = new(CsSpace.Location.ASSIGNMENT_OPERATION_OPERATOR);
- public static readonly Location BINARY_OPERATOR = new(CsSpace.Location.BINARY_OPERATOR);
- public static readonly Location EXTERN_ALIAS_IDENTIFIER = new(CsSpace.Location.EXTERN_ALIAS_IDENTIFIER);
- public static readonly Location PROPERTY_DECLARATION_EXPRESSION_BODY = new (CsSpace.Location.PROPERTY_DECLARATION_EXPRESSION_BODY);
- public static readonly Location PROPERTY_DECLARATION_INITIALIZER = new (CsSpace.Location.PROPERTY_DECLARATION_INITIALIZER);
- public static readonly Location USING_DIRECTIVE_STATIC = new(CsSpace.Location.USING_DIRECTIVE_STATIC);
- public static readonly Location USING_DIRECTIVE_UNSAFE = new(CsSpace.Location.USING_DIRECTIVE_UNSAFE);
- }
-}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CsRightPadded.cs b/Rewrite/src/Rewrite.CSharp/Tree/CsRightPadded.cs
deleted file mode 100644
index 36d70d6..0000000
--- a/Rewrite/src/Rewrite.CSharp/Tree/CsRightPadded.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-namespace Rewrite.RewriteCSharp.Tree;
-
-public interface CsRightPadded
-{
- public record Location(CsSpace.Location AfterLocation)
- {
- public static readonly Location USING_STATEMENT_AWAIT_KEYWORD = new (CsSpace.Location.USING_STATEMENT_AWAIT_KEYWORD);
- public static readonly Location USING_STATEMENT_EXPRESSION = new (CsSpace.Location.USING_STATEMENT_EXPRESSION);
- public static readonly Location METHOD_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES = new (CsSpace.Location.METHOD_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES);
- public static readonly Location ALLOWS_CONSTRAINT_CLAUSE_EXPRESSIONS = new (CsSpace.Location.ALLOWS_CONSTRAINT_CLAUSE_EXPRESSIONS);
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER_CONSTRAINTS = new(CsSpace.Location.TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER_CONSTRAINTS);
- public static readonly Location ALLOWS_CONSTRAINT_EXPRESSIONS = new(CsSpace.Location.ALLOWS_CONSTRAINT_EXPRESSIONS);
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_CONSTRAINTS = new(CsSpace.Location.TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_CONSTRAINTS);
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER = new(CsSpace.Location.TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER);
- public static readonly Location CLASS_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES = new(CsSpace.Location.CLASS_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES);
- public static readonly Location NAMED_ARGUMENT_NAME_COLUMN = new(CsSpace.Location.NAMED_ARGUMENT_NAME_COLUMN_SUFFIX);
- public static readonly Location ARRAY_RANK_SPECIFIER_SIZE = new(CsSpace.Location.ARRAY_RANK_SPECIFIER_SIZE_SUFFIX);
- public static readonly Location ATTRIBUTE_LIST_ATTRIBUTES = new(CsSpace.Location.ATTRIBUTE_LIST_ATTRIBUTE_SUFFIX);
- public static readonly Location ATTRIBUTE_LIST_TARGET = new(CsSpace.Location.ATTRIBUTE_LIST_TARGET_SUFFIX);
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_EXTERNS = new(CsSpace.Location.BLOCK_SCOPE_NAMESPACE_DECLARATION_EXTERNS_SUFFIX);
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_MEMBERS = new(CsSpace.Location.BLOCK_SCOPE_NAMESPACE_DECLARATION_MEMBERS);
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_NAME = new(CsSpace.Location.BLOCK_SCOPE_NAMESPACE_DECLARATION_NAME);
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_USINGS = new(CsSpace.Location.BLOCK_SCOPE_NAMESPACE_DECLARATION_USINGS);
- public static readonly Location COLLECTION_EXPRESSION_ELEMENTS = new(CsSpace.Location.COLLECTION_EXPRESSION_ELEMENTS);
- public static readonly Location COMPILATION_UNIT_EXTERNS = new(CsSpace.Location.COMPILATION_UNIT_EXTERNS_SUFFIX);
- public static readonly Location COMPILATION_UNIT_MEMBERS = new(CsSpace.Location.COMPILATION_UNIT_MEMBERS);
- public static readonly Location COMPILATION_UNIT_USINGS = new(CsSpace.Location.COMPILATION_UNIT_USINGS);
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_EXTERNS = new(CsSpace.Location.FILE_SCOPE_NAMESPACE_DECLARATION_EXTERNS_SUFFIX);
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_MEMBERS = new(CsSpace.Location.FILE_SCOPE_NAMESPACE_DECLARATION_MEMBERS);
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_NAME = new(CsSpace.Location.FILE_SCOPE_NAMESPACE_DECLARATION_NAME);
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_USINGS = new(CsSpace.Location.FILE_SCOPE_NAMESPACE_DECLARATION_USINGS);
- public static readonly Location INTERPOLATED_STRING_PARTS = new(CsSpace.Location.INTERPOLATED_STRING_PARTS_SUFFIX);
- public static readonly Location INTERPOLATION_ALIGNMENT = new(CsSpace.Location.INTERPOLATION_ALIGNMENT_SUFFIX);
- public static readonly Location INTERPOLATION_EXPRESSION = new(CsSpace.Location.INTERPOLATION_EXPRESSION_SUFFIX);
- public static readonly Location INTERPOLATION_FORMAT = new(CsSpace.Location.INTERPOLATION_FORMAT_SUFFIX);
- public static readonly Location NULL_SAFE_EXPRESSION_EXPRESSION = new(CsSpace.Location.NULL_SAFE_EXPRESSION_EXPRESSION_SUFFIX);
- public static readonly Location PROPERTY_DECLARATION_ACCESSORS = new(CsSpace.Location.PROPERTY_DECLARATION_ACCESSORS_PREFIX);
- public static readonly Location PROPERTY_DECLARATION_INTERFACE_SPECIFIER = new(CsSpace.Location.PROPERTY_DECLARATION_INTERFACE_SPECIFIER_PREFIX);
- public static readonly Location USING_DIRECTIVE_ALIAS = new(CsSpace.Location.USING_DIRECTIVE_ALIAS);
- public static readonly Location USING_DIRECTIVE_GLOBAL = new(CsSpace.Location.USING_DIRECTIVE_GLOBAL_SUFFIX);
- }
-}
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/CsSpace.cs b/Rewrite/src/Rewrite.CSharp/Tree/CsSpace.cs
deleted file mode 100644
index 1102478..0000000
--- a/Rewrite/src/Rewrite.CSharp/Tree/CsSpace.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using Rewrite.RewriteJava.Tree;
-
-namespace Rewrite.RewriteCSharp.Tree;
-
-public interface CsSpace
-{
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- public record Location
- {
- public static readonly Location USING_STATEMENT_AWAIT_KEYWORD = new();
- public static readonly Location USING_STATEMENT_EXPRESSION = new();
- public static readonly Location USING_STATEMENT_RESOURCE = new();
- public static readonly Location USING_STATEMENT_PREFIX = new();
- public static readonly Location TYPE_PARAMETERS_CONSTRAINT_PREFIX = new();
- public static readonly Location TYPE_PARAMETERS_CONSTRAINT_CLAUSE_PREFIX = new();
- public static readonly Location METHOD_DECLARATION_PREFIX = new();
- public static readonly Location METHOD_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES = new();
- public static readonly Location REF_STRUCT_CONSTRAINT_PREFIX = new();
- public static readonly Location ALLOWS_CONSTRAINT_CLAUSE_EXPRESSIONS = new();
- public static readonly Location ALLOWS_CONSTRAINT_CLAUSE_PREFIX = new();
- public static readonly Location DEFAULT_CONSTRAINT_PREFIX = new();
- public static readonly Location CONSTRUCTOR_CONSTRAINT_PREFIX = new();
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER_CONSTRAINTS = new();
- public static readonly Location CLASS_OR_STRUCT_CONSTRAINT_PREFIX = new();
- public static readonly Location ALLOWS_CONSTRAINT_EXPRESSIONS = new();
- public static readonly Location ALLOWS_CONSTRAINT_PREFIX = new();
- public static readonly Location TYPE_CONSTRAINT_PREFIX = new();
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_CONSTRAINTS = new();
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_TYPE_PARAMETER = new();
- public static readonly Location TYPE_PARAMETER_CONSTRAINT_CLAUSE_PREFIX = new();
- public static readonly Location CLASS_DECLARATION_TYPE_PARAMETER_CONSTRAINT_CLAUSES = new();
- public static readonly Location CLASS_DECLARATION_PREFIX = new();
- public static readonly Location NAMED_ARGUMENT_NAME_COLUMN_SUFFIX = new();
- public static readonly Location NAMED_ARGUMENT_PREFIX = new();
- public static readonly Location ANNOTATED_STATEMENT_PREFIX = new();
- public static readonly Location ARRAY_RANK_SPECIFIER_PREFIX = new();
- public static readonly Location ARRAY_RANK_SPECIFIER_SIZES = new();
- public static readonly Location ARRAY_RANK_SPECIFIER_SIZE_SUFFIX = new();
- public static readonly Location ASSIGNMENT_OPERATION_OPERATOR = new();
- public static readonly Location ASSIGNMENT_OPERATION_PREFIX = new();
- public static readonly Location ATTRIBUTE_LIST_ATTRIBUTE_SUFFIX = new();
- public static readonly Location ATTRIBUTE_LIST_PREFIX = new();
- public static readonly Location ATTRIBUTE_LIST_TARGET_SUFFIX = new();
- public static readonly Location AWAIT_EXPRESSION_PREFIX = new();
- public static readonly Location BINARY_OPERATOR = new();
- public static readonly Location BINARY_PREFIX = new();
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_END = new();
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_EXTERNS_SUFFIX = new();
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_MEMBERS = new();
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_NAME = new();
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_PREFIX = new();
- public static readonly Location BLOCK_SCOPE_NAMESPACE_DECLARATION_USINGS = new();
- public static readonly Location COLLECTION_EXPRESSION_ELEMENTS = new();
- public static readonly Location COLLECTION_EXPRESSION_PREFIX = new();
- public static readonly Location COMPILATION_UNIT_EXTERNS_SUFFIX = new();
- public static readonly Location COMPILATION_UNIT_MEMBERS = new();
- public static readonly Location COMPILATION_UNIT_USINGS = new();
- public static readonly Location EXPRESSION_STATEMENT_PREFIX = new();
- public static readonly Location EXTERN_ALIAS_IDENTIFIER = new();
- public static readonly Location EXTERN_ALIAS_PREFIX = new();
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_EXTERNS_SUFFIX = new();
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_MEMBERS = new();
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_NAME = new();
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_PREFIX = new();
- public static readonly Location FILE_SCOPE_NAMESPACE_DECLARATION_USINGS = new();
- public static readonly Location INTERPOLATED_STRING_PARTS_SUFFIX = new();
- public static readonly Location INTERPOLATED_STRING_PREFIX = new();
- public static readonly Location INTERPOLATION_ALIGNMENT_SUFFIX = new();
- public static readonly Location INTERPOLATION_EXPRESSION_SUFFIX = new();
- public static readonly Location INTERPOLATION_FORMAT_SUFFIX = new();
- public static readonly Location INTERPOLATION_PREFIX = new();
- public static readonly Location NULL_SAFE_EXPRESSION_EXPRESSION_SUFFIX = new();
- public static readonly Location NULL_SAFE_EXPRESSION_PREFIX = new();
- public static readonly Location PROPERTY_DECLARATION_ACCESSORS = new();
- public static readonly Location PROPERTY_DECLARATION_ACCESSORS_PREFIX = new();
- public static readonly Location PROPERTY_DECLARATION_EXPRESSION_BODY = new();
- public static readonly Location PROPERTY_DECLARATION_INITIALIZER = new();
- public static readonly Location PROPERTY_DECLARATION_INTERFACE_SPECIFIER_PREFIX = new();
- public static readonly Location PROPERTY_DECLARATION_PREFIX = new();
- public static readonly Location STATEMENT_EXPRESSION_PREFIX = new();
- public static readonly Location USING_DIRECTIVE_ALIAS = new();
- public static readonly Location USING_DIRECTIVE_GLOBAL_SUFFIX = new();
- public static readonly Location USING_DIRECTIVE_PREFIX = new();
- public static readonly Location USING_DIRECTIVE_STATIC = new();
- public static readonly Location USING_DIRECTIVE_UNSAFE = new();
- public static readonly Location LAMBDA_PREFIX = new();
- }
-}
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/DeclarationExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/DeclarationExpression.g.cs
new file mode 100644
index 0000000..505351d
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/DeclarationExpression.g.cs
@@ -0,0 +1,93 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class DeclarationExpression(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ TypeTree? typeExpression,
+ VariableDesignation variables
+ ) : Cs, Expression, TypedTree, MutableTree
+ {
+ public J? AcceptCSharp(CSharpVisitor
v, P p)
+ {
+ return v.VisitDeclarationExpression(this, p);
+ }
+
+ public JavaType? Type => Extensions.GetJavaType(this);
+
+ public DeclarationExpression WithType(JavaType newType)
+ {
+ return Extensions.WithJavaType(this, newType);
+ }
+ public Guid Id => id;
+
+ public DeclarationExpression WithId(Guid newId)
+ {
+ return newId == id ? this : new DeclarationExpression(newId, prefix, markers, typeExpression, variables);
+ }
+ public Space Prefix => prefix;
+
+ public DeclarationExpression WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new DeclarationExpression(id, newPrefix, markers, typeExpression, variables);
+ }
+ public Markers Markers => markers;
+
+ public DeclarationExpression WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new DeclarationExpression(id, prefix, newMarkers, typeExpression, variables);
+ }
+ public TypeTree? TypeExpression => typeExpression;
+
+ public DeclarationExpression WithTypeExpression(TypeTree? newTypeExpression)
+ {
+ return ReferenceEquals(newTypeExpression, typeExpression) ? this : new DeclarationExpression(id, prefix, markers, newTypeExpression, variables);
+ }
+ public Cs.VariableDesignation Variables => variables;
+
+ public DeclarationExpression WithVariables(Cs.VariableDesignation newVariables)
+ {
+ return ReferenceEquals(newVariables, variables) ? this : new DeclarationExpression(id, prefix, markers, typeExpression, newVariables);
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is DeclarationExpression && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/DiscardVariableDesignation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/DiscardVariableDesignation.g.cs
new file mode 100644
index 0000000..2dacf0c
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/DiscardVariableDesignation.g.cs
@@ -0,0 +1,86 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class DiscardVariableDesignation(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ J.Identifier discard
+ ) : Cs.VariableDesignation, Cs, MutableTree
+ {
+ public J? AcceptCSharp(CSharpVisitor
v, P p)
+ {
+ return v.VisitDiscardVariableDesignation(this, p);
+ }
+
+ public JavaType? Type => Extensions.GetJavaType(this);
+
+ public DiscardVariableDesignation WithType(JavaType newType)
+ {
+ return Extensions.WithJavaType(this, newType);
+ }
+ public Guid Id => id;
+
+ public DiscardVariableDesignation WithId(Guid newId)
+ {
+ return newId == id ? this : new DiscardVariableDesignation(newId, prefix, markers, discard);
+ }
+ public Space Prefix => prefix;
+
+ public DiscardVariableDesignation WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new DiscardVariableDesignation(id, newPrefix, markers, discard);
+ }
+ public Markers Markers => markers;
+
+ public DiscardVariableDesignation WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new DiscardVariableDesignation(id, prefix, newMarkers, discard);
+ }
+ public J.Identifier Discard => discard;
+
+ public DiscardVariableDesignation WithDiscard(J.Identifier newDiscard)
+ {
+ return ReferenceEquals(newDiscard, discard) ? this : new DiscardVariableDesignation(id, prefix, markers, newDiscard);
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is DiscardVariableDesignation && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs b/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs
index 3c11d69..3dc0f59 100644
--- a/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs
+++ b/Rewrite/src/Rewrite.CSharp/Tree/Extensions.cs
@@ -5,6 +5,21 @@ namespace Rewrite.RewriteCSharp.Tree;
internal static class Extensions
{
+
+
+
+ public static JavaType? GetJavaType(Cs.DeclarationExpression expr)
+ {
+ // todo: not implemented properly
+ return null;
+ }
+ public static Cs.DeclarationExpression WithJavaType(Cs.DeclarationExpression expr, JavaType newType)
+ {
+ // todo: not implemented properly
+ return expr;
+ }
+
+
public static JavaType? GetJavaType(Cs.Lambda expr)
{
return expr.LambdaExpression.Type;
@@ -74,13 +89,41 @@ public static Cs.Interpolation WithJavaType(Cs.Interpolation expr, JavaType newT
return expr.WithExpression(expr.Expression.WithType(newType));
}
- public static JavaType? GetJavaType(Cs.NamedArgument expr)
+ public static JavaType? GetJavaType(Cs.Argument expr)
{
- return expr.Type;
+ return expr.Expression.Type;
}
- public static Cs.NamedArgument WithJavaType(Cs.NamedArgument expr, JavaType newType)
+ public static Cs.Argument WithJavaType(Cs.Argument expr, JavaType newType)
{
return expr.WithExpression(expr.Expression.WithType(newType));
}
+
+ public static JavaType? GetJavaType(Cs.SingleVariableDesignation expr)
+ {
+ return expr.Name.Type;
+ }
+ public static Cs.SingleVariableDesignation WithJavaType(Cs.SingleVariableDesignation expr, JavaType newType)
+ {
+ return expr.WithName(expr.Name.WithType(newType));
+ }
+
+ public static JavaType? GetJavaType(Cs.DiscardVariableDesignation expr)
+ {
+ return expr.Discard.Type;
+ }
+ public static Cs.DiscardVariableDesignation WithJavaType(Cs.DiscardVariableDesignation expr, JavaType newType)
+ {
+ return expr.WithDiscard(expr.Discard.WithType(newType));
+ }
+
+ public static JavaType? GetJavaType(Cs.TupleExpression expr)
+ {
+ return null;
+ }
+
+ public static Cs.TupleExpression WithJavaType(Cs.TupleExpression expr, JavaType newType)
+ {
+ return expr;
+ }
}
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Keyword.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Keyword.g.cs
new file mode 100644
index 0000000..15211c6
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/Keyword.g.cs
@@ -0,0 +1,80 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class Keyword(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ KeywordKind kind
+ ) : Cs, MutableTree
+ {
+ public J? AcceptCSharp(CSharpVisitor
v, P p)
+ {
+ return v.VisitKeyword(this, p);
+ }
+
+ public Guid Id => id;
+
+ public Keyword WithId(Guid newId)
+ {
+ return newId == id ? this : new Keyword(newId, prefix, markers, kind);
+ }
+ public Space Prefix => prefix;
+
+ public Keyword WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new Keyword(id, newPrefix, markers, kind);
+ }
+ public Markers Markers => markers;
+
+ public Keyword WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new Keyword(id, prefix, newMarkers, kind);
+ }
+ public Cs.KeywordKind Kind => kind;
+
+ public Keyword WithKind(Cs.KeywordKind newKind)
+ {
+ return newKind == kind ? this : new Keyword(id, prefix, markers, newKind);
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is Keyword && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/ParenthesizedVariableDesignation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/ParenthesizedVariableDesignation.g.cs
new file mode 100644
index 0000000..f824d50
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/ParenthesizedVariableDesignation.g.cs
@@ -0,0 +1,124 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class ParenthesizedVariableDesignation(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ JContainer variables,
+ JavaType? type
+ ) : Cs.VariableDesignation, 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.VisitParenthesizedVariableDesignation(this, p);
+ }
+
+ public Guid Id => id;
+
+ public ParenthesizedVariableDesignation WithId(Guid newId)
+ {
+ return newId == id ? this : new ParenthesizedVariableDesignation(newId, prefix, markers, _variables, type);
+ }
+ public Space Prefix => prefix;
+
+ public ParenthesizedVariableDesignation WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new ParenthesizedVariableDesignation(id, newPrefix, markers, _variables, type);
+ }
+ public Markers Markers => markers;
+
+ public ParenthesizedVariableDesignation WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new ParenthesizedVariableDesignation(id, prefix, newMarkers, _variables, type);
+ }
+ private readonly JContainer _variables = variables;
+ public IList Variables => _variables.GetElements();
+
+ public ParenthesizedVariableDesignation WithVariables(IList newVariables)
+ {
+ return Padding.WithVariables(JContainer.WithElements(_variables, newVariables));
+ }
+ public JavaType? Type => type;
+
+ public ParenthesizedVariableDesignation WithType(JavaType? newType)
+ {
+ return newType == type ? this : new ParenthesizedVariableDesignation(id, prefix, markers, _variables, newType);
+ }
+ public sealed record PaddingHelper(Cs.ParenthesizedVariableDesignation T)
+ {
+ public JContainer Variables => T._variables;
+
+ public Cs.ParenthesizedVariableDesignation WithVariables(JContainer newVariables)
+ {
+ return T._variables == newVariables ? T : new Cs.ParenthesizedVariableDesignation(T.Id, T.Prefix, T.Markers, newVariables, T.Type);
+ }
+
+ }
+
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is ParenthesizedVariableDesignation && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/SingleVariableDesignation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/SingleVariableDesignation.g.cs
new file mode 100644
index 0000000..6cf98db
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/SingleVariableDesignation.g.cs
@@ -0,0 +1,86 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class SingleVariableDesignation(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ J.Identifier name
+ ) : Cs.VariableDesignation, Cs, MutableTree
+ {
+ public J? AcceptCSharp(CSharpVisitor
v, P p)
+ {
+ return v.VisitSingleVariableDesignation(this, p);
+ }
+
+ public JavaType? Type => Extensions.GetJavaType(this);
+
+ public SingleVariableDesignation WithType(JavaType newType)
+ {
+ return Extensions.WithJavaType(this, newType);
+ }
+ public Guid Id => id;
+
+ public SingleVariableDesignation WithId(Guid newId)
+ {
+ return newId == id ? this : new SingleVariableDesignation(newId, prefix, markers, name);
+ }
+ public Space Prefix => prefix;
+
+ public SingleVariableDesignation WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new SingleVariableDesignation(id, newPrefix, markers, name);
+ }
+ public Markers Markers => markers;
+
+ public SingleVariableDesignation WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new SingleVariableDesignation(id, prefix, newMarkers, name);
+ }
+ public J.Identifier Name => name;
+
+ public SingleVariableDesignation WithName(J.Identifier newName)
+ {
+ return ReferenceEquals(newName, name) ? this : new SingleVariableDesignation(id, prefix, markers, newName);
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is SingleVariableDesignation && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/TupleExpression.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/TupleExpression.g.cs
new file mode 100644
index 0000000..dade061
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/TupleExpression.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;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class TupleExpression(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ JContainer arguments
+ ) : 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.VisitTupleExpression(this, p);
+ }
+
+ public JavaType? Type => Extensions.GetJavaType(this);
+
+ public TupleExpression WithType(JavaType newType)
+ {
+ return Extensions.WithJavaType(this, newType);
+ }
+ public Guid Id => id;
+
+ public TupleExpression WithId(Guid newId)
+ {
+ return newId == id ? this : new TupleExpression(newId, prefix, markers, _arguments);
+ }
+ public Space Prefix => prefix;
+
+ public TupleExpression WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new TupleExpression(id, newPrefix, markers, _arguments);
+ }
+ public Markers Markers => markers;
+
+ public TupleExpression WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new TupleExpression(id, prefix, newMarkers, _arguments);
+ }
+ private readonly JContainer _arguments = arguments;
+ public IList Arguments => _arguments.GetElements();
+
+ public TupleExpression WithArguments(IList newArguments)
+ {
+ return Padding.WithArguments(JContainer.WithElements(_arguments, newArguments));
+ }
+ public sealed record PaddingHelper(Cs.TupleExpression T)
+ {
+ public JContainer Arguments => T._arguments;
+
+ public Cs.TupleExpression WithArguments(JContainer newArguments)
+ {
+ return T._arguments == newArguments ? T : new Cs.TupleExpression(T.Id, T.Prefix, T.Markers, newArguments);
+ }
+
+ }
+
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is TupleExpression && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/Unary.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/Unary.g.cs
new file mode 100644
index 0000000..11dcc7c
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/Unary.g.cs
@@ -0,0 +1,135 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public partial class Unary(
+ Guid id,
+ Space prefix,
+ Markers markers,
+ JLeftPadded @operator,
+ Expression expression,
+ JavaType? javaType
+ ) : 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.VisitUnary(this, p);
+ }
+
+ public Guid Id => id;
+
+ public Unary WithId(Guid newId)
+ {
+ return newId == id ? this : new Unary(newId, prefix, markers, _operator, expression, javaType);
+ }
+ public Space Prefix => prefix;
+
+ public Unary WithPrefix(Space newPrefix)
+ {
+ return newPrefix == prefix ? this : new Unary(id, newPrefix, markers, _operator, expression, javaType);
+ }
+ public Markers Markers => markers;
+
+ public Unary WithMarkers(Markers newMarkers)
+ {
+ return ReferenceEquals(newMarkers, markers) ? this : new Unary(id, prefix, newMarkers, _operator, expression, javaType);
+ }
+ private readonly JLeftPadded _operator = @operator;
+ public Type Operator => _operator.Element;
+
+ public Unary WithOperator(Type newOperator)
+ {
+ return Padding.WithOperator(_operator.WithElement(newOperator));
+ }
+ public Expression Expression => expression;
+
+ public Unary WithExpression(Expression newExpression)
+ {
+ return ReferenceEquals(newExpression, expression) ? this : new Unary(id, prefix, markers, _operator, newExpression, javaType);
+ }
+ public JavaType? JavaType => javaType;
+
+ public Unary WithJavaType(JavaType? newJavaType)
+ {
+ return newJavaType == javaType ? this : new Unary(id, prefix, markers, _operator, expression, newJavaType);
+ }
+ public enum Type
+ {
+ SuppressNullableWarning,
+ }
+ public sealed record PaddingHelper(Cs.Unary T)
+ {
+ public JLeftPadded Operator => T._operator;
+
+ public Cs.Unary WithOperator(JLeftPadded newOperator)
+ {
+ return T._operator == newOperator ? T : new Cs.Unary(T.Id, T.Prefix, T.Markers, newOperator, T.Expression, T.JavaType);
+ }
+
+ }
+
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public bool Equals(Rewrite.Core.Tree? other)
+ {
+ return other is Unary && other.Id == Id;
+ }
+ #if DEBUG_VISITOR
+ [DebuggerStepThrough]
+ #endif
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/UsingStatement.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/UsingStatement.g.cs
index 64603c0..d2ad476 100644
--- a/Rewrite/src/Rewrite.CSharp/Tree/UsingStatement.g.cs
+++ b/Rewrite/src/Rewrite.CSharp/Tree/UsingStatement.g.cs
@@ -30,7 +30,7 @@ public partial class UsingStatement(
Guid id,
Space prefix,
Markers markers,
- Space? awaitKeyword,
+ Keyword? awaitKeyword,
JContainer expression,
Statement statement
) : Cs, Statement, MutableTree
@@ -83,11 +83,11 @@ public UsingStatement WithMarkers(Markers newMarkers)
{
return ReferenceEquals(newMarkers, markers) ? this : new UsingStatement(id, prefix, newMarkers, awaitKeyword, _expression, statement);
}
- public Space? AwaitKeyword => awaitKeyword;
+ public Cs.Keyword? AwaitKeyword => awaitKeyword;
- public UsingStatement WithAwaitKeyword(Space? newAwaitKeyword)
+ public UsingStatement WithAwaitKeyword(Cs.Keyword? newAwaitKeyword)
{
- return newAwaitKeyword == awaitKeyword ? this : new UsingStatement(id, prefix, markers, newAwaitKeyword, _expression, statement);
+ return ReferenceEquals(newAwaitKeyword, awaitKeyword) ? this : new UsingStatement(id, prefix, markers, newAwaitKeyword, _expression, statement);
}
private readonly JContainer _expression = expression;
public IList Expression => _expression.GetElements();
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/VariableDesignation.g.cs b/Rewrite/src/Rewrite.CSharp/Tree/VariableDesignation.g.cs
new file mode 100644
index 0000000..30961da
--- /dev/null
+++ b/Rewrite/src/Rewrite.CSharp/Tree/VariableDesignation.g.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+#nullable enable
+#pragma warning disable CS0108
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using Rewrite.Core;
+using Rewrite.Core.Marker;
+using FileAttributes = Rewrite.Core.FileAttributes;
+using Rewrite.RewriteJava.Tree;
+
+namespace Rewrite.RewriteCSharp.Tree;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
+[SuppressMessage("ReSharper", "InvertIf")]
+[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
+[SuppressMessage("ReSharper", "RedundantNameQualifier")]
+public partial interface Cs : J
+{
+ public partial interface VariableDesignation : Expression, Cs
+ {
+ }
+}
\ No newline at end of file
diff --git a/Rewrite/src/Rewrite.CSharp/Tree/_CommonOverrides.cs b/Rewrite/src/Rewrite.CSharp/Tree/_CommonOverrides.cs
deleted file mode 100644
index e93990e..0000000
--- a/Rewrite/src/Rewrite.CSharp/Tree/_CommonOverrides.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using Rewrite.Core;
-using Rewrite.RewriteCSharp.Tree;
-using Rewrite.RewriteJava.Tree;
-
-namespace Rewrite.RewriteCSharp.Tree
-{
- public partial interface Cs
- {
- partial class UsingStatement
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
- partial class AnnotatedStatement
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ArrayRankSpecifier
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class AssignmentOperation
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class AttributeList
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class AwaitExpression
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Binary
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class BlockScopeNamespaceDeclaration
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class CollectionExpression
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class CompilationUnit
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ExpressionStatement
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ExternAlias
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class FileScopeNamespaceDeclaration
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class InterpolatedString
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Interpolation
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class NamedArgument
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class NullSafeExpression
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class PropertyDeclaration
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class StatementExpression
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class UsingDirective
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
- }
-}
diff --git a/Rewrite/src/Rewrite.Core/AsyncHelper.cs b/Rewrite/src/Rewrite.Core/AsyncHelper.cs
new file mode 100644
index 0000000..fdf07a7
--- /dev/null
+++ b/Rewrite/src/Rewrite.Core/AsyncHelper.cs
@@ -0,0 +1,28 @@
+namespace Rewrite.Remote;
+
+public static class AsyncHelper
+{
+ private static readonly TaskFactory _myTaskFactory = new
+ TaskFactory(CancellationToken.None,
+ TaskCreationOptions.None,
+ TaskContinuationOptions.None,
+ TaskScheduler.Default);
+
+ public static TResult RunSync(Func> func)
+ {
+ return AsyncHelper._myTaskFactory
+ .StartNew>(func)
+ .Unwrap()
+ .GetAwaiter()
+ .GetResult();
+ }
+
+ public static void RunSync(Func func)
+ {
+ AsyncHelper._myTaskFactory
+ .StartNew(func)
+ .Unwrap()
+ .GetAwaiter()
+ .GetResult();
+ }
+}
diff --git a/Rewrite/src/Rewrite.Java/Rewrite.Java.csproj b/Rewrite/src/Rewrite.Java/Rewrite.Java.csproj
index a0a9cbf..e8c9303 100644
--- a/Rewrite/src/Rewrite.Java/Rewrite.Java.csproj
+++ b/Rewrite/src/Rewrite.Java/Rewrite.Java.csproj
@@ -20,5 +20,9 @@
-
+
+
+
diff --git a/Rewrite/src/Rewrite.Java/Tree/Extensions.cs b/Rewrite/src/Rewrite.Java/Tree/Extensions.cs
index 5d42715..1dc955a 100644
--- a/Rewrite/src/Rewrite.Java/Tree/Extensions.cs
+++ b/Rewrite/src/Rewrite.Java/Tree/Extensions.cs
@@ -339,7 +339,7 @@ public static J.MethodInvocation WithMethodType(this J.MethodInvocation method,
public static J.MethodInvocation WithName(J.MethodInvocation method, J.Identifier name)
{
- if (method.Name == name) return method;
+ if (ReferenceEquals(method.Name, name)) return method;
// FIXME add type attribution logic
return new J.MethodInvocation(method.Id, method.Prefix, method.Markers, method.Padding.Select,
method.Padding.TypeParameters, name, method.Padding.Arguments, method.MethodType);
diff --git a/Rewrite/src/Rewrite.Java/Tree/_CommonOverrides.cs b/Rewrite/src/Rewrite.Java/Tree/_CommonOverrides.cs
deleted file mode 100644
index 7f3a383..0000000
--- a/Rewrite/src/Rewrite.Java/Tree/_CommonOverrides.cs
+++ /dev/null
@@ -1,307 +0,0 @@
-using Rewrite.Core;
-
-namespace Rewrite.RewriteJava.Tree
-{
- public partial interface J
- {
- partial class AnnotatedType
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Annotation
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ArrayAccess
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ArrayDimension
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ArrayType
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Assert
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Assignment
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class AssignmentOperation
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Binary
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Block
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Break
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Case
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ClassDeclaration
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class CompilationUnit
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Continue
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ControlParentheses
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class DoWhileLoop
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Empty
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class EnumValue
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class EnumValueSet
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class FieldAccess
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ForEachLoop
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ForLoop
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Identifier
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class If
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Import
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class InstanceOf
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class IntersectionType
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Label
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Lambda
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Literal
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class MemberReference
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class MethodDeclaration
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class MethodInvocation
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Modifier
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class MultiCatch
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class NewArray
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class NewClass
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class NullableType
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Package
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ParameterizedType
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Parentheses
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class ParenthesizedTypeTree
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Primitive
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Return
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Switch
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class SwitchExpression
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Synchronized
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Ternary
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Throw
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Try
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class TypeCast
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class TypeParameter
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class TypeParameters
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Unary
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Unknown
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class VariableDeclarations
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class WhileLoop
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Wildcard
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
-
- partial class Yield
- {
- public override string? ToString() => Core.Tree.ToString(this) ?? base.ToString();
- }
- }
-}
diff --git a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs
index 77097c1..aef2e1c 100644
--- a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs
+++ b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpReceiver.g.cs
@@ -64,14 +64,15 @@ public override J VisitCompilationUnit(Cs.CompilationUnit compilationUnit, Recei
return compilationUnit;
}
- public override J VisitNamedArgument(Cs.NamedArgument namedArgument, ReceiverContext ctx)
+ public override J VisitArgument(Cs.Argument argument, ReceiverContext ctx)
{
- namedArgument = namedArgument.WithId(ctx.ReceiveValue(namedArgument.Id)!);
- namedArgument = namedArgument.WithPrefix(ctx.ReceiveNode(namedArgument.Prefix, ReceiveSpace)!);
- namedArgument = namedArgument.WithMarkers(ctx.ReceiveNode(namedArgument.Markers, ctx.ReceiveMarkers)!);
- namedArgument = namedArgument.Padding.WithNameColumn(ctx.ReceiveNode(namedArgument.Padding.NameColumn, ReceiveRightPadded));
- namedArgument = namedArgument.WithExpression(ctx.ReceiveNode(namedArgument.Expression, ctx.ReceiveTree)!);
- return namedArgument;
+ argument = argument.WithId(ctx.ReceiveValue(argument.Id)!);
+ argument = argument.WithPrefix(ctx.ReceiveNode(argument.Prefix, ReceiveSpace)!);
+ argument = argument.WithMarkers(ctx.ReceiveNode(argument.Markers, ctx.ReceiveMarkers)!);
+ argument = argument.Padding.WithNameColumn(ctx.ReceiveNode(argument.Padding.NameColumn, ReceiveRightPadded));
+ argument = argument.WithRefKindKeyword(ctx.ReceiveNode(argument.RefKindKeyword, ctx.ReceiveTree));
+ argument = argument.WithExpression(ctx.ReceiveNode(argument.Expression, ctx.ReceiveTree)!);
+ return argument;
}
public override J VisitAnnotatedStatement(Cs.AnnotatedStatement annotatedStatement, ReceiverContext ctx)
@@ -258,6 +259,15 @@ public override J VisitPropertyDeclaration(Cs.PropertyDeclaration propertyDeclar
return propertyDeclaration;
}
+ public override J VisitKeyword(Cs.Keyword keyword, ReceiverContext ctx)
+ {
+ keyword = keyword.WithId(ctx.ReceiveValue(keyword.Id)!);
+ keyword = keyword.WithPrefix(ctx.ReceiveNode(keyword.Prefix, ReceiveSpace)!);
+ keyword = keyword.WithMarkers(ctx.ReceiveNode(keyword.Markers, ctx.ReceiveMarkers)!);
+ keyword = keyword.WithKind(ctx.ReceiveValue(keyword.Kind)!);
+ return keyword;
+ }
+
public override J VisitLambda(Cs.Lambda lambda, ReceiverContext ctx)
{
lambda = lambda.WithId(ctx.ReceiveValue(lambda.Id)!);
@@ -293,7 +303,7 @@ public override J VisitUsingStatement(Cs.UsingStatement usingStatement, Receiver
usingStatement = usingStatement.WithId(ctx.ReceiveValue(usingStatement.Id)!);
usingStatement = usingStatement.WithPrefix(ctx.ReceiveNode(usingStatement.Prefix, ReceiveSpace)!);
usingStatement = usingStatement.WithMarkers(ctx.ReceiveNode(usingStatement.Markers, ctx.ReceiveMarkers)!);
- usingStatement = usingStatement.WithAwaitKeyword(ctx.ReceiveNode(usingStatement.AwaitKeyword, ReceiveSpace));
+ usingStatement = usingStatement.WithAwaitKeyword(ctx.ReceiveNode(usingStatement.AwaitKeyword, ctx.ReceiveTree));
usingStatement = usingStatement.Padding.WithExpression(ctx.ReceiveNode(usingStatement.Padding.Expression, ReceiveContainer)!);
usingStatement = usingStatement.WithStatement(ctx.ReceiveNode(usingStatement.Statement, ctx.ReceiveTree)!);
return usingStatement;
@@ -360,6 +370,84 @@ public override J VisitDefaultConstraint(Cs.DefaultConstraint defaultConstraint,
return defaultConstraint;
}
+ public override J VisitDeclarationExpression(Cs.DeclarationExpression declarationExpression, ReceiverContext ctx)
+ {
+ declarationExpression = declarationExpression.WithId(ctx.ReceiveValue(declarationExpression.Id)!);
+ declarationExpression = declarationExpression.WithPrefix(ctx.ReceiveNode(declarationExpression.Prefix, ReceiveSpace)!);
+ declarationExpression = declarationExpression.WithMarkers(ctx.ReceiveNode(declarationExpression.Markers, ctx.ReceiveMarkers)!);
+ declarationExpression = declarationExpression.WithTypeExpression(ctx.ReceiveNode(declarationExpression.TypeExpression, ctx.ReceiveTree));
+ declarationExpression = declarationExpression.WithVariables(ctx.ReceiveNode(declarationExpression.Variables, ctx.ReceiveTree)!);
+ return declarationExpression;
+ }
+
+ public override J VisitSingleVariableDesignation(Cs.SingleVariableDesignation singleVariableDesignation, ReceiverContext ctx)
+ {
+ singleVariableDesignation = singleVariableDesignation.WithId(ctx.ReceiveValue(singleVariableDesignation.Id)!);
+ singleVariableDesignation = singleVariableDesignation.WithPrefix(ctx.ReceiveNode(singleVariableDesignation.Prefix, ReceiveSpace)!);
+ singleVariableDesignation = singleVariableDesignation.WithMarkers(ctx.ReceiveNode(singleVariableDesignation.Markers, ctx.ReceiveMarkers)!);
+ singleVariableDesignation = singleVariableDesignation.WithName(ctx.ReceiveNode(singleVariableDesignation.Name, ctx.ReceiveTree)!);
+ return singleVariableDesignation;
+ }
+
+ public override J VisitParenthesizedVariableDesignation(Cs.ParenthesizedVariableDesignation parenthesizedVariableDesignation, ReceiverContext ctx)
+ {
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.WithId(ctx.ReceiveValue(parenthesizedVariableDesignation.Id)!);
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.WithPrefix(ctx.ReceiveNode(parenthesizedVariableDesignation.Prefix, ReceiveSpace)!);
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.WithMarkers(ctx.ReceiveNode(parenthesizedVariableDesignation.Markers, ctx.ReceiveMarkers)!);
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.Padding.WithVariables(ctx.ReceiveNode(parenthesizedVariableDesignation.Padding.Variables, ReceiveContainer)!);
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.WithType(ctx.ReceiveValue(parenthesizedVariableDesignation.Type));
+ return parenthesizedVariableDesignation;
+ }
+
+ public override J VisitDiscardVariableDesignation(Cs.DiscardVariableDesignation discardVariableDesignation, ReceiverContext ctx)
+ {
+ discardVariableDesignation = discardVariableDesignation.WithId(ctx.ReceiveValue(discardVariableDesignation.Id)!);
+ discardVariableDesignation = discardVariableDesignation.WithPrefix(ctx.ReceiveNode(discardVariableDesignation.Prefix, ReceiveSpace)!);
+ discardVariableDesignation = discardVariableDesignation.WithMarkers(ctx.ReceiveNode(discardVariableDesignation.Markers, ctx.ReceiveMarkers)!);
+ discardVariableDesignation = discardVariableDesignation.WithDiscard(ctx.ReceiveNode(discardVariableDesignation.Discard, ctx.ReceiveTree)!);
+ return discardVariableDesignation;
+ }
+
+ public override J VisitTupleExpression(Cs.TupleExpression tupleExpression, ReceiverContext ctx)
+ {
+ tupleExpression = tupleExpression.WithId(ctx.ReceiveValue(tupleExpression.Id)!);
+ tupleExpression = tupleExpression.WithPrefix(ctx.ReceiveNode(tupleExpression.Prefix, ReceiveSpace)!);
+ tupleExpression = tupleExpression.WithMarkers(ctx.ReceiveNode(tupleExpression.Markers, ctx.ReceiveMarkers)!);
+ tupleExpression = tupleExpression.Padding.WithArguments(ctx.ReceiveNode(tupleExpression.Padding.Arguments, ReceiveContainer)!);
+ return tupleExpression;
+ }
+
+ public override J VisitConstructor(Cs.Constructor constructor, ReceiverContext ctx)
+ {
+ constructor = constructor.WithId(ctx.ReceiveValue(constructor.Id)!);
+ constructor = constructor.WithPrefix(ctx.ReceiveNode(constructor.Prefix, ReceiveSpace)!);
+ constructor = constructor.WithMarkers(ctx.ReceiveNode(constructor.Markers, ctx.ReceiveMarkers)!);
+ constructor = constructor.WithInitializer(ctx.ReceiveNode(constructor.Initializer, ctx.ReceiveTree));
+ constructor = constructor.WithConstructorCore(ctx.ReceiveNode(constructor.ConstructorCore, ctx.ReceiveTree)!);
+ return constructor;
+ }
+
+ public override J VisitUnary(Cs.Unary unary, ReceiverContext ctx)
+ {
+ unary = unary.WithId(ctx.ReceiveValue(unary.Id)!);
+ unary = unary.WithPrefix(ctx.ReceiveNode(unary.Prefix, ReceiveSpace)!);
+ unary = unary.WithMarkers(ctx.ReceiveNode(unary.Markers, ctx.ReceiveMarkers)!);
+ unary = unary.Padding.WithOperator(ctx.ReceiveNode(unary.Padding.Operator, ReceiveLeftPadded)!);
+ unary = unary.WithExpression(ctx.ReceiveNode(unary.Expression, ctx.ReceiveTree)!);
+ unary = unary.WithJavaType(ctx.ReceiveValue(unary.JavaType));
+ return unary;
+ }
+
+ public override J VisitConstructorInitializer(Cs.ConstructorInitializer constructorInitializer, ReceiverContext ctx)
+ {
+ constructorInitializer = constructorInitializer.WithId(ctx.ReceiveValue(constructorInitializer.Id)!);
+ constructorInitializer = constructorInitializer.WithPrefix(ctx.ReceiveNode(constructorInitializer.Prefix, ReceiveSpace)!);
+ constructorInitializer = constructorInitializer.WithMarkers(ctx.ReceiveNode(constructorInitializer.Markers, ctx.ReceiveMarkers)!);
+ constructorInitializer = constructorInitializer.WithKeyword(ctx.ReceiveNode(constructorInitializer.Keyword, ctx.ReceiveTree)!);
+ constructorInitializer = constructorInitializer.Padding.WithArguments(ctx.ReceiveNode(constructorInitializer.Padding.Arguments, ReceiveContainer)!);
+ return constructorInitializer;
+ }
+
public override J VisitAnnotatedType(J.AnnotatedType annotatedType, ReceiverContext ctx)
{
annotatedType = annotatedType.WithId(ctx.ReceiveValue(annotatedType.Id)!);
@@ -1110,13 +1198,14 @@ public Rewrite.Core.Tree Create(string type, ReceiverContext ctx) where T : R
);
}
- if (type is "Rewrite.RewriteCSharp.Tree.Cs.NamedArgument" or "org.openrewrite.csharp.tree.Cs$NamedArgument")
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.Argument" or "org.openrewrite.csharp.tree.Cs$Argument")
{
- return new Cs.NamedArgument(
+ return new Cs.Argument(
ctx.ReceiveValue(default(Guid))!,
ctx.ReceiveNode(default(Space), ReceiveSpace)!,
ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
ctx.ReceiveNode(default(JRightPadded), ReceiveRightPadded),
+ ctx.ReceiveNode(default(Cs.Keyword), ctx.ReceiveTree),
ctx.ReceiveNode(default(Expression), ctx.ReceiveTree)!
);
}
@@ -1322,6 +1411,16 @@ public Rewrite.Core.Tree Create(string type, ReceiverContext ctx) where T : R
);
}
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.Keyword" or "org.openrewrite.csharp.tree.Cs$Keyword")
+ {
+ return new Cs.Keyword(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveValue(default(Cs.KeywordKind))!
+ );
+ }
+
if (type is "Rewrite.RewriteCSharp.Tree.Cs.Lambda" or "org.openrewrite.csharp.tree.Cs$Lambda")
{
return new Cs.Lambda(
@@ -1361,7 +1460,7 @@ public Rewrite.Core.Tree Create(string type, ReceiverContext ctx) where T : R
ctx.ReceiveValue(default(Guid))!,
ctx.ReceiveNode(default(Space), ReceiveSpace)!,
ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
- ctx.ReceiveNode(default(Space), ReceiveSpace),
+ ctx.ReceiveNode(default(Cs.Keyword), ctx.ReceiveTree),
ctx.ReceiveNode(default(JContainer), ReceiveContainer)!,
ctx.ReceiveNode(default(Statement), ctx.ReceiveTree)!
);
@@ -1435,6 +1534,92 @@ public Rewrite.Core.Tree Create(string type, ReceiverContext ctx) where T : R
);
}
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.DeclarationExpression" or "org.openrewrite.csharp.tree.Cs$DeclarationExpression")
+ {
+ return new Cs.DeclarationExpression(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(TypeTree), ctx.ReceiveTree),
+ ctx.ReceiveNode(default(Cs.VariableDesignation), ctx.ReceiveTree)!
+ );
+ }
+
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.SingleVariableDesignation" or "org.openrewrite.csharp.tree.Cs$SingleVariableDesignation")
+ {
+ return new Cs.SingleVariableDesignation(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(J.Identifier), ctx.ReceiveTree)!
+ );
+ }
+
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.ParenthesizedVariableDesignation" or "org.openrewrite.csharp.tree.Cs$ParenthesizedVariableDesignation")
+ {
+ return new Cs.ParenthesizedVariableDesignation(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(JContainer), ReceiveContainer)!,
+ ctx.ReceiveValue(default(JavaType))
+ );
+ }
+
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.DiscardVariableDesignation" or "org.openrewrite.csharp.tree.Cs$DiscardVariableDesignation")
+ {
+ return new Cs.DiscardVariableDesignation(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(J.Identifier), ctx.ReceiveTree)!
+ );
+ }
+
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.TupleExpression" or "org.openrewrite.csharp.tree.Cs$TupleExpression")
+ {
+ return new Cs.TupleExpression(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(JContainer), ReceiveContainer)!
+ );
+ }
+
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.Constructor" or "org.openrewrite.csharp.tree.Cs$Constructor")
+ {
+ return new Cs.Constructor(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(Cs.ConstructorInitializer), ctx.ReceiveTree),
+ ctx.ReceiveNode(default(J.MethodDeclaration), ctx.ReceiveTree)!
+ );
+ }
+
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.Unary" or "org.openrewrite.csharp.tree.Cs$Unary")
+ {
+ return new Cs.Unary(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(JLeftPadded), ReceiveLeftPadded)!,
+ ctx.ReceiveNode(default(Expression), ctx.ReceiveTree)!,
+ ctx.ReceiveValue(default(JavaType))
+ );
+ }
+
+ if (type is "Rewrite.RewriteCSharp.Tree.Cs.ConstructorInitializer" or "org.openrewrite.csharp.tree.Cs$ConstructorInitializer")
+ {
+ return new Cs.ConstructorInitializer(
+ ctx.ReceiveValue(default(Guid))!,
+ ctx.ReceiveNode(default(Space), ReceiveSpace)!,
+ ctx.ReceiveNode(default(Markers), ctx.ReceiveMarkers)!,
+ ctx.ReceiveNode(default(Cs.Keyword), ctx.ReceiveTree)!,
+ ctx.ReceiveNode(default(JContainer), ReceiveContainer)!
+ );
+ }
+
if (type is "Rewrite.RewriteCSharp.Tree.J.AnnotatedType" or "org.openrewrite.java.tree.J$AnnotatedType")
{
return new J.AnnotatedType(
diff --git a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs
index 08c7853..c3d7018 100644
--- a/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs
+++ b/Rewrite/src/Rewrite.Remote.Codec/CSharp/CSharpSender.g.cs
@@ -55,14 +55,15 @@ public override J VisitCompilationUnit(Cs.CompilationUnit compilationUnit, Sende
return compilationUnit;
}
- public override J VisitNamedArgument(Cs.NamedArgument namedArgument, SenderContext ctx)
+ public override J VisitArgument(Cs.Argument argument, SenderContext ctx)
{
- ctx.SendValue(namedArgument, v => v.Id);
- ctx.SendNode(namedArgument, v => v.Prefix, SendSpace);
- ctx.SendNode(namedArgument, v => v.Markers, ctx.SendMarkers);
- ctx.SendNode(namedArgument, v => v.Padding.NameColumn, SendRightPadded);
- ctx.SendNode(namedArgument, v => v.Expression, ctx.SendTree);
- return namedArgument;
+ ctx.SendValue(argument, v => v.Id);
+ ctx.SendNode(argument, v => v.Prefix, SendSpace);
+ ctx.SendNode(argument, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(argument, v => v.Padding.NameColumn, SendRightPadded);
+ ctx.SendNode(argument, v => v.RefKindKeyword, ctx.SendTree);
+ ctx.SendNode(argument, v => v.Expression, ctx.SendTree);
+ return argument;
}
public override J VisitAnnotatedStatement(Cs.AnnotatedStatement annotatedStatement, SenderContext ctx)
@@ -249,6 +250,15 @@ public override J VisitPropertyDeclaration(Cs.PropertyDeclaration propertyDeclar
return propertyDeclaration;
}
+ public override J VisitKeyword(Cs.Keyword keyword, SenderContext ctx)
+ {
+ ctx.SendValue(keyword, v => v.Id);
+ ctx.SendNode(keyword, v => v.Prefix, SendSpace);
+ ctx.SendNode(keyword, v => v.Markers, ctx.SendMarkers);
+ ctx.SendValue(keyword, v => v.Kind);
+ return keyword;
+ }
+
public override J VisitLambda(Cs.Lambda lambda, SenderContext ctx)
{
ctx.SendValue(lambda, v => v.Id);
@@ -284,7 +294,7 @@ public override J VisitUsingStatement(Cs.UsingStatement usingStatement, SenderCo
ctx.SendValue(usingStatement, v => v.Id);
ctx.SendNode(usingStatement, v => v.Prefix, SendSpace);
ctx.SendNode(usingStatement, v => v.Markers, ctx.SendMarkers);
- ctx.SendNode(usingStatement, v => v.AwaitKeyword, SendSpace);
+ ctx.SendNode(usingStatement, v => v.AwaitKeyword, ctx.SendTree);
ctx.SendNode(usingStatement, v => v.Padding.Expression, SendContainer);
ctx.SendNode(usingStatement, v => v.Statement, ctx.SendTree);
return usingStatement;
@@ -351,6 +361,84 @@ public override J VisitDefaultConstraint(Cs.DefaultConstraint defaultConstraint,
return defaultConstraint;
}
+ public override J VisitDeclarationExpression(Cs.DeclarationExpression declarationExpression, SenderContext ctx)
+ {
+ ctx.SendValue(declarationExpression, v => v.Id);
+ ctx.SendNode(declarationExpression, v => v.Prefix, SendSpace);
+ ctx.SendNode(declarationExpression, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(declarationExpression, v => v.TypeExpression, ctx.SendTree);
+ ctx.SendNode(declarationExpression, v => v.Variables, ctx.SendTree);
+ return declarationExpression;
+ }
+
+ public override J VisitSingleVariableDesignation(Cs.SingleVariableDesignation singleVariableDesignation, SenderContext ctx)
+ {
+ ctx.SendValue(singleVariableDesignation, v => v.Id);
+ ctx.SendNode(singleVariableDesignation, v => v.Prefix, SendSpace);
+ ctx.SendNode(singleVariableDesignation, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(singleVariableDesignation, v => v.Name, ctx.SendTree);
+ return singleVariableDesignation;
+ }
+
+ public override J VisitParenthesizedVariableDesignation(Cs.ParenthesizedVariableDesignation parenthesizedVariableDesignation, SenderContext ctx)
+ {
+ ctx.SendValue(parenthesizedVariableDesignation, v => v.Id);
+ ctx.SendNode(parenthesizedVariableDesignation, v => v.Prefix, SendSpace);
+ ctx.SendNode(parenthesizedVariableDesignation, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(parenthesizedVariableDesignation, v => v.Padding.Variables, SendContainer);
+ ctx.SendTypedValue(parenthesizedVariableDesignation, v => v.Type);
+ return parenthesizedVariableDesignation;
+ }
+
+ public override J VisitDiscardVariableDesignation(Cs.DiscardVariableDesignation discardVariableDesignation, SenderContext ctx)
+ {
+ ctx.SendValue(discardVariableDesignation, v => v.Id);
+ ctx.SendNode(discardVariableDesignation, v => v.Prefix, SendSpace);
+ ctx.SendNode(discardVariableDesignation, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(discardVariableDesignation, v => v.Discard, ctx.SendTree);
+ return discardVariableDesignation;
+ }
+
+ public override J VisitTupleExpression(Cs.TupleExpression tupleExpression, SenderContext ctx)
+ {
+ ctx.SendValue(tupleExpression, v => v.Id);
+ ctx.SendNode(tupleExpression, v => v.Prefix, SendSpace);
+ ctx.SendNode(tupleExpression, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(tupleExpression, v => v.Padding.Arguments, SendContainer);
+ return tupleExpression;
+ }
+
+ public override J VisitConstructor(Cs.Constructor constructor, SenderContext ctx)
+ {
+ ctx.SendValue(constructor, v => v.Id);
+ ctx.SendNode(constructor, v => v.Prefix, SendSpace);
+ ctx.SendNode(constructor, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(constructor, v => v.Initializer, ctx.SendTree);
+ ctx.SendNode(constructor, v => v.ConstructorCore, ctx.SendTree);
+ return constructor;
+ }
+
+ public override J VisitUnary(Cs.Unary unary, SenderContext ctx)
+ {
+ ctx.SendValue(unary, v => v.Id);
+ ctx.SendNode(unary, v => v.Prefix, SendSpace);
+ ctx.SendNode(unary, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(unary, v => v.Padding.Operator, SendLeftPadded);
+ ctx.SendNode(unary, v => v.Expression, ctx.SendTree);
+ ctx.SendTypedValue(unary, v => v.JavaType);
+ return unary;
+ }
+
+ public override J VisitConstructorInitializer(Cs.ConstructorInitializer constructorInitializer, SenderContext ctx)
+ {
+ ctx.SendValue(constructorInitializer, v => v.Id);
+ ctx.SendNode(constructorInitializer, v => v.Prefix, SendSpace);
+ ctx.SendNode(constructorInitializer, v => v.Markers, ctx.SendMarkers);
+ ctx.SendNode(constructorInitializer, v => v.Keyword, ctx.SendTree);
+ ctx.SendNode(constructorInitializer, v => v.Padding.Arguments, SendContainer);
+ return constructorInitializer;
+ }
+
public override J VisitAnnotatedType(J.AnnotatedType annotatedType, SenderContext ctx)
{
ctx.SendValue(annotatedType, v => v.Id);
diff --git a/Rewrite/src/Rewrite.Test.CSharp/Assertions.cs b/Rewrite/src/Rewrite.Test.CSharp/Assertions.cs
index f3889e8..c1097ee 100644
--- a/Rewrite/src/Rewrite.Test.CSharp/Assertions.cs
+++ b/Rewrite/src/Rewrite.Test.CSharp/Assertions.cs
@@ -19,9 +19,9 @@ public static ValidateSource Noop()
return (sourceFile, _) => sourceFile;
}
- public static SourceSpecs CSharp([LanguageInjection("C#")] string before)
+ public static SourceSpec CSharp([LanguageInjection("C#")] string before)
{
- return CSharp(before, s => { });
+ return CSharp(before, s => { }).Cast>().First();
}
public static SourceSpecs CSharp([LanguageInjection("C#")] string before, Action> spec)
diff --git a/Rewrite/src/Rewrite.Test/LocalPrinterFixture.cs b/Rewrite/src/Rewrite.Test/LocalPrinterFixture.cs
index 77e6dcc..5b3bcf6 100644
--- a/Rewrite/src/Rewrite.Test/LocalPrinterFixture.cs
+++ b/Rewrite/src/Rewrite.Test/LocalPrinterFixture.cs
@@ -3,11 +3,16 @@
namespace Rewrite.CSharp.Tests;
-public class LocalPrinterFixture
+public class LocalPrinterFixture : IDisposable
{
public LocalPrinterFixture()
{
ITestExecutionContext.SetCurrent(new LocalTestExecutionContext());
IPrinterFactory.Set(new LocalPrinterFactory());
}
+
+ public void Dispose()
+ {
+ // TODO release managed resources here
+ }
}
diff --git a/Rewrite/src/Rewrite.Test/SourceSpecExtensions.cs b/Rewrite/src/Rewrite.Test/SourceSpecExtensions.cs
index 66a482e..80b50a0 100644
--- a/Rewrite/src/Rewrite.Test/SourceSpecExtensions.cs
+++ b/Rewrite/src/Rewrite.Test/SourceSpecExtensions.cs
@@ -12,6 +12,12 @@ public static T Parse(this SourceSpec sourceSpec) where T : SourceFile
}
+ public static T Parse(this SourceSpec sourceSpec) where T : SourceFile
+ {
+ var sourceText = sourceSpec.Before ?? "";
+ return (T)sourceSpec.Parser.Build().Parse(sourceText);
+ }
+
public static IEnumerable Parse(this SourceSpecs sourceSpec) where T : SourceFile
{
foreach (var spec in sourceSpec)
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Properties/AssemblyInfo.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..7bb647d
--- /dev/null
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+#if REMOTE_PRINTER
+[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
+#endif
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Rewrite.CSharp.Tests.v3.ncrunchproject b/Rewrite/tests/Rewrite.CSharp.Tests/Rewrite.CSharp.Tests.v3.ncrunchproject
new file mode 100644
index 0000000..b1461fe
--- /dev/null
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Rewrite.CSharp.Tests.v3.ncrunchproject
@@ -0,0 +1,27 @@
+
+
+
+
+ Rewrite.CSharp.Tests.Solutions.SolutionTests
+
+
+ Rewrite.CSharp.Tests.PlayTests
+
+
+ Rewrite.CSharp.Tests.RoslynTestCases.ParseTests.ParseAndPrint
+
+
+ Rewrite.CSharp.Tests.FindClassDeclarationTests.ClassWithoutBody2
+
+
+ Rewrite.CSharp.Tests.FindClassDeclarationTests
+
+
+ Rewrite.CSharp.Tests.FindClassTests
+
+
+ Rewrite.CSharp.Tests.RecipeOptionsTest
+
+
+
+
\ No newline at end of file
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/TestSetup.cs b/Rewrite/tests/Rewrite.CSharp.Tests/TestSetup.cs
new file mode 100644
index 0000000..062a62a
--- /dev/null
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/TestSetup.cs
@@ -0,0 +1,27 @@
+//
+//
+// using Rewrite.Test.Engine.Remote;
+// using Xunit.Abstractions;
+// using Xunit.Sdk;
+//
+// [assembly: Xunit.TestFramework("Rewrite.CSharp.Tests.TestSetup", "Rewrite.CSharp.Tests")]
+//
+// namespace Rewrite.CSharp.Tests;
+//
+// public sealed class TestSetup : XunitTestFramework, IDisposable
+// {
+// #if REMOTE_PRINTER
+// private readonly IDisposable _fixture = new RemotingFixture();
+// #else
+// private readonly IDisposable _fixture = new LocalPrinterFixture();
+// #endif
+// public TestSetup(IMessageSink messageSink)
+// :base(messageSink)
+// {
+// }
+//
+// public new void Dispose()
+// {
+// _fixture.Dispose();
+// }
+// }
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayAccessTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayAccessTests.cs
index 154f051..0bdf349 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayAccessTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayAccessTests.cs
@@ -6,7 +6,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ArrayAccessTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTests.cs
index 1792945..f172ab6 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTests.cs
@@ -5,7 +5,7 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
+
public class ArrayTests : RewriteTest
{
[Fact]
@@ -24,15 +24,14 @@ public class Foo
}
[Fact]
- public void MultiDimensionalSpace()
+ public void ImplicitArray()
{
RewriteRun(
CSharp(
"""
public class Foo
{
- object arr = /*0*/ new /*1*/ int /*2*/ [ /*3*/ 1 /*4*/ , /*5*/ 1 /*6*/ ] /*7*/ [ /*8*/ ] /*9*/
- { /*10*/ { /*11*/ { /*12*/ 1 /*13*/ , /*14*/ } /*15*/ } /*16*/ } /*17*/ ; /*18*/
+ object arr = new [] { 1 };
}
"""
)
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTypeTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTypeTests.cs
index 9bfb191..3a39c97 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTypeTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ArrayTypeTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ArrayTypeTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AssignmentTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AssignmentTests.cs
index 016e710..2ffe39a 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AssignmentTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AssignmentTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class AssignmentTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs
index 49173bd..05c4142 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AsyncTests.cs
@@ -5,7 +5,7 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
+
public class AsyncTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AttributeTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AttributeTests.cs
index 20e2086..8896032 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AttributeTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/AttributeTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class AttributeTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BinaryTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BinaryTests.cs
index 4f09f16..b4255f4 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BinaryTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BinaryTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class BinaryTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BlockTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BlockTests.cs
index 484f618..5da38ff 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BlockTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/BlockTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class BlockTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ClassDeclarationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ClassDeclarationTests.cs
index a46682f..87d58c2 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ClassDeclarationTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ClassDeclarationTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ClassDeclarationTests : RewriteTest
{
[Fact]
@@ -138,7 +137,6 @@ class Foo where T : struct;
}
[Fact]
- [KnownBug]
public void TypeParameterWithNewConstraint()
{
RewriteRun(
@@ -151,7 +149,6 @@ public void TypeParameterWithNewConstraint()
}
[Fact]
- [KnownBug]
public void TypeParameterWithMultipleConstraints()
{
RewriteRun(
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CollectionExpressionTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CollectionExpressionTests.cs
index 61b6ca9..10a8b8f 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CollectionExpressionTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CollectionExpressionTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class CollectionExpressionTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CompilationUnitTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CompilationUnitTests.cs
index f7924bf..0519e27 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CompilationUnitTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/CompilationUnitTests.cs
@@ -6,7 +6,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class CompilationUnitTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ConstructorTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ConstructorTests.cs
new file mode 100644
index 0000000..fda7770
--- /dev/null
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ConstructorTests.cs
@@ -0,0 +1,44 @@
+using Rewrite.Test.CSharp;
+using Rewrite.RewriteCSharp.Tree;
+using Rewrite.Test;
+
+namespace Rewrite.CSharp.Tests.Tree;
+
+using static Assertions;
+
+public class ConstructorTests : RewriteTest
+{
+ [Fact]
+ public void VanillaConstructor()
+ {
+ var src = CSharp("""
+ public class A
+ {
+ public A()
+ {}
+ })
+ """);
+ var lst = src.Parse();
+ lst.ToString().ShouldBeSameAs(src.Before);
+ }
+
+ [Fact]
+ public void ConstructorWithThisCall()
+ {
+ var src = CSharp("""
+ public class A
+ {
+ public A() : this(1)
+ {}
+
+ public A(int a)
+ {
+ }
+ })
+ """);
+ var lst = src.Parse();
+ lst.ToString().ShouldBeSameAs(src.Before);
+ }
+}
+
+
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/EmptyTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/EmptyTests.cs
index fcdcc58..0ceaf85 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/EmptyTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/EmptyTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class EmptyTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ExternAliasTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ExternAliasTests.cs
index e3ee9c9..f8dce8a 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ExternAliasTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ExternAliasTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ExternAliasTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/FieldTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/FieldTests.cs
index 03c3c57..0734d3b 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/FieldTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/FieldTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class FieldTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForEachLoopTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForEachLoopTests.cs
index 6291b82..5db8866 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForEachLoopTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForEachLoopTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ForEachLoopTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForLoopTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForLoopTests.cs
index b2fa356..b5dea20 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForLoopTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ForLoopTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ForLoopTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/GlobalTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/GlobalTests.cs
index 4116fe2..bef6088 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/GlobalTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/GlobalTests.cs
@@ -1,6 +1,5 @@
namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class GlobalTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/IfTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/IfTests.cs
index a3a4ea8..d026181 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/IfTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/IfTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class IfTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InstanceOfTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InstanceOfTests.cs
index ccae01b..b0f4033 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InstanceOfTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InstanceOfTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class InstanceOfTests : RewriteTest
{
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterfaceDeclarationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterfaceDeclarationTests.cs
index fa960e8..3de40f6 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterfaceDeclarationTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterfaceDeclarationTests.cs
@@ -7,7 +7,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class InterfaceDeclarationTests : RewriteTest
{
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterpolatedStringTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterpolatedStringTests.cs
index 7b8f579..db92705 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterpolatedStringTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/InterpolatedStringTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class InterpolatedStringTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LabelTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LabelTests.cs
index 103bf5c..2343061 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LabelTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LabelTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class LabelTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs
index c617885..225cbd0 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LambdaTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class LambdaTests : RewriteTest
{
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LiteralTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LiteralTests.cs
index 6cf668e..c627d24 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LiteralTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/LiteralTests.cs
@@ -7,7 +7,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class LiteralTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs
index 0477441..11724b7 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MemberAccessTests.cs
@@ -6,7 +6,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class MemberAccessTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodDeclarationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodDeclarationTests.cs
index f600c34..c4df359 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodDeclarationTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodDeclarationTests.cs
@@ -7,7 +7,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class MethodDeclarationTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs
index ccebd64..0a1d87c 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/MethodInvocationTests.cs
@@ -6,7 +6,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class MethodInvocationTests : RewriteTest
{
[Fact]
@@ -42,16 +41,59 @@ public class T
[Fact]
public void InvocationWithNamedParameters()
{
- RewriteRun(
- CSharp(
- @"
+ var src = CSharp(
+ @"
public class T
{
- string s = this.Equals(obj: null);
+ void M()
+ {
+ string s = this.Equals(obj: null, 1);
+ }
}
"
- )
);
+
+ var lst = src.Parse();
+ lst.ToString().ShouldBeSameAs(src.Before);
+ }
+
+ [Fact]
+ public void InvocationWithOutParameter()
+ {
+ var src = CSharp(
+ """
+ public class T
+ {
+ void M()
+ {
+ int.TryParse("1", out var one);
+ }
+ }
+ """
+ );
+
+ var lst = src.Parse();
+ lst.ToString().ShouldBeSameAs(src.Before);
+ }
+
+ [Fact]
+ public void InvocationWithRefParameter()
+ {
+ var src = CSharp(
+ """
+ public class T
+ {
+ void M()
+ {
+ int.TryParse("1", ref one);
+ }
+ }
+ """
+ );
+
+ var lst = src.Parse();
+ var statement = lst.Descendents().OfType().First();
+ lst.ToString().ShouldBeSameAs(src.Before);
}
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NamespaceDeclarationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NamespaceDeclarationTests.cs
index 98b4ab0..26a1e72 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NamespaceDeclarationTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NamespaceDeclarationTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class NamespaceDeclarationTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NewClassTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NewClassTests.cs
index cff7336..dc3f037 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NewClassTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NewClassTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class NewClassTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullSafeExpressionTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullSafeExpressionTests.cs
index 7e6b395..ec8ac6d 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullSafeExpressionTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullSafeExpressionTests.cs
@@ -7,7 +7,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class NullSafeExpressionTests : RewriteTest
{
[Fact]
@@ -84,8 +83,6 @@ public object M()
}
}
""");
- var lst = src.Parse().First();
-
}
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullableTypeTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullableTypeTests.cs
index 74c655e..4086451 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullableTypeTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/NullableTypeTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class NullableTypeTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ParenthesesTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ParenthesesTests.cs
index 1b33bc8..9ed1fbe 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ParenthesesTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ParenthesesTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ParenthesesTests : RewriteTest
{
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/PropertyDeclarationTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/PropertyDeclarationTests.cs
index 4f77848..89802d3 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/PropertyDeclarationTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/PropertyDeclarationTests.cs
@@ -8,7 +8,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class PropertyDeclarationTests : RewriteTest
{
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ReturnTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ReturnTests.cs
index 1958ac4..9c19134 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ReturnTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ReturnTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ReturnTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SizeOfTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SizeOfTests.cs
index 0008dd9..eba478e 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SizeOfTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SizeOfTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class SizeOfTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/StructTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/StructTests.cs
index 936e1ab..27ede0d 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/StructTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/StructTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class StructTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SwitchStatementTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SwitchStatementTests.cs
index b6d783b..1465455 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SwitchStatementTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/SwitchStatementTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class SwitchStatementTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TernaryTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TernaryTests.cs
index a72fa9d..d8644d9 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TernaryTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TernaryTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class TernaryTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ThrowTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ThrowTests.cs
index f5632fe..fc0e81e 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ThrowTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/ThrowTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class ThrowTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TryTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TryTests.cs
index 919c995..daa6ff1 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TryTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TryTests.cs
@@ -7,7 +7,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class TryTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TupleTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TupleTests.cs
new file mode 100644
index 0000000..9c1deff
--- /dev/null
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TupleTests.cs
@@ -0,0 +1,49 @@
+using FluentAssertions;
+using Rewrite.Test.CSharp;
+using Rewrite.RewriteJava.Tree;
+using Rewrite.Test;
+
+namespace Rewrite.CSharp.Tests.Tree;
+
+using static Assertions;
+
+public class TupleTests : RewriteTest
+{
+ [Fact]
+ public void TupleDeconstruction()
+ {
+ var src = CSharp(
+ """
+ public class T
+ {
+ void M()
+ {
+ var (x, y) = (1,2);
+ }
+ }
+ """
+ );
+
+ var lst = src.Parse();
+ lst.ToString().ShouldBeSameAs(src.Before);
+ }
+ [Fact]
+ public void TupleExpression()
+ {
+ var src = CSharp(
+ """
+ public class T
+ {
+ void M()
+ {
+ (var x, var y) = (1,2);
+ }
+ }
+ """
+ );
+
+ var lst = src.Parse();
+ var statement = lst.Descendents().OfType().First().Body!.Statements.First();
+ lst.ToString().ShouldBeSameAs(src.Before);
+ }
+}
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeCastTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeCastTests.cs
index 0b42184..3b2831b 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeCastTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeCastTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class TypeCastTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeOfTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeOfTests.cs
index f84ac7c..8d548b2 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeOfTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/TypeOfTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class TypeOfTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UnaryTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UnaryTests.cs
index 775bf74..e98319a 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UnaryTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UnaryTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class UnaryTests : RewriteTest
{
[Fact]
@@ -45,4 +44,18 @@ class Test {
)
);
}
+
+ [Fact]
+ void NullWarningSuppress()
+ {
+ RewriteRun(
+ CSharp(
+ """
+ class Test {
+ string a = ""!;
+ }
+ """
+ )
+ );
+ }
}
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingDirectiveTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingDirectiveTests.cs
index d494ea6..932a763 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingDirectiveTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingDirectiveTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class UsingDirectiveTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingTests.cs
index 690fbc5..a3ec1b0 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/UsingTests.cs
@@ -7,7 +7,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class UsingTests(ITestOutputHelper output) : RewriteTest
{
private readonly ITestOutputHelper _output = output;
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/VariableDeclarationsTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/VariableDeclarationsTests.cs
index 737c6d1..82b0948 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/VariableDeclarationsTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/VariableDeclarationsTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class VariableDeclarationsTests : RewriteTest
{
[Fact]
diff --git a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/WhileLoopTests.cs b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/WhileLoopTests.cs
index 8e6d354..82147c0 100644
--- a/Rewrite/tests/Rewrite.CSharp.Tests/Tree/WhileLoopTests.cs
+++ b/Rewrite/tests/Rewrite.CSharp.Tests/Tree/WhileLoopTests.cs
@@ -5,7 +5,6 @@ namespace Rewrite.CSharp.Tests.Tree;
using static Assertions;
-[Collection(Collections.PrinterAccess)]
public class WhileLoopTests : RewriteTest
{
[Fact]
diff --git a/build.gradle.kts b/build.gradle.kts
index e840e7c..90cfa41 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -6,7 +6,4 @@ plugins {
allprojects {
group = "org.openrewrite"
description = "OpenRewrite C# language module."
- repositories {
- mavenCentral()
- }
}
diff --git a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java
index 2bd6038..b253c00 100644
--- a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java
+++ b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpReceiver.java
@@ -92,13 +92,14 @@ public Cs.CompilationUnit visitCompilationUnit(Cs.CompilationUnit compilationUni
}
@Override
- public Cs.NamedArgument visitNamedArgument(Cs.NamedArgument namedArgument, ReceiverContext ctx) {
- namedArgument = namedArgument.withId(ctx.receiveNonNullValue(namedArgument.getId(), UUID.class));
- namedArgument = namedArgument.withPrefix(ctx.receiveNonNullNode(namedArgument.getPrefix(), CSharpReceiver::receiveSpace));
- namedArgument = namedArgument.withMarkers(ctx.receiveNonNullNode(namedArgument.getMarkers(), ctx::receiveMarkers));
- namedArgument = namedArgument.getPadding().withNameColumn(ctx.receiveNode(namedArgument.getPadding().getNameColumn(), CSharpReceiver::receiveRightPaddedTree));
- namedArgument = namedArgument.withExpression(ctx.receiveNonNullNode(namedArgument.getExpression(), ctx::receiveTree));
- return namedArgument;
+ public Cs.Argument visitArgument(Cs.Argument argument, ReceiverContext ctx) {
+ argument = argument.withId(ctx.receiveNonNullValue(argument.getId(), UUID.class));
+ argument = argument.withPrefix(ctx.receiveNonNullNode(argument.getPrefix(), CSharpReceiver::receiveSpace));
+ argument = argument.withMarkers(ctx.receiveNonNullNode(argument.getMarkers(), ctx::receiveMarkers));
+ argument = argument.getPadding().withNameColumn(ctx.receiveNode(argument.getPadding().getNameColumn(), CSharpReceiver::receiveRightPaddedTree));
+ argument = argument.withRefKindKeyword(ctx.receiveNode(argument.getRefKindKeyword(), ctx::receiveTree));
+ argument = argument.withExpression(ctx.receiveNonNullNode(argument.getExpression(), ctx::receiveTree));
+ return argument;
}
@Override
@@ -285,6 +286,15 @@ public Cs.PropertyDeclaration visitPropertyDeclaration(Cs.PropertyDeclaration pr
return propertyDeclaration;
}
+ @Override
+ public Cs.Keyword visitKeyword(Cs.Keyword keyword, ReceiverContext ctx) {
+ keyword = keyword.withId(ctx.receiveNonNullValue(keyword.getId(), UUID.class));
+ keyword = keyword.withPrefix(ctx.receiveNonNullNode(keyword.getPrefix(), CSharpReceiver::receiveSpace));
+ keyword = keyword.withMarkers(ctx.receiveNonNullNode(keyword.getMarkers(), ctx::receiveMarkers));
+ keyword = keyword.withKind(ctx.receiveNonNullValue(keyword.getKind(), Cs.KeywordKind.class));
+ return keyword;
+ }
+
@Override
public Cs.Lambda visitLambda(Cs.Lambda lambda, ReceiverContext ctx) {
lambda = lambda.withId(ctx.receiveNonNullValue(lambda.getId(), UUID.class));
@@ -320,7 +330,7 @@ public Cs.UsingStatement visitUsingStatement(Cs.UsingStatement usingStatement, R
usingStatement = usingStatement.withId(ctx.receiveNonNullValue(usingStatement.getId(), UUID.class));
usingStatement = usingStatement.withPrefix(ctx.receiveNonNullNode(usingStatement.getPrefix(), CSharpReceiver::receiveSpace));
usingStatement = usingStatement.withMarkers(ctx.receiveNonNullNode(usingStatement.getMarkers(), ctx::receiveMarkers));
- usingStatement = usingStatement.withAwaitKeyword(ctx.receiveNode(usingStatement.getAwaitKeyword(), CSharpReceiver::receiveSpace));
+ usingStatement = usingStatement.withAwaitKeyword(ctx.receiveNode(usingStatement.getAwaitKeyword(), ctx::receiveTree));
usingStatement = usingStatement.getPadding().withExpression(ctx.receiveNonNullNode(usingStatement.getPadding().getExpression(), CSharpReceiver::receiveContainer));
usingStatement = usingStatement.withStatement(ctx.receiveNonNullNode(usingStatement.getStatement(), ctx::receiveTree));
return usingStatement;
@@ -387,6 +397,84 @@ public Cs.DefaultConstraint visitDefaultConstraint(Cs.DefaultConstraint defaultC
return defaultConstraint;
}
+ @Override
+ public Cs.DeclarationExpression visitDeclarationExpression(Cs.DeclarationExpression declarationExpression, ReceiverContext ctx) {
+ declarationExpression = declarationExpression.withId(ctx.receiveNonNullValue(declarationExpression.getId(), UUID.class));
+ declarationExpression = declarationExpression.withPrefix(ctx.receiveNonNullNode(declarationExpression.getPrefix(), CSharpReceiver::receiveSpace));
+ declarationExpression = declarationExpression.withMarkers(ctx.receiveNonNullNode(declarationExpression.getMarkers(), ctx::receiveMarkers));
+ declarationExpression = declarationExpression.withTypeExpression(ctx.receiveNode(declarationExpression.getTypeExpression(), ctx::receiveTree));
+ declarationExpression = declarationExpression.withVariables(ctx.receiveNonNullNode(declarationExpression.getVariables(), ctx::receiveTree));
+ return declarationExpression;
+ }
+
+ @Override
+ public Cs.SingleVariableDesignation visitSingleVariableDesignation(Cs.SingleVariableDesignation singleVariableDesignation, ReceiverContext ctx) {
+ singleVariableDesignation = singleVariableDesignation.withId(ctx.receiveNonNullValue(singleVariableDesignation.getId(), UUID.class));
+ singleVariableDesignation = singleVariableDesignation.withPrefix(ctx.receiveNonNullNode(singleVariableDesignation.getPrefix(), CSharpReceiver::receiveSpace));
+ singleVariableDesignation = singleVariableDesignation.withMarkers(ctx.receiveNonNullNode(singleVariableDesignation.getMarkers(), ctx::receiveMarkers));
+ singleVariableDesignation = singleVariableDesignation.withName(ctx.receiveNonNullNode(singleVariableDesignation.getName(), ctx::receiveTree));
+ return singleVariableDesignation;
+ }
+
+ @Override
+ public Cs.ParenthesizedVariableDesignation visitParenthesizedVariableDesignation(Cs.ParenthesizedVariableDesignation parenthesizedVariableDesignation, ReceiverContext ctx) {
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.withId(ctx.receiveNonNullValue(parenthesizedVariableDesignation.getId(), UUID.class));
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.withPrefix(ctx.receiveNonNullNode(parenthesizedVariableDesignation.getPrefix(), CSharpReceiver::receiveSpace));
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.withMarkers(ctx.receiveNonNullNode(parenthesizedVariableDesignation.getMarkers(), ctx::receiveMarkers));
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.getPadding().withVariables(ctx.receiveNonNullNode(parenthesizedVariableDesignation.getPadding().getVariables(), CSharpReceiver::receiveContainer));
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.withType(ctx.receiveValue(parenthesizedVariableDesignation.getType(), JavaType.class));
+ return parenthesizedVariableDesignation;
+ }
+
+ @Override
+ public Cs.DiscardVariableDesignation visitDiscardVariableDesignation(Cs.DiscardVariableDesignation discardVariableDesignation, ReceiverContext ctx) {
+ discardVariableDesignation = discardVariableDesignation.withId(ctx.receiveNonNullValue(discardVariableDesignation.getId(), UUID.class));
+ discardVariableDesignation = discardVariableDesignation.withPrefix(ctx.receiveNonNullNode(discardVariableDesignation.getPrefix(), CSharpReceiver::receiveSpace));
+ discardVariableDesignation = discardVariableDesignation.withMarkers(ctx.receiveNonNullNode(discardVariableDesignation.getMarkers(), ctx::receiveMarkers));
+ discardVariableDesignation = discardVariableDesignation.withDiscard(ctx.receiveNonNullNode(discardVariableDesignation.getDiscard(), ctx::receiveTree));
+ return discardVariableDesignation;
+ }
+
+ @Override
+ public Cs.TupleExpression visitTupleExpression(Cs.TupleExpression tupleExpression, ReceiverContext ctx) {
+ tupleExpression = tupleExpression.withId(ctx.receiveNonNullValue(tupleExpression.getId(), UUID.class));
+ tupleExpression = tupleExpression.withPrefix(ctx.receiveNonNullNode(tupleExpression.getPrefix(), CSharpReceiver::receiveSpace));
+ tupleExpression = tupleExpression.withMarkers(ctx.receiveNonNullNode(tupleExpression.getMarkers(), ctx::receiveMarkers));
+ tupleExpression = tupleExpression.getPadding().withArguments(ctx.receiveNonNullNode(tupleExpression.getPadding().getArguments(), CSharpReceiver::receiveContainer));
+ return tupleExpression;
+ }
+
+ @Override
+ public Cs.Constructor visitConstructor(Cs.Constructor constructor, ReceiverContext ctx) {
+ constructor = constructor.withId(ctx.receiveNonNullValue(constructor.getId(), UUID.class));
+ constructor = constructor.withPrefix(ctx.receiveNonNullNode(constructor.getPrefix(), CSharpReceiver::receiveSpace));
+ constructor = constructor.withMarkers(ctx.receiveNonNullNode(constructor.getMarkers(), ctx::receiveMarkers));
+ constructor = constructor.withInitializer(ctx.receiveNode(constructor.getInitializer(), ctx::receiveTree));
+ constructor = constructor.withConstructorCore(ctx.receiveNonNullNode(constructor.getConstructorCore(), ctx::receiveTree));
+ return constructor;
+ }
+
+ @Override
+ public Cs.Unary visitUnary(Cs.Unary unary, ReceiverContext ctx) {
+ unary = unary.withId(ctx.receiveNonNullValue(unary.getId(), UUID.class));
+ unary = unary.withPrefix(ctx.receiveNonNullNode(unary.getPrefix(), CSharpReceiver::receiveSpace));
+ unary = unary.withMarkers(ctx.receiveNonNullNode(unary.getMarkers(), ctx::receiveMarkers));
+ unary = unary.getPadding().withOperator(ctx.receiveNonNullNode(unary.getPadding().getOperator(), leftPaddedValueReceiver(org.openrewrite.csharp.tree.Cs.Unary.Type.class)));
+ unary = unary.withExpression(ctx.receiveNonNullNode(unary.getExpression(), ctx::receiveTree));
+ unary = unary.withType(ctx.receiveValue(unary.getType(), JavaType.class));
+ return unary;
+ }
+
+ @Override
+ public Cs.ConstructorInitializer visitConstructorInitializer(Cs.ConstructorInitializer constructorInitializer, ReceiverContext ctx) {
+ constructorInitializer = constructorInitializer.withId(ctx.receiveNonNullValue(constructorInitializer.getId(), UUID.class));
+ constructorInitializer = constructorInitializer.withPrefix(ctx.receiveNonNullNode(constructorInitializer.getPrefix(), CSharpReceiver::receiveSpace));
+ constructorInitializer = constructorInitializer.withMarkers(ctx.receiveNonNullNode(constructorInitializer.getMarkers(), ctx::receiveMarkers));
+ constructorInitializer = constructorInitializer.withKeyword(ctx.receiveNonNullNode(constructorInitializer.getKeyword(), ctx::receiveTree));
+ constructorInitializer = constructorInitializer.getPadding().withArguments(ctx.receiveNonNullNode(constructorInitializer.getPadding().getArguments(), CSharpReceiver::receiveContainer));
+ return constructorInitializer;
+ }
+
@Override
public J.AnnotatedType visitAnnotatedType(J.AnnotatedType annotatedType, ReceiverContext ctx) {
annotatedType = annotatedType.withId(ctx.receiveNonNullValue(annotatedType.getId(), UUID.class));
@@ -1105,12 +1193,13 @@ public T create(Class type, ReceiverContext ctx) {
);
}
- if (type == Cs.NamedArgument.class) {
- return (T) new Cs.NamedArgument(
+ if (type == Cs.Argument.class) {
+ return (T) new Cs.Argument(
ctx.receiveNonNullValue(null, UUID.class),
ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
ctx.receiveNonNullNode(null, ctx::receiveMarkers),
ctx.receiveNode(null, CSharpReceiver::receiveRightPaddedTree),
+ ctx.receiveNode(null, ctx::receiveTree),
ctx.receiveNonNullNode(null, ctx::receiveTree)
);
}
@@ -1299,6 +1388,15 @@ public T create(Class type, ReceiverContext ctx) {
);
}
+ if (type == Cs.Keyword.class) {
+ return (T) new Cs.Keyword(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNonNullValue(null, Cs.KeywordKind.class)
+ );
+ }
+
if (type == Cs.Lambda.class) {
return (T) new Cs.Lambda(
ctx.receiveNonNullValue(null, UUID.class),
@@ -1334,7 +1432,7 @@ public T create(Class type, ReceiverContext ctx) {
ctx.receiveNonNullValue(null, UUID.class),
ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
ctx.receiveNonNullNode(null, ctx::receiveMarkers),
- ctx.receiveNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNode(null, ctx::receiveTree),
ctx.receiveNonNullNode(null, CSharpReceiver::receiveContainer),
ctx.receiveNonNullNode(null, ctx::receiveTree)
);
@@ -1401,6 +1499,84 @@ public T create(Class type, ReceiverContext ctx) {
);
}
+ if (type == Cs.DeclarationExpression.class) {
+ return (T) new Cs.DeclarationExpression(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNode(null, ctx::receiveTree),
+ ctx.receiveNonNullNode(null, ctx::receiveTree)
+ );
+ }
+
+ if (type == Cs.SingleVariableDesignation.class) {
+ return (T) new Cs.SingleVariableDesignation(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNonNullNode(null, ctx::receiveTree)
+ );
+ }
+
+ if (type == Cs.ParenthesizedVariableDesignation.class) {
+ return (T) new Cs.ParenthesizedVariableDesignation(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveContainer),
+ ctx.receiveValue(null, JavaType.class)
+ );
+ }
+
+ if (type == Cs.DiscardVariableDesignation.class) {
+ return (T) new Cs.DiscardVariableDesignation(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNonNullNode(null, ctx::receiveTree)
+ );
+ }
+
+ if (type == Cs.TupleExpression.class) {
+ return (T) new Cs.TupleExpression(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveContainer)
+ );
+ }
+
+ if (type == Cs.Constructor.class) {
+ return (T) new Cs.Constructor(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNode(null, ctx::receiveTree),
+ ctx.receiveNonNullNode(null, ctx::receiveTree)
+ );
+ }
+
+ if (type == Cs.Unary.class) {
+ return (T) new Cs.Unary(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNonNullNode(null, leftPaddedValueReceiver(org.openrewrite.csharp.tree.Cs.Unary.Type.class)),
+ ctx.receiveNonNullNode(null, ctx::receiveTree),
+ ctx.receiveValue(null, JavaType.class)
+ );
+ }
+
+ if (type == Cs.ConstructorInitializer.class) {
+ return (T) new Cs.ConstructorInitializer(
+ ctx.receiveNonNullValue(null, UUID.class),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveSpace),
+ ctx.receiveNonNullNode(null, ctx::receiveMarkers),
+ ctx.receiveNonNullNode(null, ctx::receiveTree),
+ ctx.receiveNonNullNode(null, CSharpReceiver::receiveContainer)
+ );
+ }
+
if (type == J.AnnotatedType.class) {
return (T) new J.AnnotatedType(
ctx.receiveNonNullValue(null, UUID.class),
diff --git a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java
index 4ef4036..3f6cf81 100644
--- a/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java
+++ b/rewrite-csharp-remote/src/main/java/org/openrewrite/csharp/remote/CSharpSender.java
@@ -75,13 +75,14 @@ public Cs.CompilationUnit visitCompilationUnit(Cs.CompilationUnit compilationUni
}
@Override
- public Cs.NamedArgument visitNamedArgument(Cs.NamedArgument namedArgument, SenderContext ctx) {
- ctx.sendValue(namedArgument, Cs.NamedArgument::getId);
- ctx.sendNode(namedArgument, Cs.NamedArgument::getPrefix, CSharpSender::sendSpace);
- ctx.sendNode(namedArgument, Cs.NamedArgument::getMarkers, ctx::sendMarkers);
- ctx.sendNode(namedArgument, e -> e.getPadding().getNameColumn(), CSharpSender::sendRightPadded);
- ctx.sendNode(namedArgument, Cs.NamedArgument::getExpression, ctx::sendTree);
- return namedArgument;
+ public Cs.Argument visitArgument(Cs.Argument argument, SenderContext ctx) {
+ ctx.sendValue(argument, Cs.Argument::getId);
+ ctx.sendNode(argument, Cs.Argument::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(argument, Cs.Argument::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(argument, e -> e.getPadding().getNameColumn(), CSharpSender::sendRightPadded);
+ ctx.sendNode(argument, Cs.Argument::getRefKindKeyword, ctx::sendTree);
+ ctx.sendNode(argument, Cs.Argument::getExpression, ctx::sendTree);
+ return argument;
}
@Override
@@ -268,6 +269,15 @@ public Cs.PropertyDeclaration visitPropertyDeclaration(Cs.PropertyDeclaration pr
return propertyDeclaration;
}
+ @Override
+ public Cs.Keyword visitKeyword(Cs.Keyword keyword, SenderContext ctx) {
+ ctx.sendValue(keyword, Cs.Keyword::getId);
+ ctx.sendNode(keyword, Cs.Keyword::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(keyword, Cs.Keyword::getMarkers, ctx::sendMarkers);
+ ctx.sendValue(keyword, Cs.Keyword::getKind);
+ return keyword;
+ }
+
@Override
public Cs.Lambda visitLambda(Cs.Lambda lambda, SenderContext ctx) {
ctx.sendValue(lambda, Cs.Lambda::getId);
@@ -303,7 +313,7 @@ public Cs.UsingStatement visitUsingStatement(Cs.UsingStatement usingStatement, S
ctx.sendValue(usingStatement, Cs.UsingStatement::getId);
ctx.sendNode(usingStatement, Cs.UsingStatement::getPrefix, CSharpSender::sendSpace);
ctx.sendNode(usingStatement, Cs.UsingStatement::getMarkers, ctx::sendMarkers);
- ctx.sendNode(usingStatement, Cs.UsingStatement::getAwaitKeyword, CSharpSender::sendSpace);
+ ctx.sendNode(usingStatement, Cs.UsingStatement::getAwaitKeyword, ctx::sendTree);
ctx.sendNode(usingStatement, e -> e.getPadding().getExpression(), CSharpSender::sendContainer);
ctx.sendNode(usingStatement, Cs.UsingStatement::getStatement, ctx::sendTree);
return usingStatement;
@@ -370,6 +380,84 @@ public Cs.DefaultConstraint visitDefaultConstraint(Cs.DefaultConstraint defaultC
return defaultConstraint;
}
+ @Override
+ public Cs.DeclarationExpression visitDeclarationExpression(Cs.DeclarationExpression declarationExpression, SenderContext ctx) {
+ ctx.sendValue(declarationExpression, Cs.DeclarationExpression::getId);
+ ctx.sendNode(declarationExpression, Cs.DeclarationExpression::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(declarationExpression, Cs.DeclarationExpression::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(declarationExpression, Cs.DeclarationExpression::getTypeExpression, ctx::sendTree);
+ ctx.sendNode(declarationExpression, Cs.DeclarationExpression::getVariables, ctx::sendTree);
+ return declarationExpression;
+ }
+
+ @Override
+ public Cs.SingleVariableDesignation visitSingleVariableDesignation(Cs.SingleVariableDesignation singleVariableDesignation, SenderContext ctx) {
+ ctx.sendValue(singleVariableDesignation, Cs.SingleVariableDesignation::getId);
+ ctx.sendNode(singleVariableDesignation, Cs.SingleVariableDesignation::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(singleVariableDesignation, Cs.SingleVariableDesignation::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(singleVariableDesignation, Cs.SingleVariableDesignation::getName, ctx::sendTree);
+ return singleVariableDesignation;
+ }
+
+ @Override
+ public Cs.ParenthesizedVariableDesignation visitParenthesizedVariableDesignation(Cs.ParenthesizedVariableDesignation parenthesizedVariableDesignation, SenderContext ctx) {
+ ctx.sendValue(parenthesizedVariableDesignation, Cs.ParenthesizedVariableDesignation::getId);
+ ctx.sendNode(parenthesizedVariableDesignation, Cs.ParenthesizedVariableDesignation::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(parenthesizedVariableDesignation, Cs.ParenthesizedVariableDesignation::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(parenthesizedVariableDesignation, e -> e.getPadding().getVariables(), CSharpSender::sendContainer);
+ ctx.sendTypedValue(parenthesizedVariableDesignation, Cs.ParenthesizedVariableDesignation::getType);
+ return parenthesizedVariableDesignation;
+ }
+
+ @Override
+ public Cs.DiscardVariableDesignation visitDiscardVariableDesignation(Cs.DiscardVariableDesignation discardVariableDesignation, SenderContext ctx) {
+ ctx.sendValue(discardVariableDesignation, Cs.DiscardVariableDesignation::getId);
+ ctx.sendNode(discardVariableDesignation, Cs.DiscardVariableDesignation::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(discardVariableDesignation, Cs.DiscardVariableDesignation::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(discardVariableDesignation, Cs.DiscardVariableDesignation::getDiscard, ctx::sendTree);
+ return discardVariableDesignation;
+ }
+
+ @Override
+ public Cs.TupleExpression visitTupleExpression(Cs.TupleExpression tupleExpression, SenderContext ctx) {
+ ctx.sendValue(tupleExpression, Cs.TupleExpression::getId);
+ ctx.sendNode(tupleExpression, Cs.TupleExpression::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(tupleExpression, Cs.TupleExpression::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(tupleExpression, e -> e.getPadding().getArguments(), CSharpSender::sendContainer);
+ return tupleExpression;
+ }
+
+ @Override
+ public Cs.Constructor visitConstructor(Cs.Constructor constructor, SenderContext ctx) {
+ ctx.sendValue(constructor, Cs.Constructor::getId);
+ ctx.sendNode(constructor, Cs.Constructor::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(constructor, Cs.Constructor::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(constructor, Cs.Constructor::getInitializer, ctx::sendTree);
+ ctx.sendNode(constructor, Cs.Constructor::getConstructorCore, ctx::sendTree);
+ return constructor;
+ }
+
+ @Override
+ public Cs.Unary visitUnary(Cs.Unary unary, SenderContext ctx) {
+ ctx.sendValue(unary, Cs.Unary::getId);
+ ctx.sendNode(unary, Cs.Unary::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(unary, Cs.Unary::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(unary, e -> e.getPadding().getOperator(), CSharpSender::sendLeftPadded);
+ ctx.sendNode(unary, Cs.Unary::getExpression, ctx::sendTree);
+ ctx.sendTypedValue(unary, Cs.Unary::getType);
+ return unary;
+ }
+
+ @Override
+ public Cs.ConstructorInitializer visitConstructorInitializer(Cs.ConstructorInitializer constructorInitializer, SenderContext ctx) {
+ ctx.sendValue(constructorInitializer, Cs.ConstructorInitializer::getId);
+ ctx.sendNode(constructorInitializer, Cs.ConstructorInitializer::getPrefix, CSharpSender::sendSpace);
+ ctx.sendNode(constructorInitializer, Cs.ConstructorInitializer::getMarkers, ctx::sendMarkers);
+ ctx.sendNode(constructorInitializer, Cs.ConstructorInitializer::getKeyword, ctx::sendTree);
+ ctx.sendNode(constructorInitializer, e -> e.getPadding().getArguments(), CSharpSender::sendContainer);
+ return constructorInitializer;
+ }
+
@Override
public J.AnnotatedType visitAnnotatedType(J.AnnotatedType annotatedType, SenderContext ctx) {
ctx.sendValue(annotatedType, J.AnnotatedType::getId);
diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java
index 6fe19b6..0553d8d 100644
--- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java
+++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpIsoVisitor.java
@@ -41,8 +41,8 @@ public Cs.CompilationUnit visitCompilationUnit(Cs.CompilationUnit compilationUni
}
@Override
- public Cs.NamedArgument visitNamedArgument(Cs.NamedArgument namedArgument, P p) {
- return (Cs.NamedArgument) super.visitNamedArgument(namedArgument, p);
+ public Cs.Argument visitArgument(Cs.Argument argument, P p) {
+ return (Cs.Argument) super.visitArgument(argument, p);
}
@Override
@@ -130,6 +130,11 @@ public Cs.PropertyDeclaration visitPropertyDeclaration(Cs.PropertyDeclaration pr
return (Cs.PropertyDeclaration) super.visitPropertyDeclaration(propertyDeclaration, p);
}
+ @Override
+ public Cs.Keyword visitKeyword(Cs.Keyword keyword, P p) {
+ return (Cs.Keyword) super.visitKeyword(keyword, p);
+ }
+
@Override
public Cs.Lambda visitLambda(Cs.Lambda lambda, P p) {
return (Cs.Lambda) super.visitLambda(lambda, p);
@@ -185,6 +190,46 @@ public Cs.DefaultConstraint visitDefaultConstraint(Cs.DefaultConstraint defaultC
return (Cs.DefaultConstraint) super.visitDefaultConstraint(defaultConstraint, p);
}
+ @Override
+ public Cs.DeclarationExpression visitDeclarationExpression(Cs.DeclarationExpression declarationExpression, P p) {
+ return (Cs.DeclarationExpression) super.visitDeclarationExpression(declarationExpression, p);
+ }
+
+ @Override
+ public Cs.SingleVariableDesignation visitSingleVariableDesignation(Cs.SingleVariableDesignation singleVariableDesignation, P p) {
+ return (Cs.SingleVariableDesignation) super.visitSingleVariableDesignation(singleVariableDesignation, p);
+ }
+
+ @Override
+ public Cs.ParenthesizedVariableDesignation visitParenthesizedVariableDesignation(Cs.ParenthesizedVariableDesignation parenthesizedVariableDesignation, P p) {
+ return (Cs.ParenthesizedVariableDesignation) super.visitParenthesizedVariableDesignation(parenthesizedVariableDesignation, p);
+ }
+
+ @Override
+ public Cs.DiscardVariableDesignation visitDiscardVariableDesignation(Cs.DiscardVariableDesignation discardVariableDesignation, P p) {
+ return (Cs.DiscardVariableDesignation) super.visitDiscardVariableDesignation(discardVariableDesignation, p);
+ }
+
+ @Override
+ public Cs.TupleExpression visitTupleExpression(Cs.TupleExpression tupleExpression, P p) {
+ return (Cs.TupleExpression) super.visitTupleExpression(tupleExpression, p);
+ }
+
+ @Override
+ public Cs.Constructor visitConstructor(Cs.Constructor constructor, P p) {
+ return (Cs.Constructor) super.visitConstructor(constructor, p);
+ }
+
+ @Override
+ public Cs.Unary visitUnary(Cs.Unary unary, P p) {
+ return (Cs.Unary) super.visitUnary(unary, p);
+ }
+
+ @Override
+ public Cs.ConstructorInitializer visitConstructorInitializer(Cs.ConstructorInitializer constructorInitializer, P p) {
+ return (Cs.ConstructorInitializer) super.visitConstructorInitializer(constructorInitializer, p);
+ }
+
@Override
public J.AnnotatedType visitAnnotatedType(J.AnnotatedType annotatedType, P p) {
return (J.AnnotatedType) super.visitAnnotatedType(annotatedType, p);
diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java
index 86c293b..860212b 100644
--- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java
+++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpPrinter.java
@@ -47,15 +47,30 @@ public J visit(@Nullable Tree tree, PrintOutputCapture p) {
}
@Override
- public J visitNamedArgument(Cs.NamedArgument namedArgument, PrintOutputCapture
p) {
- beforeSyntax(namedArgument, CsSpace.Location.NAMED_ARGUMENT_PREFIX, p);
- Cs.NamedArgument.Padding padding = namedArgument.getPadding();
+ public J visitArgument(Cs.Argument argument, PrintOutputCapture
p) {
+ beforeSyntax(argument, CsSpace.Location.NAMED_ARGUMENT_PREFIX, p);
+ Cs.Argument.Padding padding = argument.getPadding();
- visitRightPadded(padding.getNameColumn(), CsRightPadded.Location.NAMED_ARGUMENT_NAME_COLUMN, p);
- p.append(':');
- visit(namedArgument.getExpression(), p);
- afterSyntax(namedArgument, p);
- return namedArgument;
+ if (argument.getNameColumn() != null) {
+ visitRightPadded(padding.getNameColumn(), CsRightPadded.Location.NAMED_ARGUMENT_NAME_COLUMN, p);
+ p.append(':');
+ }
+ if (argument.getRefKindKeyword() != null)
+ {
+ visitKeyword(argument.getRefKindKeyword(), p);
+ }
+ visit(argument.getExpression(), p);
+ afterSyntax(argument, p);
+ return argument;
+ }
+
+ @Override
+ public Cs visitKeyword(Cs.Keyword keyword, PrintOutputCapture
p)
+ {
+ beforeSyntax(keyword, CsSpace.Location.KEYWORD_PREFIX, p);
+ p.append(keyword.getKind().toString().toLowerCase());
+ afterSyntax(keyword, p);
+ return keyword;
}
@Override
@@ -65,7 +80,7 @@ public J visitUsingStatement(Cs.UsingStatement usingStatement, PrintOutputCaptur
p.append("using");
if (usingStatement.getAwaitKeyword() != null)
{
- visitSpace(usingStatement.getAwaitKeyword(), CsSpace.Location.USING_STATEMENT_AWAIT_KEYWORD, p);
+ visitKeyword(usingStatement.getAwaitKeyword(), p);
}
visitContainer("(", usingStatement.getPadding().getExpression(), CsContainer.Location.USING_STATEMENT_EXPRESSION, "", ")", p);
@@ -73,6 +88,24 @@ public J visitUsingStatement(Cs.UsingStatement usingStatement, PrintOutputCaptur
afterSyntax(usingStatement, p);
return usingStatement;
}
+
+ @Override
+ public Cs visitUnary(Cs.Unary unary, PrintOutputCapture
p)
+ {
+ beforeSyntax(unary, Space.Location.UNARY_PREFIX, p);
+ switch (unary.getOperator())
+ {
+ default:
+ case SuppressNullableWarning:
+ visit(unary.getExpression(), p);
+ p.append("!");
+ break;
+ }
+
+ afterSyntax(unary, p);
+ return unary;
+ }
+
@Override
public Cs visitCompilationUnit(Cs.CompilationUnit compilationUnit, PrintOutputCapture
p) {
beforeSyntax(compilationUnit, Space.Location.COMPILATION_UNIT_PREFIX, p);
@@ -286,6 +319,44 @@ public J visitNullSafeExpression(Cs.NullSafeExpression nullSafeExpression, Print
return nullSafeExpression;
}
+ @Override
+ public Cs visitConstructor(Cs.Constructor constructor, PrintOutputCapture
p)
+ {
+ J.MethodDeclaration method = constructor.getConstructorCore();
+ beforeSyntax(method, Space.Location.METHOD_DECLARATION_PREFIX, p);
+ visitSpace(Space.EMPTY, Space.Location.ANNOTATIONS, p);
+ visit(method.getLeadingAnnotations(), p);
+ for (J.Modifier modifier : method.getModifiers())
+ {
+ delegate.visitModifier(modifier, p);
+ }
+
+ visit(method.getAnnotations().getName().getAnnotations(), p);
+ visit(method.getName(), p);
+
+
+ if (!method.getMarkers().findFirst(CompactConstructor.class).isPresent()) {
+ visitContainer("(", method.getPadding().getParameters(), CsContainer.Location.METHOD_DECLARATION_PARAMETERS, ",", ")", p);
+ }
+
+ visit(constructor.getInitializer(), p);
+
+ visit(method.getBody(), p);
+ afterSyntax(constructor, p);
+ return constructor;
+ }
+
+ @Override
+ public Cs visitConstructorInitializer(Cs.ConstructorInitializer node, PrintOutputCapture
p)
+ {
+ beforeSyntax(node, Space.Location.METHOD_DECLARATION_PREFIX, p);
+ p.append(":");
+ visitKeyword(node.getKeyword(), p);
+ visitContainer("(", node.getPadding().getArguments(), CsContainer.Location.CONSTRUCTOR_INITIALIZER_ARGUMENTS, ",", ")", p);
+ afterSyntax(node, p);
+ return node;
+ }
+
@Override
public J visitPropertyDeclaration(Cs.PropertyDeclaration propertyDeclaration,
PrintOutputCapture
p) {
@@ -475,6 +546,19 @@ public J visit(@Nullable Tree tree, PrintOutputCapture
p) {
}
}
+ @Override
+ public Cs visitNewArray(J.NewArray newArray, PrintOutputCapture
p)
+ {
+ beforeSyntax(newArray, Space.Location.NEW_ARRAY_PREFIX, p);
+ p.append("new");
+
+ visit(newArray.getTypeExpression(), p);
+ visit(newArray.getDimensions(), p);
+ visitContainer("{", newArray.getPadding().getInitializer(), JContainer.Location.NEW_ARRAY_INITIALIZER, ",", "}", p);
+ afterSyntax(newArray, p);
+ return newArray;
+ }
+
@Override
public J visitClassDeclaration(J.ClassDeclaration classDecl, PrintOutputCapture
p) {
J csParent = CSharpPrinter.this.getCursor().getValue();
diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java
index a1f743b..623e439 100644
--- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java
+++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/CSharpVisitor.java
@@ -51,18 +51,19 @@ public J visitCompilationUnit(Cs.CompilationUnit compilationUnit, P p) {
return compilationUnit;
}
- public J visitNamedArgument(Cs.NamedArgument namedArgument, P p) {
- namedArgument = namedArgument.withPrefix(visitSpace(namedArgument.getPrefix(), CsSpace.Location.NAMED_ARGUMENT_PREFIX, p));
- Expression tempExpression = (Expression) visitExpression(namedArgument, p);
- if (!(tempExpression instanceof Cs.NamedArgument))
+ public J visitArgument(Cs.Argument argument, P p) {
+ argument = argument.withPrefix(visitSpace(argument.getPrefix(), CsSpace.Location.ARGUMENT_PREFIX, p));
+ Expression tempExpression = (Expression) visitExpression(argument, p);
+ if (!(tempExpression instanceof Cs.Argument))
{
return tempExpression;
}
- namedArgument = (Cs.NamedArgument) tempExpression;
- namedArgument = namedArgument.withMarkers(visitMarkers(namedArgument.getMarkers(), p));
- namedArgument = namedArgument.getPadding().withNameColumn(visitRightPadded(namedArgument.getPadding().getNameColumn(), CsRightPadded.Location.NAMED_ARGUMENT_NAME_COLUMN, p));
- namedArgument = namedArgument.withExpression(visitAndCast(namedArgument.getExpression(), p));
- return namedArgument;
+ argument = (Cs.Argument) tempExpression;
+ argument = argument.withMarkers(visitMarkers(argument.getMarkers(), p));
+ argument = argument.getPadding().withNameColumn(visitRightPadded(argument.getPadding().getNameColumn(), CsRightPadded.Location.ARGUMENT_NAME_COLUMN, p));
+ argument = argument.withRefKindKeyword(visitAndCast(argument.getRefKindKeyword(), p));
+ argument = argument.withExpression(visitAndCast(argument.getExpression(), p));
+ return argument;
}
public J visitAnnotatedStatement(Cs.AnnotatedStatement annotatedStatement, P p) {
@@ -311,6 +312,12 @@ public J visitPropertyDeclaration(Cs.PropertyDeclaration propertyDeclaration, P
return propertyDeclaration;
}
+ public J visitKeyword(Cs.Keyword keyword, P p) {
+ keyword = keyword.withPrefix(visitSpace(keyword.getPrefix(), CsSpace.Location.KEYWORD_PREFIX, p));
+ keyword = keyword.withMarkers(visitMarkers(keyword.getMarkers(), p));
+ return keyword;
+ }
+
public J visitLambda(Cs.Lambda lambda, P p) {
lambda = lambda.withPrefix(visitSpace(lambda.getPrefix(), CsSpace.Location.LAMBDA_PREFIX, p));
Statement tempStatement = (Statement) visitStatement(lambda, p);
@@ -368,7 +375,7 @@ public J visitUsingStatement(Cs.UsingStatement usingStatement, P p) {
}
usingStatement = (Cs.UsingStatement) tempStatement;
usingStatement = usingStatement.withMarkers(visitMarkers(usingStatement.getMarkers(), p));
- usingStatement = usingStatement.withAwaitKeyword(visitSpace(usingStatement.getAwaitKeyword(), CsSpace.Location.USING_STATEMENT_AWAIT_KEYWORD, p));
+ usingStatement = usingStatement.withAwaitKeyword(visitAndCast(usingStatement.getAwaitKeyword(), p));
usingStatement = usingStatement.getPadding().withExpression(visitContainer(usingStatement.getPadding().getExpression(), CsContainer.Location.USING_STATEMENT_EXPRESSION, p));
usingStatement = usingStatement.withStatement(visitAndCast(usingStatement.getStatement(), p));
return usingStatement;
@@ -420,6 +427,114 @@ public J visitDefaultConstraint(Cs.DefaultConstraint defaultConstraint, P p) {
return defaultConstraint;
}
+ public J visitDeclarationExpression(Cs.DeclarationExpression declarationExpression, P p) {
+ declarationExpression = declarationExpression.withPrefix(visitSpace(declarationExpression.getPrefix(), CsSpace.Location.DECLARATION_EXPRESSION_PREFIX, p));
+ Expression tempExpression = (Expression) visitExpression(declarationExpression, p);
+ if (!(tempExpression instanceof Cs.DeclarationExpression))
+ {
+ return tempExpression;
+ }
+ declarationExpression = (Cs.DeclarationExpression) tempExpression;
+ declarationExpression = declarationExpression.withMarkers(visitMarkers(declarationExpression.getMarkers(), p));
+ declarationExpression = declarationExpression.withTypeExpression(visitAndCast(declarationExpression.getTypeExpression(), p));
+ declarationExpression = declarationExpression.withVariables(visitAndCast(declarationExpression.getVariables(), p));
+ return declarationExpression;
+ }
+
+ public J visitSingleVariableDesignation(Cs.SingleVariableDesignation singleVariableDesignation, P p) {
+ singleVariableDesignation = singleVariableDesignation.withPrefix(visitSpace(singleVariableDesignation.getPrefix(), CsSpace.Location.SINGLE_VARIABLE_DESIGNATION_PREFIX, p));
+ Expression tempExpression = (Expression) visitExpression(singleVariableDesignation, p);
+ if (!(tempExpression instanceof Cs.SingleVariableDesignation))
+ {
+ return tempExpression;
+ }
+ singleVariableDesignation = (Cs.SingleVariableDesignation) tempExpression;
+ singleVariableDesignation = singleVariableDesignation.withMarkers(visitMarkers(singleVariableDesignation.getMarkers(), p));
+ singleVariableDesignation = singleVariableDesignation.withName(visitAndCast(singleVariableDesignation.getName(), p));
+ return singleVariableDesignation;
+ }
+
+ public J visitParenthesizedVariableDesignation(Cs.ParenthesizedVariableDesignation parenthesizedVariableDesignation, P p) {
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.withPrefix(visitSpace(parenthesizedVariableDesignation.getPrefix(), CsSpace.Location.PARENTHESIZED_VARIABLE_DESIGNATION_PREFIX, p));
+ Expression tempExpression = (Expression) visitExpression(parenthesizedVariableDesignation, p);
+ if (!(tempExpression instanceof Cs.ParenthesizedVariableDesignation))
+ {
+ return tempExpression;
+ }
+ parenthesizedVariableDesignation = (Cs.ParenthesizedVariableDesignation) tempExpression;
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.withMarkers(visitMarkers(parenthesizedVariableDesignation.getMarkers(), p));
+ parenthesizedVariableDesignation = parenthesizedVariableDesignation.getPadding().withVariables(visitContainer(parenthesizedVariableDesignation.getPadding().getVariables(), CsContainer.Location.PARENTHESIZED_VARIABLE_DESIGNATION_VARIABLES, p));
+ return parenthesizedVariableDesignation;
+ }
+
+ public J visitDiscardVariableDesignation(Cs.DiscardVariableDesignation discardVariableDesignation, P p) {
+ discardVariableDesignation = discardVariableDesignation.withPrefix(visitSpace(discardVariableDesignation.getPrefix(), CsSpace.Location.DISCARD_VARIABLE_DESIGNATION_PREFIX, p));
+ Expression tempExpression = (Expression) visitExpression(discardVariableDesignation, p);
+ if (!(tempExpression instanceof Cs.DiscardVariableDesignation))
+ {
+ return tempExpression;
+ }
+ discardVariableDesignation = (Cs.DiscardVariableDesignation) tempExpression;
+ discardVariableDesignation = discardVariableDesignation.withMarkers(visitMarkers(discardVariableDesignation.getMarkers(), p));
+ discardVariableDesignation = discardVariableDesignation.withDiscard(visitAndCast(discardVariableDesignation.getDiscard(), p));
+ return discardVariableDesignation;
+ }
+
+ public J visitTupleExpression(Cs.TupleExpression tupleExpression, P p) {
+ tupleExpression = tupleExpression.withPrefix(visitSpace(tupleExpression.getPrefix(), CsSpace.Location.TUPLE_EXPRESSION_PREFIX, p));
+ Expression tempExpression = (Expression) visitExpression(tupleExpression, p);
+ if (!(tempExpression instanceof Cs.TupleExpression))
+ {
+ return tempExpression;
+ }
+ tupleExpression = (Cs.TupleExpression) tempExpression;
+ tupleExpression = tupleExpression.withMarkers(visitMarkers(tupleExpression.getMarkers(), p));
+ tupleExpression = tupleExpression.getPadding().withArguments(visitContainer(tupleExpression.getPadding().getArguments(), CsContainer.Location.TUPLE_EXPRESSION_ARGUMENTS, p));
+ return tupleExpression;
+ }
+
+ public J visitConstructor(Cs.Constructor constructor, P p) {
+ constructor = constructor.withPrefix(visitSpace(constructor.getPrefix(), CsSpace.Location.CONSTRUCTOR_PREFIX, p));
+ Statement tempStatement = (Statement) visitStatement(constructor, p);
+ if (!(tempStatement instanceof Cs.Constructor))
+ {
+ return tempStatement;
+ }
+ constructor = (Cs.Constructor) tempStatement;
+ constructor = constructor.withMarkers(visitMarkers(constructor.getMarkers(), p));
+ constructor = constructor.withInitializer(visitAndCast(constructor.getInitializer(), p));
+ constructor = constructor.withConstructorCore(visitAndCast(constructor.getConstructorCore(), p));
+ return constructor;
+ }
+
+ public J visitUnary(Cs.Unary unary, P p) {
+ unary = unary.withPrefix(visitSpace(unary.getPrefix(), CsSpace.Location.UNARY_PREFIX, p));
+ Statement tempStatement = (Statement) visitStatement(unary, p);
+ if (!(tempStatement instanceof Cs.Unary))
+ {
+ return tempStatement;
+ }
+ unary = (Cs.Unary) tempStatement;
+ Expression tempExpression = (Expression) visitExpression(unary, p);
+ if (!(tempExpression instanceof Cs.Unary))
+ {
+ return tempExpression;
+ }
+ unary = (Cs.Unary) tempExpression;
+ unary = unary.withMarkers(visitMarkers(unary.getMarkers(), p));
+ unary = unary.getPadding().withOperator(visitLeftPadded(unary.getPadding().getOperator(), CsLeftPadded.Location.UNARY_OPERATOR, p));
+ unary = unary.withExpression(visitAndCast(unary.getExpression(), p));
+ return unary;
+ }
+
+ public J visitConstructorInitializer(Cs.ConstructorInitializer constructorInitializer, P p) {
+ constructorInitializer = constructorInitializer.withPrefix(visitSpace(constructorInitializer.getPrefix(), CsSpace.Location.CONSTRUCTOR_INITIALIZER_PREFIX, p));
+ constructorInitializer = constructorInitializer.withMarkers(visitMarkers(constructorInitializer.getMarkers(), p));
+ constructorInitializer = constructorInitializer.withKeyword(visitAndCast(constructorInitializer.getKeyword(), p));
+ constructorInitializer = constructorInitializer.getPadding().withArguments(visitContainer(constructorInitializer.getPadding().getArguments(), CsContainer.Location.CONSTRUCTOR_INITIALIZER_ARGUMENTS, p));
+ return constructorInitializer;
+ }
+
public JContainer visitContainer(@Nullable JContainer container,
CsContainer.Location loc, P p) {
if (container == null) {
diff --git a/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java b/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java
index 84928f5..07aea6e 100644
--- a/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java
+++ b/rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java
@@ -24,6 +24,7 @@
import org.openrewrite.csharp.CSharpVisitor;
import org.openrewrite.java.JavaPrinter;
import org.openrewrite.java.JavaTypeVisitor;
+import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.internal.TypesInUse;
import org.openrewrite.java.tree.*;
import org.openrewrite.marker.Markers;
@@ -310,27 +311,35 @@ public Cs.CompilationUnit withUsings(List> usings)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@RequiredArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
- final class NamedArgument implements Cs, Expression {
+ final class Argument implements Cs, Expression {
@Nullable
@NonFinal
- transient WeakReference padding;
+ transient WeakReference padding;
@With
+ @Getter
@EqualsAndHashCode.Include
UUID id;
@With
+ @Getter
Space prefix;
@With
+ @Getter
Markers markers;
@Nullable
JRightPadded nameColumn;
+ @Nullable
+ @Getter
+ @With
+ Keyword refKindKeyword;
+
public J.@Nullable Identifier getNameColumn() { return nameColumn == null ? null : nameColumn.getElement(); }
- public NamedArgument withNameColumn(J.@Nullable Identifier nameColumn) {
+ public Argument withNameColumn(J.@Nullable Identifier nameColumn) {
return getPadding().withNameColumn(JRightPadded.withElement(this.nameColumn, nameColumn));
}
@@ -344,13 +353,13 @@ public NamedArgument withNameColumn(J.@Nullable Identifier nameColumn) {
@SuppressWarnings("unchecked")
@Override
- public NamedArgument withType(@Nullable JavaType type) {
- return expression.getType() == type ? this : new NamedArgument(id, prefix, markers, nameColumn, expression.withType(type));
+ public Argument withType(@Nullable JavaType type) {
+ return expression.getType() == type ? this : new Argument(id, prefix, markers, nameColumn, refKindKeyword, expression.withType(type));
}
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
- return v.visitNamedArgument(this, p);
+ return v.visitArgument(this, p);
}
public Padding getPadding() {
@@ -381,14 +390,14 @@ public String toString() {
@RequiredArgsConstructor
public static class Padding {
- private final NamedArgument t;
+ private final Argument t;
public @Nullable JRightPadded getNameColumn() {
return t.nameColumn;
}
- public NamedArgument withNameColumn(@Nullable JRightPadded target) {
- return t.nameColumn == target ? t : new NamedArgument(t.id, t.prefix, t.markers, target, t.expression);
+ public Argument withNameColumn(@Nullable JRightPadded target) {
+ return t.nameColumn == target ? t : new Argument(t.id, t.prefix, t.markers, target, t.refKindKeyword, t.expression);
}
}
@@ -1881,7 +1890,38 @@ public PropertyDeclaration withInitializer(@Nullable JLeftPadded ini
}
}
+ enum KeywordKind
+ {
+ Ref,
+ Out,
+ Await,
+ Base,
+ This
+ }
+
+ @Getter
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @RequiredArgsConstructor
+ final class Keyword implements Cs
+ {
+ @With
+ @Getter
+ @EqualsAndHashCode.Include
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+ @With
+ @Getter
+ Markers markers;
+
+ @With
+ @Getter
+ KeywordKind kind;
+ }
@Getter
@@ -2121,7 +2161,7 @@ final class UsingStatement implements Cs, Statement {
@With
@Nullable
@Getter
- Space awaitKeyword;
+ Keyword awaitKeyword;
JContainer expression;
@@ -2548,4 +2588,642 @@ public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitDefaultConstraint(this, p);
}
}
+
+ /**
+ * A declaration expression node represents a local variable declaration in an expression context.
+ * This is used in two primary scenarios in C#:
+ *
+ * - Out variable declarations: {@code Method(out int x)}
+ * - Deconstruction declarations: {@code (int x, string y) = GetPoint()}
+ *
+ * Example 1: Out variable declaration:
+ *
+ * if(int.TryParse(s, out int result)) {
+ * // use result
+ * }
+ *
+ *
+ * Example 2: Deconstruction declaration:
+ *
+ * (int x, string y) = point;
+ * (int count, (string name, int age)) = GetPersonDetails();
+ *
+ */
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @AllArgsConstructor(access = AccessLevel.PUBLIC)
+ public final class DeclarationExpression implements Cs, Expression, TypedTree {
+
+ @With
+ @EqualsAndHashCode.Include
+ @Getter
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+
+ @With
+ @Getter
+ Markers markers;
+
+
+ @With
+ @Getter
+ @Nullable
+ TypeTree typeExpression;
+
+ @With
+ @Getter
+ VariableDesignation variables;
+
+
+ @Override
+ public @Nullable JavaType getType() {
+ return variables.getType();
+ }
+
+ @Override
+ public DeclarationExpression withType(@Nullable JavaType type) {
+ return withType(type == null ? null : this.variables.withType(type));
+ }
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitDeclarationExpression(this, p);
+ }
+
+ @Override
+ @Transient
+ public CoordinateBuilder.Expression getCoordinates() {
+ return new CoordinateBuilder.Expression(this);
+ }
+ }
+
+ /**
+ * Interface for variable designators in declaration expressions.
+ * This can be either a single variable name or a parenthesized list of designators for deconstruction.
+ * @see SingleVariableDesignation
+ * @see ParenthesizedVariableDesignation
+ */
+ interface VariableDesignation extends Expression, Cs {
+ }
+
+ /**
+ * Represents a single variable declaration within a declaration expression.
+ * Used both for simple out variable declarations and as elements within deconstruction declarations.
+ *
+ * Example in out variable:
+ *
+ * int.TryParse(s, out int x) // 'int x' is the SingleVariable
+ *
+ *
+ * Example in deconstruction:
+ *
+ * (int x, string y) = point; // both 'int x' and 'string y' are SingleVariables
+ *
+ */
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @AllArgsConstructor(access = AccessLevel.PUBLIC)
+ public final class SingleVariableDesignation implements VariableDesignation, Cs {
+ @With
+ @EqualsAndHashCode.Include
+ @Getter
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+
+ @With
+ @Getter
+ Markers markers;
+
+ @With
+ @Getter
+ J.Identifier name;
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitSingleVariableDesignation(this, p);
+ }
+
+ @Override
+ public @Nullable JavaType getType() {
+ return name.getType();
+ }
+
+ @Override
+ public SingleVariableDesignation withType(@Nullable JavaType type) {
+ return this.getType() == type ? this : new Cs.SingleVariableDesignation(
+ id,
+ prefix,
+ markers,
+ name.withType(type));
+ }
+
+ @Override
+ @Transient
+ public CoordinateBuilder.Expression getCoordinates() {
+ return new CoordinateBuilder.Expression(this);
+ }
+ }
+
+ /**
+ * Represents a parenthesized list of variable declarations used in deconstruction patterns.
+ * Can contain both single variables and nested deconstruction patterns.
+ *
+ * Example of simple deconstruction:
+ *
+ * (int x, string y) = point;
+ *
+ *
+ * Example of nested deconstruction:
+ *
+ * (int count, (string name, int age)) = GetPersonDetails();
+ * // ^^^^^^^^^^^^^^^^^^ nested ParenthesizedVariable
+ * // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ outer ParenthesizedVariable
+ *
+ */
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @AllArgsConstructor(access = AccessLevel.PRIVATE)
+ @RequiredArgsConstructor
+ public final class ParenthesizedVariableDesignation implements VariableDesignation, Cs {
+ @Nullable
+ @NonFinal
+ transient WeakReference padding;
+
+ @With
+ @EqualsAndHashCode.Include
+ @Getter
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+
+ @With
+ @Getter
+ Markers markers;
+
+ JContainer variables;
+
+ public List getVariables() {
+ return variables.getElements();
+ }
+
+ public ParenthesizedVariableDesignation withVariables(List variables) {
+ return getPadding().withVariables(JContainer.withElements(this.variables, variables));
+ }
+
+ @With
+ @Getter
+ @Nullable
+ JavaType type;
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitParenthesizedVariableDesignation(this, p);
+ }
+
+ @Override
+ @Transient
+ public CoordinateBuilder.Expression getCoordinates() {
+ return new CoordinateBuilder.Expression(this);
+ }
+
+ public Padding getPadding() {
+ Padding p;
+ if (this.padding == null) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ } else {
+ p = this.padding.get();
+ if (p == null || p.t != this) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ }
+ }
+ return p;
+ }
+
+ @RequiredArgsConstructor
+ public class Padding {
+ private final ParenthesizedVariableDesignation t;
+
+ public JContainer getVariables() {
+ return t.variables;
+ }
+
+ public ParenthesizedVariableDesignation withVariables(JContainer variables) {
+ return t.variables == variables ? t : new ParenthesizedVariableDesignation(t.id, t.prefix, t.markers, variables, t.type);
+ }
+ }
+ }
+
+ /**
+ * Represents a discard designation in pattern matching expressions, indicated by an underscore (_).
+ * For example in pattern matching:
+ * ```csharp
+ * if (obj is _) // discard pattern
+ * ```
+ * Or in deconstruction:
+ * ```csharp
+ * var (x, _, z) = tuple; // discards second element
+ * ```
+ */
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @AllArgsConstructor(access = AccessLevel.PUBLIC)
+ final class DiscardVariableDesignation implements VariableDesignation, Cs {
+ @With
+ @EqualsAndHashCode.Include
+ @Getter
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+
+ @With
+ @Getter
+ Markers markers;
+
+ @With
+ @Getter
+ J.Identifier discard;
+
+ @Override
+ public @Nullable JavaType getType() {
+ return discard.getType();
+ }
+
+ @Override
+ public J2 withType(@Nullable JavaType type) {
+ return (J2) withDiscard(discard.withType(type));
+ }
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitDiscardVariableDesignation(this, p);
+ }
+
+ @Override
+ @Transient
+ public CoordinateBuilder.Expression getCoordinates() {
+ return new CoordinateBuilder.Expression(this);
+ }
+ }
+
+ /**
+ * Represents a tuple expression in C#.
+ * Can be used in tuple construction, deconstruction and tuple literals.
+ *
+ * Examples:
+ * ```csharp
+ * // Tuple construction
+ * var point = (1, 2);
+ *
+ * // Named tuple elements
+ * var person = (name: "John", age: 25);
+ *
+ * // Nested tuples
+ * var nested = (1, (2, 3));
+ *
+ * // Tuple type with multiple elements
+ * (string name, int age) person = ("John", 25);
+ * ```
+ */
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @RequiredArgsConstructor
+ @AllArgsConstructor(access = AccessLevel.PRIVATE)
+ final class TupleExpression implements Cs, Expression {
+ @Nullable
+ @NonFinal
+ transient WeakReference padding;
+
+ @With
+ @EqualsAndHashCode.Include
+ @Getter
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+
+ @With
+ @Getter
+ Markers markers;
+
+ JContainer arguments;
+
+ public List getArguments() {
+ return arguments.getElements();
+ }
+
+ public TupleExpression withArguments(List arguments) {
+ return getPadding().withArguments(JContainer.withElements(this.arguments, arguments));
+ }
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitTupleExpression(this, p);
+ }
+
+ @Override
+ public @Nullable JavaType getType() {
+ return null;
+ }
+
+ @Override
+ public TupleExpression withType(@Nullable JavaType type) {
+ return this;
+ }
+
+ @Override
+ @Transient
+ public CoordinateBuilder.Expression getCoordinates() {
+ return new CoordinateBuilder.Expression(this);
+ }
+
+ public Padding getPadding() {
+ Padding p;
+ if (this.padding == null) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ } else {
+ p = this.padding.get();
+ if (p == null || p.t != this) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ }
+ }
+ return p;
+ }
+
+ @RequiredArgsConstructor
+ public static class Padding {
+ private final TupleExpression t;
+
+ public JContainer getArguments() {
+ return t.arguments;
+ }
+
+ public TupleExpression withArguments(JContainer arguments) {
+ return t.arguments == arguments ? t : new TupleExpression(t.id, t.prefix, t.markers, arguments);
+ }
+ }
+ }
+
+ /**
+ * Represents a C# constructor declaration which may include an optional constructor initializer.
+ *
+ * For example:
+ *
+ * // Constructor with no initializer
+ * public MyClass() {
+ * }
+ *
+ * // Constructor with base class initializer
+ * public MyClass(int x) : base(x) {
+ * }
+ *
+ * // Constructor with this initializer
+ * public MyClass(string s) : this(int.Parse(s)) {
+ * }
+ *
+ */
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @AllArgsConstructor(access = AccessLevel.PUBLIC)
+ public class Constructor implements Cs, Statement {
+ @Getter
+ @With
+ @EqualsAndHashCode.Include
+ UUID id;
+
+ @Getter
+ @With
+ Space prefix;
+
+ @Getter
+ @With
+ Markers markers;
+
+ @Getter
+ @With
+ @Nullable
+ ConstructorInitializer initializer;
+
+ @Getter
+ @With
+ J.MethodDeclaration constructorCore;
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitConstructor(this, p);
+ }
+
+ @Override
+ @Transient
+ public CoordinateBuilder.Statement getCoordinates() {
+ return new CoordinateBuilder.Statement(this);
+ }
+ }
+
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @RequiredArgsConstructor
+ @AllArgsConstructor(access = AccessLevel.PRIVATE)
+ final class Unary implements Cs, Statement, Expression, TypedTree {
+ @Nullable
+ @NonFinal
+ transient WeakReference padding;
+
+ @With
+ @EqualsAndHashCode.Include
+ @Getter
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+
+ @With
+ @Getter
+ Markers markers;
+
+ JLeftPadded operator;
+
+ public Type getOperator() {
+ return operator.getElement();
+ }
+
+ public Cs.Unary withOperator(Type operator) {
+ return getPadding().withOperator(this.operator.withElement(operator));
+ }
+
+ @With
+ @Getter
+ Expression expression;
+
+ @With
+ @Nullable
+ @Getter
+ JavaType type;
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitUnary(this, p);
+ }
+
+ @Override
+ @Transient
+ public CoordinateBuilder.Statement getCoordinates() {
+ return new CoordinateBuilder.Statement(this);
+ }
+
+ @Override
+ @Transient
+ public List getSideEffects() {
+ return getOperator().isModifying() ? singletonList(this) : expression.getSideEffects();
+ }
+
+ public enum Type {
+
+ /**
+ * Represent x! syntax
+ */
+ SuppressNullableWarning;
+
+ public boolean isModifying() {
+ switch (this) {
+ default:
+ return false;
+ }
+ }
+ }
+
+ public Padding getPadding() {
+ Padding p;
+ if (this.padding == null) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ } else {
+ p = this.padding.get();
+ if (p == null || p.t != this) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ }
+ }
+ return p;
+ }
+
+ @Override
+ public String toString() {
+ return withPrefix(Space.EMPTY).printTrimmed(new JavaPrinter<>());
+ }
+
+ @RequiredArgsConstructor
+ public static class Padding {
+ private final Cs.Unary t;
+
+ public JLeftPadded getOperator() {
+ return t.operator;
+ }
+
+ public Cs.Unary withOperator(JLeftPadded operator) {
+ return t.operator == operator ? t : new Cs.Unary(t.id, t.prefix, t.markers, operator, t.expression, t.type);
+ }
+ }
+ }
+
+
+ /**
+ * Represents a constructor initializer which is a call to another constructor, either in the same class (this)
+ * or in the base class (base).
+ *
+ * Examples:
+ * ```csharp
+ * class Person {
+ * // Constructor with 'this' initializer
+ * public Person(string name) : this(name, 0) { }
+ *
+ * // Constructor with 'base' initializer
+ * public Person(string name, int age) : base(name) { }
+ * }
+ * ```
+ */
+ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
+ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
+ @RequiredArgsConstructor
+ @AllArgsConstructor(access = AccessLevel.PRIVATE)
+ final class ConstructorInitializer implements Cs {
+ @Nullable
+ @NonFinal
+ transient WeakReference padding;
+
+ @With
+ @EqualsAndHashCode.Include
+ @Getter
+ UUID id;
+
+ @With
+ @Getter
+ Space prefix;
+
+ @With
+ @Getter
+ Markers markers;
+
+ @With
+ @Getter
+ Cs.Keyword keyword;
+
+ JContainer arguments;
+
+ public List getArguments() {
+ return arguments.getElements();
+ }
+
+ public ConstructorInitializer withArguments(List arguments) {
+ return getPadding().withArguments(JContainer.withElements(this.arguments, arguments));
+ }
+
+ @Override
+ public J acceptCSharp(CSharpVisitor
v, P p) {
+ return v.visitConstructorInitializer(this, p);
+ }
+
+ public Padding getPadding() {
+ Padding p;
+ if (this.padding == null) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ } else {
+ p = this.padding.get();
+ if (p == null || p.t != this) {
+ p = new Padding(this);
+ this.padding = new WeakReference<>(p);
+ }
+ }
+ return p;
+ }
+
+ @RequiredArgsConstructor
+ public static class Padding {
+ private final ConstructorInitializer t;
+
+ public JContainer getArguments() {
+ return t.arguments;
+ }
+
+ public ConstructorInitializer withArguments(JContainer