Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 434784397
  • Loading branch information
Googler authored and pull[bot] committed Aug 31, 2023
1 parent 4fc4980 commit 4d9c2f8
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static AndroidAssets empty() {

private final ImmutableList<Artifact> assets;
private final ImmutableList<PathFragment> assetRoots;
private final @Nullable String assetDir;
@Nullable private final String assetDir;

AndroidAssets(AndroidAssets other) {
this(other.assets, other.assetRoots, other.assetDir);
Expand All @@ -167,7 +167,8 @@ public ImmutableList<PathFragment> getAssetRoots() {
return assetRoots;
}

public @Nullable String getAssetDirAsString() {
@Nullable
public String getAssetDirAsString() {
return assetDir;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ private void initJava(

filesToBuild = filesBuilder.build();

if ((attributes.hasSources()) && jar != null) {
if ( attributes.hasSources() && jar != null) {
iJar = helper.createCompileTimeJarAction(jar, javaArtifactsBuilder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public boolean signV2() {
* <p>If null/unset, the V4 signing flag should not be passed to apksigner. This extra level of
* control is needed to support environments where older build tools may be used.
*/
public @Nullable Boolean signV4() {
@Nullable
public Boolean signV4() {
return signV4;
}
}
Expand Down Expand Up @@ -1291,7 +1292,8 @@ public boolean apkSigningMethodV2() {
}

@Override
public @Nullable Boolean apkSigningMethodV4() {
@Nullable
public Boolean apkSigningMethodV4() {
return apkSigningMethod.signV4();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void expandToCommandLine(T t, Consumer<String> args) {

public String map(T t) {
return suppliers.stream()
.map(s -> (s.apply(t)))
.map(s -> s.apply(t))
.collect(Collectors.joining(joinerType.itemSeparator));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public String getIdlImportRoot() {
return hasExplicitlySpecifiedIdlImportRoot(ruleContext) ? getIdlImportRoot(ruleContext) : null;
}

private static String getIdlImportRoot(RuleContext ruleContext) {
return ruleContext.attributes().get("idl_import_root", Type.STRING);
}

/** Returns the raw (non-processed) idl_srcs, not including parcelable marker files. */
public Collection<Artifact> getIdlSources() {
return translatedIdlSources.keySet();
Expand All @@ -130,11 +134,32 @@ public Collection<Artifact> getIdlParcelables() {
return getIdlParcelables(ruleContext);
}

/** Returns the idl_parcelables defined on the given rule. */
private static ImmutableList<Artifact> getIdlParcelables(RuleContext ruleContext) {
return ruleContext.getRule().isAttrDefined("idl_parcelables", BuildType.LABEL_LIST)
? ImmutableList.copyOf(
ruleContext
.getPrerequisiteArtifacts("idl_parcelables")
.filter(AndroidRuleClasses.ANDROID_IDL)
.list())
: ImmutableList.<Artifact>of();
}

/** Returns the idl_preprocessed. */
public Collection<Artifact> getIdlPreprocessed() {
return getIdlPreprocessed(ruleContext);
}

/** Returns the idl_preprocessed defined on the given rule. */
private static Collection<Artifact> getIdlPreprocessed(RuleContext ruleContext) {
return ruleContext.isAttrDefined("idl_preprocessed", BuildType.LABEL_LIST)
? ruleContext
.getPrerequisiteArtifacts("idl_preprocessed")
.filter(AndroidRuleClasses.ANDROID_IDL)
.list()
: ImmutableList.<Artifact>of();
}

/** Returns the generated Java sources created from the idl_srcs. */
public Collection<Artifact> getIdlGeneratedJavaSources() {
return translatedIdlSources.values();
Expand Down Expand Up @@ -205,17 +230,6 @@ private Artifact createIdlJar(Artifact baseArtifact, String suffix) {
baseArtifact.getRoot());
}

/** Returns the idl_parcelables defined on the given rule. */
private static ImmutableList<Artifact> getIdlParcelables(RuleContext ruleContext) {
return ruleContext.getRule().isAttrDefined("idl_parcelables", BuildType.LABEL_LIST)
? ImmutableList.copyOf(
ruleContext
.getPrerequisiteArtifacts("idl_parcelables")
.filter(AndroidRuleClasses.ANDROID_IDL)
.list())
: ImmutableList.<Artifact>of();
}

/** Returns the idl_srcs defined on the given rule. */
private static Collection<Artifact> getIdlSrcs(RuleContext ruleContext) {
if (!ruleContext.getRule().isAttrDefined("idl_srcs", BuildType.LABEL_LIST)) {
Expand Down Expand Up @@ -498,18 +512,4 @@ private static boolean hasExplicitlySpecifiedIdlSrcsOrParcelables(RuleContext ru
return ruleContext.getRule().isAttributeValueExplicitlySpecified("idl_srcs")
|| ruleContext.getRule().isAttributeValueExplicitlySpecified("idl_parcelables");
}

private static String getIdlImportRoot(RuleContext ruleContext) {
return ruleContext.attributes().get("idl_import_root", Type.STRING);
}

/** Returns the idl_preprocessed defined on the given rule. */
private static Collection<Artifact> getIdlPreprocessed(RuleContext ruleContext) {
return ruleContext.isAttrDefined("idl_preprocessed", BuildType.LABEL_LIST)
? ruleContext
.getPrerequisiteArtifacts("idl_preprocessed")
.filter(AndroidRuleClasses.ANDROID_IDL)
.list()
: ImmutableList.<Artifact>of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AndroidResourceMergingActionBuilder {
private Artifact classJarOut;
private Artifact aapt2RTxtOut;
private Artifact manifestOut;
private @Nullable Artifact dataBindingInfoZip;
@Nullable private Artifact dataBindingInfoZip;

// Flags
private String customJavaPackage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,25 +505,6 @@ private Artifact createDesugarAction(
+ "_desugared.jar"));
}

/**
* Desugars the given Jar using an executable prerequisite {@code "$desugar"}. Rules calling this
* method must declare the appropriate prerequisite, similar to how {@link #getDefinition} does it
* for {@link DexArchiveAspect} under a different name.
*
* <p>It's useful to have this action separately since callers need to look up classpath and
* bootclasspath in a different way than this aspect does it.
*
* @return the artifact given as {@code result}, which can simplify calling code
*/
static Artifact desugar(
RuleContext ruleContext,
Artifact jar,
NestedSet<Artifact> bootclasspath,
NestedSet<Artifact> classpath,
Artifact result) {
return createDesugarAction(ruleContext, "$desugar", jar, bootclasspath, classpath, result);
}

private static Artifact createDesugarAction(
RuleContext ruleContext,
String desugarPrereqName,
Expand Down Expand Up @@ -562,6 +543,25 @@ private static Artifact createDesugarAction(
return result;
}

/**
* Desugars the given Jar using an executable prerequisite {@code "$desugar"}. Rules calling this
* method must declare the appropriate prerequisite, similar to how {@link #getDefinition} does it
* for {@link DexArchiveAspect} under a different name.
*
* <p>It's useful to have this action separately since callers need to look up classpath and
* bootclasspath in a different way than this aspect does it.
*
* @return the artifact given as {@code result}, which can simplify calling code
*/
static Artifact desugar(
RuleContext ruleContext,
Artifact jar,
NestedSet<Artifact> bootclasspath,
NestedSet<Artifact> classpath,
Artifact result) {
return createDesugarAction(ruleContext, "$desugar", jar, bootclasspath, classpath, result);
}

/**
* Creates a dexbuilder action with the given input, output, and flags. Flags must have been
* filtered and normalized to a set that the dexbuilder tool can understand.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private static Iterable<Artifact> filterUniqueSharedLibraries(
+ artifact.prettyPrint()
+ " and "
+ oldArtifact.prettyPrint()
+ ((oldArtifact.equals(linkedLibrary))
+ ( oldArtifact.equals(linkedLibrary)
? " (the library compiled for this target)"
: ""));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ResourceFilter {
private final boolean isEmpty;

static final ResourceFilter empty() {
return new ResourceFilter(ImmutableSet.of(), (artifact -> {}), /* isEmpty= */ true);
return new ResourceFilter(ImmutableSet.of(), artifact -> {}, /* isEmpty= */ true);
}

static final ResourceFilter of(
Expand Down

0 comments on commit 4d9c2f8

Please sign in to comment.