void (@NotNull Document document, @NotNull PsiFile file, @NotNull FileASTNode oldFileNode) { if (oldFileNode.getTextLength() != document.getTextLength()) { String documentText = document.getText(); String fileText = file.getText(); boolean sameText = Objects.equals(fileText, documentText); String errorMessage = "commitDocument() left PSI inconsistent: " + DebugUtil.diagnosePsiDocumentInconsistency(file, document) + "; node.length=" + oldFileNode.getTextLength() + "; doc.text" + (sameText ? "==" : "!=") + "file.text" + "; file name:" + file.getName() + "; type:" + file.getFileType() + "; lang:" + file.getLanguage(); PluginException.logPluginError(LOG, errorMessage, null, file.getLanguage().getClass()); file.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, Boolean.TRUE); try { BlockSupport blockSupport = BlockSupport.getInstance(file.getProject()); DiffLog diffLog = blockSupport.reparseRange(file, file.getNode(), new TextRange(0, documentText.length()), documentText, new StandardProgressIndicatorBase(), oldFileNode.getText()); diffLog.doActualPsiChange(file); if (oldFileNode.getTextLength() != document.getTextLength()) { PluginException.logPluginError(LOG, "PSI is broken beyond repair in: " + file, null, file.getLanguage().getClass()); } } finally { file.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, null); } } }