Eclipse包中缺少类,请参阅帮助
我想做一个小插件,用一个命令打印当前的项目名称。代码片段如下所示:Eclipse包中缺少类,请参阅帮助,eclipse,plugins,eclipse-plugin,Eclipse,Plugins,Eclipse Plugin,我想做一个小插件,用一个命令打印当前的项目名称。代码片段如下所示: IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart editorPart = window.getActivePage().getActiveEditor(); if (editorPart != null){ IFileEditorInput input =
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
}
问题:找不到IFileEditorInput(错误消息:无法解析为类型)。我已经导入org.eclipse.ui.*;在文件的顶部,但它不起作用。似乎IFileEditorInput缺失,但我如何才能找到它
多谢各位 您需要在
org.eclipse.ui.ide
插件上添加依赖项IFileEditorInput
位于org.eclipse.ui
包中,但不是相同名称的插件,这很容易混淆。您还可以通过使用包依赖项而不是显式地依赖于某些插件来避免这种类型的混淆