gpt4 book ai didi

java - Eclipse 插件 : Find location of selected project

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:50:08 24 4
gpt4 key购买 nike

我一直试图在 Eclipse 中找到选定项目的位置通过我的编辑器插件的代码,我取得了一些成功。我无法在一种情况下找到该项目。当使用编辑器的文件在 Eclipse 的最后一个 session 中保持打开状态并重新打开 Eclipse 时,如果不打开和关闭文件,我无法找到当前项目的位置,因为此方法:Eclipse Plugin: how to get the path to the currently selected project不管用。有什么建议么?提前致谢。

最佳答案

Eclipse 实际上并没有“当前项目”的概念。每个 View 中都有一个当前选择,但大多数 View 不保存 session 之间的选择。

在编辑器中,您可能需要当前正在编辑的文件所属的项目。在编辑器中,您可以使用类似的东西:

IEditorInput editorInput = getEditorInput();

IFile file = (IFile)editorInput.getAdapter(IFile.class);

IProject project = file.getProject();

注意:如果您正在编辑不在工作区中的文件,file 可能为空。您不需要对最新版本的 Eclipse 进行 (IFile) 转换。

关于java - Eclipse 插件 : Find location of selected project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44589251/

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