All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openrewrite.csharp.tree.Cs Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2024 the original author or authors.
 * 

* Licensed under the Moderne Source Available License (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

* https://docs.moderne.io/licensing/moderne-source-available-license *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.openrewrite.csharp.tree; import com.fasterxml.jackson.annotation.JsonCreator; import lombok.*; import lombok.experimental.FieldDefaults; import lombok.experimental.NonFinal; import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.csharp.CSharpPrinter; import org.openrewrite.csharp.CSharpVisitor; import org.openrewrite.csharp.service.CSharpNamingService; import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.NamingService; 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.Marker; import org.openrewrite.marker.Markers; import java.beans.Transient; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Predicate; import java.util.stream.Collectors; import static java.util.Collections.singletonList; public interface Cs extends J { @SuppressWarnings("unchecked") @Override default R accept(TreeVisitor v, P p) { return (R) acceptCSharp(v.adapt(CSharpVisitor.class), p); } @Override default

boolean isAcceptable(TreeVisitor v, P p) { return v.isAdaptableTo(CSharpVisitor.class); }

@Nullable J acceptCSharp(CSharpVisitor

v, P p); @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class CompilationUnit implements Cs, JavaSourceFile { @Nullable @NonFinal transient SoftReference typesInUse; @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; @Getter @With Path sourcePath; @Getter @With @Nullable FileAttributes fileAttributes; @Getter @Nullable @With(AccessLevel.PRIVATE) String charsetName; @Getter @With boolean charsetBomMarked; @Getter @With @Nullable Checksum checksum; @Override public Charset getCharset() { return charsetName == null ? StandardCharsets.UTF_8 : Charset.forName(charsetName); } @SuppressWarnings("unchecked") @Override public SourceFile withCharset(Charset charset) { return withCharsetName(charset.name()); } @Override public @Nullable Package getPackageDeclaration() { return null; } @Override public Cs.CompilationUnit withPackageDeclaration(Package packageDeclaration) { return this; } List> externs; public List getExterns() { return JRightPadded.getElements(externs); } public Cs.CompilationUnit withExterns(List externs) { return getPadding().withExterns(JRightPadded.withElements(this.externs, externs)); } List> usings; public List getUsings() { return JRightPadded.getElements(usings); } public Cs.CompilationUnit withUsings(List usings) { return getPadding().withUsings(JRightPadded.withElements(this.usings, usings)); } @Getter @With List attributeLists; List> members; public List getMembers() { return JRightPadded.getElements(members); } public Cs.CompilationUnit withMembers(List members) { return getPadding().withMembers(JRightPadded.withElements(this.members, members)); } @Override @Transient public List getImports() { return Collections.emptyList(); } @Override public Cs.CompilationUnit withImports(List imports) { return this; } @Override @Transient public List getClasses() { return Collections.emptyList(); } @Override public JavaSourceFile withClasses(List classes) { return this; } @Getter @With Space eof; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitCompilationUnit(this, p); } @Override public

TreeVisitor> printer(Cursor cursor) { return new CSharpPrinter<>(); } @Override public TypesInUse getTypesInUse() { TypesInUse cache; if (this.typesInUse == null) { cache = TypesInUse.build(this); this.typesInUse = new SoftReference<>(cache); } else { cache = this.typesInUse.get(); if (cache == null || cache.getCu() != this) { cache = TypesInUse.build(this); this.typesInUse = new SoftReference<>(cache); } } return cache; } @Transient @Override public long getWeight(Predicate uniqueIdentity) { AtomicInteger n = new AtomicInteger(); new CSharpVisitor() { final JavaTypeVisitor typeVisitor = new JavaTypeVisitor() { @Override public JavaType visit(@Nullable JavaType javaType, AtomicInteger n) { if (javaType != null && uniqueIdentity.test(javaType)) { n.incrementAndGet(); return super.visit(javaType, n); } //noinspection ConstantConditions return javaType; } }; @Override public J preVisit(J tree, AtomicInteger n) { n.incrementAndGet(); return tree; } @Override public JavaType visitType(@Nullable JavaType javaType, AtomicInteger n) { return typeVisitor.visit(javaType, n); } }.visit(this, n); return n.get(); } @Override 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 @Incubating(since = "8.2.0") public T service(Class service) { if (NamingService.class.getName().equals(service.getName())) { return (T) new CSharpNamingService(); } return JavaSourceFile.super.service(service); } @RequiredArgsConstructor public static class Padding implements JavaSourceFile.Padding { private final Cs.CompilationUnit t; @Override public List> getImports() { return Collections.emptyList(); } @Override public JavaSourceFile withImports(List> imports) { return t; } public List> getMembers() { return t.members; } public Cs.CompilationUnit withMembers(List> members) { return t.members == members ? t : new Cs.CompilationUnit(t.id, t.prefix, t.markers, t.sourcePath, t.fileAttributes, t.charsetName, t.charsetBomMarked, t.checksum, t.externs, t.usings, t.attributeLists, members, t.eof); } public List> getExterns() { return t.externs; } public Cs.CompilationUnit withExterns(List> externs) { return t.externs == externs ? t : new Cs.CompilationUnit(t.id, t.prefix, t.markers, t.sourcePath, t.fileAttributes, t.charsetName, t.charsetBomMarked, t.checksum, externs, t.usings, t.attributeLists, t.members, t.eof); } public List> getUsings() { return t.usings; } public Cs.CompilationUnit withUsings(List> usings) { return t.usings == usings ? t : new Cs.CompilationUnit(t.id, t.prefix, t.markers, t.sourcePath, t.fileAttributes, t.charsetName, t.charsetBomMarked, t.checksum, t.externs, usings, t.attributeLists, t.members, t.eof); } } } @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ForEachVariableLoop implements Cs, Loop { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter Control controlElement; JRightPadded body; @Override public Statement getBody() { return body.getElement(); } @Override @SuppressWarnings("unchecked") public ForEachVariableLoop withBody(Statement body) { return getPadding().withBody(this.body.withElement(body)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitForEachVariableLoop(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) public static final class Control implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; JRightPadded variable; public Expression getVariable() { return variable.getElement(); } public Control withVariable(Expression variable) { return getPadding().withVariable(this.variable.withElement(variable)); } JRightPadded iterable; public Expression getIterable() { return iterable.getElement(); } public Control withIterable(Expression iterable) { return getPadding().withIterable(this.iterable.withElement(iterable)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitForEachVariableLoopControl(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; } @Override public String toString() { return withPrefix(Space.EMPTY).printTrimmed(new JavaPrinter<>()); } @RequiredArgsConstructor public static class Padding { private final Control t; public JRightPadded getVariable() { return t.variable; } public Control withVariable(JRightPadded variable) { return t.variable == variable ? t : new Control(t.id, t.prefix, t.markers, variable, t.iterable); } public JRightPadded getIterable() { return t.iterable; } public Control withIterable(JRightPadded iterable) { return t.iterable == iterable ? t : new Control(t.id, t.prefix, t.markers, t.variable, iterable); } } } 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 Cs.ForEachVariableLoop t; public JRightPadded getBody() { return t.body; } public ForEachVariableLoop withBody(JRightPadded body) { return t.body == body ? t : new ForEachVariableLoop(t.id, t.prefix, t.markers, t.controlElement, body); } } } @Getter @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class Argument implements Cs, Expression { @Nullable @NonFinal 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 @Nullable Identifier getNameColumn() { return nameColumn == null ? null : nameColumn.getElement(); } public Argument withNameColumn(@Nullable Identifier nameColumn) { return getPadding().withNameColumn(JRightPadded.withElement(this.nameColumn, nameColumn)); } @With Expression expression; @Override public @Nullable JavaType getType() { return expression.getType(); } @SuppressWarnings("unchecked") @Override 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.visitArgument(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; } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } @Override public String toString() { return withPrefix(Space.EMPTY).printTrimmed(new CSharpPrinter<>()); } @RequiredArgsConstructor public static class Padding { private final Argument t; public @Nullable JRightPadded getNameColumn() { return t.nameColumn; } public Argument withNameColumn(@Nullable JRightPadded target) { return t.nameColumn == target ? t : new Argument(t.id, t.prefix, t.markers, target, t.refKindKeyword, t.expression); } } } @Getter @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor final class AnnotatedStatement implements Cs, Statement { @With @EqualsAndHashCode.Include UUID id; @With Space prefix; @With Markers markers; @With List attributeLists; @With Statement statement; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitAnnotatedStatement(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } @Override public String toString() { return withPrefix(Space.EMPTY).printTrimmed(new CSharpPrinter<>()); } } @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ArrayRankSpecifier implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @EqualsAndHashCode.Include @Getter @With UUID id; @Getter @With Space prefix; @Getter @With Markers markers; JContainer sizes; public List getSizes() { return sizes.getElements(); } public ArrayRankSpecifier withSizes(List sizes) { return getPadding().withSizes(JContainer.withElements(this.sizes, sizes)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitArrayRankSpecifier(this, p); } @Override public @Nullable JavaType getType() { return sizes.getElements().isEmpty() ? null : sizes.getPadding().getElements().get(0).getElement().getType(); } @Override public T withType(@Nullable JavaType type) { throw new IllegalArgumentException("Cannot set type on " + getClass()); } @Override 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 ArrayRankSpecifier t; public @Nullable JContainer getSizes() { return t.sizes; } public ArrayRankSpecifier withSizes(@Nullable JContainer sizes) { return t.sizes == sizes ? t : new ArrayRankSpecifier(t.id, t.prefix, t.markers, sizes); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class AssignmentOperation implements Cs, Statement, Expression, TypedTree { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter Expression variable; JLeftPadded operator; public OperatorType getOperator() { return operator.getElement(); } public Cs.AssignmentOperation withOperator(OperatorType operator) { return getPadding().withOperator(this.operator.withElement(operator)); } @With @Getter Expression assignment; @With @Nullable @Getter JavaType type; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitAssignmentOperation(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } @Override @Transient public List getSideEffects() { return singletonList(this); } public enum OperatorType { NullCoalescing } 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 CSharpPrinter<>()); } @RequiredArgsConstructor public static class Padding { private final Cs.AssignmentOperation t; public JLeftPadded getOperator() { return t.operator; } public Cs.AssignmentOperation withOperator(JLeftPadded operator) { return t.operator == operator ? t : new Cs.AssignmentOperation(t.id, t.prefix, t.markers, t.variable, operator, t.assignment, t.type); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class AttributeList implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @Nullable JRightPadded target; public @Nullable Identifier getTarget() { return target == null ? null : target.getElement(); } public AttributeList withTarget(@Nullable Identifier target) { return getPadding().withTarget(JRightPadded.withElement(this.target, target)); } List> attributes; public List getAttributes() { return JRightPadded.getElements(attributes); } public AttributeList withAttributes(List attributes) { return getPadding().withAttributes(JRightPadded.withElements(this.attributes, attributes)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitAttributeList(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; } @Override public String toString() { return withPrefix(Space.EMPTY).printTrimmed(new JavaPrinter<>()); } @RequiredArgsConstructor public static class Padding { private final AttributeList t; public @Nullable JRightPadded getTarget() { return t.target; } public AttributeList withTarget(@Nullable JRightPadded target) { return t.target == target ? t : new AttributeList(t.id, t.prefix, t.markers, target, t.attributes); } public List> getAttributes() { return t.attributes; } public AttributeList withAttributes(List> attributes) { return t.attributes == attributes ? t : new AttributeList(t.id, t.prefix, t.markers, t.target, attributes); } } } @Getter @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @With final class AwaitExpression implements Cs, Expression, Statement { @EqualsAndHashCode.Include UUID id; Space prefix; Markers markers; J expression; @Nullable JavaType type; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitAwaitExpression(this, p); } @Override 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) @Data final class Binary implements Cs, Expression, TypedTree { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include UUID id; @With Space prefix; @With Markers markers; @With Expression left; JLeftPadded operator; public OperatorType getOperator() { return operator.getElement(); } public Cs.Binary withOperator(OperatorType operator) { return getPadding().withOperator(this.operator.withElement(operator)); } @With Expression right; @With @Nullable JavaType type; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitBinary(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } @Transient @Override public List getSideEffects() { List sideEffects = new ArrayList<>(2); sideEffects.addAll(left.getSideEffects()); sideEffects.addAll(right.getSideEffects()); return sideEffects; } public enum OperatorType { As, NullCoalescing } 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 CSharpPrinter<>()); } @RequiredArgsConstructor public static class Padding { private final Cs.Binary t; public JLeftPadded getOperator() { return t.operator; } public Cs.Binary withOperator(JLeftPadded operator) { return t.operator == operator ? t : new Cs.Binary(t.id, t.prefix, t.markers, t.left, operator, t.right, t.type); } } } @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) class BlockScopeNamespaceDeclaration implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; JRightPadded name; public Expression getName() { return name.getElement(); } public BlockScopeNamespaceDeclaration withName(Expression name) { return getPadding().withName(JRightPadded.withElement(this.name, name)); } List> externs; public List getExterns() { return JRightPadded.getElements(externs); } public BlockScopeNamespaceDeclaration withExterns(List externs) { return getPadding().withExterns(JRightPadded.withElements(this.externs, externs)); } List> usings; public List getUsings() { return JRightPadded.getElements(usings); } public BlockScopeNamespaceDeclaration withUsings(List usings) { return getPadding().withUsings(JRightPadded.withElements(this.usings, usings)); } List> members; public List getMembers() { return JRightPadded.getElements(members); } public BlockScopeNamespaceDeclaration withMembers(List members) { return getPadding().withMembers(JRightPadded.withElements(this.members, members)); } @Getter @With Space end; @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitBlockScopeNamespaceDeclaration(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 BlockScopeNamespaceDeclaration t; public JRightPadded getName() { return t.name; } public BlockScopeNamespaceDeclaration withName(JRightPadded name) { return t.name == name ? t : new BlockScopeNamespaceDeclaration(t.id, t.prefix, t.markers, name, t.externs, t.usings, t.members, t.end); } public List> getExterns() { return t.externs; } public BlockScopeNamespaceDeclaration withExterns(List> externs) { return t.externs == externs ? t : new BlockScopeNamespaceDeclaration(t.id, t.prefix, t.markers, t.name, externs, t.usings, t.members, t.end); } public List> getUsings() { return t.usings; } public BlockScopeNamespaceDeclaration withUsings(List> usings) { return t.usings == usings ? t : new BlockScopeNamespaceDeclaration(t.id, t.prefix, t.markers, t.name, t.externs, usings, t.members, t.end); } public List> getMembers() { return t.members; } public BlockScopeNamespaceDeclaration withMembers(List> members) { return t.members == members ? t : new BlockScopeNamespaceDeclaration(t.id, t.prefix, t.markers, t.name, t.externs, t.usings, members, t.end); } } } @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class CollectionExpression implements Cs, Expression, TypedTree { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; List> elements; public List getElements() { return JRightPadded.getElements(elements); } public CollectionExpression withElements(List elements) { return getPadding().withElements(JRightPadded.withElements(this.elements, elements)); } @Getter @With JavaType type; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitCollectionExpression(this, p); } @Transient @Override 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 CollectionExpression t; public List> getElements() { return t.elements; } public CollectionExpression withElements(List> elements) { return t.elements == elements ? t : new CollectionExpression(t.id, t.prefix, t.markers, elements, t.type); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ExpressionStatement implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; JRightPadded expression; public Expression getExpression() { return expression.getElement(); } public ExpressionStatement withExpression(Expression expression) { return getPadding().withExpression(this.expression.withElement(expression)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitExpressionStatement(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 ExpressionStatement t; public JRightPadded getExpression() { return t.expression; } public ExpressionStatement withExpression(JRightPadded expression) { return t.expression == expression ? t : new ExpressionStatement(t.id, t.prefix, t.markers, expression); } } } @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ExternAlias implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; JLeftPadded identifier; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitExternAlias(this, p); } @Transient @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 ExternAlias t; public JLeftPadded getIdentifier() { return t.identifier; } public ExternAlias withIdentifier(JLeftPadded identifier) { return t.identifier == identifier ? t : new ExternAlias(t.id, t.prefix, t.markers, identifier); } } } @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) class FileScopeNamespaceDeclaration implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; JRightPadded name; public Expression getName() { return name.getElement(); } public FileScopeNamespaceDeclaration withName(Expression name) { return getPadding().withName(JRightPadded.withElement(this.name, name)); } List> externs; public List getExterns() { return JRightPadded.getElements(externs); } public FileScopeNamespaceDeclaration withExterns(List externs) { return getPadding().withExterns(JRightPadded.withElements(this.externs, externs)); } List> usings; public List getUsings() { return JRightPadded.getElements(usings); } public FileScopeNamespaceDeclaration withUsings(List usings) { return getPadding().withUsings(JRightPadded.withElements(this.usings, usings)); } List> members; public List getMembers() { return JRightPadded.getElements(members); } public FileScopeNamespaceDeclaration withMembers(List members) { return getPadding().withMembers(JRightPadded.withElements(this.members, members)); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitFileScopeNamespaceDeclaration(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 FileScopeNamespaceDeclaration t; public JRightPadded getName() { return t.name; } public FileScopeNamespaceDeclaration withName(JRightPadded name) { return t.name == name ? t : new FileScopeNamespaceDeclaration(t.id, t.prefix, t.markers, name, t.externs, t.usings, t.members); } public List> getExterns() { return t.externs; } public FileScopeNamespaceDeclaration withExterns(List> externs) { return t.externs == externs ? t : new FileScopeNamespaceDeclaration(t.id, t.prefix, t.markers, t.name, externs, t.usings, t.members); } public List> getUsings() { return t.usings; } public FileScopeNamespaceDeclaration withUsings(List> usings) { return t.usings == usings ? t : new FileScopeNamespaceDeclaration(t.id, t.prefix, t.markers, t.name, t.externs, usings, t.members); } public List> getMembers() { return t.members; } public FileScopeNamespaceDeclaration withMembers(List> members) { return t.members == members ? t : new FileScopeNamespaceDeclaration(t.id, t.prefix, t.markers, t.name, t.externs, t.usings, members); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) class InterpolatedString implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; @Getter @With String start; List> parts; public List getParts() { return JRightPadded.getElements(parts); } public InterpolatedString withParts(List parts) { return getPadding().withParts(JRightPadded.withElements(this.parts, parts)); } @Getter @With String end; @Override public JavaType getType() { return JavaType.Primitive.String; } @SuppressWarnings("unchecked") @Override public InterpolatedString withType(@Nullable JavaType type) { return this; } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitInterpolatedString(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 InterpolatedString t; public List> getParts() { return t.parts; } public InterpolatedString withParts(List> parts) { return t.parts == parts ? t : new InterpolatedString(t.id, t.prefix, t.markers, t.start, parts, t.end); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) class Interpolation implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; JRightPadded expression; public Expression getExpression() { return expression.getElement(); } public Interpolation withExpression(Expression expression) { return getPadding().withExpression(JRightPadded.withElement(this.expression, expression)); } @Nullable JRightPadded alignment; public @Nullable Expression getAlignment() { return alignment != null ? alignment.getElement() : null; } public Interpolation withAlignment(@Nullable Expression alignment) { return getPadding().withAlignment(JRightPadded.withElement(this.alignment, alignment)); } @Nullable JRightPadded format; public @Nullable Expression getFormat() { return format != null ? format.getElement() : null; } public Interpolation withFormat(@Nullable Expression format) { return getPadding().withFormat(JRightPadded.withElement(this.format, format)); } @Override public JavaType getType() { return expression.getElement().getType(); } @SuppressWarnings("unchecked") @Override public Interpolation withType(@Nullable JavaType type) { return getPadding().withExpression(expression.withElement(expression.getElement().withType(type))); } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitInterpolation(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 Interpolation t; public JRightPadded getExpression() { return t.expression; } public Interpolation withExpression(JRightPadded expression) { return t.expression == expression ? t : new Interpolation(t.id, t.prefix, t.markers, expression, t.alignment, t.format); } public @Nullable JRightPadded getAlignment() { return t.alignment; } public Interpolation withAlignment(@Nullable JRightPadded alignment) { return t.alignment == alignment ? t : new Interpolation(t.id, t.prefix, t.markers, t.expression, alignment, t.format); } public @Nullable JRightPadded getFormat() { return t.format; } public Interpolation withFormat(@Nullable JRightPadded format) { return t.format == format ? t : new Interpolation(t.id, t.prefix, t.markers, t.expression, t.alignment, format); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) class NullSafeExpression implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; JRightPadded expression; public Expression getExpression() { return expression.getElement(); } public NullSafeExpression withExpression(Expression expression) { return getPadding().withExpression(JRightPadded.withElement(this.expression, expression)); } @Override public @Nullable JavaType getType() { return expression.getElement().getType(); } @Override public T withType(@Nullable JavaType type) { Expression newExpression = expression.getElement().withType(type); if (newExpression == expression.getElement()) { return (T) this; } return (T) new NullSafeExpression(id, prefix, markers, JRightPadded.withElement(expression, newExpression)); } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitNullSafeExpression(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 NullSafeExpression t; public JRightPadded getExpression() { return t.expression; } public NullSafeExpression withExpression(JRightPadded expression) { return t.expression == expression ? t : new NullSafeExpression(t.id, t.prefix, t.markers, expression); } } } @Getter @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @With final class StatementExpression implements Cs, Expression { @EqualsAndHashCode.Include UUID id; Space prefix; Markers markers; Statement statement; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitStatementExpression(this, p); } @Override public @Nullable JavaType getType() { return null; } @Override public T withType(@Nullable JavaType type) { return (T) this; } @Transient @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) class UsingDirective implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; JRightPadded global; public boolean isGlobal() { return global.getElement(); } public UsingDirective withGlobal(boolean global) { return getPadding().withGlobal(JRightPadded.withElement(this.global, global)); } JLeftPadded statik; public boolean isStatic() { return statik.getElement(); } public UsingDirective withStatic(boolean statik) { return getPadding().withStatic(JLeftPadded.withElement(this.statik, statik)); } JLeftPadded unsafe; public boolean isUnsafe() { return unsafe.getElement(); } public UsingDirective withUnsafe(boolean unsafe) { return getPadding().withUnsafe(JLeftPadded.withElement(this.unsafe, unsafe)); } @Nullable JRightPadded alias; public @Nullable Identifier getAlias() { return alias != null ? alias.getElement() : null; } public UsingDirective withAlias(@Nullable Identifier alias) { return getPadding().withAlias(JRightPadded.withElement(this.alias, alias)); } @Getter @With TypeTree namespaceOrType; @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitUsingDirective(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 UsingDirective t; public JRightPadded getGlobal() { return t.global; } public UsingDirective withGlobal(JRightPadded global) { return t.global == global ? t : new UsingDirective(t.id, t.prefix, t.markers, global, t.statik, t.unsafe, t.alias, t.namespaceOrType); } public JLeftPadded getStatic() { return t.statik; } public UsingDirective withStatic(JLeftPadded statik) { return t.statik == statik ? t : new UsingDirective(t.id, t.prefix, t.markers, t.global, statik, t.unsafe, t.alias, t.namespaceOrType); } public JLeftPadded getUnsafe() { return t.unsafe; } public UsingDirective withUnsafe(JLeftPadded unsafe) { return t.unsafe == unsafe ? t : new UsingDirective(t.id, t.prefix, t.markers, t.global, t.statik, unsafe, t.alias, t.namespaceOrType); } public @Nullable JRightPadded getAlias() { return t.alias; } public UsingDirective withAlias(JRightPadded alias) { return t.alias == alias ? t : new UsingDirective(t.id, t.prefix, t.markers, t.global, t.statik, t.unsafe, t.alias, t.namespaceOrType); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) class PropertyDeclaration implements Cs, Statement, TypedTree { @Nullable @NonFinal transient WeakReference padding; @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; @With @Getter List attributeLists; @With @Getter List modifiers; @With @Getter TypeTree typeExpression; @Nullable JRightPadded interfaceSpecifier; @With @Getter Identifier name; @With @Getter Block accessors; @Nullable JLeftPadded initializer; @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } @Override public JavaType getType() { return typeExpression.getType(); } @Override public PropertyDeclaration withType(@Nullable JavaType type) { return getPadding().withType(this.typeExpression.withType(type)); } public @Nullable NameTree getInterfaceSpecifier() { return interfaceSpecifier != null ? interfaceSpecifier.getElement() : null; } public PropertyDeclaration withInterfaceSpecifier(@Nullable NameTree interfaceSpecifier) { return getPadding().withInterfaceSpecifier(JRightPadded.withElement(this.interfaceSpecifier, interfaceSpecifier)); } public @Nullable Expression getInitializer() { return initializer != null ? initializer.getElement() : null; } public PropertyDeclaration withInitializer(@Nullable Expression initializer) { return getPadding().withInitializer(JLeftPadded.withElement(this.initializer, initializer)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitPropertyDeclaration(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.pd != this) { p = new Padding(this); this.padding = new WeakReference<>(p); } } return p; } @RequiredArgsConstructor public static class Padding { private final PropertyDeclaration pd; public TypeTree getType() { return pd.typeExpression; } public @Nullable JRightPadded getInterfaceSpecifier() { return pd.interfaceSpecifier; } public PropertyDeclaration withInterfaceSpecifier(@Nullable JRightPadded interfaceSpecifier) { return pd.interfaceSpecifier == interfaceSpecifier ? pd : new PropertyDeclaration(pd.id, pd.prefix, pd.markers, pd.attributeLists, pd.modifiers, pd.typeExpression, interfaceSpecifier, pd.name, pd.accessors, pd.initializer); } public PropertyDeclaration withType(TypeTree type) { return pd.typeExpression == type ? pd : new PropertyDeclaration(pd.id, pd.prefix, pd.markers, pd.attributeLists, pd.modifiers, type, pd.interfaceSpecifier, pd.name, pd.accessors, pd.initializer); } public @Nullable JLeftPadded getInitializer() { return pd.initializer; } public PropertyDeclaration withInitializer(@Nullable JLeftPadded initializer) { return pd.initializer == initializer ? pd : new PropertyDeclaration(pd.id, pd.prefix, pd.markers, pd.attributeLists, pd.modifiers, pd.typeExpression, pd.interfaceSpecifier, pd.name, pd.accessors, initializer); } } } @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; @Override public @Nullable

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitKeyword(this, p); } public enum KeywordKind { Ref, Out, Await, Base, This, Break, Return, Not } } @Getter @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor final class Lambda implements Cs, Statement, Expression { @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitLambda(this, p); } @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter J.Lambda lambdaExpression; @With @Getter List modifiers; @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } @Override public @Nullable JavaType getType() { return lambdaExpression.getType(); } @Override public Cs.Lambda withType(@Nullable JavaType type) { return this.getType() == type ? this : new Cs.Lambda( id, prefix, markers, lambdaExpression.withType(type), modifiers); } @Override public String toString() { return withPrefix(Space.EMPTY).printTrimmed(new CSharpPrinter<>()); } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ClassDeclaration implements Cs, Statement, TypedTree { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter List attributeList; @With @Getter List modifiers; J.ClassDeclaration.Kind kind; public J.ClassDeclaration.Kind.Type getKind() { return kind.getType(); } public Cs.ClassDeclaration withKind(J.ClassDeclaration.Kind.Type type) { J.ClassDeclaration.Kind k = getPadding().getKind(); if (k.getType() == type) { return this; } else { return getPadding().withKind(k.withType(type)); } } @With @Getter Identifier name; @Nullable JContainer typeParameters; public @Nullable List getTypeParameters() { return typeParameters == null ? null : typeParameters.getElements(); } public Cs.ClassDeclaration withTypeParameters(@Nullable List typeParameters) { return getPadding().withTypeParameters(JContainer.withElementsNullable(this.typeParameters, typeParameters)); } @Nullable JContainer primaryConstructor; public @Nullable List getPrimaryConstructor() { return primaryConstructor == null ? null : primaryConstructor.getElements(); } public Cs.ClassDeclaration withPrimaryConstructor(@Nullable List primaryConstructor) { return getPadding().withPrimaryConstructor(JContainer.withElementsNullable(this.primaryConstructor, primaryConstructor)); } @Nullable JLeftPadded extendings; public @Nullable TypeTree getExtendings() { return extendings == null ? null : extendings.getElement(); } public Cs.ClassDeclaration withExtendings(@Nullable TypeTree extendings) { return getPadding().withExtendings(JLeftPadded.withElement(this.extendings, extendings)); } @Nullable JContainer implementings; public @Nullable List getImplementings() { return implementings == null ? null : implementings.getElements(); } public Cs.ClassDeclaration withImplementings(@Nullable List implementings) { return getPadding().withImplementings(JContainer.withElementsNullable(this.implementings, implementings)); } @With @Getter @Nullable Block body; @Nullable JContainer typeParameterConstraintClauses; @Nullable public List getTypeParameterConstraintClauses() { return typeParameterConstraintClauses == null ? null : typeParameterConstraintClauses.getElements(); } public Cs.ClassDeclaration withTypeParameterConstraintClauses(@Nullable List typeParameterConstraintClauses) { return getPadding().withTypeParameterConstraintClauses(JContainer.withElementsNullable(this.typeParameterConstraintClauses, typeParameterConstraintClauses)); } @Getter JavaType.@Nullable FullyQualified type; @SuppressWarnings("unchecked") @Override public Cs.ClassDeclaration withType(@Nullable JavaType type) { if (type == this.type) { return this; } if (type != null && !(type instanceof JavaType.FullyQualified)) { throw new IllegalArgumentException("A class can only be type attributed with a fully qualified type name"); } return new Cs.ClassDeclaration(id, prefix, markers, attributeList, modifiers, kind, name, typeParameters, primaryConstructor, extendings, implementings, body, typeParameterConstraintClauses, (JavaType.FullyQualified) type); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitClassDeclaration(this, p); } @Override @Transient public CoordinateBuilder.ClassDeclaration getCoordinates() { //todo: Setup coordinate builder - atm it's private // return new CoordinateBuilder.ClassDeclaration(this); return null; } 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 Cs.ClassDeclaration t; public @Nullable JContainer getPrimaryConstructor() { return t.primaryConstructor; } public Cs.ClassDeclaration withPrimaryConstructor(@Nullable JContainer primaryConstructor) { return t.primaryConstructor == primaryConstructor ? t : new Cs.ClassDeclaration(t.id, t.prefix, t.markers, t.attributeList, t.modifiers, t.kind, t.name, t.typeParameters, primaryConstructor, t.extendings, t.implementings, t.body, t.typeParameterConstraintClauses, t.type); } public @Nullable JLeftPadded getExtendings() { return t.extendings; } public Cs.ClassDeclaration withExtendings(@Nullable JLeftPadded extendings) { return t.extendings == extendings ? t : new Cs.ClassDeclaration(t.id, t.prefix, t.markers, t.attributeList, t.modifiers, t.kind, t.name, t.typeParameters, t.primaryConstructor, extendings, t.implementings, t.body, t.typeParameterConstraintClauses, t.type); } public @Nullable JContainer getImplementings() { return t.implementings; } public Cs.ClassDeclaration withImplementings(@Nullable JContainer implementings) { return t.implementings == implementings ? t : new Cs.ClassDeclaration(t.id, t.prefix, t.markers, t.attributeList, t.modifiers, t.kind, t.name, t.typeParameters, t.primaryConstructor, t.extendings, implementings, t.body, t.typeParameterConstraintClauses, t.type); } public J.ClassDeclaration.Kind getKind() { return t.kind; } public Cs.ClassDeclaration withKind(J.ClassDeclaration.Kind kind) { return t.kind == kind ? t : new Cs.ClassDeclaration(t.id, t.prefix, t.markers, t.attributeList, t.modifiers, kind, t.name, t.typeParameters, t.primaryConstructor, t.extendings, t.implementings, t.body, t.typeParameterConstraintClauses, t.type); } public @Nullable JContainer getTypeParameters() { return t.typeParameters; } public Cs.ClassDeclaration withTypeParameters(@Nullable JContainer typeParameters) { return t.typeParameters == typeParameters ? t : new Cs.ClassDeclaration(t.id, t.prefix, t.markers, t.attributeList, t.modifiers, t.kind, t.name, typeParameters, t.primaryConstructor, t.extendings, t.implementings, t.body, t.typeParameterConstraintClauses, t.type); } public @Nullable JContainer getTypeParameterConstraintClauses() { return t.typeParameterConstraintClauses; } public Cs.ClassDeclaration withTypeParameterConstraintClauses(@Nullable JContainer typeParameterConstraintClauses) { return t.typeParameterConstraintClauses == typeParameterConstraintClauses ? t : new Cs.ClassDeclaration(t.id, t.prefix, t.markers, t.attributeList, t.modifiers, t.kind, t.name, t.typeParameters, t.primaryConstructor, t.extendings, t.implementings, t.body, typeParameterConstraintClauses, t.type); } } } // CS specific method exists to allow for modelling for the following not possible in J version: // - implicit interface implementations // - Cs.AttributeList that may appear before any of the type variables // - generics constraints that appear on the end of the method declaration @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class MethodDeclaration implements Cs, Statement, TypedTree { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter List attributes; @With @Getter List modifiers; @Nullable JContainer typeParameters; @With @Getter TypeTree returnTypeExpression; @Nullable JRightPadded explicitInterfaceSpecifier; public TypeTree getExplicitInterfaceSpecifier() { return explicitInterfaceSpecifier.getElement(); } public Cs.MethodDeclaration withExplicitInterfaceSpecifier(TypeTree explicitInterfaceSpecifier) { return getPadding().withExplicitInterfaceSpecifier(this.explicitInterfaceSpecifier.withElement(explicitInterfaceSpecifier)); } @With @Getter Identifier name; JContainer parameters; public List getParameters() { return parameters.getElements(); } public Cs.MethodDeclaration withParameters(List parameters) { return getPadding().withParameters(JContainer.withElements(this.parameters, parameters)); } /** * Null for abstract method declarations and interface method declarations. */ @With @Getter @Nullable Block body; @Getter JavaType.@Nullable Method methodType; public Cs.MethodDeclaration withMethodType(JavaType.@Nullable Method type) { if (type == this.methodType) { return this; } return new Cs.MethodDeclaration(id, prefix, markers, attributes, modifiers, typeParameters, returnTypeExpression, explicitInterfaceSpecifier, name, parameters, body, type, typeParameterConstraintClauses); } JContainer typeParameterConstraintClauses; public List getTypeParameterConstraintClauses() { return typeParameterConstraintClauses.getElements(); } public Cs.MethodDeclaration withTypeParameterConstraintClauses(List typeParameterConstraintClauses) { return getPadding().withTypeParameterConstraintClauses(JContainer.withElementsNullable(this.typeParameterConstraintClauses, typeParameterConstraintClauses)); } @Override public JavaType getType() { return methodType == null ? null : methodType.getReturnType(); } @SuppressWarnings("unchecked") @Override public Cs.MethodDeclaration withType(@Nullable JavaType type) { throw new UnsupportedOperationException("To change the return type of this method declaration, use withMethodType(..)"); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitMethodDeclaration(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 Cs.MethodDeclaration t; public JContainer getParameters() { return t.parameters; } public Cs.MethodDeclaration withParameters(JContainer parameters) { return t.parameters == parameters ? t : new Cs.MethodDeclaration(t.id, t.prefix, t.markers, t.attributes, t.modifiers, t.typeParameters, t.returnTypeExpression, t.explicitInterfaceSpecifier, t.name, parameters, t.body, t.methodType, t.typeParameterConstraintClauses); } @Nullable public JRightPadded getExplicitInterfaceSpecifier() { return t.explicitInterfaceSpecifier; } public Cs.MethodDeclaration withExplicitInterfaceSpecifier(JRightPadded explicitInterfaceSpecifier) { return t.explicitInterfaceSpecifier == explicitInterfaceSpecifier ? t : new Cs.MethodDeclaration(t.id, t.prefix, t.markers, t.attributes, t.modifiers, t.typeParameters, t.returnTypeExpression, explicitInterfaceSpecifier, t.name, t.parameters, t.body, t.methodType, t.typeParameterConstraintClauses); } public @Nullable JContainer getTypeParameters() { return t.typeParameters; } public Cs.MethodDeclaration withTypeParameters(@Nullable JContainer typeParameters) { return t.typeParameters == typeParameters ? t : new Cs.MethodDeclaration(t.id, t.prefix, t.markers, t.attributes, t.modifiers, typeParameters, t.returnTypeExpression, t.explicitInterfaceSpecifier, t.name, t.parameters, t.body, t.methodType, t.typeParameterConstraintClauses); } public @Nullable JContainer getTypeParameterConstraintClauses() { return t.typeParameterConstraintClauses; } public Cs.MethodDeclaration withTypeParameterConstraintClauses(@Nullable JContainer typeParameterConstraintClauses) { return t.typeParameterConstraintClauses == typeParameterConstraintClauses ? t : new Cs.MethodDeclaration(t.id, t.prefix, t.markers, t.attributes, t.modifiers, t.typeParameters, t.returnTypeExpression, t.explicitInterfaceSpecifier, t.name, t.parameters, t.body, t.methodType, typeParameterConstraintClauses); } } } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class UsingStatement implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Nullable @Getter Keyword awaitKeyword; JLeftPadded expression; public Expression getExpression() { return expression.getElement(); } public UsingStatement withExpression(Expression expression) { return getPadding().withExpression(this.expression.withElement(expression)); } /** * The block is null for using declaration form. */ @With @Getter Statement statement; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitUsingStatement(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 UsingStatement t; public JLeftPadded getExpression() { return t.expression; } public UsingStatement withExpression(JLeftPadded expression) { return t.expression == expression ? t : new UsingStatement(t.id, t.prefix, t.markers, t.awaitKeyword, expression, t.statement); } } } //endregion @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class TypeParameterConstraintClause implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** * class A<T> where T : class */ JRightPadded typeParameter; /** * class A<T> where T : class, ISomething */ JContainer typeParameterConstraints; public Identifier getTypeParameter() { return typeParameter.getElement(); } public TypeParameterConstraintClause withTypeParameter(Identifier typeParameter) { return getPadding().withTypeParameter(JRightPadded.withElement(this.typeParameter, typeParameter)); } public List getTypeParameterConstraints() { return typeParameterConstraints.getElements(); } public TypeParameterConstraintClause withTypeParameterConstraints(List typeParameterConstraints) { return getPadding().withTypeParameterConstraints(JContainer.withElementsNullable(this.typeParameterConstraints, typeParameterConstraints)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitTypeParameterConstraintClause(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 TypeParameterConstraintClause t; public @Nullable JRightPadded getTypeParameter() { return t.typeParameter; } public TypeParameterConstraintClause withTypeParameter(@Nullable JRightPadded typeParameter) { return t.typeParameter == typeParameter ? t : new TypeParameterConstraintClause(t.id, t.prefix, t.markers, typeParameter, t.typeParameterConstraints); } public @Nullable JContainer getTypeParameterConstraints() { return t.typeParameterConstraints; } public TypeParameterConstraintClause withTypeParameterConstraints(@Nullable JContainer typeConstraints) { return t.typeParameterConstraints == typeConstraints ? t : new TypeParameterConstraintClause(t.id, t.prefix, t.markers, t.typeParameter, typeConstraints); } } } interface TypeParameterConstraint extends J { } /** * Represents a type constraint in a type parameter's constraint clause. * Example: where T : SomeClass * where T : IInterface */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class TypeConstraint implements Cs, TypeParameterConstraint, TypedTree { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter TypeTree typeExpression; @Override public JavaType getType() { return typeExpression.getType(); } @Override public TypeConstraint withType(@Nullable JavaType type) { return getPadding().withType(this.typeExpression.withType(type)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitTypeConstraint(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.pd != this) { p = new Padding(this); this.padding = new WeakReference<>(p); } } return p; } @RequiredArgsConstructor public static class Padding { private final TypeConstraint pd; public TypeTree getType() { return pd.typeExpression; } public TypeConstraint withType(TypeTree type) { return pd.typeExpression == type ? pd : new TypeConstraint(pd.id, pd.prefix, pd.markers, type); } } } /* ------------------ */ interface AllowsConstraint extends J { } /** * Represents an `allows` constraint in a where clause. * Example: where T : allows operator + */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class AllowsConstraintClause implements Cs, TypeParameterConstraint { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; JContainer expressions; public List getExpressions() { return expressions.getElements(); } public AllowsConstraintClause withExpressions(List expressions) { return getPadding().withExpressions(JContainer.withElements(this.expressions, expressions)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitAllowsConstraintClause(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 AllowsConstraintClause t; public JContainer getExpressions() { return t.expressions; } public AllowsConstraintClause withExpressions(JContainer expressions) { return t.expressions == expressions ? t : new AllowsConstraintClause(t.id, t.prefix, t.markers, expressions); } } } /** * Represents a ref struct constraint in a where clause. * Example: where T : allows ref struct */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor final class RefStructConstraint implements Cs, AllowsConstraint { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitRefStructConstraint(this, p); } } /** * Represents a class/struct constraint in a where clause. * Example: where T : class, where T : struct */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor final class ClassOrStructConstraint implements Cs, TypeParameterConstraint { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter TypeKind kind; public enum TypeKind { Class, Struct } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitClassOrStructConstraint(this, p); } } /** * Represents a constructor constraint in a where clause. * Example: *

     * where T : new()
     *           ^^^^^
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor final class ConstructorConstraint implements Cs, TypeParameterConstraint { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitConstructorConstraint(this, p); } } /** * Represents a default constraint in a where clause. * Example: *

     * where T : default
     *           ^^^^^^^
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor final class DefaultConstraint implements Cs, TypeParameterConstraint { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @Override 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, y) = GetPoint()}
  • *
* Example 1: Out variable declaration: *
     * if(int.TryParse(s, out int result)) {
     *     // use result
     * }
     * 
* Example 2: Deconstruction declaration: *
     * int (x, y) = point;
     * ^^^^^^^^^^
     * (int count, var (name, age)) = GetPersonDetails();
     *             ^^^^^^^^^^^^^^^ DeclarationExpression
     *                 ^^^^^^^^^^^ ParenthesizedVariableDesignation
     *  ^^^^^^^^^ DeclarationExpression
     *      ^^^^^ SingleVariableDesignation
     * 
*/ @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); } } //region VariableDesignation /** * 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 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 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. * Example of simple deconstruction: *

     * int (x, y) = point;
     * 
