Spo*_*ike 6 java eclipse eclipse-api
我正在编写一个插件来解析项目中的一堆文件.但目前我一直在寻找Eclipse API寻找答案.
插件的工作方式如下:每当我打开源文件时,我都会让插件解析源代码的相应构建文件(这可以通过缓存解析结果进一步开发).获取文件很简单:
public void showSelection(IWorkbenchPart sourcePart) {
// Gets the currently selected file from the editor
IFile file = (IFile) workbenchPart.getSite().getPage().getActiveEditor()
.getEditorInput().getAdapter(IFile.class);
if (file != null) {
String path = file.getProjectRelativePath();
/** Snipped out: Rip out the source path part
* and replace with build path
* Then parse it. */
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我必须使用硬编码字符串作为源文件和构建文件的路径.任何人都知道如何从Eclipse中检索构建路径?(顺便说一下,我在CDT工作).还有一种简单的方法来确定源文件的源路径(例如,"src"目录下的一个文件)是什么?
| 归档时间: |
|
| 查看次数: |
3988 次 |
| 最近记录: |