如何让这个插件能获取到当前的工程路径

2025-04-13 02:49:02
推荐回答(1个)
回答1:

插件中访问 ResourcesPlugin 提供的方法,它先通过 workspace 和 project 和 path 得到一个 File 然后转换成绝对值就是磁盘目录了。
其实你已经通过 action 得到当前选中的 Java 文件,对吧,.

IPath path = null;IFile file = null;path.makeAbsolute().toOSString();file.getFullPath().makeAbsolute().toOSString();

如果你用 ResourcesPlugin 得到 workspace 里面的文件,那你的dependences 里面应该添加对 org.eclipse.core.resources 插件的支持。