String (ChainVariable outVar, String code, StreamToLoopReplacementContext context) { PsiType type = outVar.getType(); String iterationParameter; PsiExpressionList argList = myCall.getArgumentList(); if (type instanceof PsiPrimitiveType) { // Not using argList.getExpressions() here as we want to preserve comments and formatting between the expressions PsiElement[] children = argList.getChildren(); // first and last children are (parentheses), we need to remove them iterationParameter = StreamEx.of(children, 1, children.length - 1) .map(PsiElement::getText) .joining("", "new " + type.getCanonicalText() + "[] {", "}"); } else { iterationParameter = "java.util.Arrays.<" + type.getCanonicalText() + ">asList" + argList.getText(); } return context.getLoopLabel() + "for(" + outVar.getDeclaration() + ": " + iterationParameter + ") {" + code + "}\n"; }