21
21
import org .openrewrite .Recipe ;
22
22
import org .openrewrite .TreeVisitor ;
23
23
import org .openrewrite .java .JavaIsoVisitor ;
24
- import org .openrewrite .java .tree .Expression ;
25
24
import org .openrewrite .java .tree .J ;
26
25
import org .openrewrite .java .tree .JavaType ;
27
- import org .openrewrite .java .tree .TypeUtils ;
28
26
import software .amazon .awssdk .annotations .SdkInternalApi ;
29
27
import software .amazon .awssdk .migration .internal .utils .NamingUtils ;
30
28
@@ -51,17 +49,14 @@ private static class V1GetterToV2Visitor extends JavaIsoVisitor<ExecutionContext
51
49
public J .MethodInvocation visitMethodInvocation (J .MethodInvocation method , ExecutionContext executionContext ) {
52
50
method = super .visitMethodInvocation (method , executionContext );
53
51
54
- JavaType selectType ;
55
-
56
- Expression select = method .getSelect ();
52
+ JavaType .Method methodType = method .getMethodType ();
57
53
58
- if (select == null || select . getType () == null ) {
54
+ if (methodType == null ) {
59
55
return method ;
60
56
}
61
- selectType = select .getType ();
62
57
63
58
String methodName = method .getSimpleName ();
64
- JavaType .FullyQualified fullyQualified = TypeUtils . asFullyQualified ( selectType );
59
+ JavaType .FullyQualified fullyQualified = methodType . getDeclaringType ( );
65
60
66
61
if (!shouldChangeGetter (fullyQualified )) {
67
62
return method ;
@@ -71,21 +66,11 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
71
66
methodName = NamingUtils .removeGet (methodName );
72
67
}
73
68
74
- JavaType .Method methodType = method .getMethodType ();
75
-
76
- if (methodType != null ) {
77
- methodType = methodType .withName (methodName )
78
- .withReturnType (selectType );
79
-
80
- if (fullyQualified != null ) {
81
- methodType = methodType .withDeclaringType (fullyQualified );
82
- }
83
-
84
- method = method .withName (method .getName ()
85
- .withSimpleName (methodName )
86
- .withType (methodType ))
87
- .withMethodType (methodType );
88
- }
69
+ methodType = methodType .withName (methodName );
70
+ method = method .withName (method .getName ()
71
+ .withSimpleName (methodName )
72
+ .withType (methodType ))
73
+ .withMethodType (methodType );
89
74
90
75
return method ;
91
76
}
0 commit comments