This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I propose to add new method to ClassIndex that would return all resources referencing a queried package. public Set<FileObject> getResources(ElementHandle<PackageElement> element, Set<ClassIndex.SearchKind> searchKind, Set<ClassIndex.SearchScope> scope) With present queries I am not able to find package reference e.g. 'org.mypkg' used in following statement import org.mypkg.*;
It's not so easy to distinguish the package name from enclosing class name, may require change of index format.
Fixed jet-main 6e6ba0910998
Created attachment 112309 [details] ClassIndexTest added test It looks like the newly added API does not fix this issue. I added a test case which seems to fail.
In fact import of package which has no type used is not used, see JLS.
(In reply to comment #4) > In fact import of package which has no type used is not used, see JLS. true, but we still need to be able to find these statements. When the last class gets removed from a package, the package no longer exists and these statements become invalid.
I found a ugly workaround how to do it. It's so ugly that I will not describe it here ;-). I will try it and let you know.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/6e6ba0910998 User: Tomas Zezula <tzezula@netbeans.org> Log: #131944:Missing API query to search package references
The getResourcesForPkg ans getRefrencesForPkg is now able to find references for unused package import. jet-main 797bd4e21cff
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/797bd4e21cff User: Tomas Zezula <tzezula@netbeans.org> Log: #131944: Missing API query to search package references