RE: [mdr-users] Newbie: correct way to find usages of one class by another
"Richard Kennard" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.mdr.user |
|---|---|
| Organization | Kennard Consulting |
| Message-ID | <001e01c565c8$36473cb0$ae131fd3@kennard> |
Martin, Whenever I try to use the Collection returned from JavaClass.getReference I get: org.netbeans.mdr.util.DebugException: Invalid key at org.netbeans.mdr.storagemodel.MdrStorage.getObjectsFromIndex(MdrStorage.java :725) at org.netbeans.mdr.storagemodel.IndexImmutSet.getObjects(IndexImmutSet.java:66 ) at org.netbeans.mdr.storagemodel.IndexImmutSet.toArray(IndexImmutSet.java:101) at org.netbeans.mdr.handlers.IndexSetWrapper.toArray(IndexSetWrapper.java:129) at java.util.ArrayList.<init>(ArrayList.java:137) I have tried this with a couple of different JavaClass', and besides the error looks like it isn't something that should be in production code? Any help would be greatly appreciated, Thanks, Richard. -----Original Message----- From: Martin Matula [mailto:[email protected]] Sent: Tuesday, 24 May 2005 6:55 AM To: [email protected] Cc: [email protected] Subject: Re: [mdr-users] Newbie: correct way to find usages of one class by another [Cross posting to refactoring mailing list since it's more appropriate for this kind of questions...] Richard Kennard wrote: >Dear All, > >What is the correct way to find all usages of, say, a class 'Foo'? > >If I construct a WhereUsedQuery and pass it a JavaClass of Foo, I only >get back usages of its constructor (and static enums and the like). > > That's weird, WhereUsedQuery should work (otherwise the Find Usages feature would not work). Anyway, if you want to find usages programmatically, it is better to call JavaClass.getReferences() (WhereUsedQuery is kind of heavy-weight, since it wraps the results by RefactoringElements). Regards, Martin