diff --git a/src/main/java/idea/plugin/psiviewer/model/PsiViewerTreeModel.java b/src/main/java/idea/plugin/psiviewer/model/PsiViewerTreeModel.java index d2efc98..7585285 100755 --- a/src/main/java/idea/plugin/psiviewer/model/PsiViewerTreeModel.java +++ b/src/main/java/idea/plugin/psiviewer/model/PsiViewerTreeModel.java @@ -22,6 +22,7 @@ package idea.plugin.psiviewer.model; +import com.intellij.openapi.application.ReadAction; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiWhiteSpace; import idea.plugin.psiviewer.controller.project.PsiViewerProjectService; @@ -69,14 +70,16 @@ public boolean isLeaf(Object node) { } private List getFilteredChildren(PsiElement psi) { - final List filteredChildren = new ArrayList<>(); + return ReadAction.compute(() -> { + final List filteredChildren = new ArrayList<>(); - for (PsiElement e = psi.getFirstChild(); e != null; e = e.getNextSibling()) - if (isValid(e)) { - filteredChildren.add(e); - } + for (PsiElement e = psi.getFirstChild(); e != null; e = e.getNextSibling()) + if (isValid(e)) { + filteredChildren.add(e); + } - return filteredChildren; + return filteredChildren; + }); } private boolean isValid(PsiElement psiElement) {