diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/actions/CollapseBlockAction.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/actions/CollapseBlockAction.java index 2a9bed699e74..cc99902c34fd 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/actions/CollapseBlockAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/actions/CollapseBlockAction.java @@ -11,16 +11,25 @@ import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; +import java.util.List; + public class CollapseBlockAction extends BaseCodeInsightAction { @NotNull @Override protected CodeInsightActionHandler getHandler() { return new CodeInsightActionHandler() { public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) { - CollapseBlockHandler.EP_NAME - .allForLanguage(file.getLanguage()) - .forEach(handler->handler.invoke(project, editor, file)); + getHandlersForFile(file).forEach(handler->handler.invoke(project, editor, file)); } }; } + + protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { + return !getHandlersForFile(file).isEmpty(); + } + + @NotNull + private static List getHandlersForFile(@NotNull PsiFile file) { + return CollapseBlockHandler.EP_NAME.allForLanguage(file.getLanguage()); + } }