Skip to content

Commit

Permalink
Clean up code that directly imports nested classes like Builder, Entr…
Browse files Browse the repository at this point in the history
…y, etc.

PiperOrigin-RevId: 195100125
  • Loading branch information
katre authored and Copybara-Service committed May 2, 2018
1 parent 7b94972 commit bb4ffd6
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.packages.SkylarkProviderIdentifier;
import com.google.devtools.build.lib.rules.android.AndroidRuleClasses.AndroidBaseRule;
Expand All @@ -39,7 +38,7 @@ public class AarImportBaseRule implements RuleDefinition {
static final String ZIPPER = "$zipper";

@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) {
return builder
/* <!-- #BLAZE_RULE($aar_import_base).ATTRIBUTE(aar) -->
The <code>.aar</code> file to provide to the Android targets that depend on this target.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction.Builder;
import com.google.devtools.build.lib.analysis.actions.SpawnActionTemplate;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
Expand Down Expand Up @@ -539,7 +538,7 @@ public static RuleConfiguredTargetBuilder createAndroidBinary(
AndroidRuleClasses.INSTRUMENTATION_TEST_CHECK_RESULTS);

SpawnAction.Builder checkAction =
new Builder()
new SpawnAction.Builder()
.setExecutable(checker)
.addInput(targetManifest)
.addInput(instrumentationManifest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.util.FileType;

/** Rule definition for the {@code android_device_script_fixture} rule. */
Expand All @@ -32,7 +31,7 @@ public class AndroidDeviceScriptFixtureRule implements RuleDefinition {
static final FileType DEVICE_SCRIPT_FIXTURE = FileType.of(".sh");

@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) {
return builder
.setUndocumented()
.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;

/** Rule definition for the {@code android_host_service_fixture} rule. */
public class AndroidHostServiceFixtureRule implements RuleDefinition {
@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) {
return builder
.setUndocumented()
.add(attr("executable", LABEL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -299,7 +298,7 @@ private static void generateAndroidIdlCompilationActions(
preprocessedArgs.add("-p" + idlPreprocessed.getExecPathString());
}

for (Entry<Artifact, Artifact> entry : translatedIdlSources.entrySet()) {
for (Map.Entry<Artifact, Artifact> entry : translatedIdlSources.entrySet()) {
createAndroidIdlAction(
ruleContext,
entry.getKey(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.util.FileTypeSet;

/** Rule definition for the {@code android_instrumentation_test} rule. */
public class AndroidInstrumentationTestRule implements RuleDefinition {

@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) {
return builder
/* <!-- #BLAZE_RULE(android_instrumentation_test).ATTRIBUTE(test_app) -->
The <a href="${link android_binary}">android_binary</a> target containing the test classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.rules.config.ConfigFeatureFlagProvider;
import com.google.devtools.build.lib.rules.java.JavaConfiguration;
Expand All @@ -35,7 +34,7 @@
public class AndroidLocalTestBaseRule implements RuleDefinition {

@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) {
return builder
.requiresConfigurationFragments(
JavaConfiguration.class, AndroidLocalTestConfiguration.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
Expand Down Expand Up @@ -504,7 +503,7 @@ private void configureCommonFlags(
StampedAndroidManifest primaryManifest,
List<Artifact> outs,
NestedSetBuilder<Artifact> inputs,
Builder builder) {
CustomCommandLine.Builder builder) {

// Add data
builder.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.google.devtools.build.lib.packages.AttributeMap;
import com.google.devtools.build.lib.packages.ImplicitOutputsFunction.SafeImplicitOutputsFunction;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.packages.SkylarkProviderIdentifier;
import com.google.devtools.build.lib.packages.TriState;
Expand Down Expand Up @@ -367,7 +366,7 @@ public Iterable<String> getImplicitOutputs(
/** Definition of the {@code android_sdk} rule. */
public static final class AndroidSdkRule implements RuleDefinition {
@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) {
return builder
.requiresConfigurationFragments(JavaConfiguration.class, AndroidConfiguration.class)
.setUndocumented()
Expand Down Expand Up @@ -1071,7 +1070,7 @@ public AndroidToolsDefaultsJarRule(Label... compatibleWithAndroidEnvironments) {
}

@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) {
builder
.setUndocumented()
.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.analysis.WrappingProvider;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.HostTransition;
Expand Down Expand Up @@ -437,7 +436,7 @@ static Artifact createDexArchiveAction(
Set<String> incrementalDexopts,
Artifact dexArchive) {
CustomCommandLine args =
new Builder()
new CustomCommandLine.Builder()
.addExecPath("--input_jar", jar)
.addExecPath("--output_zip", dexArchive)
.addAll(ImmutableList.copyOf(incrementalDexopts))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.google.devtools.build.lib.util.OS;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

/** Builder for creating manifest merger actions. */
public class ManifestMergerActionBuilder {
Expand Down Expand Up @@ -175,9 +174,9 @@ private <K, V> String mapToDictionaryString(
}

StringBuilder sb = new StringBuilder();
Iterator<Entry<K, V>> iter = map.entrySet().iterator();
Iterator<Map.Entry<K, V>> iter = map.entrySet().iterator();
while (iter.hasNext()) {
Entry<K, V> entry = iter.next();
Map.Entry<K, V> entry = iter.next();
sb.append(Functions.compose(ESCAPER, keyConverter).apply(entry.getKey()));
sb.append(':');
sb.append(Functions.compose(ESCAPER, valueConverter).apply(entry.getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
import com.android.aapt.ConfigurationOuterClass.Configuration.UiModeType;
import com.android.aapt.Resources;
import com.android.aapt.Resources.ConfigValue;
import com.android.aapt.Resources.Entry;
import com.android.aapt.Resources.Package;
import com.android.aapt.Resources.ResourceTable;
import com.android.aapt.Resources.Type;
import com.android.aapt.Resources.Value;
import com.android.aapt.Resources.Visibility.Level;
import com.android.ide.common.resources.configuration.CountryCodeQualifier;
Expand Down Expand Up @@ -269,7 +267,7 @@ private void readPackages(KeyValueConsumers consumers, ResourceTable resourceTab
resolver.resolveFor(resourceTablePackage.getPackageName());
String packageName = resourceTablePackage.getPackageName();

for (Type resourceFormatType : resourceTablePackage.getTypeList()) {
for (Resources.Type resourceFormatType : resourceTablePackage.getTypeList()) {
ResourceType resourceType = ResourceType.getEnum(resourceFormatType.getName());

for (Resources.Entry resource : resourceFormatType.getEntryList()) {
Expand Down Expand Up @@ -390,7 +388,7 @@ private FullyQualifiedName createAndRecordFqn(
ReferenceResolver packageResolver,
String packageName,
ResourceType resourceType,
Entry resource,
Resources.Entry resource,
List<String> qualifiers) {
final FullyQualifiedName fqn =
FullyQualifiedName.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -301,7 +300,7 @@ private UnwrittenMergedAndroidData doMerge(
}

// overwriting resources
for (Entry<DataKey, DataResource> entry : parsedPrimary.iterateOverwritableEntries()) {
for (Map.Entry<DataKey, DataResource> entry : parsedPrimary.iterateOverwritableEntries()) {
if (direct.containsOverwritable(entry.getKey())) {
primaryConsumers.overwritingConsumer.accept(
entry.getKey(), entry.getValue().overwrite(direct.getOverwritable(entry.getKey())));
Expand Down Expand Up @@ -338,7 +337,7 @@ private UnwrittenMergedAndroidData doMerge(
}

// combining resources
for (Entry<DataKey, DataResource> entry : parsedPrimary.iterateCombiningEntries()) {
for (Map.Entry<DataKey, DataResource> entry : parsedPrimary.iterateCombiningEntries()) {
primaryConsumers.combiningConsumer.accept(entry.getKey(), entry.getValue());
}
for (Map.Entry<DataKey, DataResource> entry : direct.iterateCombiningEntries()) {
Expand All @@ -359,7 +358,7 @@ private UnwrittenMergedAndroidData doMerge(
}

// assets
for (Entry<DataKey, DataAsset> entry : parsedPrimary.iterateAssetEntries()) {
for (Map.Entry<DataKey, DataAsset> entry : parsedPrimary.iterateAssetEntries()) {
if (direct.containsAsset(entry.getKey())) {
primaryConsumers.assetConsumer.accept(
entry.getKey(), entry.getValue().overwrite(direct.getAsset(entry.getKey())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
Expand Down Expand Up @@ -89,7 +88,7 @@ private void writeKeyValuesTo(
DataSourceTable sourceTable,
byte[] sourceTableBytes)
throws IOException {
Set<Entry<DataKey, DataValue>> entries = map.entrySet();
Set<Map.Entry<DataKey, DataValue>> entries = map.entrySet();
int[] orderedValueSizes = new int[entries.size()];
int valueSizeIndex = 0;
// Serialize all the values in sorted order to a intermediate buffer, so that the keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -271,7 +270,7 @@ private void copy(final Path sourcePath, final Path destinationPath) {
/** Finalizes all operations and flushes the buffers. */
@Override
public void flush() throws IOException {
for (Entry<String, ResourceValuesDefinitions> entry : valueTags.entrySet()) {
for (Map.Entry<String, ResourceValuesDefinitions> entry : valueTags.entrySet()) {
writeTasks.add(
executorService.submit(
entry.getValue().createWritingTask(resourceDirectory().resolve(entry.getKey()))));
Expand Down Expand Up @@ -345,14 +344,14 @@ public Boolean call() throws Exception {
StandardOpenOption.WRITE)) {
writer.write(PRELUDE);
writer.write(START_RESOURCES_TAG);
for (Entry<String, String> prefixToUri : namespaces) {
for (Map.Entry<String, String> prefixToUri : namespaces) {
writer.write(" xmlns:");
writer.write(prefixToUri.getKey());
writer.write("=\"");
writer.write(prefixToUri.getValue());
writer.write("\"");
}
for (Entry<String, String> attribute : attributes.entrySet()) {
for (Map.Entry<String, String> attribute : attributes.entrySet()) {
writer.write(" ");
writer.write(attribute.getKey());
writer.write("=\"");
Expand Down Expand Up @@ -537,9 +536,9 @@ public StartTag named(String name) {
}

@Override
public StartTag addAttributesFrom(Iterable<Entry<String, String>> entries) {
public StartTag addAttributesFrom(Iterable<Map.Entry<String, String>> entries) {
StartTag tag = this;
for (Entry<String, String> entry : entries) {
for (Map.Entry<String, String> entry : entries) {
tag = tag.attribute(entry.getKey()).setTo(entry.getValue());
}
return tag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.Flushable;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.CheckReturnValue;
import javax.xml.namespace.QName;
Expand Down Expand Up @@ -138,7 +139,7 @@ interface StartTag {
/** Adds "name" attribute to the {@link StartTag}. */
StartTag named(String key);
/** Adds all the {@link Entry} as key="value" to the {@link StartTag}. */
StartTag addAttributesFrom(Iterable<Entry<String, String>> entries);
StartTag addAttributesFrom(Iterable<Map.Entry<String, String>> entries);
/** Starts an attribute of prefix:name. */
Attribute attribute(String prefix, String name);
/** Starts an attribute of name. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
Expand Down Expand Up @@ -145,7 +144,7 @@ public Path mergeManifest(

// Add mergee manifests
List<Pair<String, File>> libraryManifests = new ArrayList<>();
for (Entry<Path, String> mergeeManifest : mergeeManifests.entrySet()) {
for (Map.Entry<Path, String> mergeeManifest : mergeeManifests.entrySet()) {
libraryManifests.add(Pair.of(mergeeManifest.getValue(), mergeeManifest.getKey().toFile()));
}
manifestMerger.addLibraryManifests(libraryManifests);
Expand Down
Loading

0 comments on commit bb4ffd6

Please sign in to comment.