eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Unable to get correct Resource from IPackageBinding

Open
#930 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

For a project with multiple source folders - in our case there are src/main/java and src/test/java source roots - we get the wrong Resource for the package of a Type in the src/test/java root. For example:
`
ITypeBinding binding; // Populated elsewhere

IPackageBinding pkg = binding.getPackage(); // This binding is for the package in src/main/java, not where "binding" is

IResource resource = pkg.getJavaElement().getResource(); // This resource represents the folder in src/main/java
`
Seen in Eclipse 2022-09 with Java 17.
Note that the package does exist in both source-roots - as you would expect when writing JUnit tests.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.