我可以使用以下代码获取一组 ICompilationUnit,但我需要从 ICompilationUnit 或 IWorkspaceRoot 获取物理文件路径。
我怎样才能做到这一点?
private static Set<ICompilationUnit> getFiles(String projname)
throws CoreException {
IWorkspaceRoot ws = ResourcesPlugin.getWorkspace().getRoot();
IProject proj = ws.getProject(projname);
IJavaProject javaProject = JavaCore.create(proj);
Set<ICompilationUnit> files = new HashSet<ICompilationUnit>();
javaProject.open(new NullProgressMonitor());
for (IPackageFragment packFrag : javaProject.getPackageFragments()) {
for (ICompilationUnit icu : packFrag.getCompilationUnits()) {
files.add(icu);
}
}
javaProject.close();
return files;
}