Skip to content

Commit

Permalink
Protect sync-before-build by an experiment
Browse files Browse the repository at this point in the history
(cherry picked from commit 585b195)
  • Loading branch information
Googler authored and mai93 committed Aug 8, 2023
1 parent dabaa4e commit 0b1c58e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions base/src/com/google/idea/blaze/base/qsync/QuerySync.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class QuerySync {
private static final Supplier<Boolean> COMPOSE_ENABLED =
Suppliers.memoize(new BoolExperiment("aswb.query.sync.enable.compose", false)::getValue);

/** Enabled sync before build for Query Sync. */
private static final Supplier<Boolean> SYNC_BEFORE_BUILD_ENABLED =
Suppliers.memoize(new BoolExperiment("query.sync.before.build", false)::getValue);

private QuerySync() {}

public static boolean isEnabled() {
Expand All @@ -43,6 +47,10 @@ public static boolean isComposeEnabled() {
return isEnabled() && COMPOSE_ENABLED.get();
}

public static boolean isSyncBeforeBuildEnabled() {
return SYNC_BEFORE_BUILD_ENABLED.get();
}

public static void assertNotEnabled(String reason) {
if (isEnabled()) {
NotSupportedWithQuerySyncException e = new NotSupportedWithQuerySyncException(reason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.idea.blaze.base.qsync.settings;

import com.google.idea.blaze.base.qsync.QuerySync;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.util.NlsContexts.ConfigurableName;
Expand All @@ -41,7 +42,12 @@ public QuerySyncConfigurable() {
panel.add(displayDetailsText);

syncBeforeBuild = new JBCheckBox("Sync automatically before building dependencies");
panel.add(syncBeforeBuild);
if (QuerySync.isSyncBeforeBuildEnabled()) {
panel.add(syncBeforeBuild);
} else {
// Disable sync before build if the experiment is disabled
syncBeforeBuild.setSelected(false);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.idea.blaze.base.qsync.settings;

import com.google.idea.blaze.base.qsync.QuerySync;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
Expand All @@ -30,7 +31,7 @@ public class QuerySyncSettings implements PersistentStateComponent<QuerySyncSett
// A place holder setting, to be changed later
public boolean showDetailedInformationInEditor = true;

public boolean syncBeforeBuild = true;
public boolean syncBeforeBuild = QuerySync.isSyncBeforeBuildEnabled();

public static QuerySyncSettings getInstance() {
return ApplicationManager.getApplication().getService(QuerySyncSettings.class);
Expand Down

0 comments on commit 0b1c58e

Please sign in to comment.