Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to get a IType from a class name ?
How to get a IType from a class name ? [message #299872] Mon, 27 February 2006 08:36 Go to next message
Eclipse UserFriend
Originally posted by: angelo.nomail.com

Hi,

how can I get a IType instance for a specific complete class name?
(like 'org.mypackage.MyBean'). The class name can be referencing both
a source file or a binary type (.class file).

I need an API like:

IType t = findType(myClassName);

Another question is: suppose I have a IType and from this a get a IMethod
instance. How I can get the return type (as an IType) from the IMethod
object?
The current IMethod.getReturnType() return just an encoded method
signature String (and I didn't find how to resolve this using the
Signature class).


Thanks in advance
Angelo
Re: How to get a IType from a class name ? [message #299891 is a reply to message #299872] Mon, 27 February 2006 15:11 Go to previous message
Eclipse UserFriend
Originally posted by: varavamu.yahoo.com

Use:
ICompilationUnit comp = JavaCore.createCompilationUnitFrom(IFile)
IType type = comp.findPrimaryType();

for your second question:
private boolean returnsVoid(IMethod method) throws JavaModelException {
return method.getReturnType().charAt(0) == Signature.C_VOID;
}
hth,
Vijay

Angelo wrote:
> Hi,
>
> how can I get a IType instance for a specific complete class name?
> (like 'org.mypackage.MyBean'). The class name can be referencing both
> a source file or a binary type (.class file).
>
> I need an API like:
>
> IType t = findType(myClassName);
>
> Another question is: suppose I have a IType and from this a get a
> IMethod instance. How I can get the return type (as an IType) from the
> IMethod object?
> The current IMethod.getReturnType() return just an encoded method
> signature String (and I didn't find how to resolve this using the
> Signature class).
>
>
> Thanks in advance
> Angelo
>
Previous Topic:Ant builder questions
Next Topic:how to call a plugin action??
Goto Forum:
  


Current Time: Sun Apr 27 02:38:03 EDT 2025

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

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

Back to the top