How to programmatically find a java file in eclipse from full classname?

后端 未结 3 1544
温柔的废话
温柔的废话 2020-12-19 18:22

Inside an eclipse plugin, I\'d like to open a file in editor. I know the full package and class name, how can I determine the path of the java file from this?

3条回答
  •  一个人的身影
    2020-12-19 18:59

    Take a look at IJavaProject.findType( name ) method. Once you have an IType, you can use getPath() or getResource() methods to locate the file. This method searches across a project and everything visible from that project. To search the whole workspace, iterate through all the Java projects in the workspace, calling the findType() method on each in turn.

提交回复
热议问题