更新「舊」Eclipse插件時遇到一些問題。這裏是我想要做什麼原插件做了什麼:在IFile上創建IMarker時發生ResourceException(鏈接資源)
內>設置鏈接的位置 - (控制檯上解析編譯器輸出與文件名和錯誤信息 - >仍然有效)
文件 - >設置標記位置的文件
我在過去做了什麼是從文件的路徑字符串得到的IFile和產生從中鏈接和標記:
IFile ifile;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath path = new Path(fileName);
IFiles[] files = workspace.getRoot().findFilesForLocation(path);
...
ifile = iFiles[0];
Map attributes = new HashMap();
attributes.put(IMarker.SEVERITY, new Integer (severity));
MarkerUtilities.setLineNumber(attributes, lineNumber);
MarkerUtilities.setMessage(attributes, message);
MarkerUtilities.createMarker(ifile, attributes,
IMarker
由於findFilesForLocation是dep我試圖尋找另一種方式,但我沒有取得任何成功。使用已更改的代碼來獲取IFile總是會導致異常:org.eclipse.core.internal.resources.ResourceException:Resource'/path/to/file.c'不存在。 這是否可能與源文件僅鏈接到項目中,而不是物理上在項目中有關?
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath location = new Path(fileName);
IFile ifile = workspace.getRoot().getFile(location);
任何人都可以幫忙嗎?
謝謝!