Skip to content

Commit

Permalink
Migrate to JSpecify from OpenRewrite JSR-305 meta-annotations
Browse files Browse the repository at this point in the history
Use this link to re-run the recipe: https://app.moderne.io/builder/lFW7wUiCk?organizationId=T3BlblJld3JpdGU%3D

Co-authored-by: Moderne <[email protected]>
  • Loading branch information
jkschneider and TeamModerne committed Aug 15, 2024
1 parent ac8c497 commit 2a65662
Show file tree
Hide file tree
Showing 42 changed files with 69 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/kotlin/AddImport.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package org.openrewrite.kotlin;

import lombok.EqualsAndHashCode;
import org.jspecify.annotations.Nullable;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.marker.JavaSourceSet;
import org.openrewrite.java.search.FindMethods;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/kotlin/Assertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


import org.intellij.lang.annotations.Language;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.ThrowingConsumer;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.search.FindMissingTypes;
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.marker.Extension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.kotlin.table.KotlinSourceFile;
import org.openrewrite.kotlin.tree.K;
import org.openrewrite.marker.SearchResult;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/kotlin/KotlinParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices;
import org.jetbrains.kotlin.utils.PathUtil;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaParser;
import org.openrewrite.java.internal.JavaTypeCache;
import org.openrewrite.java.marker.JavaSourceSet;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/kotlin/KotlinVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package org.openrewrite.kotlin;

