Simplify opening of Bazel project using ProjectUtil.
Using ProjectUtil makes sure that a confirmation dialog asking where to open the new project is shown.
@@ -17,15 +17,14 @@ package com.google.idea.blaze.base.project;
import com.google.idea.blaze.base.settings.Blaze;
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
+import com.intellij.ide.impl.ProjectUtil;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.projectImport.ProjectOpenProcessor;
import icons.BlazeIcons;
import java.io.IOException;
import javax.annotation.Nullable;
import javax.swing.Icon;
-import org.jdom.JDOMException;
/** Allows directly opening a project with project data directory embedded within the project. */
public class BlazeProjectOpenProcessor extends ProjectOpenProcessor {
@@ -81,19 +80,11 @@ public class BlazeProjectOpenProcessor extends ProjectOpenProcessor {
@Override
public Project doOpenProject(
VirtualFile file, @Nullable Project projectToClose, boolean forceOpenInNewFrame) {
- ProjectManager pm = ProjectManager.getInstance();
- if (projectToClose != null) {
- pm.closeProject(projectToClose);
- }
- try {
VirtualFile ideaSubdirectory = getIdeaSubdirectory(file);
if (ideaSubdirectory == null) {
return null;
}
VirtualFile projectSubdirectory = ideaSubdirectory.getParent();
- return pm.loadAndOpenProject(projectSubdirectory.getPath());
- } catch (IOException | JDOMException e) {
- return null;
- }
+ return ProjectUtil.openProject(projectSubdirectory.getPath(), projectToClose, forceOpenInNewFrame);
}
}
