Skip to content

Empty src/main folder appears when Show Non-Java Resources is enabled #1062

Description

@wenytang-ms

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions