RedundantSortAsListHandler (PsiMethodCallExpression call) { if (MethodCallUtils.isVarArgCall(call)) return null; PsiExpression arg = call.getArgumentList().getExpressions()[0]; if (!(arg.getType() instanceof PsiArrayType)) return null; PsiExpressionList parent = tryCast(PsiUtil.skipParenthesizedExprUp(call.getParent()), PsiExpressionList.class); if (parent != null) { PsiMethodCallExpression outerCall = tryCast(parent.getParent(), PsiMethodCallExpression.class); if (COLLECTIONS_SORT.test(outerCall) && PsiTreeUtil.isAncestor(parent.getExpressions()[0], call, false)) { return new RedundantSortAsListHandler(true); } } else { PsiMethodCallExpression chainedCall = ExpressionUtils.getCallForQualifier(call); if (LIST_SORT.test(chainedCall)) { return new RedundantSortAsListHandler(false); } } return null; }