void () { final String item = createLongSequenceOfCharacterConstants(); final String fileText = "class Bar { char[] item = { " + item + "};\n }"; VirtualFile file = myFixture.addFileToProject("foo/Bar.java", fileText).getVirtualFile(); assertNotNull(findClass("Bar")); final Document document = FileDocumentManager.getInstance().getDocument(file); for (int i = 0; i < 2; ++i) { WriteCommandAction.runWriteCommandAction(getProject(), () -> document.replaceString(0, document.getTextLength(), item + item)); PsiDocumentManager.getInstance(getProject()).commitDocument(document); assertNull(findClass("Bar")); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.replaceString(0, document.getTextLength(), fileText)); PsiDocumentManager.getInstance(getProject()).commitDocument(document); assertNotNull(findClass("Bar")); } }