2
我正在開發CDT eclipse插件,我試圖使用以下代碼獲取使用CDT代碼在eclipse項目資源管理器中存在的源文件的列表,空值。使用CDT從現有eclipse項目獲取源文件列表
情況1:
IFile[] files2 = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new URI("file:/"+workingDirectory));
for (IFile file : files2) {
System.out.println("fullpath " +file.getFullPath());
}
情況2:
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(getProject().getRawLocationURI());
for (IFile file : files) {
System.out.println("fullpath " +file.getFullPath());
}
情形3:
IFile[] files3 = ResourceLookup.findFilesByName(getProject().getFullPath(),ResourcesPlugin.getWorkspace().getRoot().getProjects(),false);
for (IFile file : files3) {
System.out.println("fullpath " +file.getFullPath());
}
CASE4:
IFolder srcFolder = project.getFolder("src");
案例1,2,3給我輸出空,在我期待的文件列表;案例4中的 :我正在獲取「helloworld/src」文件的列表,但我期望從現有項目的主文件中獲取文件,例如:「helloworld」 請在此建議我。
尤金,感謝您的回覆;嗯,它列出了項目源文件,在單個項目的情況下,但我的情況我有標準的製作項目,在主標準制作項目內我已經創建了一個項目,我想主項目的源文件列表;也使用內部項目的給定代碼列表源文件;但我只想獲取相關的項目源文件;請建議; –
@AnilKumar看看IResourceVisitor(和IResource :: accept) – Eugene