File tree Expand file tree Collapse file tree 2 files changed +50
-4
lines changed
main/java/org/openrewrite/java/migrate/joda
test/java/org/openrewrite/java/migrate/joda Expand file tree Collapse file tree 2 files changed +50
-4
lines changed Original file line number Diff line number Diff line change 2626import org .openrewrite .analysis .dataflow .Dataflow ;
2727import org .openrewrite .analysis .dataflow .analysis .SinkFlowSummary ;
2828import org .openrewrite .java .JavaIsoVisitor ;
29- import org .openrewrite .java .tree . Expression ;
30- import org .openrewrite .java .tree .J ;
29+ import org .openrewrite .java .JavadocVisitor ;
30+ import org .openrewrite .java .tree .* ;
3131import org .openrewrite .java .tree .J .VariableDeclarations .NamedVariable ;
32- import org .openrewrite .java .tree .JavaType ;
33- import org .openrewrite .java .tree .MethodCall ;
3432
3533import java .util .*;
3634import java .util .concurrent .atomic .AtomicBoolean ;
@@ -52,6 +50,19 @@ public JodaTimeScanner(JodaTimeRecipe.Accumulator acc) {
5250 this .acc = acc ;
5351 }
5452
53+ @ Override
54+ protected JavadocVisitor <ExecutionContext > getJavadocVisitor () {
55+ return new JavadocVisitor <ExecutionContext >(this ) {
56+ /**
57+ * Do not visit the method referenced from the Javadoc, may cause recipe to fail.
58+ */
59+ @ Override
60+ public Javadoc visitReference (Javadoc .Reference reference , ExecutionContext ctx ) {
61+ return reference ;
62+ }
63+ };
64+ }
65+
5566 @ Override
5667 public J visitCompilationUnit (J .CompilationUnit cu , ExecutionContext ctx ) {
5768 super .visitCompilationUnit (cu , ctx );
Original file line number Diff line number Diff line change @@ -467,4 +467,39 @@ public Interval interval() {
467467 )
468468 );
469469 }
470+
471+ @ Test
472+ void migrateWithMethodReferenceInComment () {
473+ //language=java
474+ rewriteRun (
475+ java (
476+ """
477+ import org.joda.time.DateTime;
478+
479+ class A {
480+ public void foo() {
481+ /**
482+ * some method reference in comment
483+ * {@link java.util.List#add(DateTime)}
484+ */
485+ System.out.println(new DateTime());
486+ }
487+ }
488+ """ ,
489+ """
490+ import java.time.ZonedDateTime;
491+
492+ class A {
493+ public void foo() {
494+ /**
495+ * some method reference in comment
496+ * {@link java.util.List#add(DateTime)}
497+ */
498+ System.out.println(ZonedDateTime.now());
499+ }
500+ }
501+ """
502+ )
503+ );
504+ }
470505}
You can’t perform that action at this time.
0 commit comments