PsiExpression (PsiExpression expression, @NotNull TypeEvaluator evaluator) { @NonNls String newExpressionString = GuavaConversionUtil.adjustLambdaContainingExpression(((PsiMethodCallExpression)expression).getArgumentList().getExpressions()[0], true, myTargetType, evaluator).getText() + ".negate()"; final PsiElement parent = expression.getParent(); if (parent instanceof PsiMethodReferenceExpression) { expression = replaceTypeCast(expression, parent); } else if (!GuavaConversionUtil.isJavaLambda(parent, evaluator)) { newExpressionString += "::test"; } final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(expression.getProject()); PsiExpression convertedExpression = (PsiExpression)expression.replace(elementFactory.createExpressionFromText(newExpressionString, expression)); convertedExpression = convertedExpression.getParent() instanceof PsiMethodReferenceExpression ? (PsiExpression)convertedExpression.getParent().replace(convertedExpression) : convertedExpression; final PsiElement maybeTypeCast = convertedExpression.getParent(); if (maybeTypeCast instanceof PsiTypeCastExpression && RedundantCastUtil.isCastRedundant((PsiTypeCastExpression)maybeTypeCast)) { convertedExpression = (PsiExpression)maybeTypeCast.replace(((PsiTypeCastExpression)maybeTypeCast).getOperand()); } return convertedExpression; }