* Example of nested deconstruction: *
     * (int count, var (string name, int age)) = GetPersonDetails();
     *             ^^^^^^^^^^^^^^^^^^^^^^^^^^ nested ParenthesizedVariable
     *  ^^^^^^^^^ SingleVariableDesignation
     * 
*/ @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: *

     *
     * if (obj is _) // discard pattern
     *
     * // Or in deconstruction:
     *
     * 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 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); } } //endregion /** * Represents a tuple expression in C#. * Can be used in tuple construction, deconstruction and tuple literals. * Examples: *

     * // 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); } } /** * Represents a C# destructor which is a method called before an object is destroyed by the garbage collector. * A destructor must be named the same as the class prefixed with a tilde (~), cannot be explicitly called, * cannot have parameters or access modifiers, and cannot be overloaded or inherited. *

* For example: *

     *     // Basic destructor
     *     ~MyClass()
     *     {
     *         // Cleanup code
     *     }
     *
     *     // Destructor with cleanup logic
     *     ~ResourceHandler()
     *     {
     *         if (handle != IntPtr.Zero)
     *         {
     *             CloseHandle(handle);
     *         }
     *     }
     *
     *     // Class with both constructor and destructor
     *     public class FileWrapper
     *     {
     *         public FileWrapper()
     *         {
     *             // Initialize
     *         }
     *
     *         ~FileWrapper()
     *         {
     *             // Cleanup
     *         }
     *     }
     * 
