Eclipse “Open Type” dialog restricted to a particular interface

天大地大妈咪最大 提交于 2019-12-07 13:46:33
Rich Seller

This answer shows how to obtain the type hierarchy for a particular type. You could use similar processing to obtain the TypeHierarchy for the interface, then populate the list with the resultant types.

IProject project; //currently selected project

//get the java project and locate the interface type
JavaProject javaProject = JavaCore.create(project);
IType myInterface = 
    javaProject.findType("MyInterface","name.seller.rich");

//get the sub types from the interface's type hierarchy
ITypeHierarchy hierarchy =
    myInterface .newTypeHierarchy(new NullProgressMonitor());

IType[] subTypes = hierarchy.getAllSubtypes(myInterface );

//do something with the sub types
...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!