通常,此代码用于从 转换File
为IFile
:
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IPath location= Path.fromOSString(file.getAbsolutePath());
IFile ifile= workspace.getRoot().getFileForLocation(location);
但这仅适用于项目中的 java 文件。如何获取IFile
whenFile
文件不在工作区(不在项目中)?