@Override public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file){ PsiDocumentManager.getInstance(project).commitAllDocuments(); CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project); foldingManager.updateFoldRegions(editor); final FoldRegion[] allFoldRegions = editor.getFoldingModel().getAllFoldRegions(); Runnable processor = new Runnable() { @Override public void run() { for (FoldRegion region : allFoldRegions) { PsiElement element = EditorFoldingInfo.get(editor).getPsiElement(region); if (element instanceof PsiDocCommentBase) { region.setExpanded(myExpand); } } } }; editor.getFoldingModel().runBatchFoldingOperation(processor); }
@RequiredWriteAction @Override public void invokeInWriteAction(@Nonnull Project project, @Nonnull final Editor editor, @Nonnull PsiFile file){ PsiDocumentManager.getInstance(project).commitAllDocuments(); CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project); foldingManager.updateFoldRegions(editor); final FoldRegion[] allFoldRegions = editor.getFoldingModel().getAllFoldRegions(); Runnable processor = new Runnable() { @Override public void run() { for (FoldRegion region : allFoldRegions) { PsiElement element = EditorFoldingInfo.get(editor).getPsiElement(region); if (element instanceof PsiDocCommentBase) { region.setExpanded(myExpand); } } } }; editor.getFoldingModel().runBatchFoldingOperation(processor); }