TypeConversionDescriptorBase (@Nullable PsiType from, @Nullable PsiType to, @NotNull PsiMethod method, @NotNull String methodName, PsiExpression context, TypeMigrationLabeler labeler) { if (!(context instanceof PsiMethodCallExpression)) { if ("or".equals(methodName)) { PsiMethodCallExpression methodCallExpression = null; if (context.getParent() instanceof PsiMethodCallExpression) { methodCallExpression = (PsiMethodCallExpression)context.getParent(); } if (methodCallExpression == null) { return null; } final PsiClass aClass = getParameterClass(method); if (aClass != null) { final String qName = aClass.getQualifiedName(); if (GUAVA_OPTIONAL.equals(qName)) { TypeConversionDescriptor descriptor = new TypeConversionDescriptor(null, "java.util.Optional.ofNullable($val$.orElseGet($o$::get))") { @Override public PsiExpression replace(PsiExpression expression, @NotNull TypeEvaluator evaluator) { setStringToReplace("$val$.or(" + GuavaOptionalConversionUtil.simplifyParameterPattern((PsiMethodCallExpression)expression) + ")"); return super.replace(expression, evaluator); } }; if (to != null) { descriptor.withConversionType(to); } return descriptor; } return GuavaLambda.SUPPLIER.getClassQName().equals(qName) ? new GuavaTypeConversionDescriptor("$val$.or($other$)", "$val$.orElseGet($other$)", context) : new TypeConversionDescriptor("$val$.or($other$)", "$val$.orElse($other$)"); } return null; } else if ("transform".equals(methodName)) { final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)(context.getParent()); final PsiExpression[] arguments = methodCall.getArgumentList().getExpressions(); if (arguments.length != 1) { return null; } final PsiExpression functionArgument = arguments[0]; final TypeConversionDescriptor descriptor = new GuavaTypeConversionDescriptor("$val$.transform($fun$)", "$val$.map($fun$)", context); final PsiType typeParameter = GuavaConversionUtil.getFunctionReturnType(functionArgument); if (typeParameter == null) { return descriptor; } final String rawOptionalType = JAVA_OPTIONAL + "<" + typeParameter.getCanonicalText(false) + ">"; return descriptor.withConversionType(JavaPsiFacade.getElementFactory(method.getProject()).createTypeFromText(rawOptionalType, context)); } return null; } final PsiClass aClass = method.getContainingClass(); if (aClass == null || !(GuavaFluentIterableConversionRule.FLUENT_ITERABLE.equals(aClass.getQualifiedName()) || GUAVA_OPTIONAL.equals(aClass.getQualifiedName()))) { return null; } return GuavaFluentIterableConversionRule.buildCompoundDescriptor((PsiMethodCallExpression) context, to, labeler); }