void (@NotNull PsiFile file) { final Project project = file.getProject(); final Document document = PsiDocumentManager.getInstance(project).getDocument(file); if (document == null) return; String beforeText = file.getText(); long oldStamp = document.getModificationStamp(); DocumentUtil.writeInRunUndoTransparentAction(() -> new OptimizeImportsProcessor(project, file).run()); if (oldStamp != document.getModificationStamp()) { String afterText = file.getText(); if (Comparing.strEqual(beforeText, afterText)) { LOG.error("Import optimizer hasn't optimized any imports", new Throwable(file.getViewProvider().getVirtualFile().getPath()), CoreAttachmentFactory.createAttachment(file.getViewProvider().getVirtualFile())); } } }