Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Get a Itype from IField
Get a Itype from IField [message #239236] Tue, 26 December 2006 12:14 Go to next message
Eclipse User
Originally posted by: lucas.goncalves.powerlogic.com.br

Anybody knows how to get a IType from a field's type.
ex. i have a IField correspondent to
private Address ad;

Now i need a IType of Address, but i don't known how to get it from IField.
Re: Get a Itype from IField [message #239273 is a reply to message #239236] Wed, 27 December 2006 05:28 Go to previous messageGo to next message
Frederic Fusier is currently offline Frederic Fusier
Messages: 147
Registered: July 2009
Senior Member
Lucas wrote:
> Anybody knows how to get a IType from a field's type.
> ex. i have a IField correspondent to
> private Address ad;
>
> Now i need a IType of Address, but i don't known how to get it from IField.

I think getDeclaringType() should match your need. It's implemented on
IMember (IField super-interface).

Note that documentation of this method sounds really wrong and I've
opened a bug for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=169114
Re: Get a Itype from IField [message #239278 is a reply to message #239273] Wed, 27 December 2006 06:54 Go to previous messageGo to next message
Frederic Fusier is currently offline Frederic Fusier
Messages: 147
Registered: July 2009
Senior Member
Frederic Fusier wrote:
> Lucas wrote:
>> Anybody knows how to get a IType from a field's type.
>> ex. i have a IField correspondent to
>> private Address ad;
>>
>> Now i need a IType of Address, but i don't known how to get it from
>> IField.
>
> I think getDeclaringType() should match your need. It's implemented on
> IMember (IField super-interface).
>
> Note that documentation of this method sounds really wrong and I've
> opened a bug for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=169114

Ooops, forget my previous answer, I misunderstood getDeclaringType()
behavior. I've also invalidated the bug...
My mind seems not to work very well between Christmas and New year feast.
Re: Get a Itype from IField [message #239282 is a reply to message #239278] Wed, 27 December 2006 07:59 Go to previous messageGo to next message
Frederic Fusier is currently offline Frederic Fusier
Messages: 147
Registered: July 2009
Senior Member
Frederic Fusier wrote:
> Frederic Fusier wrote:
>> Lucas wrote:
>>> Anybody knows how to get a IType from a field's type.
>>> ex. i have a IField correspondent to
>>> private Address ad;
>>>
>>> Now i need a IType of Address, but i don't known how to get it from
>>> IField.
>>
>> I think getDeclaringType() should match your need. It's implemented on
>> IMember (IField super-interface).
>>
>> Note that documentation of this method sounds really wrong and I've
>> opened a bug for this:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=169114
>
> Ooops, forget my previous answer, I misunderstood getDeclaringType()
> behavior. I've also invalidated the bug...
> My mind seems not to work very well between Christmas and New year feast.

In fact, it seems you cannot directly get the IType for the field's
type, but only its signature using field.getTypeSignature().

Then for BinaryField, it's easy to get corresponding IType using
following code:
String typeSignature = field.getTypeSignature();
field.getJavaProject().findType(Signature.toString(typeSigna ture))

For SourceField, it's a little bit more tricky as the type signature is
not resolved...
Re: Get a Itype from IField [message #239434 is a reply to message #239236] Wed, 03 January 2007 04:43 Go to previous message
Eddie Man is currently offline Eddie Man
Messages: 102
Registered: July 2009
Senior Member
IField field;

IType type = (IType) field.getParent()

ILucas wrote:
> Anybody knows how to get a IType from a field's type.
> ex. i have a IField correspondent to
> private Address ad;
>
> Now i need a IType of Address, but i don't known how to get it from IField.
Previous Topic:Filtering of completion proposals in Java editor
Next Topic:How do I integrate the JDK documentation and API reference into Eclipse help system?
Goto Forum:
  


Current Time: Sun May 26 01:25:48 EDT 2013

Powered by FUDForum. Page generated in 0.01641 seconds