Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@
*/
package org.openrewrite.csharp;

import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.marker.Markers;
import org.openrewrite.tree.*;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.tree.*;
import org.openrewrite.csharp.tree.*;

import java.util.List;
import org.openrewrite.java.tree.*;

public class CSharpIsoVisitor<P> extends CSharpVisitor<P>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package org.openrewrite.csharp;

import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.PrintOutputCapture;
import org.openrewrite.Tree;
import org.openrewrite.csharp.marker.OmitBraces;
import org.openrewrite.csharp.marker.SingleExpressionBlock;
import org.openrewrite.csharp.tree.*;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaPrinter;
import org.openrewrite.java.marker.CompactConstructor;
import org.openrewrite.java.marker.Semicolon;
Expand Down Expand Up @@ -714,7 +714,7 @@ private void beforeSyntax(Cs cs, CsSpace.Location loc, PrintOutputCapture<P> p)
beforeSyntax(cs.getPrefix(), cs.getMarkers(), loc, p);
}

private void beforeSyntax(Space prefix, Markers markers, @Nullable CsSpace.Location loc, PrintOutputCapture<P> p) {
private void beforeSyntax(Space prefix, Markers markers, CsSpace.@Nullable Location loc, PrintOutputCapture<P> p) {
for (Marker marker : markers.getMarkers()) {
p.append(p.getMarkerPrinter().beforePrefix(marker, new Cursor(getCursor(), marker), JAVA_MARKER_WRAPPER));
}
Expand All @@ -727,7 +727,7 @@ private void beforeSyntax(Space prefix, Markers markers, @Nullable CsSpace.Locat
}
}

private void beforeSyntax(Space prefix, Markers markers, @Nullable Space.Location loc, PrintOutputCapture<P> p) {
private void beforeSyntax(Space prefix, Markers markers, Space.@Nullable Location loc, PrintOutputCapture<P> p) {
for (Marker marker : markers.getMarkers()) {
p.append(p.getMarkerPrinter().beforePrefix(marker, new Cursor(getCursor(), marker), JAVA_MARKER_WRAPPER));
}
Expand All @@ -749,4 +749,4 @@ private void afterSyntax(Markers markers, PrintOutputCapture<P> p) {
p.append(p.getMarkerPrinter().afterSyntax(marker, new Cursor(getCursor(), marker), JAVA_MARKER_WRAPPER));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.csharp.tree.*;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.marker.Markers;
import org.openrewrite.tree.*;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.tree.*;
import org.openrewrite.csharp.tree.*;
import org.openrewrite.marker.Markers;
import org.openrewrite.tree.*;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
@NonNullFields
package org.openrewrite.csharp.marker;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
import org.openrewrite.internal.lang.NonNullFields;
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
@NonNullFields
package org.openrewrite.csharp;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
import org.openrewrite.internal.lang.NonNullFields;
58 changes: 27 additions & 31 deletions rewrite-csharp/src/main/java/org/openrewrite/csharp/tree/Cs.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
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.internal.lang.Nullable;
import org.openrewrite.java.JavaPrinter;
import org.openrewrite.java.internal.TypesInUse;
import org.openrewrite.java.tree.*;
Expand Down Expand Up @@ -54,8 +54,7 @@ default <P> boolean isAcceptable(TreeVisitor<?, P> v, P p) {
return v.isAdaptableTo(CSharpVisitor.class);
}

@Nullable
default <P> J acceptCSharp(CSharpVisitor<P> v, P p) {
default <P> @Nullable J acceptCSharp(CSharpVisitor<P> v, P p) {
return v.defaultValue(this, p);
}

Expand Down Expand Up @@ -121,11 +120,12 @@ public SourceFile withCharset(Charset charset) {
return withCharsetName(charset.name());
}

@Nullable
public Package getPackageDeclaration() {
@Override
public @Nullable Package getPackageDeclaration() {
return null;
}

@Override
public Cs.CompilationUnit withPackageDeclaration(Package packageDeclaration) {
return this;
}
Expand Down Expand Up @@ -164,15 +164,18 @@ public Cs.CompilationUnit withMembers(List<Statement> members) {
return getPadding().withMembers(JRightPadded.withElements(this.members, members));
}

@Override
@Transient
public List<Import> getImports() {
return Collections.emptyList();
}

@Override
public Cs.CompilationUnit withImports(List<Import> imports) {
return this;
}

@Override
@Transient
public List<ClassDeclaration> getClasses() {
return Collections.emptyList();
Expand Down Expand Up @@ -213,6 +216,7 @@ public TypesInUse getTypesInUse() {
return cache;
}

@Override
public Padding getPadding() {
Padding p;
if (this.padding == null) {
Expand Down Expand Up @@ -378,8 +382,7 @@ public Padding getPadding() {
public static class Padding {
private final ArrayRankSpecifier t;

@Nullable
public JContainer<Expression> getSizes() {
public @Nullable JContainer<Expression> getSizes() {
return t.sizes;
}

Expand Down Expand Up @@ -514,12 +517,12 @@ final class AttributeList implements Cs {
@Nullable
JRightPadded<Identifier> target;

@Nullable
public J.Identifier getTarget() {

public J.@Nullable Identifier getTarget() {
return target == null ? null : target.getElement();
}

public AttributeList withTarget(@Nullable J.Identifier target) {
public AttributeList withTarget(J.@Nullable Identifier target) {
return getPadding().withTarget(JRightPadded.withElement(this.target, target));
}

Expand Down Expand Up @@ -1259,8 +1262,7 @@ public Interpolation withExpression(Expression expression) {
@Nullable
JRightPadded<Expression> alignment;

@Nullable
public Expression getAlignment() {
public @Nullable Expression getAlignment() {
return alignment != null ? alignment.getElement() : null;
}

Expand All @@ -1271,8 +1273,7 @@ public Interpolation withAlignment(@Nullable Expression alignment) {
@Nullable
JRightPadded<Expression> format;

@Nullable
public Expression getFormat() {
public @Nullable Expression getFormat() {
return format != null ? format.getElement() : null;
}

Expand Down Expand Up @@ -1328,17 +1329,15 @@ public Interpolation withExpression(JRightPadded<Expression> expression) {
return t.expression == expression ? t : new Interpolation(t.id, t.prefix, t.markers, expression, t.alignment, t.format);
}

@Nullable
public JRightPadded<Expression> getAlignment() {
public @Nullable JRightPadded<Expression> getAlignment() {
return t.alignment;
}

public Interpolation withAlignment(@Nullable JRightPadded<Expression> alignment) {
return t.alignment == alignment ? t : new Interpolation(t.id, t.prefix, t.markers, t.expression, alignment, t.format);
}

@Nullable
public JRightPadded<Expression> getFormat() {
public @Nullable JRightPadded<Expression> getFormat() {
return t.format;
}

Expand Down Expand Up @@ -1525,12 +1524,12 @@ public UsingDirective withUnsafe(boolean unsafe) {
@Nullable
JRightPadded<Identifier> alias;

@Nullable
public J.Identifier getAlias() {

public J.@Nullable Identifier getAlias() {
return alias != null ? alias.getElement() : null;
}

public UsingDirective withAlias(@Nullable J.Identifier alias) {
public UsingDirective withAlias(J.@Nullable Identifier alias) {
return getPadding().withAlias(JRightPadded.withElement(this.alias, alias));
}

Expand Down Expand Up @@ -1591,8 +1590,7 @@ public UsingDirective withUnsafe(JLeftPadded<Boolean> unsafe) {
return t.unsafe == unsafe ? t : new UsingDirective(t.id, t.prefix, t.markers, t.global, t.statik, unsafe, t.alias, t.namespaceOrType);
}

@Nullable
public JRightPadded<Identifier> getAlias() {
public @Nullable JRightPadded<Identifier> getAlias() {
return t.alias;
}

Expand Down Expand Up @@ -1657,25 +1655,25 @@ 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));
}

@Nullable
public NameTree getInterfaceSpecifier() {
public @Nullable NameTree getInterfaceSpecifier() {
return interfaceSpecifier!= null ? interfaceSpecifier.getElement() : null;
}

public PropertyDeclaration withInterfaceSpecifier(@Nullable NameTree interfaceSpecifier) {
return getPadding().withInterfaceSpecifier(JRightPadded.withElement(this.interfaceSpecifier, interfaceSpecifier));
}

@Nullable
public Expression getInitializer() {
public @Nullable Expression getInitializer() {
return initializer != null ? initializer.getElement() : null;
}

Expand Down Expand Up @@ -1711,8 +1709,7 @@ public TypeTree getType() {
return pd.typeExpression;
}

@Nullable
public JRightPadded<NameTree> getInterfaceSpecifier() {
public @Nullable JRightPadded<NameTree> getInterfaceSpecifier() {
return pd.interfaceSpecifier;
}

Expand Down Expand Up @@ -1742,8 +1739,7 @@ public PropertyDeclaration withType(TypeTree type) {
pd.initializer);
}

@Nullable
public JLeftPadded<Expression> getInitializer() {
public @Nullable JLeftPadded<Expression> getInitializer() {
return pd.initializer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
@NonNullFields
package org.openrewrite.csharp.tree;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
import org.openrewrite.internal.lang.NonNullFields;