gpt4 book ai didi

eclipse - Eclipse 包中缺少类,帮助

转载 作者:行者123 更新时间:2023-12-02 18:39:08 25 4
gpt4 key购买 nike

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

    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(错误消息:无法解析为类型)。我有 import org.eclipse.ui.*;在文件的顶部,但它不起作用。似乎 IFileEditorInput 丢失了,但是我如何找到它?

非常感谢!

最佳答案

您需要添加对 org.eclipse.ui.ide 插件的依赖项。 IFileEditorInput 位于 org.eclipse.ui 中,但不是同名的插件,这很令人困惑。您还可以通过使用包依赖项来避免这种类型的困惑,而不是显式依赖某些插件。

关于eclipse - Eclipse 包中缺少类,帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6378390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com