Skip to content

Commit

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

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
jkschneider and TeamModerne authored Aug 15, 2024
1 parent fbf4c65 commit adec9d5
Show file tree
Hide file tree
Showing 31 changed files with 50 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/analysis/InvocationMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.Incubating;
import org.openrewrite.Tree;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.MethodMatcher;
import org.openrewrite.java.tree.*;

Expand All @@ -44,7 +44,7 @@ public interface InvocationMatcher {
* @param type The type of the method invocation or constructor.
* @return True if the invocation or constructor matches the criteria of this matcher.
*/
boolean matches(@Nullable JavaType.Method type);
boolean matches(JavaType.@Nullable Method type);

default boolean matches(@Nullable MethodCall methodCall) {
if (methodCall == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.constantfold;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.Incubating;
import org.openrewrite.Tree;
import org.openrewrite.analysis.util.CursorUtil;
import org.openrewrite.internal.SelfLoathing;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.JavaTemplate;
import org.openrewrite.java.VariableNameUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package org.openrewrite.analysis.controlflow;

import lombok.AllArgsConstructor;
import org.jspecify.annotations.Nullable;
import org.openrewrite.PrintOutputCapture;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaPrinter;
import org.openrewrite.java.tree.*;
import org.openrewrite.marker.Markers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.openrewrite.analysis.controlflow;

import lombok.Value;
import org.openrewrite.internal.lang.NonNull;
import org.jspecify.annotations.NonNull;

import java.util.Comparator;
import java.util.IdentityHashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Incubating;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.tree.Expression;
import org.openrewrite.java.tree.J;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/openrewrite/analysis/controlflow/Guard.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import lombok.AccessLevel;
import lombok.Getter;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.Incubating;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.*;

import java.util.Optional;
Expand All @@ -35,11 +35,10 @@ public final class Guard {
private final Expression expression;

@Getter
@Nullable
private final J.Case theCase;
private final J.@Nullable Case theCase;


private Guard(Cursor cursor, @Nullable Expression expression, @Nullable J.Case theCase) {
private Guard(Cursor cursor, @Nullable Expression expression, J.@Nullable Case theCase) {
if (expression == null && theCase == null) {
throw new IllegalArgumentException("Guard must have either an expression or a case");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.controlflow;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import fj.data.Option;
import lombok.AllArgsConstructor;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.Incubating;
import org.openrewrite.analysis.controlflow.ControlFlow;
import org.openrewrite.analysis.dataflow.analysis.*;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.Expression;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.openrewrite.analysis.dataflow;

import lombok.RequiredArgsConstructor;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Cursor;
import org.openrewrite.Incubating;
import org.openrewrite.Tree;
import org.openrewrite.analysis.dataflow.analysis.SinkFlowSummary;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.tree.Expression;
import org.openrewrite.java.tree.J;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.dataflow.analysis;

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

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import lombok.Data;
import lombok.Getter;
import org.jspecify.annotations.Nullable;
import org.openrewrite.analysis.BasicInvocationMatcher;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.tree.JavaType;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.dataflow.internal.csv;

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

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* The primary entry point for interacting with this logic is
* {@link org.openrewrite.analysis.dataflow.Dataflow#startingAt(org.openrewrite.Cursor)}.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.dataflow;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.analysis.InvocationMatcher;
import org.openrewrite.analysis.dataflow.DataFlowNode;
import org.openrewrite.analysis.dataflow.DataFlowSpec;
import org.openrewrite.analysis.dataflow.TaintFlowSpec;
import org.openrewrite.analysis.dataflow.global.GlobalDataFlow;
import org.openrewrite.analysis.trait.expr.Call;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.MethodMatcher;

import java.util.function.Predicate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.analysis.dataflow.DataFlowNode;
import org.openrewrite.analysis.dataflow.DataFlowSpec;
import org.openrewrite.analysis.dataflow.FindLocalFlowPaths;
import org.openrewrite.analysis.dataflow.TaintFlowSpec;
import org.openrewrite.analysis.trait.expr.Expr;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.MethodMatcher;
import org.openrewrite.java.search.UsesMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.openrewrite.analysis.search;

import lombok.RequiredArgsConstructor;
import org.jspecify.annotations.Nullable;
import org.openrewrite.Incubating;
import org.openrewrite.Tree;
import org.openrewrite.analysis.InvocationMatcher;
import org.openrewrite.internal.LoathingOfOthers;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaSourceFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package org.openrewrite.analysis.search;

import org.jspecify.annotations.Nullable;
import org.openrewrite.Incubating;
import org.openrewrite.Tree;
import org.openrewrite.analysis.InvocationMatcher;
import org.openrewrite.internal.LoathingOfOthers;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaSourceFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* The primary entry point for interacting with this logic is
* {@link org.openrewrite.analysis.dataflow.Dataflow#startingAt(org.openrewrite.Cursor)}.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.search;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/analysis/trait/Top.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.openrewrite.analysis.trait;

import org.openrewrite.internal.lang.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.UUID;

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

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

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

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* </p>
* The traits are modeled after CodeQL's representation of the Java syntax and the queries and predicates it provides.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.trait;

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

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

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

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/analysis/util/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
@NullMarked
package org.openrewrite.analysis.util;

import org.openrewrite.internal.lang.NonNullApi;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/
package org.openrewrite.analysis.dataflow;

import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Tree;
import org.openrewrite.TreeVisitor;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand Down

0 comments on commit adec9d5

Please sign in to comment.