boolean (@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file, boolean executeAction) { final InjectedLanguageManager instance = InjectedLanguageManager.getInstance(project); while (true) { final List<CollapseBlockHandler> handlers = CollapseBlockHandler.EP_NAME.allForLanguage(file.getLanguage()); if (handlers.isEmpty()) { if (!instance.isInjectedFragment(file) || !(editor instanceof EditorWindow)) { return false; } file = instance.getTopLevelFile(file); if (file == null) { return false; } editor = ((EditorWindow)editor).getDelegate(); continue; } if (executeAction) { final Editor finalEditor = editor; final PsiFile finalFile = file; handlers.forEach(handler -> handler.invoke(project, finalEditor, finalFile)); } return true; } }