/*
 * Copyright 2019 The Bazel Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.idea.blaze.base.sync;

import com.google.auto.value.AutoValue;
import com.google.idea.blaze.base.bazel.BuildSystemProvider;
import com.google.idea.blaze.base.settings.Blaze;
import com.google.idea.blaze.base.settings.BuildBinaryType;
import com.google.idea.common.experiments.BoolExperiment;
import com.intellij.openapi.project.Project;

/** Parameters specific to blaze builds during sync. */
@AutoValue
public abstract class BlazeBuildParams {

  private static final BoolExperiment parallelizeRemoteSyncs =
      new BoolExperiment("parallelize.remote.syncs", true);

  public static BlazeBuildParams fromProject(Project project) {
    BuildSystemProvider provider = Blaze.getBuildSystemProvider(project);
    BuildBinaryType binaryType = provider.getSyncBinaryType();
    return builder()
        .setBlazeBinaryPath(provider.getSyncBinaryPath(project))
        .setBlazeBinaryType(binaryType)
        .setParallelizeBuilds(parallelizeRemoteSyncs.getValue() && binaryType.isRemote)
        .build();
  }

  public abstract String blazeBinaryPath();

  public abstract BuildBinaryType blazeBinaryType();

  /**
   * Whether batched build invocations are run in parallel, when possible (only when building
   * remotely).
   */
  public abstract boolean parallelizeBuilds();

  public static Builder builder() {
    return new AutoValue_BlazeBuildParams.Builder();
  }

  /** Builder class for {@link BlazeBuildParams}. */
  @AutoValue.Builder
  public abstract static class Builder {

    public abstract Builder setBlazeBinaryPath(String value);

    public abstract Builder setBlazeBinaryType(BuildBinaryType value);

    // not public; derived from BuildBinaryType
    abstract Builder setParallelizeBuilds(boolean parallelizeBuilds);

    abstract BuildBinaryType blazeBinaryType();

    abstract BlazeBuildParams autoBuild();

    public BlazeBuildParams build() {
      setParallelizeBuilds(parallelizeRemoteSyncs.getValue() && blazeBinaryType().isRemote);
      return autoBuild();
    }
  }
}

@@ -872,66 +872,8 @@
 pe;%0A
-import com.google.idea.common.experiments.BoolExperiment;%0A
 impo
@@ -913,16 +913,16 @@
 roject;%0A
+
 %0A/** Par
@@ -1027,132 +1027,8 @@
  %7B%0A%0A
-  private static final BoolExperiment parallelizeRemoteSyncs =%0A      new BoolExperiment(%22parallelize.remote.syncs%22, true);%0A%0A
   pu
@@ -1350,16 +1350,16 @@
 ryType)%0A
+
         
@@ -1384,45 +1384,8 @@
 lds(
-parallelizeRemoteSyncs.getValue() && 
 bina
@@ -2319,45 +2319,8 @@
 lds(
-parallelizeRemoteSyncs.getValue() && 
 blaz

Delete experiment parallelize.remote.syncs. It's not used.