File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
main/java/org/openrewrite/java
test/java/org/openrewrite/java Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public String getInstanceNameSuffix() {
65
65
66
66
@ Override
67
67
public TreeVisitor <?, ExecutionContext > getVisitor () {
68
- TypeMatcher typeMatcher = new TypeMatcher (typePattern , false );
68
+ TypeMatcher typeMatcher = new TypeMatcher (typePattern );
69
69
return new JavaIsoVisitor <ExecutionContext >() {
70
70
@ Override
71
71
public J .Import visitImport (J .Import anImport , ExecutionContext ctx ) {
Original file line number Diff line number Diff line change @@ -37,11 +37,48 @@ public class Foo {}
37
37
"""
38
38
package foo;
39
39
public class Bar extends Foo {}
40
+ """ ,
41
+ """
42
+ package foo.bar;
43
+ public class Baz {
44
+ public static void someStaticMethod() {}
45
+ }
40
46
"""
41
47
));
42
48
}
43
49
44
50
@ DocumentExample
51
+ @ Test
52
+ void wildcardAndStaticImportsRecognized () {
53
+ rewriteRun (
54
+ spec -> spec .recipe (new AddCommentToImport (SHORT_COMMENT , "foo.bar.Baz" )),
55
+ //language=java
56
+ java (
57
+ """
58
+ package blah;
59
+ // Will not match direct package
60
+ import foo.*;
61
+ import foo.bar.*;
62
+ import foo.bar.Baz;
63
+ import static foo.bar.Baz.someStaticMethod;
64
+ class Other {}
65
+ """ ,
66
+ """
67
+ package blah;
68
+ // Will not match direct package
69
+ import foo.*;
70
+ /* Short comment to add */
71
+ import foo.bar.*;
72
+ /* Short comment to add */
73
+ import foo.bar.Baz;
74
+ /* Short comment to add */
75
+ import static foo.bar.Baz.someStaticMethod;
76
+ class Other {}
77
+ """
78
+ )
79
+ );
80
+ }
81
+
45
82
@ Test
46
83
void addSingleLineComment () {
47
84
rewriteRun (
You can’t perform that action at this time.
0 commit comments