void (@NotNull Document document, @Nullable Project project) { try (AccessToken ignored = ClientId.withClientId(ClientId.getLocalId())) { ThreadingAssertions.assertEventDispatchThread(); VirtualFile file = getFile(document); assert file != null; if (!file.isValid()) return; if (!fireBeforeFileContentReload(file, document)) { return; } boolean[] isReloadable = {isReloadable(file, document, project)}; if (isReloadable[0]) { CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction( new ExternalChangeAction.ExternalDocumentChange(document, project) { @Override public void run() { if (!isBinaryWithoutDecompiler(file)) { LoadTextUtil.clearCharsetAutoDetectionReason(file); file.setBOM(null); // reset BOM in case we had one and the external change stripped it away file.setCharset(null, null, false); boolean wasWritable = document.isWritable(); document.setReadOnly(false); boolean tooLarge = FileUtilRt.isTooLarge(file.getLength()); isReloadable[0] = isReloadable(file, document, project); if (isReloadable[0]) { CharSequence reloaded = tooLarge ? LoadTextUtil.loadText(file, getPreviewCharCount(file)) : LoadTextUtil.loadText(file); ((DocumentEx)document).replaceText(reloaded, file.getModificationStamp()); setDocumentTooLarge(document, tooLarge); } document.setReadOnly(!wasWritable); } } } ), UIBundle.message("file.cache.conflict.action"), null, UndoConfirmationPolicy.REQUEST_CONFIRMATION); } if (isReloadable[0]) { myMultiCaster.fileContentReloaded(file, document); } else { unbindFileFromDocument(file, document); myMultiCaster.fileWithNoDocumentChanged(file); myMultiCaster.afterDocumentUnbound(file, document); } myUnsavedDocuments.remove(document); } }