From 1bb454da62aaf59fb60726092c92d6ffb9b1667e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Schn=C3=A9ider?= Date: Thu, 15 Aug 2024 00:38:36 -0400 Subject: [PATCH] Migrate to JSpecify from OpenRewrite JSR-305 meta-annotations (#114) Use this link to re-run the recipe: https://app.moderne.io/builder/gW3xaSLWV?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../java/micronaut/AddAnnotationProcessorPath.java | 2 +- .../java/micronaut/AddSnakeYamlDependencyIfNeeded.java | 2 +- .../micronaut/AddTestResourcesClientDependencyIfNeeded.java | 2 +- .../java/micronaut/ChangeAnnotationProcessorPath.java | 6 +++--- .../java/micronaut/CopyNonInheritedAnnotations.java | 2 +- .../org/openrewrite/java/micronaut/MavenExclusions.java | 2 +- .../java/micronaut/TypeRequiresIntrospection.java | 6 +++--- .../java/micronaut/UpdateSecurityPropertiesIfNeeded.java | 2 +- .../java/micronaut/UpdateSecurityYamlIfNeeded.java | 2 +- .../java/org/openrewrite/java/micronaut/package-info.java | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openrewrite/java/micronaut/AddAnnotationProcessorPath.java b/src/main/java/org/openrewrite/java/micronaut/AddAnnotationProcessorPath.java index 1f5563e..d488199 100644 --- a/src/main/java/org/openrewrite/java/micronaut/AddAnnotationProcessorPath.java +++ b/src/main/java/org/openrewrite/java/micronaut/AddAnnotationProcessorPath.java @@ -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.search.UsesType; import org.openrewrite.java.tree.JavaSourceFile; import org.openrewrite.maven.MavenIsoVisitor; diff --git a/src/main/java/org/openrewrite/java/micronaut/AddSnakeYamlDependencyIfNeeded.java b/src/main/java/org/openrewrite/java/micronaut/AddSnakeYamlDependencyIfNeeded.java index a14dad6..1da52cc 100644 --- a/src/main/java/org/openrewrite/java/micronaut/AddSnakeYamlDependencyIfNeeded.java +++ b/src/main/java/org/openrewrite/java/micronaut/AddSnakeYamlDependencyIfNeeded.java @@ -15,8 +15,8 @@ */ package org.openrewrite.java.micronaut; +import org.jspecify.annotations.Nullable; import org.openrewrite.*; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.dependencies.AddDependency; import java.util.ArrayList; diff --git a/src/main/java/org/openrewrite/java/micronaut/AddTestResourcesClientDependencyIfNeeded.java b/src/main/java/org/openrewrite/java/micronaut/AddTestResourcesClientDependencyIfNeeded.java index fa22d66..1138be3 100644 --- a/src/main/java/org/openrewrite/java/micronaut/AddTestResourcesClientDependencyIfNeeded.java +++ b/src/main/java/org/openrewrite/java/micronaut/AddTestResourcesClientDependencyIfNeeded.java @@ -15,8 +15,8 @@ */ package org.openrewrite.java.micronaut; +import org.jspecify.annotations.Nullable; import org.openrewrite.*; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.maven.AddDependency; import org.openrewrite.maven.MavenIsoVisitor; import org.openrewrite.maven.search.FindProperties; diff --git a/src/main/java/org/openrewrite/java/micronaut/ChangeAnnotationProcessorPath.java b/src/main/java/org/openrewrite/java/micronaut/ChangeAnnotationProcessorPath.java index 61717ea..429ec3f 100644 --- a/src/main/java/org/openrewrite/java/micronaut/ChangeAnnotationProcessorPath.java +++ b/src/main/java/org/openrewrite/java/micronaut/ChangeAnnotationProcessorPath.java @@ -17,13 +17,13 @@ import lombok.EqualsAndHashCode; import lombok.Value; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.openrewrite.ExecutionContext; import org.openrewrite.Option; import org.openrewrite.Recipe; import org.openrewrite.TreeVisitor; import org.openrewrite.internal.StringUtils; -import org.openrewrite.internal.lang.NonNull; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.maven.MavenVisitor; import org.openrewrite.semver.DependencyMatcher; import org.openrewrite.xml.AddOrUpdateChild; @@ -146,7 +146,7 @@ private Xml.Tag maybeUpdateAnnotationProcessorPaths(Xml.Tag annotationProcessorP }); } - private void maybeAddExclusionsToPath(@NonNull Xml.Tag path, @NonNull List exclusionsToAdd) { + private void maybeAddExclusionsToPath(Xml.@NonNull Tag path, @NonNull List exclusionsToAdd) { if (!exclusionsToAdd.isEmpty()) { Xml.Tag exclusionsTag = Xml.Tag.build("\n\n" + MavenExclusions.buildContent(exclusionsToAdd) + diff --git a/src/main/java/org/openrewrite/java/micronaut/CopyNonInheritedAnnotations.java b/src/main/java/org/openrewrite/java/micronaut/CopyNonInheritedAnnotations.java index c2f1e99..86f4941 100644 --- a/src/main/java/org/openrewrite/java/micronaut/CopyNonInheritedAnnotations.java +++ b/src/main/java/org/openrewrite/java/micronaut/CopyNonInheritedAnnotations.java @@ -16,12 +16,12 @@ package org.openrewrite.java.micronaut; import lombok.Data; +import org.jspecify.annotations.Nullable; import org.openrewrite.ExecutionContext; import org.openrewrite.ScanningRecipe; import org.openrewrite.Tree; import org.openrewrite.TreeVisitor; import org.openrewrite.internal.ListUtils; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.JavaIsoVisitor; import org.openrewrite.java.tree.J; import org.openrewrite.java.tree.JavaType; diff --git a/src/main/java/org/openrewrite/java/micronaut/MavenExclusions.java b/src/main/java/org/openrewrite/java/micronaut/MavenExclusions.java index cbcf748..af2853e 100644 --- a/src/main/java/org/openrewrite/java/micronaut/MavenExclusions.java +++ b/src/main/java/org/openrewrite/java/micronaut/MavenExclusions.java @@ -15,7 +15,7 @@ */ package org.openrewrite.java.micronaut; -import org.openrewrite.internal.lang.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/org/openrewrite/java/micronaut/TypeRequiresIntrospection.java b/src/main/java/org/openrewrite/java/micronaut/TypeRequiresIntrospection.java index 53c5fb8..236e4fe 100644 --- a/src/main/java/org/openrewrite/java/micronaut/TypeRequiresIntrospection.java +++ b/src/main/java/org/openrewrite/java/micronaut/TypeRequiresIntrospection.java @@ -16,11 +16,11 @@ package org.openrewrite.java.micronaut; import lombok.Data; +import org.jspecify.annotations.Nullable; import org.openrewrite.ExecutionContext; import org.openrewrite.ScanningRecipe; import org.openrewrite.Tree; import org.openrewrite.TreeVisitor; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.AnnotationMatcher; import org.openrewrite.java.JavaIsoVisitor; import org.openrewrite.java.JavaParser; @@ -42,7 +42,7 @@ public String getDescription() { return "In Micronaut 2.x a reflection-based strategy was used to retrieve that information if the class was not annotated with `@Introspected`. As of Micronaut 3.x it is required to annotate classes with `@Introspected` that are used in this way."; } - private static boolean parentRequiresIntrospection(@Nullable JavaType.FullyQualified type) { + private static boolean parentRequiresIntrospection(JavaType.@Nullable FullyQualified type) { if (type == null) { return false; } @@ -98,7 +98,7 @@ public TreeVisitor getVisitor(Accumulator acc) { } private static final class FindParamsAndReturnTypes extends JavaIsoVisitor> { - private void maybeAddType(@Nullable JavaType.FullyQualified type, Set foundTypes) { + private void maybeAddType(JavaType.@Nullable FullyQualified type, Set foundTypes) { if (type != null && !TypeRequiresIntrospection.parentRequiresIntrospection(type)) { foundTypes.add(type); } diff --git a/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityPropertiesIfNeeded.java b/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityPropertiesIfNeeded.java index 595c8a3..35b1f40 100644 --- a/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityPropertiesIfNeeded.java +++ b/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityPropertiesIfNeeded.java @@ -15,8 +15,8 @@ */ package org.openrewrite.java.micronaut; +import org.jspecify.annotations.Nullable; import org.openrewrite.*; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.properties.ChangePropertyKey; import java.util.ArrayList; diff --git a/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityYamlIfNeeded.java b/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityYamlIfNeeded.java index 0650b5d..455f79c 100644 --- a/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityYamlIfNeeded.java +++ b/src/main/java/org/openrewrite/java/micronaut/UpdateSecurityYamlIfNeeded.java @@ -15,8 +15,8 @@ */ package org.openrewrite.java.micronaut; +import org.jspecify.annotations.Nullable; import org.openrewrite.*; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.yaml.CopyValue; import org.openrewrite.yaml.DeleteKey; import org.openrewrite.yaml.MergeYaml; diff --git a/src/main/java/org/openrewrite/java/micronaut/package-info.java b/src/main/java/org/openrewrite/java/micronaut/package-info.java index eb0197b..2ccc709 100644 --- a/src/main/java/org/openrewrite/java/micronaut/package-info.java +++ b/src/main/java/org/openrewrite/java/micronaut/package-info.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@NonNullApi @NonNullFields +@NullMarked @NonNullFields package org.openrewrite.java.micronaut; -import org.openrewrite.internal.lang.NonNullApi; +import org.jspecify.annotations.NullMarked; import org.openrewrite.internal.lang.NonNullFields;