}
}
for (Map.Entry<File, Project> entry : fileToProject.entrySet()) {
File file = entry.getKey();
Project project = entry.getValue();
if (!file.equals(project.getDir())) {
if (file.isDirectory()) {
try {
File dir = file.getCanonicalFile();
if (dir.equals(project.getDir())) {
continue;
}
} catch (IOException ioe) {
// pass
}
}
project.addFile(file);
}
}
// Partition the projects up such that we only return projects that aren't
// included by other projects (e.g. because they are library projects)
Collection<Project> allProjects = fileToProject.values();
Set<Project> roots = new HashSet<Project>(allProjects);
for (Project project : allProjects) {
roots.removeAll(project.getAllLibraries());
}
// Report issues for all projects that are explicitly referenced. We need to
// do this here, since the project initialization will mark all library
// projects as no-report projects by default.
for (Project project : allProjects) {
// Report issues for all projects explicitly listed or found via a directory
// traversal -- including library projects.
project.setReportIssues(true);
}
if (LintUtils.assertionsEnabled()) {
// Make sure that all the project directories are unique. This ensures
// that we didn't accidentally end up with different project instances
// for a library project discovered as a directory as well as one
// initialized from the library project dependency list
IdentityHashMap<Project, Project> projects =
new IdentityHashMap<Project, Project>();
for (Project project : roots) {
projects.put(project, project);
for (Project library : project.getAllLibraries()) {
projects.put(library, library);
}
}
Set<File> dirs = new HashSet<File>();
for (Project project : projects.keySet()) {
assert !dirs.contains(project.getDir());
dirs.add(project.getDir());
}
}
return roots;
}