Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Accessing IType from IField
Accessing IType from IField [message #31980] Tue, 20 May 2003 14:23 Go to next message
Eclipse UserFriend
Originally posted by: picklerj_nospam.yahoo.com

I am using the org.eclipse.jdt.core package in a plugin to introspect
information about a user's classes. I have a situation in which I have
accessed a particular IField within an IType. I know that this IField is
another Java object contained within the same IJavaProject. When I get that
IField, how do I access the IType associated with it? Ideally I'm trying to
get the fully-qualified name of the IField, but all I can find through the
JDT API is the simple name for an IField.

In other words, how do I programmatically access the IType associated with
the IField "anotherTypeField" below? Is this possible?

public class MyType {
private AnotherType anotherTypeField;
...
}

Thanks,
DW
Re: Accessing IType from IField [message #32015 is a reply to message #31980] Tue, 20 May 2003 15:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam_kiezun.ch.ibm.spam.protection.com

try ICodeAssist.codeSelect
(ICompilationUnit is an ICodeAssist)

a.
--
eclipse.org
Re: Accessing IType from IField [message #32261 is a reply to message #32015] Tue, 20 May 2003 16:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: picklerj_nospam.yahoo.com

That gives me an IJavaElement, which I can already access from the IField
since it extends the IJavaElement interface. I don't see any methods in
IJavaElement that will let me get at the IType of the IField. The
"getElementType" in IJavaElement will only return an integer, which will
merely indicate that my IField is of type IJavaElement.FIELD.

DW

"Adam Kiezun" <adam_kiezun@ch.ibm.spam.protection.com> wrote in message
news:badubb$sga$1@rogue.oti.com...
> try ICodeAssist.codeSelect
> (ICompilationUnit is an ICodeAssist)
>
> a.
> --
> eclipse.org
>
>
Re: Accessing IType from IField [message #32474 is a reply to message #31980] Tue, 20 May 2003 16:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam.kiezun.gmx.net.remove

> In other words, how do I programmatically access the IType associated with
> the IField "anotherTypeField" below? Is this possible?
>
> public class MyType {
> private AnotherType anotherTypeField;
> ...
> }

so do you want the declaring class or the declared type?
it's not clear from what you said ("IType associated with the IField" is at
least ambiguous).
in other words: what would be name of the IType you're after? "MyType" or
"AnotherType"? or do want yet something else?

a.
--
eclipse.org
Re: Accessing IType from IField [message #32543 is a reply to message #32474] Tue, 20 May 2003 17:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: picklerj_nospam.yahoo.com

"Adam Kiezun" <adam.kiezun@gmx.net.remove> wrote in message
news:bae43c$230$1@rogue.oti.com...
> > In other words, how do I programmatically access the IType associated
with
> > the IField "anotherTypeField" below? Is this possible?
> >
> > public class MyType {
> > private AnotherType anotherTypeField;
> > ...
> > }
>
> so do you want the declaring class or the declared type?
> it's not clear from what you said ("IType associated with the IField" is
at
> least ambiguous).
> in other words: what would be name of the IType you're after? "MyType" or
> "AnotherType"? or do want yet something else?
>
> a.
> --
> eclipse.org
>

Sorry about the ambiguity...what I'm ultimately looking for is the
fully-qualified name of the class associated with the IField. So in my
example above if I have the following...

import com.mycompany.AnotherType;

public class MyType {
private AnotherType anotherTypeField;
...
}

....then what I want to programmatically access when I retrieve the IField
associated with "anotherTypeField" would be "com.mycopmany.AnotherType".

DW
Re: Accessing IType from IField [message #32576 is a reply to message #32543] Tue, 20 May 2003 17:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam.kiezun.gmx.net.remove

> ...then what I want to programmatically access when I retrieve the IField
> associated with "anotherTypeField" would be "com.mycopmany.AnotherType".

in that case, simply call IType.resolveType

a.
--
eclipse.org
Re: Accessing IType from IField [message #34434 is a reply to message #32576] Wed, 21 May 2003 15:33 Go to previous message
Eclipse UserFriend
Originally posted by: picklerj_nospam.yahoo.com

"Adam Kiezun" <adam.kiezun@gmx.net.remove> wrote in message
news:bae5fa$3go$1@rogue.oti.com...
> > ...then what I want to programmatically access when I retrieve the
IField
> > associated with "anotherTypeField" would be "com.mycopmany.AnotherType".
>
> in that case, simply call IType.resolveType
>
> a.
> --
> eclipse.org
>
>
>

That's exactly what I was looking for.

Thanks,
DW
Previous Topic:If I could design a awt application visually?
Next Topic:Makefiles for Java projects?
Goto Forum:
  


Current Time: Wed Jul 16 08:00:41 EDT 2025

Powered by FUDForum. Page generated in 0.08060 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top