IntentionAction (final PsiExpressionList list, final int i, final PsiType toType) { PsiMethodCallExpression call = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprDown(list.getExpressions()[i]), PsiMethodCallExpression.class); if (call == null) return null; PsiMethod method = call.resolveMethod(); if (method == null) return null; PsiReferenceExpression ref = call.getMethodExpression(); // Do not suggest to change return type if the same method is used several times in this argument list // In this case it's unlikely that compilation error will be fixed, and can be confusing boolean noOtherRefs = PsiTreeUtil.processElements( list, e -> e == ref || !(e instanceof PsiReferenceExpression) || !((PsiReferenceExpression)e).isReferenceTo(method)); if (!noOtherRefs) return null; return QuickFixFactory.getInstance().createMethodReturnFix(method, toType, true); }