[英]Eclipse Plugin Dev: How do I get the paths for the currently selected project?
我正在寫一個插件,它將解析項目中的一堆文件。 但是目前,我仍在搜索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. */
}
}
我的問題是我必須對源文件和構建文件所在的路徑使用硬編碼的字符串 。 有人知道如何從Eclipse檢索構建路徑嗎? (順便說一下,我正在CDT工作)。 還有一種簡單的方法可以確定源文件的源路徑(例如,一個文件位於“ src”目錄下)嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.