import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.SourceFile;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.marker.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.Expression;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.Space;
Expand All @@ -37,8 +37,8 @@
@Value
@EqualsAndHashCode(callSuper = false)
public class EqualsMethodUsage extends Recipe {
@Nullable
private static J.Binary equalsBinaryTemplate;

private static J.@Nullable Binary equalsBinaryTemplate;

@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.PrintOutputCapture;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.Space;
import org.openrewrite.kotlin.KotlinIsoVisitor;
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.kotlin.cleanup;

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 @@ -16,10 +16,10 @@
package org.openrewrite.kotlin.format;


import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.SourceFile;
import org.openrewrite.Tree;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaSourceFile;
import org.openrewrite.kotlin.KotlinIsoVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package org.openrewrite.kotlin.format;


import org.jspecify.annotations.Nullable;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.KotlinIsoVisitor;
import org.openrewrite.kotlin.marker.OmitBraces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package org.openrewrite.kotlin.format;

import com.fasterxml.jackson.annotation.JsonCreator;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.marker.ImplicitReturn;
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.KotlinIsoVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package org.openrewrite.kotlin.format;

import com.fasterxml.jackson.annotation.JsonCreator;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.JavadocVisitor;
import org.openrewrite.java.tree.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package org.openrewrite.kotlin.format;

import org.jspecify.annotations.Nullable;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.JavadocVisitor;
import org.openrewrite.java.tree.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.openrewrite.kotlin.format;


import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.NonNull;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.JavadocVisitor;
import org.openrewrite.java.tree.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@


import com.fasterxml.jackson.annotation.JsonCreator;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Tree;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaSourceFile;
import org.openrewrite.java.tree.Space;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package org.openrewrite.kotlin.format;

import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Tree;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.J;
import org.openrewrite.kotlin.KotlinIsoVisitor;
import org.openrewrite.kotlin.style.IntelliJ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package org.openrewrite.kotlin.format;

import org.jspecify.annotations.Nullable;
import org.openrewrite.PrintOutputCapture;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.marker.OmitParentheses;
import org.openrewrite.java.marker.TrailingComma;
import org.openrewrite.java.tree.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package org.openrewrite.kotlin.format;

import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.marker.ImplicitReturn;
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.KotlinIsoVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package org.openrewrite.kotlin.format;


import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.KotlinIsoVisitor;
import org.openrewrite.kotlin.marker.OmitBraces;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/kotlin/format/package-info.java
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.kotlin.format;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
import org.openrewrite.internal.lang.NonNullFields;
10 changes: 5 additions & 5 deletions src/main/java/org/openrewrite/kotlin/internal/KotlinPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package org.openrewrite.kotlin.internal;

import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.PrintOutputCapture;
import org.openrewrite.Tree;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaPrinter;
import org.openrewrite.java.marker.ImplicitReturn;
import org.openrewrite.java.marker.OmitParentheses;
Expand Down Expand Up @@ -645,7 +645,7 @@ public J visitClassDeclaration(J.ClassDeclaration classDecl, PrintOutputCapture<
return visitClassDeclaration0(classDecl, null, p);
}

private J.ClassDeclaration visitClassDeclaration0(J.ClassDeclaration classDecl, @Nullable K.TypeConstraints typeConstraints, PrintOutputCapture<P> p) {
private J.ClassDeclaration visitClassDeclaration0(J.ClassDeclaration classDecl, K.@Nullable TypeConstraints typeConstraints, PrintOutputCapture<P> p) {
beforeSyntax(classDecl, Space.Location.CLASS_DECLARATION_PREFIX, p);
visit(classDecl.getLeadingAnnotations(), p);
for (J.Modifier m : classDecl.getModifiers()) {
Expand Down Expand Up @@ -884,7 +884,7 @@ public J visitMethodDeclaration(J.MethodDeclaration method, PrintOutputCapture<P
return visitMethodDeclaration0(method, null, p);
}

private J.MethodDeclaration visitMethodDeclaration0(J.MethodDeclaration method, @Nullable K.TypeConstraints typeConstraints, PrintOutputCapture<P> p) {
private J.MethodDeclaration visitMethodDeclaration0(J.MethodDeclaration method, K.@Nullable TypeConstraints typeConstraints, PrintOutputCapture<P> p) {
// Do not print generated methods.
for (Marker marker : method.getMarkers().getMarkers()) {
if (marker instanceof Implicit || marker instanceof PrimaryConstructor) {
Expand Down Expand Up @@ -1404,7 +1404,7 @@ private void beforeSyntax(J j, Space.Location loc, PrintOutputCapture<P> p) {
beforeSyntax(j.getPrefix(), j.getMarkers(), loc, p);
}

private void beforeSyntax(Space prefix, Markers markers, @Nullable KSpace.Location loc, PrintOutputCapture<P> p) {
private void beforeSyntax(Space prefix, Markers markers, KSpace.@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 @@ -1421,7 +1421,7 @@ private void beforeSyntax(K k, Space.Location loc, PrintOutputCapture<P> p) {
beforeSyntax(k.getPrefix(), k.getMarkers(), loc, p);
}

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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
import org.jetbrains.kotlin.parsing.ParseUtilsKt;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.FileAttributes;
import org.openrewrite.ParseExceptionResult;
import org.openrewrite.Tree;
import org.openrewrite.internal.EncodingDetectingInputStream;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.lang.NonNull;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.marker.ImplicitReturn;
import org.openrewrite.java.marker.OmitParentheses;
import org.openrewrite.java.marker.Quoted;
Expand Down Expand Up @@ -3669,7 +3669,7 @@ private J.Identifier createIdentifier(String name, Space prefix,

private J.Identifier createIdentifier(String name, Space prefix,
@Nullable JavaType type,
@Nullable JavaType.Variable fieldType) {
JavaType.@Nullable Variable fieldType) {
Markers markers = Markers.EMPTY;
String updated = name;
if (name.startsWith("`")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.internal.JavaTypeCache;
import org.openrewrite.java.tree.*;
import org.openrewrite.kotlin.KotlinIrTypeMapping;
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.kotlin.internal;

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.kotlin.internal.template;

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 @@ -19,7 +19,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Value;
import lombok.With;
import org.openrewrite.internal.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.openrewrite.java.tree.Space;
import org.openrewrite.marker.Marker;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/kotlin/marker/KObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Value;
import lombok.With;
import org.openrewrite.internal.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.openrewrite.java.tree.Space;
import org.openrewrite.marker.Marker;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/kotlin/marker/package-info.java
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.kotlin.marker;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
import org.openrewrite.internal.lang.NonNullFields;
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/kotlin/package-info.java
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.kotlin;

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

0 comments on commit 2a65662

Please sign in to comment.