PsiExpression (PsiExpression expression, @NotNull TypeEvaluator evaluator) { if (expression.getParent() instanceof PsiMethodReferenceExpression) { expression = (PsiExpression)expression.getParent(); } if (expression instanceof PsiMethodReferenceExpression) { expression = setupAsMethodReference(expression); } else if (expression instanceof PsiReferenceExpression) { setupAsReference(); } else { setupAsMethodCall(); } final PsiExpression converted = super.replace(expression, evaluator); final PsiElement parent = converted.getParent(); if (parent instanceof PsiParenthesizedExpression) { if (!ParenthesesUtils.areParenthesesNeeded((PsiParenthesizedExpression)parent, true)) { return (PsiExpression)parent.replace(converted); } } return converted; }