Get IResources methods in eclipse development?
I'm developing an e开发者_如何学Pythonclipse plugin and need to list of IMethods that belong to an IResource.
I see IType has a getMethods function but not sure how to go about converting an IResource to an IType
Help appreciated
Nicky
First step, get the ICompilationUnit
from the IResource
:
ICompilationUnit icu = (ICompilationUnit) JavaCore.create(resource);
Next, use either getTypes()
or getType(String)
to get your IType
.
I don't have a full solution, but some ideas:
- globally an IResource cannot be converted/cast to IType (AFAIK)
- as IType is specific to the JDT, I suggest opening a Java resource file, converting it to ICompilationUnit, that can be traversed to get the IType
For the basic idea I suggest looking at the tutorial page of Lars Vogel, more specifically Section 4, where it creates a menu item to the Project Navigator, that converts a Java file to HTML.
IResource represents a file (or folder, or project) in the workspace. They can be C++, javascript or even image files. As the other repliers said, the IResource itself isn't the Java file; you need the ICompilationUnit.
精彩评论