PsiTreeUtil findChildrenOfAnyType but don't go deeper

已回答

Hello,

 

Is there an alternative for findChildrenOfAnyType which doesn't descend found elements? I want to create a structure view with TreeElements, but I don't want all sub sub sub elements to be also listed directly below the root element.

If not: what is the best way to realize this? I mean manually traversing should be the last choice, shouldn't it? It would ignore compiled psi element restrictions etc.

 

Kind regards

0

Brandan,

Have you checked the other methods in the PsiTreeUtil class? Would PsiTreeUtil.getChildrenOfType(PsiElement, Class<T>) or PsiTreeUtil.getChildrenOfTypeAsList(PsiElement, Class<T>) fit your needs?

0

Hello Jakub,

 

Thank you for your answer. Unfortunately thats not what I need. There might be "random" intermediate elements which should not be shown inside the structure view. They are not to be removed, because I need them internally. So I need recursion (find... instead of get), but only to a controllable extent.

 

Kind regards

0

com.intellij.psi.SyntaxTraverser could be used for more powerful tree navigation

0

请先登录再写评论。