Skip to content

Commit

Permalink
#137 | Deprecated API - Impex Folding traverser
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored Jan 8, 2023
1 parent 31b78aa commit 74bacc7
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.FoldingGroup;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.PsiElementProcessor.CollectFilteredElements;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.SyntaxTraverser;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -106,12 +105,10 @@ protected Collection<PsiElement> findFoldingBlocksAndLineBreaks(@Nullable final
return Collections.emptyList();
}

final List<PsiElement> foldingBlocks = new ArrayList<>();
PsiTreeUtil.processElements(root, new CollectFilteredElements<>(
PsiElementFilterFactory.getPsiElementFilter(), foldingBlocks
));

return foldingBlocks;
final var filter = PsiElementFilterFactory.getPsiElementFilter();
return SyntaxTraverser.psiTraverser(root)
.filter(filter::isAccepted)
.toList();
}

@Nullable
Expand Down

0 comments on commit 74bacc7

Please sign in to comment.