PsiExpression (@Nullable PsiExpression initializer, @NotNull PsiElementFactory factory, @Nullable PsiType type) { if (initializer instanceof PsiArrayInitializerExpression && type instanceof PsiArrayType) { PsiNewExpression result = (PsiNewExpression)factory.createExpressionFromText("new " + type.getCanonicalText() + "{}", null); Objects.requireNonNull(result.getArrayInitializer()).replace(initializer); return result; } return initializer; }