Description
When Show Non-Java Resources is enabled, the Java Projects view can display an empty physical folder hierarchy such as src/main alongside the actual Java package roots (src/main/java and src/main/resources).
This was reported as part of #1044. This issue tracks only the empty src/main hierarchy, which is a rendering/data-model bug. The visibility of build output such as target is a separate filtering-policy question.
Root cause
The project children returned by java.getPackageData combine Java classpath roots with IJavaProject.getNonJavaResources().
The physical src folder can therefore be emitted as a non-Java folder even though its descendants are represented separately as Java package roots. When that folder is expanded, Java elements such as src/main/java and src/main/resources are filtered from its non-Java children, leaving an empty src/main hierarchy in the tree.
Relevant implementation:
jdtls.ext/.../PackageCommand.java#getProjectChildren
jdtls.ext/.../parser/ResourceSet.java
jdtls.ext/.../parser/JavaResourceVisitor.java
Expected behavior
Enabling Show Non-Java Resources should continue to show actual non-Java files, such as YAML and XML resources, but should not display ancestor folders that have no visible children because their content is already represented by Java package roots.
Acceptance criteria
- Non-Java resource files remain visible.
- Empty duplicate ancestor hierarchies such as
src/main are not shown.
- Existing Java source and resource package roots remain visible and functional.
- Add regression coverage for the returned project tree and an E2E UI scenario if practical.
Related: #1044
Description
When Show Non-Java Resources is enabled, the Java Projects view can display an empty physical folder hierarchy such as
src/mainalongside the actual Java package roots (src/main/javaandsrc/main/resources).This was reported as part of #1044. This issue tracks only the empty
src/mainhierarchy, which is a rendering/data-model bug. The visibility of build output such astargetis a separate filtering-policy question.Root cause
The project children returned by
java.getPackageDatacombine Java classpath roots withIJavaProject.getNonJavaResources().The physical
srcfolder can therefore be emitted as a non-Java folder even though its descendants are represented separately as Java package roots. When that folder is expanded, Java elements such assrc/main/javaandsrc/main/resourcesare filtered from its non-Java children, leaving an emptysrc/mainhierarchy in the tree.Relevant implementation:
jdtls.ext/.../PackageCommand.java#getProjectChildrenjdtls.ext/.../parser/ResourceSet.javajdtls.ext/.../parser/JavaResourceVisitor.javaExpected behavior
Enabling Show Non-Java Resources should continue to show actual non-Java files, such as YAML and XML resources, but should not display ancestor folders that have no visible children because their content is already represented by Java package roots.
Acceptance criteria
src/mainare not shown.Related: #1044