*

* Note: In modern C#, it's recommended to implement IDisposable pattern instead of relying on destructors * for deterministic cleanup of resources, as destructors are non-deterministic and can impact performance. */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) public class DestructorDeclaration implements Cs, Statement { @Getter @With @EqualsAndHashCode.Include UUID id; @Getter @With Space prefix; @Getter @With Markers markers; @Getter @With J.MethodDeclaration methodCore; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitDestructorDeclaration(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, /** * Represent *int pointer types syntax */ PointerIndirection, /** * Represent &a for pointer value access */ AddressOf, /** * Represent [^3] syntax */ FromEnd; // [^3] 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: *

     * 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 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 arguments) { return t.arguments == arguments ? t : new ConstructorInitializer(t.id, t.prefix, t.markers, t.keyword, arguments); } } } /** * Represents a C# tuple type specification, which allows grouping multiple types into a single type. * Can be used in method returns, variable declarations, etc. *

* For example: *

     *   // Simple tuple type
     *   (int, string) coordinates;
     *
     *   // Tuple type with named elements
     *   (int x, string label) namedTuple;
     *
     *   // Nested tuple types
     *   (int, (string, bool)) complexTuple;
     *
     *   // As method return type
     *   public (string name, int age) GetPersonDetails() { }
     *
     *   // As parameter type
     *   public void ProcessData((int id, string value) data) { }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) public class TupleType implements Cs, TypeTree, Expression { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; JContainer elements; @With @Nullable @Getter JavaType type; public List getElements() { return elements.getElements(); } public TupleType withElements(List elements) { return getPadding().withElements(JContainer.withElements(this.elements, elements)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitTupleType(this, p); } @Override 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 TupleType t; public JContainer getElements() { return t.elements; } public TupleType withElements(JContainer elements) { return t.elements == elements ? t : new TupleType(t.id, t.prefix, t.markers, elements, t.type); } } } /** * Represents a single element within a tuple type, which may include an optional * identifier for named tuple elements. */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) public class TupleElement implements Cs { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter TypeTree type; @With @Getter @Nullable Identifier name; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitTupleElement(this, p); } } /** * Represents a C# new class instantiation expression, which can optionally include an object/collection initializer. *

* For example: *

     * // Simple new class without initializer
     * new Person("John", 25)
     *
     * // New class with object initializer
     * new Person { Name = "John", Age = 25 }
     *
     * // New class with collection initializer
     * new List { 1, 2, 3 }
     *
     * // New class with constructor and initializer
     * new Person("John") { Age = 25 }
     * 
* The newClassCore field contains the basic class instantiation including constructor call, * while the initializer field contains the optional object/collection initializer expressions * wrapped in a JContainer to preserve whitespace around curly braces and between initializer expressions. */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor final class NewClass implements Cs, Statement, Expression { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter J.NewClass newClassCore; @With @Getter @Nullable InitializerExpression initializer; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitNewClass(this, p); } @Override public @Nullable JavaType getType() { return newClassCore.getType(); } @Override public Cs.NewClass withType(@Nullable JavaType type) { return newClassCore.getType() == type ? this : new Cs.NewClass(id, prefix, markers, newClassCore.withType(type), initializer); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } } /** * Represents an initializer expression that consists of a list of expressions, typically used in array * or collection initialization contexts. The expressions are contained within delimiters like curly braces. *

* For example: *

     * new int[] { 1, 2, 3 }
     *            ^^^^^^^^^
     * new List { "a", "b", "c" }
     *                   ^^^^^^^^^^^^^^^
     * 
* The JContainer wrapper captures whitespace before the opening brace, while also preserving whitespace * after each expression (before commas) through its internal JRightPadded elements. */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class InitializerExpression implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; JContainer expressions; public List getExpressions() { return expressions.getElements(); } public InitializerExpression withExpressions(List expressions) { return getPadding().withExpressions(JContainer.withElements(this.expressions, expressions)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitInitializerExpression(this, p); } @Override public @Nullable JavaType getType() { return null; } @Override public InitializerExpression withType(@Nullable JavaType type) { return this; } @Override 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 InitializerExpression t; public JContainer getExpressions() { return t.expressions; } public InitializerExpression withExpressions(JContainer expressions) { return t.expressions == expressions ? t : new InitializerExpression(t.id, t.prefix, t.markers, expressions); } } } /** * Represents implicit element access in C# which allows accessing elements without specifying the element accessor target. * This is commonly used in object initializers, collection initializers and anonymous object initializers. *

* For example: *

     * // Collection initializer
     * new List {
     *     { 10, 20 }, // ImplicitElementAccess with two arguments
     *     { 30, 40 }
     * }
     *
     * // Object initializer
     * new Dictionary {
     *     { "key1", "value1" }, // ImplicitElementAccess wrapping key-value pair arguments
     *     { "key2", "value2" }
     * }
     * 
* The argumentList field contains the list of arguments wrapped in braces, with whitespace preserved * before the opening brace and between arguments. */ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ImplicitElementAccess implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; JContainer argumentList; public List getArgumentList() { return argumentList.getElements(); } public ImplicitElementAccess withArgumentList(List argumentList) { return getPadding().withArgumentList(JContainer.withElements(this.argumentList, argumentList)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitImplicitElementAccess(this, p); } @Override public @Nullable JavaType getType() { return null; } @Override public ImplicitElementAccess withType(@Nullable JavaType type) { return this; } @Override 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 ImplicitElementAccess t; public JContainer getArgumentList() { return t.argumentList; } public ImplicitElementAccess withArgumentList(JContainer argumentList) { return t.argumentList == argumentList ? t : new ImplicitElementAccess(t.id, t.prefix, t.markers, argumentList); } } } /** * Represents a C# yield statement which can either return a value or break from an iterator. *

* For example: *

     *   yield return value;   // Returns next value in iterator
     *   yield break;          // Signals end of iteration
     * 
*/ @Getter @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class Yield implements Cs, Statement { @With @EqualsAndHashCode.Include UUID id; @With Space prefix; @With Markers markers; @With Keyword returnOrBreakKeyword; @With @Nullable Expression expression; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitYield(this, p); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } } /** * An expression that yields the default value of a type. *

* For example: *

     *   default(int)         // Returns 0
     *   default(string)      // Returns null
     *   default(bool)        // Returns false
     *   default(MyClass)     // Returns null
     *   var x = default;     // Type inferred from context (C# 7.1+)
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class DefaultExpression implements Cs, Expression, TypedTree { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @Nullable JContainer typeOperator; public List getTypeOperator() { return typeOperator == null ? Collections.emptyList() : typeOperator.getElements(); } public DefaultExpression withTypeOperator(@Nullable List typeOperator) { return getPadding().withTypeOperator(JContainer.withElementsNullable(this.typeOperator, typeOperator)); } @Override public @Nullable JavaType getType() { List types = getTypeOperator(); return types.isEmpty() ? null : types.get(0).getType(); } @Override public DefaultExpression withType(@Nullable JavaType javaType) { List types = getTypeOperator(); if (types.isEmpty()) { return this; } return withTypeOperator(ListUtils.map(types, t -> t.withType(javaType))); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitDefaultExpression(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 static class Padding { private final DefaultExpression t; public @Nullable JContainer getTypeOperator() { return t.typeOperator; } public DefaultExpression withTypeOperator(@Nullable JContainer typeOperator) { return t.typeOperator == typeOperator ? t : new DefaultExpression(t.id, t.prefix, t.markers, typeOperator); } } } /** * Represents a C# is pattern expression that performs pattern matching. * The expression consists of a value to test, followed by the 'is' keyword and a pattern. *

* For example: *

     *     // Type pattern
     *     if (obj is string)
     *
     *     // Type pattern with declaration
     *     if (obj is string str)
     *
     *     // Constant pattern
     *     if (number is 0)
     *
     *     // Property pattern
     *     if (person is { Name: "John", Age: 25 })
     *
     *     // Relational pattern
     *     if (number is > 0)
     *
     *     // Var pattern
     *     if (expr is var result)
     *
     *     // List pattern
     *     if (list is [1, 2, 3])
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class IsPattern implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter Expression expression; JLeftPadded pattern; public Pattern getPattern() { return pattern.getElement(); } public IsPattern withPattern(Pattern pattern) { return getPadding().withPattern(this.pattern.withElement(pattern)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitIsPattern(this, p); } @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public IsPattern 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 IsPattern t; public JLeftPadded getPattern() { return t.pattern; } public IsPattern withPattern(JLeftPadded pattern) { return t.pattern == pattern ? t : new IsPattern(t.id, t.prefix, t.markers, t.expression, pattern); } } } //region Patterns /** * Base interface for all C# pattern types that can appear on the right-hand side of an 'is' expression. * This includes type patterns, constant patterns, declaration patterns, property patterns, etc. */ interface Pattern extends Expression, Cs { } /** * Represents a unary pattern in C#, which negates another pattern using the "not" keyword. *

* For example: *

     *     // Using "not" pattern to negate a type pattern
     *     if (obj is not string) { }
     *
     *     // Using "not" pattern with constant pattern
     *     if (value is not 0) { }
     *
     *     // Using "not" pattern with other patterns
     *     switch (obj) {
     *         case not null: // Negates null constant pattern
     *             break;
     *         case not int: // Negates type pattern
     *             break;
     *     }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class UnaryPattern implements Cs, Pattern, Expression { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * a is not b
         *      ^^^
         * 
*/ @With @Getter Keyword operator; @With @Getter Pattern pattern; @Override public @Nullable JavaType getType() { return JavaType.Primitive.Boolean; } @Override public UnaryPattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitUnaryPattern(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a C# type pattern, which matches a value against a type and optionally assigns it to a new variable. *

* For example: *

     *     // Simple type pattern
     *     if (obj is string)
     *
     *     // Type pattern with variable declaration
     *     if (obj is string str)
     *
     *     // Type pattern with array type
     *     if (obj is int[])
     *
     *     // Type pattern with generic type
     *     if (obj is List<string> stringList)
     *
     *     // Type pattern with nullable type
     *     if (obj is string? nullableStr)
     *
     *     // Switch expression with type pattern
     *     object value = someValue switch {
     *         string s => s.Length,
     *         int n => n * 2,
     *         _ => 0
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class TypePattern implements Pattern { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter TypeTree typeIdentifier; @Nullable @With @Getter VariableDesignation designation; @Override public JavaType getType() { return typeIdentifier.getType(); } @Override public TypePattern withType(@Nullable JavaType type) { return withType(this.typeIdentifier.withType(type)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitTypePattern(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a C# binary pattern that combines two patterns with a logical operator. * The binary pattern is used in pattern matching to create compound pattern tests. *

* For example: *

     *     // Using 'and' to combine patterns
     *     if (obj is string { Length: > 0 } and not null)
     *
     *     // Using 'or' to combine patterns
     *     if (number is > 0 or < -10)
     *
     *     // Combining type patterns
     *     if (obj is IList and not string)
     *
     *     // Complex combinations
     *     if (value is >= 0 and <= 100)
     *
     *     // Multiple binary patterns
     *     if (obj is IEnumerable and not string and not int[])
     *
     *     // In switch expressions
     *     return size switch {
     *         < 0 or > 100 => "Invalid",
     *         >= 0 and <= 50 => "Small",
     *         _ => "Large"
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class BinaryPattern implements Pattern { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter Pattern left; JLeftPadded operator; @With @Getter Pattern right; public OperatorType getOperator() { return operator.getElement(); } public BinaryPattern withOperator(OperatorType operator) { return getPadding().withOperator(this.operator.withElement(operator)); } public enum OperatorType { And, Or } @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public BinaryPattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitBinaryPattern(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 static class Padding { private final BinaryPattern t; public JLeftPadded getOperator() { return t.operator; } public BinaryPattern withOperator(JLeftPadded operator) { return t.operator == operator ? t : new BinaryPattern(t.id, t.prefix, t.markers, t.left, operator, t.right); } } } /** * Represents a C# constant pattern that matches against literal values or constant expressions. *

* For example: *

     *     // Literal constant patterns
     *     if (obj is null)
     *     if (number is 42)
     *     if (flag is true)
     *     if (ch is 'A')
     *     if (str is "hello")
     *
     *     // Constant expressions
     *     const int MAX = 100;
     *     if (value is MAX)
     *
     *     // In switch expressions
     *     return value switch {
     *         null => "undefined",
     *         0 => "zero",
     *         1 => "one",
     *         _ => "other"
     *     };
     *
     *     // With other pattern combinations
     *     if (str is not null and "example")
     *
     *     // Enum constant patterns
     *     if (day is DayOfWeek.Sunday)
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class ConstantPattern implements Pattern { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (obj is 42)
         *            ^^
         * 
*/ @With @Getter Expression value; @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public ConstantPattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitConstantPattern(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a C# discard pattern (_), which matches any value and discards it. *

* For example: *

     *     // Simple discard pattern in is expression
     *     if (obj is _)
     *
     *     // In switch expressions
     *     return value switch {
     *         1 => "one",
     *         2 => "two",
     *         _ => "other"    // Discard pattern as default case
     *     };
     *
     *     // With relational patterns
     *     if (value is > 0 and _)
     *
     *     // In property patterns
     *     if (obj is { Id: _, Name: "test" })
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class DiscardPattern implements Pattern { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter JavaType type; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitDiscardPattern(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a C# list pattern that matches elements in a list or array against a sequence of patterns. *

* For example: *

     *     // Simple list patterns
     *     if (array is [1, 2, 3] lst)
     *     if (list is [1, _, 3])
     *
     *     // With designation
     *     if (points is [(0, 0), (1, 1)] coords)
     *
     *     // With slices
     *     if (numbers is [1, .., 5] sequence)
     *     if (values is [1, 2, .., 8, 9] arr)
     *
     *     // With subpatterns
     *     if (points is [(0, 0), (1, 1)])
     *
     *     // With type patterns
     *     if (list is [int i, string s] result)
     *
     *     // In switch expressions
     *     return array switch {
     *         [var first, _] arr => arr.Length,
     *         [1, 2, ..] seq => "starts with 1,2",
     *         [] empty => "empty",
     *         _ => "other"
     *     };
     *
     *     // With length patterns
     *     if (array is [> 0, <= 10] valid)
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ListPattern implements Pattern { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (array is [1, 2, 3] lst)
         *              ^^^^^^^^^
         * 
*/ JContainer patterns; /** *
         * if (array is [1, 2, 3] lst)
         *                        ^^^
         * 
*/ @With @Getter @Nullable VariableDesignation designation; public List getPatterns() { return patterns.getElements(); } public ListPattern withPatterns(List patterns) { return getPadding().withPatterns(JContainer.withElements(this.patterns, patterns)); } @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public ListPattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitListPattern(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 static class Padding { private final ListPattern t; public JContainer getPatterns() { return t.patterns; } public ListPattern withPatterns(JContainer patterns) { return t.patterns == patterns ? t : new ListPattern(t.id, t.prefix, t.markers, patterns, t.designation); } } } /** * Represents a C# parenthesized pattern expression that groups a nested pattern. *

* For example: *

     *     // Simple parenthesized pattern
     *     if (obj is (string or int))
     *
     *     // With nested patterns
     *     if (obj is not (null or ""))
     *
     *     // In complex pattern combinations
     *     if (value is > 0 and (int or double))
     *
     *     // In switch expressions
     *     return value switch {
     *         (> 0 and < 10) => "single digit",
     *         (string or int) => "basic type",
     *         _ => "other"
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class ParenthesizedPattern implements Pattern { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (obj is (string or int))
         *            ^^^^^^^^^^^^^^^
         * 
*/ JContainer pattern; public List getPattern() { return pattern.getElements(); } public ParenthesizedPattern withPattern(List pattern) { return getPadding().withPattern(JContainer.withElements(this.pattern, pattern)); } @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public ParenthesizedPattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitParenthesizedPattern(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 static class Padding { private final ParenthesizedPattern t; public JContainer getPattern() { return t.pattern; } public ParenthesizedPattern withPattern(JContainer pattern) { return t.pattern == pattern ? t : new ParenthesizedPattern(t.id, t.prefix, t.markers, pattern); } } } /** * Represents a C# recursive pattern that can match nested object structures, including property patterns and positional patterns. *

* For example: *

     *     // Simple property pattern
     *     if (obj is { Name: "test", Age: > 18 })
     *
     *     // With type pattern
     *     if (obj is Person { Name: "test" } p)
     *
     *     // With nested patterns
     *     if (obj is { Address: { City: "NY" } })
     *
     *     // Positional patterns (deconstructions)
     *     if (point is (int x, int y) { x: > 0, y: > 0 })
     *
     *     // With variable designation
     *     if (obj is { Id: int id, Name: string name } result)
     *
     *     // In switch expressions
     *     return shape switch {
     *         Circle { Radius: var r } => Math.PI * r * r,
     *         Rectangle { Width: var w, Height: var h } => w * h,
     *         _ => 0
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class RecursivePattern implements Pattern { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (obj is Person { Name: "test" })
         *            ^^^^^^
         * 
*/ @With @Getter @Nullable TypeTree typeQualifier; /** *
         * if (point is (int x, int y))
         *              ^^^^^^^^^^^^^^
         * 
*/ @With @Getter @Nullable PositionalPatternClause positionalPattern; /** *
         * if (obj is { Name: "test", Age: 18 })
         *            ^^^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ @With @Getter @Nullable PropertyPatternClause propertyPattern; /** *
         * if (obj is Person { Name: "test" } p)
         *                                    ^
         * 
*/ @With @Getter @Nullable VariableDesignation designation; @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public RecursivePattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitRecursivePattern(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a var pattern that is used in switch statement pattern matching. *

     * case var (x, y):
     *      ^^^
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class VarPattern implements Cs, Pattern { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * case var (x, y):
         *          ^^^^^^
         * 
*/ @With @Getter VariableDesignation designation; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitVarPattern(this, p); } @Override public @Nullable JavaType getType() { return designation.getType(); } @Override public VarPattern withType(@Nullable JavaType type) { return withDesignation(designation.withType(type)); } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a positional pattern clause in C# pattern matching, which matches the deconstructed parts of an object. *

* For example: *

     *     // Simple positional pattern
     *     if (point is (0, 0))
     *
     *     // With variable declarations
     *     if (point is (int x, int y))
     *
     *     // With nested patterns
     *     if (point is (> 0, < 100))
     *
     *     // In switch expressions
     *     return point switch {
     *         (0, 0) => "origin",
     *         (var x, var y) when x == y => "on diagonal",
     *         _ => "other"
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class PositionalPatternClause implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (point is (0, 0))
         *              ^^^^^^
         * 
*/ JContainer subpatterns; public List getSubpatterns() { return subpatterns.getElements(); } public PositionalPatternClause withSubpatterns(List subpatterns) { return getPadding().withSubpatterns(JContainer.withElements(this.subpatterns, subpatterns)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitPositionalPatternClause(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 PositionalPatternClause t; public JContainer getSubpatterns() { return t.subpatterns; } public PositionalPatternClause withSubpatterns(JContainer subpatterns) { return t.subpatterns == subpatterns ? t : new PositionalPatternClause(t.id, t.prefix, t.markers, subpatterns); } } } /** * Represents a C# relational pattern that matches values using comparison operators. *

* For example: *

     *     // Simple relational patterns
     *     if (number is > 0)
     *     if (value is <= 100)
     *
     *     // In switch expressions
     *     return size switch {
     *         > 100 => "Large",
     *         < 0 => "Invalid",
     *         _ => "Normal"
     *     };
     *
     *     // Combined with other patterns
     *     if (x is > 0 and < 100)
     *
     *     // With properties
     *     if (person is { Age: >= 18 })
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class RelationalPattern implements Pattern { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (number is > 100)
         *               ^
         * 
*/ JLeftPadded operator; /** *
         * if (number is > 100)
         *                 ^^^
         * 
*/ @With @Getter Expression value; public OperatorType getOperator() { return operator.getElement(); } public RelationalPattern withOperator(OperatorType operator) { return getPadding().withOperator(this.operator.withElement(operator)); } public enum OperatorType { LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual } @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public RelationalPattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitRelationalPattern(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 static class Padding { private final RelationalPattern t; public JLeftPadded getOperator() { return t.operator; } public RelationalPattern withOperator(JLeftPadded operator) { return t.operator == operator ? t : new RelationalPattern(t.id, t.prefix, t.markers, operator, t.value); } } } /** * Represents a C# slice pattern that matches sequences with arbitrary elements between fixed elements. *

* For example: *

     *     // Simple slice pattern
     *     if (array is [1, .., 5])
     *
     *     // Multiple elements before and after
     *     if (array is [1, 2, .., 8, 9])
     *
     *     // Just prefix elements
     *     if (array is [1, 2, ..])
     *
     *     // Just suffix elements
     *     if (array is [.., 8, 9])
     *
     *     // In switch expressions
     *     return array switch {
     *         [var first, .., var last] => $"{first}..{last}",
     *         [var single] => single.ToString(),
     *         [] => "empty"
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class SlicePattern implements Pattern { @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @Override public JavaType getType() { return JavaType.Primitive.Boolean; } @Override public SlicePattern withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitSlicePattern(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a property pattern clause in C# pattern matching, which matches against object properties. *

* For example: *

     *     // Simple property pattern
     *     if (obj is { Name: "test" })
     *
     *     // Multiple properties
     *     if (person is { Name: "John", Age: > 18 })
     *
     *     // Nested property patterns
     *     if (order is { Customer: { Name: "test" } })
     *
     *     // With variable declarations
     *     if (person is { Id: int id, Name: string name })
     *
     *     // In switch expressions
     *     return shape switch {
     *         { Type: "circle", Radius: var r } => Math.PI * r * r,
     *         { Type: "square", Side: var s } => s * s,
     *         _ => 0
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class PropertyPatternClause implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (obj is { Name: "test", Age: 18 })
         *            ^^^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ JContainer subpatterns; public List getSubpatterns() { return subpatterns.getElements(); } public PropertyPatternClause withSubpatterns(List subpatterns) { return getPadding().withSubpatterns(JContainer.withElements(this.subpatterns, subpatterns)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitPropertyPatternClause(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 PropertyPatternClause t; public JContainer getSubpatterns() { return t.subpatterns; } public PropertyPatternClause withSubpatterns(JContainer subpatterns) { return t.subpatterns == subpatterns ? t : new PropertyPatternClause(t.id, t.prefix, t.markers, subpatterns); } } } /** * Represents a subpattern in C# pattern matching, which can appear in property patterns or positional patterns. * Each subpattern consists of an optional name with a corresponding pattern. *

* For example: *

     *     // In property patterns
     *     if (obj is { Name: "test", Age: > 18 })
     *                  ^^^^^^^^^^^^  ^^^^^^^^^
     *
     *     // In positional patterns
     *     if (point is (x: > 0, y: > 0))
     *                   ^^^^^^  ^^^^^^
     *
     *     // With variable declarations
     *     if (person is { Id: var id, Name: string name })
     *                     ^^^^^^^^^^  ^^^^^^^^^^^^^^^^^
     *
     *     // Nested patterns
     *     if (obj is { Address: { City: "NY" } })
     *                  ^^^^^^^^^^^^^^^^^^^^^^^
     *
     *     // In switch expressions
     *     return shape switch {
     *         { Radius: var r } => Math.PI * r * r,
     *           ^^^^^^^^^^^
     *         { Width: var w, Height: var h } => w * h,
     *           ^^^^^^^^^^^^  ^^^^^^^^^^^^^
     *         _ => 0
     *     };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class Subpattern implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @Getter @EqualsAndHashCode.Include UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * if (obj is { Name: "test" })
         *               ^^^^
         * if (point is (x: > 0))
         *               ^
         * 
*/ @With @Getter @Nullable Expression name; /** *
         * if (obj is { Name: "test" })
         *                    ^^^^^
         * if (point is (x: > 0))
         *                  ^^
         * 
*/ JLeftPadded pattern; public Pattern getPattern() { return pattern.getElement(); } public Subpattern withPattern(Pattern pattern) { return getPadding().withPattern(this.pattern.withElement(pattern)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitSubpattern(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 Subpattern t; public JLeftPadded getPattern() { return t.pattern; } public Subpattern withPattern(JLeftPadded pattern) { return t.pattern == pattern ? t : new Subpattern(t.id, t.prefix, t.markers, t.name, pattern); } } } //endregion /** * Represents a C# switch expression which provides a concise way to handle multiple patterns with corresponding expressions. *

* For example: *

     * var description = size switch {
     *     < 0 => "negative",
     *     0 => "zero",
     *     > 0 => "positive"
     * };
     *
     * var color = (r, g, b) switch {
     *     var (r, g, b) when r == g && g == b => "grayscale",
     *     ( > 128, _, _) => "bright red",
     *     _ => "other"
     * };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class SwitchExpression implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * size switch { ... }
         * ^^^^
         * 
*/ JRightPadded expression; public Expression getExpression() { return expression.getElement(); } public Cs.SwitchExpression withExpression(Expression expression) { return getPadding().withExpression(this.expression.withElement(expression)); } /** *
         * size switch { ... }
         *             ^^^^^
         * 
*/ JContainer arms; public List getArms() { return arms.getElements(); } public Cs.SwitchExpression withArms(List arms) { return getPadding().withArms(JContainer.withElements(this.arms, arms)); } @Override public JavaType getType() { return arms.getElements().isEmpty() ? null : arms.getElements().get(0).getExpression().getType(); } @Override public Cs.SwitchExpression withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitSwitchExpression(this, p); } @Override 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 Cs.SwitchExpression t; public JRightPadded getExpression() { return t.expression; } public Cs.SwitchExpression withExpression(JRightPadded expression) { return t.expression == expression ? t : new Cs.SwitchExpression(t.id, t.prefix, t.markers, expression, t.arms); } public JContainer getArms() { return t.arms; } public Cs.SwitchExpression withArms(JContainer arms) { return t.arms == arms ? t : new Cs.SwitchExpression(t.id, t.prefix, t.markers, t.expression, arms); } } } /** * Represents a single case arm in a switch expression, consisting of a pattern, optional when clause, and result expression. *

* For example: *

     * case < 0 when IsValid() => "negative",
     * > 0 => "positive",
     * _ => "zero"
     *
     * // With complex patterns and conditions
     * (age, role) switch {
     *     ( > 21, "admin") when HasPermission() => "full access",
     *     ( > 18, _) => "basic access",
     *     _ => "no access"
     * }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class SwitchExpressionArm implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * < 0 when IsValid() => "negative"
         * ^^^
         * 
*/ @With @Getter Pattern pattern; /** *
         * < 0 when IsValid() => "negative"
         *     ^^^^^^^^^^^^^^
         * 
*/ @Nullable JLeftPadded whenExpression; public @Nullable Expression getWhenExpression() { return whenExpression == null ? null : whenExpression.getElement(); } public SwitchExpressionArm withWhenExpression(@Nullable Expression whenExpression) { return getPadding().withWhenExpression(JLeftPadded.withElement(this.whenExpression, whenExpression)); } /** *
         * < 0 when IsValid() => "negative"
         *                       ^^^^^^^^^^
         * 
*/ JLeftPadded expression; public Expression getExpression() { return expression.getElement(); } public SwitchExpressionArm withExpression(Expression expression) { return getPadding().withExpression(this.expression.withElement(expression)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitSwitchExpressionArm(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 SwitchExpressionArm t; public @Nullable JLeftPadded getWhenExpression() { return t.whenExpression; } public SwitchExpressionArm withWhenExpression(@Nullable JLeftPadded whenExpression) { return t.whenExpression == whenExpression ? t : new SwitchExpressionArm(t.id, t.prefix, t.markers, t.pattern, whenExpression, t.expression); } public JLeftPadded getExpression() { return t.expression; } public SwitchExpressionArm withExpression(JLeftPadded expression) { return t.expression == expression ? t : new SwitchExpressionArm(t.id, t.prefix, t.markers, t.pattern, t.whenExpression, expression); } } } /** * Represents a switch statement section containing one or more case labels followed by a list of statements. *

* For example: *

     * switch(value) {
     *     case 1:                    // single case label
     *     case 2:                    // multiple case labels
     *         Console.WriteLine("1 or 2");
     *         break;
     *
     *     case int n when n > 0:     // pattern case with when clause
     *         Console.WriteLine("positive");
     *         break;
     *
     *     case Person { Age: > 18 }: // recursive pattern
     *         Console.WriteLine("adult");
     *         break;
     *
     *     default:                   // default label
     *         Console.WriteLine("default");
     *         break;
     * }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class SwitchSection implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * case 1:
         * case 2:
         * ^^^^^^^
         * 
*/ @Getter @With List labels; /** *
         * case 1:
         *     Console.WriteLine("1");
         *     break;
         *     ^^^^^^^^^^^^^^^^^^^^
         * 
*/ List> statements; public List getStatements() { return JRightPadded.getElements(statements); } public SwitchSection withStatements(List statements) { return getPadding().withStatements(JRightPadded.withElements(this.statements, statements)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitSwitchSection(this, p); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 SwitchSection t; public List> getStatements() { return t.statements; } public SwitchSection withStatements(List> statements) { return t.statements == statements ? t : new SwitchSection(t.id, t.prefix, t.markers, t.labels, statements); } } } public interface SwitchLabel extends Expression { } /** * Represents a default case label in a switch statement. *

* For example: *

     * switch(value) {
     *     case 1:
     *         break;
     *     default:      // default label
     *         Console.WriteLine("default");
     *         break;
     * }
     *
     * // Also used in switch expressions
     * var result = value switch {
     *     1 => "one",
     *     default => "other"
     * };
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class DefaultSwitchLabel implements Cs, SwitchLabel, Expression { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * default:
         *        ^
         * 
*/ @With @Getter Space colonToken; @Override public JavaType getType() { return null; } @Override public DefaultSwitchLabel withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitDefaultSwitchLabel(this, p); } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } /** * Represents a pattern-based case label in a switch statement, optionally including a when clause. *

* For example: *

     * switch(obj) {
     *     case int n when n > 0:
     *     case string s when s.Length > 0:
     *     case [] when IsValid():
     *     case Person { Age: > 18 }:
     *     case not null:
     *     case > 100:
     * }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class CasePatternSwitchLabel implements Cs, SwitchLabel { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * case int n when n > 0:
         *      ^^^^^
         * 
*/ @With @Getter Pattern pattern; /** *
         * case int n when n > 0:
         *            ^^^^^^^^^^
         * 
*/ @Nullable JLeftPadded whenClause; public @Nullable Expression getWhenClause() { return whenClause == null ? null : whenClause.getElement(); } public CasePatternSwitchLabel withWhenClause(@Nullable Expression whenClause) { return getPadding().withWhenClause(JLeftPadded.withElement(this.whenClause, whenClause)); } /** *
         * case int n when n > 0 :
         *                      ^
         * 
*/ @With @Getter Space colonToken; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitCasePatternSwitchLabel(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; } @Override public @Nullable JavaType getType() { return pattern.getType(); } @Override public T withType(@Nullable JavaType type) { return null; } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } @RequiredArgsConstructor public static class Padding { private final CasePatternSwitchLabel t; public @Nullable JLeftPadded getWhenClause() { return t.whenClause; } public CasePatternSwitchLabel withWhenClause(@Nullable JLeftPadded whenClause) { return t.whenClause == whenClause ? t : new CasePatternSwitchLabel(t.id, t.prefix, t.markers, t.pattern, whenClause, t.colonToken); } } } /** * Represents a C# switch statement for control flow based on pattern matching and case labels. *

* For example: *

     * switch(value) {
     *     case 1:
     *         Console.WriteLine("one");
     *         break;
     *
     *     case int n when n > 0:
     *         Console.WriteLine("positive");
     *         break;
     *
     *     case Person { Age: > 18 }:
     *         Console.WriteLine("adult");
     *         break;
     *
     *     case string s:
     *         Console.WriteLine($"string: {s}");
     *         break;
     *
     *     default:
     *         Console.WriteLine("default");
     *         break;
     * }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class SwitchStatement implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * switch(value) {
         *       ^^^^^^
         * 
*/ JContainer expression; public List getExpression() { return expression.getElements(); } public SwitchStatement withExpression(List expression) { return getPadding().withExpression(JContainer.withElements(this.expression, expression)); } /** *
         * switch(value) {
         *     case 1:
         *         Console.WriteLine("one");
         *         break;
         *     default:
         *         Console.WriteLine("default");
         *         break;
         * }
         * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ JContainer sections; public List getSections() { return sections.getElements(); } public SwitchStatement withSections(List sections) { return getPadding().withSections(JContainer.withElements(this.sections, sections)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitSwitchStatement(this, p); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 SwitchStatement t; public JContainer getExpression() { return t.expression; } public SwitchStatement withExpression(JContainer expression) { return t.expression == expression ? t : new SwitchStatement(t.id, t.prefix, t.markers, expression, t.sections); } public JContainer getSections() { return t.sections; } public SwitchStatement withSections(JContainer sections) { return t.sections == sections ? t : new SwitchStatement(t.id, t.prefix, t.markers, t.expression, sections); } } } /** * Represents a C# lock statement which provides thread synchronization. *

* For example: *

     *     // Simple lock statement
     *     lock (syncObject) {
     *         // protected code
     *     }
     *
     *     // Lock with local variable
     *     lock (this.lockObj) {
     *         sharedResource.Modify();
     *     }
     *
     *     // Lock with property
     *     lock (SyncRoot) {
     *         // thread-safe operations
     *     }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class LockStatement implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * lock (syncObject) { }
         *      ^^^^^^^^^^
         * 
*/ @With @Getter J.ControlParentheses expression; /** *
         * lock (syncObject) { }
         *                  ^^^^^
         * 
*/ JRightPadded statement; public Statement getStatement() { return statement.getElement(); } public LockStatement withStatement(Statement statement) { return getPadding().withStatement(this.statement.withElement(statement)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitLockStatement(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 LockStatement t; public JRightPadded getStatement() { return t.statement; } public LockStatement withStatement(JRightPadded statement) { return t.statement == statement ? t : new LockStatement(t.id, t.prefix, t.markers, t.expression, statement); } } } /** * Represents a C# fixed statement which pins a moveable variable at a memory location. * The fixed statement prevents the garbage collector from relocating a movable variable * and declares a pointer to that variable. *

* For example: *

     *     // Fixed statement with array
     *     fixed (int* p = array) {
     *         // use p
     *     }
     *
     *     // Fixed statement with string
     *     fixed (char* p = str) {
     *         // use p
     *     }
     *
     *     // Multiple pointers in one fixed statement
     *     fixed (byte* p1 = &b1, p2 = &b2) {
     *         // use p1 and p2
     *     }
     *
     *     // Fixed statement with custom type
     *     fixed (CustomStruct* ptr = &struct) {
     *         // use ptr
     *     }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class FixedStatement implements Cs, Statement { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * fixed (int* p = array) { }
         *       ^^^^^^^^^^^^^^
         * 
*/ @Getter @With ControlParentheses declarations; /** *
         * fixed (int* p = array) { }
         *                       ^^^^^
         * 
*/ @With @Getter J.Block block; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitFixedStatement(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } } /** * Represents a C# checked statement which enforces overflow checking for arithmetic operations * and conversions. Operations within a checked block will throw OverflowException if arithmetic * overflow occurs. *

* For example: *

     *     // Basic checked block
     *     checked {
     *         int result = int.MaxValue + 1; // throws OverflowException
     *     }
     *
     *     // Checked with multiple operations
     *     checked {
     *         int a = int.MaxValue;
     *         int b = a + 1;     // throws OverflowException
     *         short s = (short)a; // throws OverflowException if out of range
     *     }
     *
     *     // Nested arithmetic operations
     *     checked {
     *         int result = Math.Abs(int.MinValue); // throws OverflowException
     *     }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class CheckedStatement implements Cs, Statement { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * checked {
         *         ^^^^^^^^^
         * }
         * ^
         * 
*/ @With @Getter J.Block block; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitCheckedStatement(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } } /** * Represents a C# unsafe statement block which allows direct memory manipulation and pointer operations. * Code within an unsafe block can perform operations like pointer arithmetic, fixed-size buffers, * and direct memory access. *

* For example: *

     *     // Basic unsafe block
     *     unsafe {
     *         int* ptr = &value;
     *     }
     *
     *     // Unsafe with pointer operations
     *     unsafe {
     *         int* p1 = &x;
     *         int* p2 = p1 + 1;
     *         *p2 = 100;
     *     }
     *
     *     // Unsafe with fixed buffers
     *     unsafe {
     *         fixed (byte* ptr = bytes) {
     *             // Direct memory access
     *         }
     *     }
     *
     *     // Unsafe with sizeof operations
     *     unsafe {
     *         int size = sizeof(CustomStruct);
     *         byte* buffer = stackalloc byte[size];
     *     }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class UnsafeStatement implements Cs, Statement { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * unsafe {
         *        ^^^^^^^^^
         * }
         * ^
         * 
*/ @With @Getter J.Block block; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitUnsafeStatement(this, p); } @Override @Transient public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(this); } } /** * Represents a C# range expression which creates a Range value representing a sequence of indices. * Range expressions use the '..' operator to specify start and end bounds, and can use '^' to specify * indices from the end. *

* For example: *

     *     // Full range
     *     arr[..]
     *
     *     // Range with start index
     *     arr[2..]
     *
     *     // Range with end index
     *     arr[..5]
     *
     *     // Range with both indices
     *     arr[2..5]
     *
     *     // Range with end-relative indices using '^'
     *     arr[..^1]     // excludes last element
     *     arr[1..^1]    // from index 1 to last-1
     *     arr[^2..^1]   // second-to-last to last-but-one
     *
     *     // Standalone range expressions
     *     Range r1 = 1..4;
     *     Range r2 = ..^1;
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class RangeExpression implements Cs, Expression { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * 2  ..5
         * ^^^
         * 
*/ @Nullable JRightPadded start; /** *
         * 2..5
         *   ^
         * 
*/ @With @Getter @Nullable Expression end; public @Nullable Expression getStart() { return start == null ? null : start.getElement(); } public RangeExpression withStart(@Nullable Expression start) { return getPadding().withStart(JRightPadded.withElement(this.start, start)); } @Override public JavaType getType() { return null; } @Override public RangeExpression withType(@Nullable JavaType type) { return this; } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitRangeExpression(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 static class Padding { private final RangeExpression t; public @Nullable JRightPadded getStart() { return t.start; } public RangeExpression withStart(@Nullable JRightPadded start) { return t.start == start ? t : new RangeExpression(t.id, t.prefix, t.markers, start, t.end); } } } /** * Represents a C# LINQ query expression that provides SQL-like syntax for working with collections. *

* For example: *

     *     // Simple query
     *     from user in users
     *     where user.Age > 18
     *     select user.Name
     *
     *     // Query with multiple clauses
     *     from c in customers
     *     join o in orders on c.Id equals o.CustomerId
     *     where o.Total > 1000
     *     orderby o.Date
     *     select new { c.Name, o.Total }
     *
     *     // Query with multiple from clauses
     *     from c in customers
     *     from o in c.Orders
     *     where o.Total > 1000
     *     select new { c.Name, o.Total }
     * 
*/ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class QueryExpression implements Cs, Expression { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * from user in users
         * ^^^^^^^^^^^^^^^^^^
         * 
*/ @With @Getter FromClause fromClause; /** *
         * from user in users
         * where user.Age > 18
         * select user.Name
         * ^^^^^^^^^^^^^^^^^ excluding the from clause
         * 
*/ @With @Getter QueryBody body; @Override public @Nullable JavaType getType() { return fromClause.getType(); } @Override public QueryExpression withType(@Nullable JavaType type) { return withFromClause(fromClause.withType(type)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitQueryExpression(this, p); } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } public interface SelectOrGroupClause extends Cs { } /** * Represents the body of a LINQ query expression, consisting of the query clauses and a final select or group clause. *

* For example: *

     *     // Body of query includes everything after initial 'from':
     *     from c in customers
     *     where c.Age > 18       // Clauses part
     *     orderby c.LastName     // Clauses part
     *     select c.Name          // SelectOrGroup part
     *     into oldCustomers      // Continuation part
     *     where oldCustomers...
     *
     *     // Another example with join:
     *     from o in orders
     *     join c in customers    // Clauses part
     *         on o.CustomerId equals c.Id
     *     where o.Total > 1000   // Clauses part
     *     select new { o, c }    // SelectOrGroup part
     * 
*/ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class QueryBody implements Cs { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * from c in customers
         * where c.Age > 18
         * ^^^^^^^^^^^^^^^^
         * orderby c.LastName
         * ^^^^^^^^^^^^^^^^^^
         * select c.Name
         * 
*/ @With @Getter List clauses; /** *
         * from c in customers
         * where c.Age > 18
         * select c.Name
         * ^^^^^^^^^^^^^ the final select or group clause
         * 
*/ @With @Getter @Nullable SelectOrGroupClause selectOrGroup; /** *
         * from c in customers
         * select c
         * into temp            // Continuation starts here
         * where temp.Age > 18
         * select temp.Name
         * 
*/ @With @Getter @Nullable QueryContinuation continuation; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitQueryBody(this, p); } } interface QueryClause extends Cs { } /** * Represents a LINQ from clause that introduces a range variable and its source collection. * This is typically the initial clause of a LINQ query. *

* For example: *

     *     // Simple from clause
     *     from user in users
     *
     *     // With type
     *     from Customer c in customers
     *
     *     // With pattern match
     *     from (x, y) in points
     *
     *     // With type and pattern
     *     from (int x, int y) in coordinates
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class FromClause implements Cs, QueryClause, Expression { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * from Customer c in customers
         *     ^^^^^^^^^
         * 
*/ @With @Getter @Nullable TypeTree typeIdentifier; /** *
         * from Customer c in customers
         *              ^^
         * 
*/ JRightPadded identifier; /** *
         * from user in users
         *             ^^^^^^
         * 
*/ @With @Getter Expression expression; public Expression getIdentifier() { return identifier.getElement(); } public FromClause withIdentifier(Identifier identifier) { return getPadding().withIdentifier(this.identifier.withElement(identifier)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitFromClause(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; } @Override public @Nullable JavaType getType() { return expression.getType(); } @Override public FromClause withType(@Nullable JavaType type) { return this.withExpression(expression.withType(type)); } @Override public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } @RequiredArgsConstructor public static class Padding { private final FromClause t; public JRightPadded getIdentifier() { return t.identifier; } public FromClause withIdentifier(JRightPadded identifier) { return t.identifier == identifier ? t : new FromClause(t.id, t.prefix, t.markers, t.typeIdentifier, identifier, t.expression); } } } /** * Represents a let clause in a C# LINQ query expression that introduces * a new range variable based on a computation. *

* For example: *

     *     // Simple let clause
     *     from n in numbers
     *     let square = n * n
     *     select square
     *
     *     // Multiple let clauses
     *     from s in strings
     *     let length = s.Length
     *     let upperCase = s.ToUpper()
     *     select new { s, length, upperCase }
     *
     *     // Let with complex expressions
     *     from p in people
     *     let fullName = p.FirstName + " " + p.LastName
     *     let age = DateTime.Now.Year - p.BirthYear
     *     select new { fullName, age }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class LetClause implements Cs, QueryClause { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * let square = n * n
         *    ^^^^^^^^^
         * 
*/ JRightPadded identifier; /** *
         * let square = n * n
         *             ^^^^^^
         * 
*/ @With @Getter Expression expression; public J.Identifier getIdentifier() { return identifier.getElement(); } public LetClause withIdentifier(J.Identifier identifier) { return getPadding().withIdentifier(JRightPadded.withElement(this.identifier, identifier)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitLetClause(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 LetClause t; public JRightPadded getIdentifier() { return t.identifier; } public LetClause withIdentifier(JRightPadded identifier) { return t.identifier == identifier ? t : new LetClause(t.id, t.prefix, t.markers, identifier, t.expression); } } } /** * Represents a C# join clause in a LINQ query expression. *

* For example: *

     * // Simple join
     * join customer in customers on order.CustomerId equals customer.Id
     *
     * // Join with into (group join)
     * join category in categories
     *   on product.CategoryId equals category.Id
     *   into productCategories
     *
     * // Multiple joins
     * from order in orders
     * join customer in customers
     *   on order.CustomerId equals customer.Id
     * join employee in employees
     *   on order.EmployeeId equals employee.Id
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class JoinClause implements Cs, QueryClause { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * join customer in customers
         *     ^^^^^^^^^^^^
         * 
*/ JRightPadded identifier; /** *
         * join customer in customers on order.CustomerId equals customer.Id
         *                 ^^^^^^^^^^^^^
         * 
*/ JRightPadded inExpression; /** *
         * join customer in customers on order.CustomerId equals customer.Id
         *                              ^^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ JRightPadded leftExpression; /** *
         * join customer in customers on order.CustomerId equals customer.Id
         *                                                      ^^^^^^^^^^^^
         * 
*/ @With @Getter Expression rightExpression; /** *
         * join category in categories on product.CategoryId equals category.Id into productCategories
         *                                                                     ^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ @Nullable JLeftPadded into; public Identifier getIdentifier() { return identifier.getElement(); } public JoinClause withIdentifier(Identifier identifier) { return getPadding().withIdentifier(this.identifier.withElement(identifier)); } public Expression getInExpression() { return inExpression.getElement(); } public JoinClause withInExpression(Expression inExpression) { return getPadding().withInExpression(this.inExpression.withElement(inExpression)); } public Expression getLeftExpression() { return leftExpression.getElement(); } public JoinClause withLeftExpression(Expression leftExpression) { return getPadding().withLeftExpression(this.leftExpression.withElement(leftExpression)); } public @Nullable JoinIntoClause getInto() { return into == null ? null : into.getElement(); } public JoinClause withInto(@Nullable JoinIntoClause into) { return getPadding().withInto(this.into.withElement(into)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitJoinClause(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 JoinClause t; public JRightPadded getIdentifier() { return t.identifier; } public JoinClause withIdentifier(JRightPadded identifier) { return t.identifier == identifier ? t : new JoinClause(t.id, t.prefix, t.markers, identifier, t.inExpression, t.leftExpression, t.rightExpression, t.into); } public JRightPadded getInExpression() { return t.inExpression; } public JoinClause withInExpression(JRightPadded inExpression) { return t.inExpression == inExpression ? t : new JoinClause(t.id, t.prefix, t.markers, t.identifier, inExpression, t.leftExpression, t.rightExpression, t.into); } public JRightPadded getLeftExpression() { return t.leftExpression; } public JoinClause withLeftExpression(JRightPadded leftExpression) { return t.leftExpression == leftExpression ? t : new JoinClause(t.id, t.prefix, t.markers, t.identifier, t.inExpression, leftExpression, t.rightExpression, t.into); } public @Nullable JLeftPadded getInto() { return t.into; } public JoinClause withInto(@Nullable JLeftPadded into) { return t.into == into ? t : new JoinClause(t.id, t.prefix, t.markers, t.identifier, t.inExpression, t.leftExpression, t.rightExpression, into); } } } /** * Represents the 'into' portion of a group join clause in C# LINQ syntax. * Used to specify the identifier that will hold the grouped results. *

* For example: *

     * // Group join using into clause
     * join category in categories
     *    on product.CategoryId equals category.Id
     *    into productCategories
     *
     * // Multiple group joins
     * join orders in db.Orders
     *    on customer.Id equals orders.CustomerId
     *    into customerOrders
     * join returns in db.Returns
     *    on customer.Id equals returns.CustomerId
     *    into customerReturns
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class JoinIntoClause implements Cs, QueryClause { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * into productCategories
         *     ^^^^^^^^^^^^^^^^^^
         * 
*/ @With @Getter Identifier identifier; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitJoinIntoClause(this, p); } } /** * Represents a C# LINQ where clause that filters elements in a query based on a condition. *

* For example: *

     *     // Simple where clause
     *     from p in people
     *     where p.Age >= 18
     *     select p
     *
     *     // Multiple where clauses
     *     from p in people
     *     where p.Age >= 18
     *     where p.Name.StartsWith("J")
     *     select p
     *
     *     // Where with complex condition
     *     from o in orders
     *     where o.Total > 1000 && o.Status == "Pending"
     *     select o
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class WhereClause implements Cs, QueryClause { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * where p.Age >= 18
         *      ^^^^^^^^^^^^
         * 
*/ @With @Getter Expression condition; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitWhereClause(this, p); } } /** * Represents a C# LINQ orderby clause that specifies the ordering of results in a query. *

* For example: *

     *     // Simple orderby with single key
     *     from p in people
     *     orderby p.LastName
     *     select p
     *
     *     // Multiple orderings
     *     from p in people
     *     orderby p.LastName ascending, p.FirstName descending
     *     select p
     *
     *     // Orderby with complex key expressions
     *     from o in orders
     *     orderby o.Customer.Name, o.Total * 1.08
     *     select o
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class OrderByClause implements Cs, QueryClause { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * orderby p.LastName ascending, p.FirstName descending
         *         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ List> orderings; public List getOrderings() { return JRightPadded.getElements(orderings); } public OrderByClause withOrderings(List orderings) { return getPadding().withOrderings(JRightPadded.withElements(this.orderings, orderings)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitOrderByClause(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 OrderByClause t; public List> getOrderings() { return t.orderings; } public OrderByClause withOrderings(List> orderings) { return t.orderings == orderings ? t : new OrderByClause(t.id, t.prefix, t.markers, orderings); } } } /** * Represents a LINQ query continuation using the 'into' keyword, which allows query results to be * further processed in subsequent query clauses. *

* For example: *

     *     // Query continuation with grouping
     *     from c in customers
     *     group c by c.Country into g
     *     select new { Country = g.Key, Count = g.Count() }
     *
     *     // Multiple continuations
     *     from n in numbers
     *     group n by n % 2 into g
     *     select new { Modulo = g.Key, Items = g } into r
     *     where r.Items.Count() > 2
     *     select r
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class QueryContinuation implements Cs { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * group c by c.Country into g
         *                         ^^^
         * 
*/ @With @Getter J.Identifier identifier; /** *
         * group c by c.Country into g
         * select new { Country = g.Key }
         * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ @With @Getter QueryBody body; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitQueryContinuation(this, p); } } /** * Represents a single ordering clause within C# orderby expression. *

     * orderby name ascending
     * orderby age descending, name ascending
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class Ordering implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * orderby name ascending
         *        ^^^^
         * 
*/ JRightPadded expression; public Expression getExpression() { return expression.getElement(); } public Ordering withExpression(Expression expression) { return getPadding().withExpression(this.expression.withElement(expression)); } /** *
         * orderby name ascending
         *             ^^^^^^^^^
         * 
*/ @With @Getter @Nullable DirectionKind direction; public enum DirectionKind { Ascending, Descending } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitOrdering(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 Ordering t; public JRightPadded getExpression() { return t.expression; } public Ordering withExpression(JRightPadded expression) { return t.expression == expression ? t : new Ordering(t.id, t.prefix, t.markers, expression, t.direction); } } } /** * Represents a select clause in a LINQ expression in C#. *

     * // Simple select
     * select item
     *
     * // Select with projection
     * select new { Name = p.Name, Age = p.Age }
     * 
*/ @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class SelectClause implements Cs, SelectOrGroupClause { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * select item
         *        ^^^^
         * 
*/ @With @Getter Expression expression; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitSelectClause(this, p); } } /** * Represents a group clause in a LINQ query. *

     * // Simple group by
     * group item by key
     *
     * // Group by with complex key
     * group customer by new { customer.State, customer.City }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class GroupClause implements Cs, SelectOrGroupClause { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * group item by key
         *       ^^^^
         * 
*/ JRightPadded groupExpression; public Expression getGroupExpression() { return groupExpression.getElement(); } public GroupClause withGroupExpression(Expression groupExpression) { return getPadding().withGroupExpression(this.groupExpression.withElement(groupExpression)); } /** *
         * group item by key
         *              ^^^
         * 
*/ @With @Getter Expression key; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitGroupClause(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 GroupClause t; public JRightPadded getGroupExpression() { return t.groupExpression; } public GroupClause withGroupExpression(JRightPadded groupExpression) { return t.groupExpression == groupExpression ? t : new GroupClause(t.id, t.prefix, t.markers, groupExpression, t.key); } } } /** * Represents a C# indexer declaration which allows objects to be indexed like arrays. *

     * // Simple indexer
     * public int this[int index] { get { } set { } }
     *
     * // Indexer with multiple parameters
     * public string this[int x, int y] { get; set; }
     *
     * // Readonly indexer
     * public MyType this[string key] { get; }
     *
     * // Interface indexer
     * string this[int index] { get; set; }
     *
     * // Protected indexer with expression body
     * protected internal int this[int i] => array[i];
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class IndexerDeclaration implements Cs, Statement, TypedTree { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter List modifiers; /** *
         * public int this[int index]
         *        ^^^
         * 
*/ @With @Getter TypeTree typeExpression; /** *
         * public TypeName ISomeType.this[int index]
         *                 ^^^^^^^^^^^^^^
         * 
* Either FieldAccess (when interface qualified) or Identifier ("this") */ @Getter @With Expression indexer; /** *
         * public int this[int index] { get; set; }
         *               ^^^^^^^^^^
         * 
*/ JContainer parameters; /** *
         * public int this[int index] => array[index];
         *                            ^^^^^^^^^^^^^^^^
         * 
*/ @Nullable JLeftPadded expressionBody; /** *
         * public int this[int index] { get; set; }
         *                           ^^^^^^^^^^^^
         * 
*/ @Nullable @With @Getter Block accessors; @Override public JavaType getType() { return typeExpression.getType(); } @Override public IndexerDeclaration withType(@Nullable JavaType type) { return withTypeExpression(typeExpression.withType(type)); } public List getParameters() { return parameters.getElements(); } public IndexerDeclaration withParameters(List parameters) { return getPadding().withParameters(JContainer.withElements(this.parameters, parameters)); } public @Nullable Expression getExpressionBody() { return expressionBody != null ? expressionBody.getElement() : null; } public IndexerDeclaration withExpressionBody(@Nullable Expression expressionBody) { return getPadding().withExpressionBody(JLeftPadded.withElement(this.expressionBody, expressionBody)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitIndexerDeclaration(this, p); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 IndexerDeclaration t; public JContainer getParameters() { return t.parameters; } public IndexerDeclaration withParameters(JContainer parameters) { return t.parameters == parameters ? t : new IndexerDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.typeExpression, t.indexer, parameters, t.expressionBody, t.accessors); } public @Nullable JLeftPadded getExpressionBody() { return t.expressionBody; } public IndexerDeclaration withExpressionBody(@Nullable JLeftPadded expressionBody) { return t.expressionBody == expressionBody ? t : new IndexerDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.typeExpression, t.indexer, t.parameters, expressionBody, t.accessors); } } } /** * Represents a C# delegate declaration which defines a type that can reference methods. * Delegates act as type-safe function pointers and provide the foundation for events in C#. *

* For example: *

     * // Simple non-generic delegate with single parameter
     * public delegate void Logger(string message);
     *
     * // Generic delegate
     * public delegate T Factory() where T : class, new();
     *
     * // Delegate with multiple parameters and constraint
     * public delegate TResult Convert(T input)
     *     where T : struct
     *     where TResult : class;
     *
     * // Static delegate (C# 11+)
     * public static delegate int StaticHandler(string msg);
     *
     * // Protected access
     * protected delegate bool Validator(T item);
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class DelegateDeclaration implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * public delegate void MyDelegate(string message);
         * ^^^^^^
         * 
*/ @With @Getter List modifiers; /** *
         * public delegate void MyDelegate(string message);
         *               ^^^^
         * 
*/ JLeftPadded returnType; public TypeTree getReturnType() { return returnType.getElement(); } public DelegateDeclaration withReturnType(TypeTree returnType) { return getPadding().withReturnType(this.returnType.withElement(returnType)); } /** *
         * public delegate void MyDelegate(string message);
         *                     ^^^^^^^^^^^
         * 
*/ @With @Getter Identifier identifier; /** *
         * public delegate T GenericDelegate(T item);
         *                                  ^^^
         * 
*/ @Nullable JContainer typeParameters; /** *
         * public delegate void MyDelegate(string message);
         *                                ^^^^^^^^^^^^^^^^
         * 
*/ JContainer parameters; /** *
         * public delegate T Factory() where T : class;
         *                               ^^^^^^^^^^^^^^^^
         * 
*/ @Nullable JContainer typeParameterConstraintClauses; public List getTypeParameters() { return typeParameters == null ? Collections.emptyList() : typeParameters.getElements(); } public DelegateDeclaration withTypeParameters(@Nullable List typeParameters) { return getPadding().withTypeParameters(JContainer.withElementsNullable(this.typeParameters, typeParameters)); } public List getParameters() { return parameters.getElements(); } public DelegateDeclaration withParameters(List parameters) { return getPadding().withParameters(JContainer.withElements(this.parameters, parameters)); } public List getTypeParameterConstraintClauses() { return typeParameterConstraintClauses == null ? Collections.emptyList() : typeParameterConstraintClauses.getElements(); } public DelegateDeclaration withTypeParameterConstraintClauses(@Nullable List clauses) { return getPadding().withTypeParameterConstraintClauses(JContainer.withElementsNullable(this.typeParameterConstraintClauses, clauses)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitDelegateDeclaration(this, p); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 DelegateDeclaration t; public JLeftPadded getReturnType() { return t.returnType; } public DelegateDeclaration withReturnType(JLeftPadded returnType) { return t.returnType == returnType ? t : new DelegateDeclaration(t.id, t.prefix, t.markers, t.modifiers, returnType, t.identifier, t.typeParameters, t.parameters, t.typeParameterConstraintClauses); } public @Nullable JContainer getTypeParameters() { return t.typeParameters; } public DelegateDeclaration withTypeParameters(@Nullable JContainer typeParameters) { return t.typeParameters == typeParameters ? t : new DelegateDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.returnType, t.identifier, typeParameters, t.parameters, t.typeParameterConstraintClauses); } public JContainer getParameters() { return t.parameters; } public DelegateDeclaration withParameters(JContainer parameters) { return t.parameters == parameters ? t : new DelegateDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.returnType, t.identifier, t.typeParameters, parameters, t.typeParameterConstraintClauses); } public @Nullable JContainer getTypeParameterConstraintClauses() { return t.typeParameterConstraintClauses; } public DelegateDeclaration withTypeParameterConstraintClauses(@Nullable JContainer clauses) { return t.typeParameterConstraintClauses == clauses ? t : new DelegateDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.returnType, t.identifier, t.typeParameters, t.parameters, clauses); } } } /** * Represents a C# operator conversion declaration that defines custom type conversion behavior. *

     * // Implicit conversion
     * public static implicit operator string(MyType t) => t.ToString();
     *
     * // Explicit conversion
     * public static explicit operator int(MyType t) { return t.Value; }
     *
     * // With expression body
     * public static explicit operator double(MyType t) => t.Value;
     *
     * // With block body
     * public static implicit operator bool(MyType t) {
     *     return t.Value != 0;
     * }
     */
    @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
    @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
    @RequiredArgsConstructor
    @AllArgsConstructor(access = AccessLevel.PRIVATE)
    final class ConversionOperatorDeclaration implements Cs, Statement {

        @Nullable
        @NonFinal
        transient WeakReference padding;

        @With
        @EqualsAndHashCode.Include
        @Getter
        UUID id;

        @With
        @Getter
        Space prefix;

        @With
        @Getter
        Markers markers;

        /**
         * 
         * public static implicit operator string(MyType t)
         * ^^^^^^^^^^^^^
         * 
*/ @With @Getter List modifiers; /** *
         * public static implicit operator string(MyType t)
         *               ^^^^^^^^
         * 
*/ JLeftPadded kind; public ExplicitImplicit getKind() { return kind.getElement(); } public ConversionOperatorDeclaration withKind(ExplicitImplicit kind) { return getPadding().withKind(this.kind.withElement(kind)); } /** *
         * public static implicit operator string(MyType t)
         *                                ^^^^^^^
         * 
*/ JLeftPadded returnType; public TypeTree getReturnType() { return returnType.getElement(); } public ConversionOperatorDeclaration withReturnType(TypeTree returnType) { return getPadding().withReturnType(this.returnType.withElement(returnType)); } /** *
         * public static implicit operator string(MyType t)
         *                                      ^^^^^^^^^
         * 
*/ JContainer parameters; /** *
         * public static implicit operator string(MyType t) => t.ToString();
         *                                                 ^^^^^^^^^^^^^^^
         * 
*/ @Nullable JLeftPadded expressionBody; /** *
         * public static implicit operator string(MyType t) { return t.ToString(); }
         *                                                 ^^^^^^^^^^^^^^^^^^^^^^^
         * 
*/ @With @Getter @Nullable Block body; public enum ExplicitImplicit { Implicit, Explicit } public List getParameters() { return parameters.getElements(); } public ConversionOperatorDeclaration withParameters(List parameters) { return getPadding().withParameters(JContainer.withElements(this.parameters, parameters)); } public @Nullable Expression getExpressionBody() { return expressionBody != null ? expressionBody.getElement() : null; } public ConversionOperatorDeclaration withExpressionBody(@Nullable Expression expressionBody) { return getPadding().withExpressionBody(JLeftPadded.withElement(this.expressionBody, expressionBody)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitConversionOperatorDeclaration(this, p); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 ConversionOperatorDeclaration t; public JLeftPadded getReturnType() { return t.returnType; } public ConversionOperatorDeclaration withReturnType(JLeftPadded returnType) { return t.returnType == returnType ? t : new ConversionOperatorDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.kind, returnType, t.parameters, t.expressionBody, t.body); } public JLeftPadded getKind() { return t.kind; } public ConversionOperatorDeclaration withKind(JLeftPadded kind) { return t.kind == kind ? t : new ConversionOperatorDeclaration(t.id, t.prefix, t.markers, t.modifiers, kind, t.returnType, t.parameters, t.expressionBody, t.body); } public JContainer getParameters() { return t.parameters; } public ConversionOperatorDeclaration withParameters(JContainer parameters) { return t.parameters == parameters ? t : new ConversionOperatorDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.kind, t.returnType, parameters, t.expressionBody, t.body); } public @Nullable JLeftPadded getExpressionBody() { return t.expressionBody; } public ConversionOperatorDeclaration withExpressionBody(@Nullable JLeftPadded expressionBody) { return t.expressionBody == expressionBody ? t : new ConversionOperatorDeclaration(t.id, t.prefix, t.markers, t.modifiers, t.kind, t.returnType, t.parameters, expressionBody, t.body); } } } /** * Represents a C# type parameter in generic type declarations, including optional variance and constraints. *

* For example: *

     *     // Simple type parameter
     *     class Container<T>
     *
     *     // Type parameter with variance
     *     interface IEnumerable<out T>
     *
     *     // Type parameter with attributes
     *     class Handler<[Category("A")] T>
     *
     *     // Type parameter with variance and attributes
     *     interface IComparer<[NotNull] in T>
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class TypeParameter implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter List attributeLists; /** *
         * interface IEnumerable
         *                      ^^^
         * 
*/ @Nullable JLeftPadded variance; /** *
         * class Container
         *                 ^
         * 
*/ @With @Getter Identifier name; public enum VarianceKind { In, Out } public @Nullable VarianceKind getVariance() { return variance == null ? null : variance.getElement(); } public Cs.TypeParameter withVariance(@Nullable VarianceKind variance) { return getPadding().withVariance(JLeftPadded.withElement(this.variance, variance)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitTypeParameter(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 Cs.TypeParameter t; public @Nullable JLeftPadded getVariance() { return t.variance; } public Cs.TypeParameter withVariance(@Nullable JLeftPadded variance) { return t.variance == variance ? t : new Cs.TypeParameter(t.id, t.prefix, t.markers, t.attributeLists, variance, t.name); } } } /** * Represents a C# enum declaration, including optional modifiers, attributes, and enum members. *

* For example: *

     *     // Simple enum
     *     public enum Colors { Red, Green, Blue }
     *
     *     // Enum with base type
     *     enum Flags : byte { None, All }
     *
     *     // Enum with attributes and explicit values
     *     [Flags]
     *     internal enum Permissions {
     *         None = 0,
     *         Read = 1,
     *         Write = 2,
     *         ReadWrite = Read | Write
     *     }
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class EnumDeclaration implements Cs, Statement { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter @Nullable List attributeLists; @With @Getter List modifiers; /** *
         * public enum Colors { Red, Green }
         *            ^^^^^^
         * 
*/ JLeftPadded name; public Identifier getName() { return name.getElement(); } public EnumDeclaration withName(Identifier name) { return getPadding().withName(JLeftPadded.withElement(this.name, name)); } /** *
         * enum Flags : byte { None }
         *           ^^^^^^^
         * 
*/ @Nullable JLeftPadded baseType; /** *
         * enum Colors { Red, Green, Blue }
         *             ^^^^^^^^^^^^^^^^^^
         * 
*/ @Nullable JContainer members; public @Nullable TypeTree getBaseType() { return baseType == null ? null : baseType.getElement(); } public EnumDeclaration withBaseType(@Nullable TypeTree baseType) { return getPadding().withBaseType(JLeftPadded.withElement(this.baseType, baseType)); } public @Nullable List getMembers() { return members.getElements(); } public EnumDeclaration withMembers(@Nullable List members) { return getPadding().withMembers(members != null ? JContainer.withElements(this.members, members) : null); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitEnumDeclaration(this, p); } @Override public CoordinateBuilder.Statement getCoordinates() { return new CoordinateBuilder.Statement(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 EnumDeclaration t; public @Nullable JLeftPadded getName() { return t.name; } public EnumDeclaration withName(JLeftPadded name) { return t.name == name ? t : new EnumDeclaration(t.id, t.prefix, t.markers, t.attributeLists, t.modifiers, name, t.baseType, t.members); } public @Nullable JLeftPadded getBaseType() { return t.baseType; } public EnumDeclaration withBaseType(@Nullable JLeftPadded baseType) { return t.baseType == baseType ? t : new EnumDeclaration(t.id, t.prefix, t.markers, t.attributeLists, t.modifiers, t.name, baseType, t.members); } public JContainer getMembers() { return t.members; } public EnumDeclaration withMembers(JContainer members) { return t.members == members ? t : new EnumDeclaration(t.id, t.prefix, t.markers, t.attributeLists, t.modifiers, t.name, t.baseType, members); } } } /** * Represents a C# enum member declaration, including optional attributes and initializer. *

* For example: *

     *     // Simple enum member
     *     Red,
     *
     *     // Member with initializer
     *     Green = 2,
     *
     *     // Member with attributes and expression initializer
     *     [Obsolete]
     *     Blue = Red | Green,
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class EnumMemberDeclaration implements Cs { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Getter List attributeLists; /** *
         * Red = 1
         * ^^^
         * 
*/ @With @Getter Identifier name; /** *
         * Red = 1
         *     ^^^
         * 
*/ @Nullable JLeftPadded initializer; public @Nullable Expression getInitializer() { return initializer == null ? null : initializer.getElement(); } public EnumMemberDeclaration withInitializer(@Nullable Expression initializer) { return getPadding().withInitializer(JLeftPadded.withElement(this.initializer, initializer)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitEnumMemberDeclaration(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 EnumMemberDeclaration t; public @Nullable JLeftPadded getInitializer() { return t.initializer; } public EnumMemberDeclaration withInitializer(@Nullable JLeftPadded initializer) { return t.initializer == initializer ? t : new EnumMemberDeclaration(t.id, t.prefix, t.markers, t.attributeLists, t.name, initializer); } } } /** * Represents a C# alias qualified name, which uses an extern alias to qualify a name. *

* For example: *

     *     // Using LibA to qualify TypeName
     *     LibA::TypeName
     *
     *     // Using LibB to qualify namespace
     *     LibB::System.Collections
     * 
*/ @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) final class AliasQualifiedName implements Cs, TypeTree, Expression, Marker { @Nullable @NonFinal transient WeakReference padding; @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; /** *
         * LibA::TypeName
         * ^^^^
         * 
*/ JRightPadded alias; /** *
         * LibA::TypeName
         *      ^^^^^^^^
         * 
* In case of method invocation, whole expression gets placed here */ @With @Getter Expression name; public Identifier getAlias() { return alias.getElement(); } public AliasQualifiedName withAlias(Identifier alias) { return getPadding().withAlias(JRightPadded.withElement(this.alias, alias)); } @Override public JavaType getType() { return name.getType(); } @Override public AliasQualifiedName withType(@Nullable JavaType type) { return withName(name.withType(type)); } @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitAliasQualifiedName(this, p); } @Override 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 AliasQualifiedName t; public JRightPadded getAlias() { return t.alias; } public AliasQualifiedName withAlias(JRightPadded alias) { return t.alias == alias ? t : new AliasQualifiedName(t.id, t.prefix, t.markers, alias, t.name); } } } @ToString @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @AllArgsConstructor(access = AccessLevel.PUBLIC) final class ArrayType implements Cs, Expression, TypeTree { @With @EqualsAndHashCode.Include @Getter UUID id; @With @Getter Space prefix; @With @Getter Markers markers; @With @Nullable @Getter TypeTree typeExpression; @With @Getter List dimensions; @With @Nullable @Getter JavaType type; @Override public

J acceptCSharp(CSharpVisitor

v, P p) { return v.visitArrayType(this, p); } @Override @Transient public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } }