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 <001801c56694$28792c70$ae131fd3@kennard>
Martin,

Thanks for that: I deleted the 'mdrstorage' folder and it seems to run okay.
However, my problem now is I cannot make head nor tail of what is returned?

If I do:

	JavaClass myClass = ...resolve class...( "com.foo" );

	myClass.getReferences();

I get back a collection of ElementReferences, but any which way I try to use
these ElementReferences (I've tried toString(), getName(), getElement(),
getElement().getType().getName()) they only seem to ever return information
about 'com.foo', not the classes that are referencing it! All the
ElementReferences are of type MultipartId$Impl?

How am I supposed to use the collection returned by getReferences() to
determine who is referencing my class?

Many thanks for all your help over the months,

Richard.

-----Original Message-----
From: Martin Matula [mailto:[email protected]] 
Sent: Wednesday, 1 June 2005 6:23 AM
To: [email protected]
Subject: Re: [mdr-users] Newbie: correct way to find usages of one class by
another


Hm. I think I've never seen such error. Try to clean 
$nbuserdir/var/cache/mdrstorage dir and run your code again. If you get 
the same behavior consistently, please file a new issue in issuezilla 
and provide any information you can (at least attach your messages.log 
from $nbuserdir/var/log/).
Thanks,
Martin

Richard Kennard wrote:

>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:6
6
>)
>	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
>
>
>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.