ProjectLocator.guessProjectForFile() behavior restored

This commit is contained in:
Roman Shevchenko
2010-10-06 15:49:26 +04:00
parent 399f3df130
commit 96999f75d4
@@ -33,14 +33,16 @@ public class ProjectLocatorImpl extends ProjectLocator {
@Nullable
public Project guessProjectForFile(final VirtualFile file) {
ProjectManager projectManager = ProjectManager.getInstance();
if (projectManager == null || file == null) return null;
if (projectManager == null) return null;
final Project[] projects = projectManager.getOpenProjects();
if (projects.length == 0) return null;
if (projects.length == 1 && !projects[0].isDisposed()) return projects[0];
for (Project project : projects) {
if (project.isInitialized() && !project.isDisposed() && ProjectRootManager.getInstance(project).getFileIndex().isInContent(file)) {
return project;
if (file != null) {
for (Project project : projects) {
if (project.isInitialized() && !project.isDisposed() && ProjectRootManager.getInstance(project).getFileIndex().isInContent(file)) {
return project;
}
}
}