public J visitMethodInvocation()

in v2-migration/src/main/java/software/amazon/awssdk/v2migration/ChangeSdkType.java [338:382]


        public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
            if (method.getMethodType() == null) {
                return method;
            }

            JavaType.FullyQualified declaringType = method.getMethodType().getDeclaringType();
            JavaType returnType = method.getMethodType().getReturnType();
            if (isV1ClientClass(returnType) && isSupportedV1ClientClass(returnType)) {
                if (returnType instanceof JavaType.FullyQualified) {
                    String fullyQualifiedName = ((JavaType.FullyQualified) returnType).getFullyQualifiedName();
                    storeV1ClassMetadata(fullyQualifiedName);
                }
            }

            if (isSupportedV1Class(declaringType)) {
                String fullyQualifiedName = declaringType.getFullyQualifiedName();
                storeV1ClassMetadata(fullyQualifiedName);

                Pair<JavaType.Class, JavaType> oldTypeToNewTypePair = oldTypeToNewType.get(fullyQualifiedName);
                JavaType.Class originalType = oldTypeToNewTypePair.left();
                JavaType targetType = oldTypeToNewTypePair.right();
                if (method.getMethodType().hasFlags(Flag.Static)) {
                    if (method.getMethodType().getDeclaringType().isAssignableFrom(originalType)) {
                        JavaSourceFile cu = getCursor().firstEnclosingOrThrow(JavaSourceFile.class);

                        for (J.Import anImport : cu.getImports()) {
                            if (anImport.isStatic() && anImport.getQualid().getTarget().getType() != null) {
                                JavaType.FullyQualified fqn =
                                    TypeUtils.asFullyQualified(anImport.getQualid().getTarget().getType());
                                if (fqn != null && TypeUtils.isOfClassType(fqn, originalType.getFullyQualifiedName()) &&
                                    method.getSimpleName().equals(anImport.getQualid().getSimpleName())) {
                                    JavaType.FullyQualified targetFqn = (JavaType.FullyQualified) targetType;

                                    addImport(targetFqn);
                                    maybeAddImport(targetFqn.getFullyQualifiedName(), method.getName().getSimpleName());
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            return super.visitMethodInvocation(method, ctx);
        }