0

I have a java project (maven project) with different packages which compiles fine and all works expect the following message is shown when right clicking a directory in the package explorer and go to Source->Format

"The selection contains no compilation unit"

However, going one hierarchy depper (the package within the package), the Source->Format works. It's not on all packages but on a few and I don't know why.

How can I solve this?

nimo23
  • 5,170
  • 10
  • 46
  • 75
  • Can you show a package where it does work, and one where it doesn't? When you say "java project (maven project)", is it a Java project as Eclipse understands Java projects? – nitind Feb 20 '21 at 23:35
  • Yes, it's a eclipse java project. The `.project` already has `org.eclipse.jdt.core.javanature`. – nimo23 Feb 21 '21 at 00:24
  • The package, which does not work, is nothing special. It only contains java files and other packages. The compiling and all other typical java stuff works as usual. The package (where it does not work) has also a **pale color** (a little grayed out) in compare to its containing packages (where it works). – nimo23 Feb 21 '21 at 00:29
  • What version of Eclipse are you using? There are some old bugs (marked as fixed) about support for recursive source tree formatting – Stephen C Feb 21 '21 at 02:32
  • Does the first answer to https://stackoverflow.com/questions/5133781 answer your question? – Stephen C Feb 21 '21 at 03:02
  • @StephenC I am using current release Version: 2020-12 (4.18.0). No, the anwer does not help.I already have enabled java facet. And all other things works as usual. But when selecting such greyed out java-source-package and doing `Source->Format`, or `Source->Organize Imports` or anything within the `Source-menu`, the message above is shown. Going one hierarchy deeper, where the package is not greyed out, all works as usual. – nimo23 Feb 21 '21 at 08:09
  • Did you use the CTRL key?? – Stephen C Feb 21 '21 at 08:10
  • yes, CTRL key on mac does not help. – nimo23 Feb 21 '21 at 08:12
  • In that case, maybe there isn't a solution at all. – Stephen C Feb 21 '21 at 08:17
  • I also removed the greyed out parent package and create a new one with the same content (packages which are not greyed out). Does not help: The new parent package is also greyed out. – nimo23 Feb 21 '21 at 08:17
  • I guess so. Maybe recreating the project from scratch may work. I will try.. – nimo23 Feb 21 '21 at 08:18

0 Answers0