void (Runnable runnable, Project project) { while (true) { DumbService dumbService = DumbService.getInstance(project); dumbService.waitForSmartMode(); boolean passed = PsiDocumentManager.getInstance(project).commitAndRunReadAction(() -> { if (dumbService.isDumb()) return false; runnable.run(); return true; }); if (passed) { break; } } }