void () { @org.intellij.lang.annotations.Language("JAVA") String text = "class A { String s = \"\"; }"; configureFromFileText("a.java", text); assertEmpty(highlightErrors()); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); String hugeExpr = "\"-\"" + "+\"b\"".repeat(10000); int pos = getEditor().getDocument().getText().indexOf("\"\""); ApplicationManager.getApplication().runWriteAction(() -> { getEditor().getDocument().replaceString(pos, pos + 2, hugeExpr); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); }); PsiField field = ((PsiJavaFile)getFile()).getClasses()[0].getFields()[0]; PsiExpression expression = field.getInitializer(); assert expression != null; PsiType type = expression.getType(); assert type != null; assertEquals("PsiType:String", type.toString()); }