Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 425873532
  • Loading branch information
Googler authored and copybara-github committed Feb 2, 2022
1 parent 3f666c7 commit 368fcf7
Show file tree
Hide file tree
Showing 25 changed files with 51 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public ImmutableMap<String, Depset> getNativeLibsStarlark() {
for (Map.Entry<String, NestedSet<Artifact>> entry : getNativeLibs().entrySet()) {
builder.put(entry.getKey(), Depset.of(Artifact.TYPE, entry.getValue()));
}
return builder.build();
return builder.buildOrThrow();
}

/** Provider class for {@link AndroidIdeInfoProvider} objects. */
Expand Down Expand Up @@ -360,7 +360,7 @@ public AndroidIdeInfoProvider createInfo(
ImmutableList.copyOf(
Sequence.cast(idlGeneratedJavaFiles, Artifact.class, "idl_generated_java_files")),
ImmutableList.copyOf(Sequence.cast(apksUnderTest, Artifact.class, "apks_under_test")),
builder.build(),
builder.buildOrThrow(),
fromNoneable(resourceApk, Artifact.class));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private static ImmutableMap<Artifact, Artifact> generateTranslatedIdlArtifacts(
Artifact output = ruleContext.getGenfilesArtifact(javaOutputPath.getPathString());
outputJavaSources.put(idl, output);
}
return outputJavaSources.build();
return outputJavaSources.buildOrThrow();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,12 @@ private static Map<Artifact, Label> getMergeeManifests(
}
switch (manifestMergerOrder) {
case ALPHABETICAL:
return ImmutableSortedMap.copyOf(builder.build(), Artifact.EXEC_PATH_COMPARATOR);
return ImmutableSortedMap.copyOf(builder.buildOrThrow(), Artifact.EXEC_PATH_COMPARATOR);
case ALPHABETICAL_BY_CONFIGURATION:
return ImmutableSortedMap.copyOf(builder.build(), Artifact.ROOT_RELATIVE_PATH_COMPARATOR);
return ImmutableSortedMap.copyOf(
builder.buildOrThrow(), Artifact.ROOT_RELATIVE_PATH_COMPARATOR);
case DEPENDENCY:
return builder.build();
return builder.buildOrThrow();
}
throw new AssertionError(manifestMergerOrder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public Builder addDesugaredJar(Artifact jar, Artifact desugared) {

/** Returns the finished {@link AndroidRuntimeJarProvider}. */
public AndroidRuntimeJarProvider build() {
return new AndroidRuntimeJarProvider(transitiveMappings.add(newlyDesugared.build()).build());
return new AndroidRuntimeJarProvider(
transitiveMappings.add(newlyDesugared.buildOrThrow()).build());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private ImmutableMap<String, BuildOptions> handleAndroidPlatforms(

addNonCpuSplits(result, platform.getName(), splitOptions);
}
return result.build();
return result.buildOrThrow();
}

/** Returns a single-split transition that uses the "--cpu" and does not change any flags. */
Expand All @@ -156,7 +156,7 @@ private ImmutableMap<String, BuildOptions> handleDefaultSplit(
ImmutableMap.Builder<String, BuildOptions> result = ImmutableMap.builder();
result.put(cpu, buildOptions.underlying());
addNonCpuSplits(result, cpu, buildOptions);
return result.build();
return result.buildOrThrow();
}

/**
Expand Down Expand Up @@ -196,7 +196,7 @@ private ImmutableMap<String, BuildOptions> handleFatApkCpus(
result.put(cpu, splitOptions.underlying());
addNonCpuSplits(result, cpu, splitOptions);
}
return result.build();
return result.buildOrThrow();
}

private void setCcFlagsFromAndroid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void buildAndRegister(String message, String mnemonic) {
spawnActionBuilder.addCommandLine(commandLine.build(), FORCED_PARAM_FILE_INFO);
}

spawnActionBuilder.setExecutionInfo(executionInfo.build());
spawnActionBuilder.setExecutionInfo(executionInfo.buildOrThrow());

dataContext.registerAction(spawnActionBuilder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private String unescape(String input) {
public Map<String, String> convert(String input) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
if (input.isEmpty()) {
return builder.build();
return builder.buildOrThrow();
}

String[] elements = input.split(":");
Expand All @@ -66,7 +66,7 @@ public Map<String, String> convert(String input) {
}
builder.put(unescape(name), unescape(value));
}
return builder.build();
return builder.buildOrThrow();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,14 @@ private synchronized void close(@Nullable AbortReason reason) {
for (BuildEventTransport transport : transports) {
closeFuturesMapBuilder.put(transport, transport.close());
}
closeFuturesMap = closeFuturesMapBuilder.build();
closeFuturesMap = closeFuturesMapBuilder.buildOrThrow();

ImmutableMap.Builder<BuildEventTransport, ListenableFuture<Void>> halfCloseFuturesMapBuilder =
ImmutableMap.builder();
for (BuildEventTransport transport : transports) {
halfCloseFuturesMapBuilder.put(transport, transport.getHalfCloseFuture());
}
halfCloseFuturesMap = halfCloseFuturesMapBuilder.build();
halfCloseFuturesMap = halfCloseFuturesMapBuilder.buildOrThrow();
}

private void maybeReportArtifactSet(CompletionContext ctx, NestedSet<?> set) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public GCStatsRecorder(Iterable<GarbageCollectorMXBean> mxBeans) {
initialData.put(name, new GCStat(name, mxBean.getCollectionCount(),
mxBean.getCollectionTime()));
}
this.initialData = initialData.build();
this.initialData = initialData.buildOrThrow();
}

public Iterable<GCStat> getCurrentGcStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ InvocationPolicy getInvocationPolicy() {
}

ImmutableMap<String, InfoItem> getInfoItems() {
return infoItems.build();
return infoItems.buildOrThrow();
}

ImmutableList<QueryFunction> getQueryFunctions() {
Expand Down Expand Up @@ -196,6 +196,6 @@ public ServerBuilder addAuthHeadersProvider(

/** Returns a map of all registered {@link AuthHeadersProvider}s. */
public ImmutableMap<String, AuthHeadersProvider> getAuthHeadersProvidersMap() {
return authHeadersProvidersMap.build();
return authHeadersProvidersMap.buildOrThrow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ImmutableMap<String, Integer> getSummary(ImmutableList<String> reportFirs
result.put(e.getElement(), e.getCount());
}

return result.build();
return result.buildOrThrow();
}

public static String convertSummaryToString(ImmutableMap<String, Integer> spawnSummary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ BlazeWorkspace build(
runtime.getActionKeyContext(),
workspaceStatusActionFactory,
diffAwarenessFactories.build(),
skyFunctions.build(),
skyFunctions.buildOrThrow(),
skyframeExecutorRepositoryHelpersHolder,
skyKeyStateReceiver == null
? SkyframeExecutor.SkyKeyStateReceiver.NULL_INSTANCE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void createValue_basic() throws Exception {
.setVersion(Version.parse("1.0"))
.setKey(createModuleKey("rules_java", ""))
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"dep",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private static FakeBzlmodRepoRuleHelper getFakeBzlmodRepoRuleHelper() {
ImmutableList.of(
"https://maven.google.com", "https://repo1.maven.org/maven2")))
.build());
return new FakeBzlmodRepoRuleHelper(repoSpecs.build());
return new FakeBzlmodRepoRuleHelper(repoSpecs.buildOrThrow());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void setup() throws Exception {
GET_REPO_SPEC_BY_NAME_FUNCTION,
new GetRepoSpecByNameFunction(new BzlmodRepoRuleHelperImpl()))
.put(SkyFunctions.PRECOMPUTED, new PrecomputedFunction())
.build(),
.buildOrThrow(),
differencer);

PrecomputedValue.STARLARK_SEMANTICS.set(differencer, StarlarkSemantics.DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static RepositoryMapping createRepositoryMapping(ModuleKey key, String...
RepositoryName.createFromValidStrippedName(names[i]),
RepositoryName.createFromValidStrippedName(names[i + 1]));
}
return RepositoryMapping.create(mappingBuilder.build(), key.getCanonicalRepoName());
return RepositoryMapping.create(mappingBuilder.buildOrThrow(), key.getCanonicalRepoName());
}

public static TagClass createTagClass(Attribute... attrs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void setup() throws Exception {
ruleClassProvider,
directories,
new BzlmodRepoRuleHelperImpl()))
.build(),
.buildOrThrow(),
differencer);

