/*
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* 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 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.java.JavaPrinter;
import org.openrewrite.java.JavaTypeVisitor;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.internal.TypesInUse;
import org.openrewrite.java.tree.*;
import org.openrewrite.marker.Markers;
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 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, P> v, P p) {
return v.isAdaptableTo(CSharpVisitor.class);
}
default
@Nullable J acceptCSharp(CSharpVisitor
v, P p) {
return v.defaultValue(this, 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, PrintOutputCapture
> 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;
}
@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);
}
}
}
@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 J.@Nullable Identifier getNameColumn() { return nameColumn == null ? null : nameColumn.getElement(); }
public Argument withNameColumn(J.@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 J.@Nullable Identifier getTarget() {
return target == null ? null : target.getElement();
}
public AttributeList withTarget(J.@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 {
@EqualsAndHashCode.Include
UUID id;
Space prefix;
Markers markers;
Expression expression;
@Nullable
JavaType type;
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitAwaitExpression(this, p);
}
@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)
@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);
}
}
}
@Getter
@ToString
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@RequiredArgsConstructor
@With
final class ExpressionStatement implements Cs, Statement {
@EqualsAndHashCode.Include
UUID id;
Space prefix;
Markers markers;
Expression expression;
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitExpressionStatement(this, p);
}
@Transient
@Override
public CoordinateBuilder.Statement getCoordinates() {
return new CoordinateBuilder.Statement(this);
}
}
@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 J.@Nullable Identifier getAlias() {
return alias != null ? alias.getElement() : null;
}
public UsingDirective withAlias(J.@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);
}
}
}
enum KeywordKind
{
Ref,
Out,
Await,
Base,
This
}
@Getter
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@RequiredArgsConstructor
final class Keyword implements Cs
{
@With
@Getter
@EqualsAndHashCode.Include
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
@With
@Getter
KeywordKind kind;
}
@Getter
@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 {
@Nullable
@NonFinal
transient WeakReference padding;
@With
@Getter
@EqualsAndHashCode.Include
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
@With
@Getter
J.ClassDeclaration classDeclarationCore;
JContainer typeParameterConstraintClauses;
public List getTypeParameterConstraintClauses() {
return typeParameterConstraintClauses.getElements();
}
public Cs.ClassDeclaration withTypeParameterConstraintClauses(List typeParameterConstraintClauses) {
return getPadding().withTypeParameterConstraintClauses(JContainer.withElementsNullable(this.typeParameterConstraintClauses, typeParameterConstraintClauses));
}
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitClassDeclaration(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 CoordinateBuilder.Statement getCoordinates() {
return new CoordinateBuilder.Statement(this);
}
@RequiredArgsConstructor
public static class Padding {
private final Cs.ClassDeclaration t;
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.classDeclarationCore, typeParameterConstraintClauses);
}
}
}
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@RequiredArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
final class MethodDeclaration implements Cs, Statement {
@Nullable
@NonFinal
transient WeakReference padding;
@With
@Getter
@EqualsAndHashCode.Include
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
@With
@Getter
J.MethodDeclaration methodDeclarationCore;
JContainer typeParameterConstraintClauses;
public List getTypeParameterConstraintClauses() {
return typeParameterConstraintClauses.getElements();
}
public Cs.MethodDeclaration withTypeParameterConstraintClauses(List typeParameterConstraintClauses) {
return getPadding().withTypeParameterConstraintClauses(JContainer.withElementsNullable(this.typeParameterConstraintClauses, typeParameterConstraintClauses));
}
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitMethodDeclaration(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 CoordinateBuilder.Statement getCoordinates() {
return new CoordinateBuilder.Statement(this);
}
@RequiredArgsConstructor
public static class Padding {
private final Cs.MethodDeclaration t;
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.methodDeclarationCore, typeParameterConstraintClauses);
}
}
}
//region UsingStatement
@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;
JContainer expression;
public List getExpression() {
return expression.getElements();
}
public UsingStatement withExpression(List expression) {
return getPadding().withExpression(JContainer.withElements(this.expression, 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 JContainer getExpression() {
return t.expression;
}
public UsingStatement withExpression(JContainer 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 Cs.TypeParameterConstraintClause withTypeParameter(Identifier typeParameter) {
return getPadding().withTypeParameter(JRightPadded.withElement(this.typeParameter, typeParameter));
}
public List getTypeParameterConstraints() {
return typeParameterConstraints.getElements();
}
public Cs.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 Cs.TypeParameterConstraintClause t;
public @Nullable JRightPadded getTypeParameter() {
return t.typeParameter;
}
public Cs.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 Cs.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, string y) = GetPoint()}
*
* Example 1: Out variable declaration:
*
* if(int.TryParse(s, out int result)) {
* // use result
* }
*
*
* Example 2: Deconstruction declaration:
*
* (int x, string y) = point;
* (int count, (string name, int age)) = GetPersonDetails();
*
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
public final class DeclarationExpression implements Cs, Expression, TypedTree {
@With
@EqualsAndHashCode.Include
@Getter
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
@With
@Getter
@Nullable
TypeTree typeExpression;
@With
@Getter
VariableDesignation variables;
@Override
public @Nullable JavaType getType() {
return variables.getType();
}
@Override
public DeclarationExpression withType(@Nullable JavaType type) {
return withType(type == null ? null : this.variables.withType(type));
}
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitDeclarationExpression(this, p);
}
@Override
@Transient
public CoordinateBuilder.Expression getCoordinates() {
return new CoordinateBuilder.Expression(this);
}
}
/**
* Interface for variable designators in declaration expressions.
* This can be either a single variable name or a parenthesized list of designators for deconstruction.
* @see SingleVariableDesignation
* @see ParenthesizedVariableDesignation
*/
interface VariableDesignation extends Expression, Cs {
}
/**
* Represents a single variable declaration within a declaration expression.
* Used both for simple out variable declarations and as elements within deconstruction declarations.
*
* Example in out variable:
*
* int.TryParse(s, out int x) // 'int x' is the SingleVariable
*
*
* Example in deconstruction:
*
* (int x, string y) = point; // both 'int x' and 'string y' are SingleVariables
*
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
public final class SingleVariableDesignation implements VariableDesignation, Cs {
@With
@EqualsAndHashCode.Include
@Getter
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
@With
@Getter
J.Identifier name;
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitSingleVariableDesignation(this, p);
}
@Override
public @Nullable JavaType getType() {
return name.getType();
}
@Override
public SingleVariableDesignation withType(@Nullable JavaType type) {
return this.getType() == type ? this : new Cs.SingleVariableDesignation(
id,
prefix,
markers,
name.withType(type));
}
@Override
@Transient
public CoordinateBuilder.Expression getCoordinates() {
return new CoordinateBuilder.Expression(this);
}
}
/**
* Represents a parenthesized list of variable declarations used in deconstruction patterns.
* Can contain both single variables and nested deconstruction patterns.
*
* Example of simple deconstruction:
*
* (int x, string y) = point;
*
*
* Example of nested deconstruction:
*
* (int count, (string name, int age)) = GetPersonDetails();
* // ^^^^^^^^^^^^^^^^^^ nested ParenthesizedVariable
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ outer ParenthesizedVariable
*
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public final class ParenthesizedVariableDesignation implements VariableDesignation, Cs {
@Nullable
@NonFinal
transient WeakReference padding;
@With
@EqualsAndHashCode.Include
@Getter
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
JContainer variables;
public List getVariables() {
return variables.getElements();
}
public ParenthesizedVariableDesignation withVariables(List variables) {
return getPadding().withVariables(JContainer.withElements(this.variables, variables));
}
@With
@Getter
@Nullable
JavaType type;
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitParenthesizedVariableDesignation(this, p);
}
@Override
@Transient
public CoordinateBuilder.Expression getCoordinates() {
return new CoordinateBuilder.Expression(this);
}
public Padding getPadding() {
Padding p;
if (this.padding == null) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
} else {
p = this.padding.get();
if (p == null || p.t != this) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
}
}
return p;
}
@RequiredArgsConstructor
public class Padding {
private final ParenthesizedVariableDesignation t;
public JContainer getVariables() {
return t.variables;
}
public ParenthesizedVariableDesignation withVariables(JContainer variables) {
return t.variables == variables ? t : new ParenthesizedVariableDesignation(t.id, t.prefix, t.markers, variables, t.type);
}
}
}
/**
* Represents a discard designation in pattern matching expressions, indicated by an underscore (_).
* For example in pattern matching:
* ```csharp
* if (obj is _) // discard pattern
* ```
* Or in deconstruction:
* ```csharp
* var (x, _, z) = tuple; // discards second element
* ```
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
final class DiscardVariableDesignation implements VariableDesignation, Cs {
@With
@EqualsAndHashCode.Include
@Getter
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
@With
@Getter
J.Identifier discard;
@Override
public @Nullable JavaType getType() {
return discard.getType();
}
@Override
public J2 withType(@Nullable JavaType type) {
return (J2) withDiscard(discard.withType(type));
}
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitDiscardVariableDesignation(this, p);
}
@Override
@Transient
public CoordinateBuilder.Expression getCoordinates() {
return new CoordinateBuilder.Expression(this);
}
}
/**
* Represents a tuple expression in C#.
* Can be used in tuple construction, deconstruction and tuple literals.
*
* Examples:
* ```csharp
* // Tuple construction
* var point = (1, 2);
*
* // Named tuple elements
* var person = (name: "John", age: 25);
*
* // Nested tuples
* var nested = (1, (2, 3));
*
* // Tuple type with multiple elements
* (string name, int age) person = ("John", 25);
* ```
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@RequiredArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
final class TupleExpression implements Cs, Expression {
@Nullable
@NonFinal
transient WeakReference padding;
@With
@EqualsAndHashCode.Include
@Getter
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
JContainer arguments;
public List getArguments() {
return arguments.getElements();
}
public TupleExpression withArguments(List arguments) {
return getPadding().withArguments(JContainer.withElements(this.arguments, arguments));
}
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitTupleExpression(this, p);
}
@Override
public @Nullable JavaType getType() {
return null;
}
@Override
public TupleExpression withType(@Nullable JavaType type) {
return this;
}
@Override
@Transient
public CoordinateBuilder.Expression getCoordinates() {
return new CoordinateBuilder.Expression(this);
}
public Padding getPadding() {
Padding p;
if (this.padding == null) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
} else {
p = this.padding.get();
if (p == null || p.t != this) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
}
}
return p;
}
@RequiredArgsConstructor
public static class Padding {
private final TupleExpression t;
public JContainer getArguments() {
return t.arguments;
}
public TupleExpression withArguments(JContainer arguments) {
return t.arguments == arguments ? t : new TupleExpression(t.id, t.prefix, t.markers, arguments);
}
}
}
/**
* Represents a C# constructor declaration which may include an optional constructor initializer.
*
* For example:
*
* // Constructor with no initializer
* public MyClass() {
* }
*
* // Constructor with base class initializer
* public MyClass(int x) : base(x) {
* }
*
* // Constructor with this initializer
* public MyClass(string s) : this(int.Parse(s)) {
* }
*
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
public class Constructor implements Cs, Statement {
@Getter
@With
@EqualsAndHashCode.Include
UUID id;
@Getter
@With
Space prefix;
@Getter
@With
Markers markers;
@Getter
@With
@Nullable
ConstructorInitializer initializer;
@Getter
@With
J.MethodDeclaration constructorCore;
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitConstructor(this, p);
}
@Override
@Transient
public CoordinateBuilder.Statement getCoordinates() {
return new CoordinateBuilder.Statement(this);
}
}
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@RequiredArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
final class Unary implements Cs, Statement, Expression, TypedTree {
@Nullable
@NonFinal
transient WeakReference padding;
@With
@EqualsAndHashCode.Include
@Getter
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
JLeftPadded operator;
public Type getOperator() {
return operator.getElement();
}
public Cs.Unary withOperator(Type operator) {
return getPadding().withOperator(this.operator.withElement(operator));
}
@With
@Getter
Expression expression;
@With
@Nullable
@Getter
JavaType type;
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitUnary(this, p);
}
@Override
@Transient
public CoordinateBuilder.Statement getCoordinates() {
return new CoordinateBuilder.Statement(this);
}
@Override
@Transient
public List getSideEffects() {
return getOperator().isModifying() ? singletonList(this) : expression.getSideEffects();
}
public enum Type {
/**
* Represent x! syntax
*/
SuppressNullableWarning;
public boolean isModifying() {
switch (this) {
default:
return false;
}
}
}
public Padding getPadding() {
Padding p;
if (this.padding == null) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
} else {
p = this.padding.get();
if (p == null || p.t != this) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
}
}
return p;
}
@Override
public String toString() {
return withPrefix(Space.EMPTY).printTrimmed(new JavaPrinter<>());
}
@RequiredArgsConstructor
public static class Padding {
private final Cs.Unary t;
public JLeftPadded getOperator() {
return t.operator;
}
public Cs.Unary withOperator(JLeftPadded operator) {
return t.operator == operator ? t : new Cs.Unary(t.id, t.prefix, t.markers, operator, t.expression, t.type);
}
}
}
/**
* Represents a constructor initializer which is a call to another constructor, either in the same class (this)
* or in the base class (base).
*
* Examples:
* ```csharp
* class Person {
* // Constructor with 'this' initializer
* public Person(string name) : this(name, 0) { }
*
* // Constructor with 'base' initializer
* public Person(string name, int age) : base(name) { }
* }
* ```
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@RequiredArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
final class ConstructorInitializer implements Cs {
@Nullable
@NonFinal
transient WeakReference padding;
@With
@EqualsAndHashCode.Include
@Getter
UUID id;
@With
@Getter
Space prefix;
@With
@Getter
Markers markers;
@With
@Getter
Cs.Keyword keyword;
JContainer arguments;
public List getArguments() {
return arguments.getElements();
}
public ConstructorInitializer withArguments(List arguments) {
return getPadding().withArguments(JContainer.withElements(this.arguments, arguments));
}
@Override
public J acceptCSharp(CSharpVisitor
v, P p) {
return v.visitConstructorInitializer(this, p);
}
public Padding getPadding() {
Padding p;
if (this.padding == null) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
} else {
p = this.padding.get();
if (p == null || p.t != this) {
p = new Padding(this);
this.padding = new WeakReference<>(p);
}
}
return p;
}
@RequiredArgsConstructor
public static class Padding {
private final ConstructorInitializer t;
public JContainer getArguments() {
return t.arguments;
}
public ConstructorInitializer withArguments(JContainer 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