Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Allow to suppress automatic Bazel project opening if .ijwb or so … #5208

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.google.idea.blaze.base.project;

import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import static com.google.idea.blaze.base.project.BlazeProjectOpenProcessor.getIdeaSubdirectory;

import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
import com.google.idea.blaze.base.projectview.ProjectView;
import com.google.idea.blaze.base.projectview.ProjectView.Builder;
import com.google.idea.blaze.base.projectview.ProjectViewSet;
import com.google.idea.blaze.base.projectview.parser.ProjectViewParser;
import com.google.idea.blaze.base.projectview.section.ListSection;
import com.google.idea.blaze.base.projectview.section.ScalarSection;
import com.google.idea.blaze.base.projectview.section.sections.AutomaticallyDeriveTargetsSection;
import com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry;
import com.google.idea.blaze.base.projectview.section.sections.DirectorySection;
import com.google.idea.blaze.base.projectview.section.sections.TextBlock;
import com.google.idea.blaze.base.projectview.section.sections.TextBlockSection;
import com.google.idea.blaze.base.settings.Blaze;
Expand All @@ -24,7 +20,6 @@
import com.google.idea.blaze.base.wizard2.WorkspaceTypeData;
import com.google.idea.sdkcompat.general.BaseSdkCompat;
import com.intellij.ide.SaveAndSyncHandler;
import com.intellij.ide.impl.OpenProjectTask;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
Expand Down Expand Up @@ -89,8 +84,10 @@ public boolean lookForProjectsInDirectory() {

@Override
public boolean canOpenProject(@NotNull VirtualFile virtualFile) {
// Auto import activated only if it is not disabled, there is no existing project model in the folder
// and Bazel workspace is detected.
return !Registry.is("bazel.auto.import.disabled")
&& isBazelWorkspace(virtualFile);
&& getIdeaSubdirectory(virtualFile) == null && isBazelWorkspace(virtualFile);
tpasternak marked this conversation as resolved.
Show resolved Hide resolved
}

private boolean isBazelWorkspace(VirtualFile virtualFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
import com.google.idea.sdkcompat.general.BaseSdkCompat;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.projectImport.ProjectOpenProcessor;
import icons.BlazeIcons;
Expand All @@ -42,7 +43,7 @@ public Icon getIcon() {
private static final String DEPRECATED_PROJECT_DATA_SUBDIRECTORY = ".project";

@Nullable
private static VirtualFile getIdeaSubdirectory(VirtualFile file) {
public static VirtualFile getIdeaSubdirectory(VirtualFile file) {
VirtualFile projectSubdirectory = file.findChild(BlazeDataStorage.PROJECT_DATA_SUBDIRECTORY);
if (projectSubdirectory == null || !projectSubdirectory.isDirectory()) {
projectSubdirectory = file.findChild(DEPRECATED_PROJECT_DATA_SUBDIRECTORY);
Expand All @@ -68,7 +69,7 @@ public boolean canOpenProject(VirtualFile file) {

@Override
public boolean isStrongProjectInfoHolder() {
return true;
return Registry.is("bazel.project.auto.open.if.present", true);
dkashyn-sfdc marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down