15
15
*/
16
16
package org .openrewrite .java .migrate ;
17
17
18
- import org .openrewrite .ExecutionContext ;
19
- import org .openrewrite .Preconditions ;
20
18
import org .openrewrite .Recipe ;
21
- import org .openrewrite .TreeVisitor ;
22
- import org .openrewrite .java .JavaIsoVisitor ;
23
- import org .openrewrite .java .search .UsesJavaVersion ;
24
- import org .openrewrite .java .tree .J ;
19
+ import org .openrewrite .staticanalysis .RemoveExtraSemicolons ;
25
20
21
+ import java .util .List ;
22
+
23
+ import static java .util .Collections .singletonList ;
24
+
25
+ /**
26
+ * @deprecated Use {@link RemoveExtraSemicolons} instead.
27
+ */
28
+ @ Deprecated
26
29
public class RemoveIllegalSemicolons extends Recipe {
27
30
@ Override
28
31
public String getDisplayName () {
@@ -33,22 +36,11 @@ public String getDisplayName() {
33
36
public String getDescription () {
34
37
//language=markdown
35
38
return "Remove semicolons after package declarations and imports, no longer accepted in Java 21 as of " +
36
- "[JDK-8027682](https://bugs.openjdk.org/browse/JDK-8027682)." ;
39
+ "[JDK-8027682](https://bugs.openjdk.org/browse/JDK-8027682)." ;
37
40
}
38
41
39
42
@ Override
40
- public TreeVisitor <?, ExecutionContext > getVisitor () {
41
- return Preconditions .check (new UsesJavaVersion <>(21 ), new JavaIsoVisitor <ExecutionContext >() {
42
- @ Override
43
- public J .Import visitImport (J .Import _import , ExecutionContext ctx ) {
44
- J .Import im = super .visitImport (_import , ctx );
45
- if (im .getPrefix ().getWhitespace ().contains (";" )) {
46
- im = im .withPrefix (im .getPrefix ()
47
- .withWhitespace (im .getPrefix ().getWhitespace ()
48
- .replaceAll ("\\ s*;(\\ R*)\\ s*" , "$1" )));
49
- }
50
- return im ;
51
- }
52
- });
43
+ public List <Recipe > getRecipeList () {
44
+ return singletonList (new RemoveExtraSemicolons ());
53
45
}
54
46
}
0 commit comments