private PsiClass createArrayClass(String text, LanguageLevel level) { PsiClass psiClass = ((PsiExtensibleClass) createClassFromText(text, null)).getOwnInnerClasses().get(0); ensureNonWritable(psiClass); PsiFile file = psiClass.getContainingFile(); ((PsiJavaFileBaseImpl) file).clearCaches(); PsiUtil.FILE_LANGUAGE_LEVEL_KEY.set(file, level); return psiClass; }
private static void ensureNonWritable(PsiClass arrayClass) { try { arrayClass.getContainingFile().getViewProvider().getVirtualFile().setWritable(false); } catch (IOException ignored) { } }