RedundantAsListForIterationHandler (PsiMethodCallExpression call) { if (MethodCallUtils.isVarArgCall(call)) return null; PsiExpression arg = call.getArgumentList().getExpressions()[0]; if (!(arg.getType() instanceof PsiArrayType)) return null; if (isAllowedContext(call)) { return new RedundantAsListForIterationHandler(); } PsiElement parent = PsiUtil.skipParenthesizedExprUp(call.getParent()); if (parent instanceof PsiLocalVariable localVariable) { if (!(localVariable.getParent() instanceof PsiDeclarationStatement) || ((PsiDeclarationStatement)localVariable.getParent()).getDeclaredElements().length != 1) { return null; } PsiCodeBlock block = PsiTreeUtil.getParentOfType(localVariable, PsiCodeBlock.class); List<PsiReferenceExpression> references = VariableAccessUtils.getVariableReferences(localVariable, block); if (!references.isEmpty() && ContainerUtil.and(references, RedundantAsListForIterationHandler::isAllowedContext)) { return new RedundantAsListForIterationHandler(); } } return null; }