Search in sources :

Example 1 with PsiDocCommentBase

use of com.intellij.psi.PsiDocCommentBase in project intellij-community by JetBrains.

the class CollapseExpandDocCommentsHandler method invoke.

@Override
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
    CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project);
    foldingManager.updateFoldRegions(editor);
    final FoldRegion[] allFoldRegions = editor.getFoldingModel().getAllFoldRegions();
    Runnable processor = () -> {
        for (FoldRegion region : allFoldRegions) {
            PsiElement element = EditorFoldingInfo.get(editor).getPsiElement(region);
            if (element instanceof PsiDocCommentBase) {
                region.setExpanded(myExpand);
            }
        }
    };
    editor.getFoldingModel().runBatchFoldingOperation(processor);
}
Also used : CodeFoldingManager(com.intellij.codeInsight.folding.CodeFoldingManager) PsiDocCommentBase(com.intellij.psi.PsiDocCommentBase) FoldRegion(com.intellij.openapi.editor.FoldRegion) PsiElement(com.intellij.psi.PsiElement)

Aggregations

CodeFoldingManager (com.intellij.codeInsight.folding.CodeFoldingManager)1 FoldRegion (com.intellij.openapi.editor.FoldRegion)1 PsiDocCommentBase (com.intellij.psi.PsiDocCommentBase)1 PsiElement (com.intellij.psi.PsiElement)1