Skip to content

Commit

Permalink
Fix test, add declarative JSpecify recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Aug 14, 2024
1 parent e22f9c6 commit be346a0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions rewrite-core/src/main/resources/META-INF/rewrite/jspecify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Copyright 2024 the original author or authors.
# <p>
# 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
# <p>
# https://www.apache.org/licenses/LICENSE-2.0
# <p>
# 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.
#

type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.jspecify.MigrateFromOpenRewriteAnnotations
displayName: Migrate OpenRewrite nullable annotations to JSpecify
description: Migrate from OpenRewrite's JSR-305 meta-annotations to JSpecify.
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.openrewrite.internal.lang.Nullable
newFullyQualifiedTypeName: org.jspecify.annotations.Nullable
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.openrewrite.internal.lang.NonNullApi
newFullyQualifiedTypeName: org.jspecify.annotations.NullMarked
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.openrewrite.internal.lang.NonNull
newFullyQualifiedTypeName: org.jspecify.annotations.NonNull
ignoreDefinition: true
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.jspecify
artifactId: jspecify
version: latest.release
onlyIfUsing: org.jspecify.annotations..*
configuration: implementation
scope: compile
acceptTransitive: true
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FindAnnotationsTest implements RewriteTest {
@Test
void matchMetaAnnotation() {
rewriteRun(
spec -> spec.recipe(new FindAnnotations("@javax.annotation.Nonnull", true))
spec -> spec.recipe(new FindAnnotations("@org.jspecify.annotations.Nullable", true))
.parser(JavaParser.fromJavaVersion().classpath(JavaParser.runtimeClasspath())),
java(
"""
Expand Down

0 comments on commit be346a0

Please sign in to comment.