PsiStatement (PsiExpression initializer, String type, String varName, PsiIfStatement ifStatement, PsiElementFactory factory) { if (initializer == null) return null; final String initializerText; if (initializer instanceof PsiArrayInitializerExpression) { initializerText = "new " + type + initializer.getText(); } else { initializerText = initializer.getText(); } return factory.createStatementFromText(varName + "=" + initializerText + ";", ifStatement); }