-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New `AnnotationService` * Deprecate `getAllAnnotations()` methods * Optimize `JavaVisitor#service()` * Optimize `JavaVisitor#service()` * Polish * Add `@deprecated` Javadoc tags
- Loading branch information
1 parent
6892a98
commit 946e627
Showing
10 changed files
with
196 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
rewrite-java-test/src/test/java/org/openrewrite/java/service/AnnotationServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2023 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. | ||
*/ | ||
package org.openrewrite.java.service; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openrewrite.test.RewriteTest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.openrewrite.java.Assertions.java; | ||
|
||
public class AnnotationServiceTest implements RewriteTest { | ||
|
||
@Test | ||
void classAnnotations() { | ||
rewriteRun( | ||
java( | ||
""" | ||
import javax.annotation.processing.Generated; | ||
@SuppressWarnings("all") | ||
public @Generated("foo") class T {} | ||
""", | ||
spec -> spec.afterRecipe(cu -> { | ||
AnnotationService service = cu.service(AnnotationService.class); | ||
assertThat(service.getAllAnnotations(cu)).isEmpty(); | ||
assertThat(service.getAllAnnotations(cu.getClasses().get(0))).satisfiesExactly( | ||
ann0 -> assertThat(ann0.getSimpleName()).isEqualTo("SuppressWarnings"), | ||
ann1 -> assertThat(ann1.getSimpleName()).isEqualTo("Generated") | ||
); | ||
}) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.