Using Eclipse JDT, how to get IType on behalf of a class?

Is there a simple and easy way to get IType on behalf of a class? I think there must be some kind of static method somewhere. Basically, I would like to do something like:

IType objectType = Somewhere.getType("java.lang.Object") 

Does anyone know something like this? I searched in vain.

+6
eclipse eclipse-jdt
source share
2 answers

Given IProject, IJavaProject # findType search methods, for example, can be used.

 IType objectType = project.findType("java.lang.Object"); 
+6
source share

Take a look at org.eclipse.jdt.core.search.SearchEngine . I have not tried it myself, I usually use ASTParser with the Resolve parameter (which is when analyzing the source), but it should do the trick.

+1
source share

All Articles