2727import org .openrewrite .java .JavaTemplate ;
2828import org .openrewrite .java .tree .J ;
2929
30+ import java .util .Collections ;
3031import java .util .HashSet ;
3132import java .util .Optional ;
3233import java .util .Set ;
3637
3738@ Value
3839@ EqualsAndHashCode (callSuper = false )
39- public class ConvertGetter extends Recipe {
40+ public class UseLombokGetter extends Recipe {
4041
4142 @ Override
4243 public String getDisplayName () {
@@ -54,6 +55,11 @@ public String getDescription() {
5455 " - Does not offer any of the configuration keys listed in https://projectlombok.org/features/GetterSetter." ;
5556 }
5657
58+ @ Override
59+ public Set <String > getTags () {
60+ return Collections .singleton ("lombok" );
61+ }
62+
5763 @ Override
5864 public TreeVisitor <?, ExecutionContext > getVisitor () {
5965 return new MethodRemover ();
@@ -84,9 +90,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
8490
8591 @ Override
8692 public J .@ Nullable MethodDeclaration visitMethodDeclaration (J .MethodDeclaration method , ExecutionContext ctx ) {
87- assert method .getMethodType () != null ;
88-
89- if (LombokUtils .isEffectivelyGetter (method )) {
93+ if (method .getMethodType () != null && LombokUtils .isEffectivelyGetter (method )) {
9094 J .Return return_ = (J .Return ) method .getBody ().getStatements ().get (0 );
9195 Variable fieldType = ((J .Identifier ) return_ .getExpression ()).getFieldType ();
9296 boolean nameMatch = method .getSimpleName ().equals (LombokUtils .deriveGetterMethodName (fieldType ));
@@ -106,7 +110,6 @@ private static class Finding {
106110 AccessLevel accessLevel ;
107111 }
108112
109-
110113 @ Value
111114 @ EqualsAndHashCode (callSuper = false )
112115 static class FieldAnnotator extends JavaIsoVisitor <ExecutionContext > {
0 commit comments