void (@NotNull PsiMethodCallExpression call) { PsiMethodCallExpression comparingCall = tryCast(PsiUtil.skipParenthesizedExprDown(call.getArgumentList().getExpressions()[0]), PsiMethodCallExpression.class); String targetMethod = REPLACEMENTS.mapFirst(comparingCall); if (targetMethod == null) return; PsiExpressionList comparingArgs = comparingCall.getArgumentList(); if (targetMethod.equals("thenComparing") && comparingArgs.getExpressionCount() == 1) { PsiMethodCallExpression copy = (PsiMethodCallExpression)call.copy(); copy.getArgumentList().replace(comparingArgs.copy()); // Call becomes ambiguous after simplification if (!THEN_COMPARING_FUNCTION.matches(copy)) return; } String name = comparingCall.getMethodExpression().getReferenceName(); holder .registerProblem(comparingCall.getMethodExpression(), JavaBundle.message("inspection.simplifiable.comparator.comparing.message", name), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new DeleteComparingCallFix(name, targetMethod)); }