Hide empty packages from Project Tree

Hello.

I need to customize project view tree and create a class extended from com.intellij.ide.projectView.impl.ProjectViewPane and override
com.intellij.ide.projectView.impl.ProjectViewPane#createStructure.

All works fine, but the tree still contains packages without files that match the filter. How can I remove or hide them from the tree?

3 comments

You can register own `TreeStructureProvider` and implement the `modify` method.
It may process children and remove empty PsiDirectoryNode.
Note, that this approach is very incovenient, because you cannot create new folder to add new file.
See https://youtrack.jetbrains.com/issue/IDEA-25714

0

Thanks, I will try this method.

Is it possible to add action to hide/show empty directories to Options of ProjectView?

0

Only if you create and register own AbstractProjectViewPane:

<projectViewPane implementation="your.custom.ProjectViewPane"/>

and extend AbstractProjectViewPane#addToolbarActions

0

Please sign in to leave a comment.