void (final PsiClass targetClass, Consumer<? super PsiClass> invokeImpl) { if (!FileModificationService.getInstance().prepareFileForWrite(targetClass.getContainingFile())) { return; } IdeDocumentHistory.getInstance(targetClass.getProject()).includeCurrentPlaceAsChangePlace(); ApplicationManager.getApplication().runWriteAction(() -> invokeImpl.accept(targetClass)); }