Bug 131944 - Missing API query to search package references
Missing API query to search package references
Product: java
Classification: Unclassified
Component: Source
All All
: P2 (vote)
: 7.1
Assigned To: Tomas Zezula
Depends on: 203806
Blocks: 94325 131846 168923
  Show dependency treegraph
Reported: 2008-04-03 14:57 UTC by Jan Pokorsky
Modified: 2011-10-25 14:45 UTC (History)
0 users

See Also:

ClassIndexTest added test (2.47 KB, patch)
2011-10-21 14:05 UTC, Ralph Ruijs
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Pokorsky 2008-04-03 14:57:53 UTC
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.*;
Comment 1 Tomas Zezula 2009-12-15 01:51:04 UTC
It's not so easy to distinguish the package name from enclosing class name, may require change of index format.
Comment 2 Tomas Zezula 2011-10-20 14:04:15 UTC
Fixed jet-main 6e6ba0910998
Comment 3 Ralph Ruijs 2011-10-21 14:05:09 UTC
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.
Comment 4 Tomas Zezula 2011-10-21 14:16:01 UTC
In fact import of package which has no type used is not used, see JLS.
Comment 5 Ralph Ruijs 2011-10-21 14:20:37 UTC
(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.
Comment 6 Tomas Zezula 2011-10-21 18:25:11 UTC
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.
Comment 7 Quality Engineering 2011-10-24 14:12:32 UTC
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
Comment 8 Tomas Zezula 2011-10-24 17:54:49 UTC
The getResourcesForPkg ans getRefrencesForPkg is now able to find references for unused package import. jet-main 797bd4e21cff
Comment 9 Quality Engineering 2011-10-25 14:45:22 UTC
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

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo