Eclipse包中缺少的类,帮助

xia*_*ong 4 eclipse plugins eclipse-plugin

我想用一个打印当前项目名称的命令做一个小插件.代码片段如下:

    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);

    IEditorPart editorPart = window.getActivePage().getActiveEditor();
    if (editorPart != null){
        IFileEditorInput input = (IFileEditorInput)editorPart.getEditorInput() ;
        IFile file = input.getFile();
        IProject activeProject = file.getProject();
        String activeProjectName = activeProject.getName();
        //... use activeProjectName 
    }
Run Code Online (Sandbox Code Playgroud)

问题:无法找到IFileEditorInput(错误消息:无法解析为某种类型).我有导入org.eclipse.ui.*; 在文件的顶部,但它不起作用.似乎缺少IFileEditorInput,但我怎么能找到它?

非常感谢你!

Tom*_*ett 10

您需要在org.eclipse.ui.ide插件上添加依赖项.IFileEditorInput生活在org.eclipse.ui 包中,但不是同名的插件,这是令人困惑的.您还可以通过使用包依赖关系而不是明确依赖某些插件来避免这种混淆.