void () { final int pos = getEditor().getDocument().getText().indexOf("\"\""); int hugeExprLength; { // replace small expression with huge binary one CharSequence myHugeExpr = getHugeExpr(); hugeExprLength = myHugeExpr.length(); WriteCommandAction.runWriteCommandAction(null, () -> { getEditor().getDocument().replaceString(pos, pos + 2, myHugeExpr); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); }); } doTestConfiguredFile(false, false, null); // modify huge binary expression (1) ApplicationManager.getApplication().runWriteAction(() -> { getEditor().getDocument().insertString(pos, "\".\"+"); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); }); doTestConfiguredFile(false, false, null); // modify huge binary expression (2) ApplicationManager.getApplication().runWriteAction(() -> { getEditor().getDocument().replaceString(pos, pos + 4, ""); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); }); doTestConfiguredFile(false, false, null); // replace huge binary expression with small one ApplicationManager.getApplication().runWriteAction(() -> { getEditor().getDocument().replaceString(pos, pos + hugeExprLength, "\".\""); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); }); doTestConfiguredFile(false, false, null); }