PrecomputedValue.STARLARK_SEMANTICS.set(differencer, StarlarkSemantics.DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void setup() throws Exception {
ruleClassProvider,
directories,
new BzlmodRepoRuleHelperImpl()))
.build(),
.buildOrThrow(),
differencer);

PrecomputedValue.STARLARK_SEMANTICS.set(differencer, StarlarkSemantics.DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void diamond_simple() throws Exception {
.setKey(createModuleKey("D", "2.0"))
.setCompatibilityLevel(1)
.build())
.build();
.buildOrThrow();

assertThat(Selection.run(depGraph, /*overrides=*/ ImmutableMap.of()))
.containsExactly(
Expand Down Expand Up @@ -241,7 +241,7 @@ public void circularDependencyDueToSelection() throws Exception {
.setVersion(Version.parse("1.0"))
.setKey(createModuleKey("D", "1.0"))
.build())
.build();
.buildOrThrow();

assertThat(Selection.run(depGraph, /*overrides=*/ ImmutableMap.of()))
.containsExactly(
Expand Down Expand Up @@ -315,7 +315,7 @@ public void differentCompatibilityLevelIsRejected() throws Exception {
.setKey(createModuleKey("D", "2.0"))
.setCompatibilityLevel(2)
.build())
.build();
.buildOrThrow();

ExternalDepsException e =
assertThrows(
Expand Down Expand Up @@ -401,7 +401,7 @@ public void differentCompatibilityLevelIsOkIfUnreferenced() throws Exception {
.setKey(createModuleKey("C", "1.1"))
.setCompatibilityLevel(1)
.build())
.build();
.buildOrThrow();

// After selection, C 2.0 is gone, so we're okay.
// A 1.0 -> B 1.1
Expand Down Expand Up @@ -477,7 +477,7 @@ public void multipleVersionOverride_fork_allowedVersionMissingInDepGraph() throw
.setVersion(Version.parse("2.0"))
.setKey(createModuleKey("B", "2.0"))
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"B",
Expand Down Expand Up @@ -522,7 +522,7 @@ public void multipleVersionOverride_fork_goodCase() throws Exception {
.setVersion(Version.parse("2.0"))
.setKey(createModuleKey("B", "2.0"))
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"B",
Expand Down Expand Up @@ -589,7 +589,7 @@ public void multipleVersionOverride_fork_sameVersionUsedTwice() throws Exception
.setVersion(Version.parse("1.5"))
.setKey(createModuleKey("B", "1.5"))
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"B",
Expand Down Expand Up @@ -649,7 +649,7 @@ public void multipleVersionOverride_diamond_differentCompatibilityLevels() throw
.setKey(createModuleKey("D", "2.0"))
.setCompatibilityLevel(2)
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"D",
Expand Down Expand Up @@ -740,7 +740,7 @@ public void multipleVersionOverride_diamond_sameCompatibilityLevel() throws Exce
.setVersion(Version.parse("2.0"))
.setKey(createModuleKey("D", "2.0"))
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"D",
Expand Down Expand Up @@ -887,7 +887,7 @@ public void multipleVersionOverride_diamond_snappingToNextHighestVersion() throw
.setKey(createModuleKey("C", "2.0"))
.setCompatibilityLevel(2)
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"C",
Expand Down Expand Up @@ -1037,7 +1037,7 @@ public void multipleVersionOverride_diamond_dontSnapToDifferentCompatibility() t
.setKey(createModuleKey("C", "2.0"))
.setCompatibilityLevel(2)
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"C",
Expand Down Expand Up @@ -1118,7 +1118,7 @@ public void multipleVersionOverride_diamond_unknownCompatibility() throws Except
.setKey(createModuleKey("C", "3.0"))
.setCompatibilityLevel(3)
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"C",
Expand Down Expand Up @@ -1235,7 +1235,7 @@ public void multipleVersionOverride_diamond_badVersionsAreOkayIfUnreferenced() t
.setKey(createModuleKey("C", "3.0"))
.setCompatibilityLevel(3)
.build())
.build();
.buildOrThrow();
ImmutableMap<String, ModuleOverride> overrides =
ImmutableMap.of(
"C",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public class AndroidCompiledDataDeserializer implements AndroidDataDeserializer
.put(UiModeType.UI_MODE_TYPE_TELEVISION, UiMode.TELEVISION)
.put(UiModeType.UI_MODE_TYPE_VRHEADSET, UiMode.NORMAL)
.put(UiModeType.UI_MODE_TYPE_WATCH, UiMode.WATCH)
.build();
.buildOrThrow();

private static final ImmutableMap<Configuration.UiModeNight, NightMode> NIGHT_MODE_MAP =
ImmutableMap.of(
Expand Down Expand Up @@ -245,7 +245,7 @@ public class AndroidCompiledDataDeserializer implements AndroidDataDeserializer
.put(320, Density.XHIGH)
.put(480, Density.XXHIGH)
.put(640, Density.XXXHIGH)
.build();
.buildOrThrow();

private final boolean includeFileContentsForValidation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public List<Path> getCopiedFiles() {
.put("xxhdpi", 480)
.put("560dpi", 560)
.put("xxxhdpi", 640)
.build();
.buildOrThrow();

private static final Function<ResourceInfo, String> GET_RESOURCE_ID =
new Function<ResourceInfo, String>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public static void main(String[] args) throws Exception {
mergedManifest =
manifestProcessor.mergeManifest(
manifest,
mergeeManifests.build(),
mergeeManifests.buildOrThrow(),
options.mergeType,
options.manifestValues,
options.customPackage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private ImmutableList<FieldInitializer> getStyleableInitializers(
// The styleable array should be sorted by ID value.
// Make sure that if we have android: framework attributes, their IDs are listed first.
ImmutableMap<String, Integer> arrayInitMap =
arrayInitValues.orderEntriesByValue(Ordering.<Integer>natural()).build();
arrayInitValues.orderEntriesByValue(Ordering.<Integer>natural()).buildOrThrow();
initList.add(
IntArrayFieldInitializer.of(
dependencyInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static XmlResourceValue parsePlurals(
}
}
return PluralXmlResourceValue.createWithAttributesAndValues(
ImmutableMap.copyOf(parseTagAttributes(start)), values.build());
ImmutableMap.copyOf(parseTagAttributes(start)), values.buildOrThrow());
}

static XmlResourceValue parseStyle(XMLEventReader eventReader, StartElement start)
Expand Down
Loading

0 comments on commit 368fcf7

Please sign in to comment.