How to expand folded package chain in Intellij IDEA?

JavaIntellij Idea

Java Problem Overview


Intellij IDEA automatically chain packages together if the intermediate ones are otherwise empty. It is a nice feature in general. However, sometimes you don't want them to be chained, especially when you are in the middle of creating new package structures for your new project. I might have come across the setting for disabling this feature for a certain package, but I can't find it where now. So, does anyone know how to control this feature? Thank you very much.

BTW, in case you need clarification, what I mean by package chaining is as follows. Suppose you have this package structure:

$ tree com
com
└── company
    └── project
        └── some
            └── feature

Since there are really nothing else inside the intermediate folders, Intellij IDEA will automatically display it like

com.company.project.some.feature

in the project explorer, which looks like the packages are chained together.

Java Solutions


Solution 1 - Java

Uncheck "Hide Empty Middle Packages" under the Project View settings dropdown:

Hide Empty Middle Packages

Solution 2 - Java

As another solution of how to create another file in the intermediate package:

Use expanded hierarchy of packages on the top of the window as shown below As shown below

Solution 3 - Java

Or you just can right-click on left-sided project tab and pick "Compact Middle Packages"

Solution 4 - Java

Just simply uncheck flatten modules, flatten package on right-click on PACKAGE drop-down.

Solution 5 - Java

As @Shreyash Choudhary said, uncheck Flatten Package in Project settings worked for me on v. 2021.3.2.

IntelliJ example

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJBTView Question on Stackoverflow
Solution 1 - JavaDaniel KaplanView Answer on Stackoverflow
Solution 2 - JavaKhojiakbarView Answer on Stackoverflow
Solution 3 - JavaSonnersView Answer on Stackoverflow
Solution 4 - JavaShreyash ChoudharyView Answer on Stackoverflow
Solution 5 - JavaJúlia PolbachView Answer on Stackoverflow