mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CPP-2906 OC-13262 Code Fold of control flow statements (if/else, do/while, for, switch)
Disable the action for languages without `Collapse Block` handlers
This commit is contained in:
+12
-3
@@ -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<CollapseBlockHandler> getHandlersForFile(@NotNull PsiFile file) {
|
||||
return CollapseBlockHandler.EP_NAME.allForLanguage(file.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user