Skip to content

Commit

Permalink
Rename LateBoundLabel#getDefault(Rule, AttributeMap, T) to #resolve().
Browse files Browse the repository at this point in the history
Its old name was confusing because resolve() and getDefault() do radically different things: getDefault() returns a good enough lie for when BuildConfiguration is not available, and resolve() resolves the dependency when we do have a BuildConfiguration.

--
MOS_MIGRATED_REVID=120212630
  • Loading branch information
lberki authored and damienmg committed Apr 19, 2016
1 parent 97e5ab0 commit 0dbe07f
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Object getDefault(AttributeMap rule) {
static final LateBoundLabelList<BuildConfiguration> ACTION_LISTENER =
new LateBoundLabelList<BuildConfiguration>() {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
// action_listeners are special rules; they tell the build system to add extra_actions to
// existing rules. As such they need an edge to every ConfiguredTarget with the limitation
Expand All @@ -94,7 +94,7 @@ public List<Label> getDefault(Rule rule, AttributeMap attributes,
private static final LateBoundLabelList<BuildConfiguration> COVERAGE_SUPPORT =
new LateBoundLabelList<BuildConfiguration>(ImmutableList.of(COVERAGE_SUPPORT_LABEL)) {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.isCodeCoverageEnabled()
? ImmutableList.copyOf(configuration.getCoverageLabels())
Expand All @@ -105,7 +105,7 @@ public List<Label> getDefault(Rule rule, AttributeMap attributes,
private static final LateBoundLabelList<BuildConfiguration> GCOV =
new LateBoundLabelList<BuildConfiguration>(ImmutableList.of(COVERAGE_SUPPORT_LABEL)) {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.isCodeCoverageEnabled()
? ImmutableList.copyOf(configuration.getGcovLabels())
Expand All @@ -116,7 +116,7 @@ public List<Label> getDefault(Rule rule, AttributeMap attributes,
private static final LateBoundLabelList<BuildConfiguration> COVERAGE_REPORT_GENERATOR =
new LateBoundLabelList<BuildConfiguration>(ImmutableList.of(COVERAGE_SUPPORT_LABEL)) {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.isCodeCoverageEnabled()
? ImmutableList.copyOf(configuration.getCoverageReportGeneratorLabels())
Expand All @@ -130,7 +130,7 @@ public List<Label> getDefault(Rule rule, AttributeMap attributes,
private static final LateBoundLabel<BuildConfiguration> RUN_UNDER =
new LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
RunUnder runUnder = configuration.getRunUnder();
return runUnder == null ? null : runUnder.getLabel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private void resolveLateBoundAttributes(

// TODO(bazel-team): We should check if the implementation tries to access an undeclared
// fragment.
Object actualValue = lateBoundDefault.getDefault(rule, attributeMap, actualConfig);
Object actualValue = lateBoundDefault.resolve(rule, attributeMap, actualConfig);
if (EvalUtils.isNullOrNone(actualValue)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public String getCategory() {
public static final LateBoundLabel<BuildConfiguration> CC_TOOLCHAIN =
new LateBoundLabel<BuildConfiguration>(CROSSTOOL_LABEL) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(CppConfiguration.class).getCcToolchainRuleLabel();
}
Expand All @@ -171,7 +171,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
public static final LateBoundLabel<BuildConfiguration> DEFAULT_MALLOC =
new LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(CppConfiguration.class).customMalloc();
}
Expand All @@ -180,7 +180,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
public static final LateBoundLabel<BuildConfiguration> STL =
new LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return getStl(rule, configuration);
}
Expand All @@ -192,7 +192,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
public static final LateBoundLabel<BuildConfiguration> LIPO_CONTEXT_COLLECTOR =
new LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
// This attribute connects a target to the LIPO context target configured with the
// lipo input collector configuration.
CppConfiguration cppConfiguration = configuration.getFragment(CppConfiguration.class);
Expand Down Expand Up @@ -680,7 +680,7 @@ public Metadata getMetadata() {
private static final LateBoundLabel<BuildConfiguration> LIPO_CONTEXT =
new LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
Label result = configuration.getFragment(CppConfiguration.class).getLipoContextLabel();
return (rule == null || rule.getLabel().equals(result)) ? null : result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ public interface LateBoundDefault<T> {
* @param attributes interface for retrieving the values of the rule's other attributes
* @param o the configuration to evaluate with
*/
Object getDefault(Rule rule, AttributeMap attributes, T o)
Object resolve(Rule rule, AttributeMap attributes, T o)
throws EvalException, InterruptedException;
}

Expand Down Expand Up @@ -1035,7 +1035,7 @@ public final Label getDefault() {
}

@Override
public abstract Label getDefault(Rule rule, AttributeMap attributes, T configuration);
public abstract Label resolve(Rule rule, AttributeMap attributes, T configuration);
}

/**
Expand Down Expand Up @@ -1069,7 +1069,7 @@ public final List<Label> getDefault() {
}

@Override
public abstract List<Label> getDefault(Rule rule, AttributeMap attributes, T configuration);
public abstract List<Label> resolve(Rule rule, AttributeMap attributes, T configuration);
}

/**
Expand Down Expand Up @@ -1099,7 +1099,7 @@ public Object getDefault() {
}

@Override
public Object getDefault(Rule rule, AttributeMap attributes, Object o)
public Object resolve(Rule rule, AttributeMap attributes, Object o)
throws EvalException, InterruptedException {
Map<String, Object> attrValues = new HashMap<>();
for (Attribute attr : rule.getAttributes()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class SkylarkRuleClassFunctions {
private static final LateBoundLabel<BuildConfiguration> RUN_UNDER =
new LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
RunUnder runUnder = configuration.getRunUnder();
return runUnder == null ? null : runUnder.getLabel();
Expand All @@ -130,7 +130,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
private static final LateBoundLabelList<BuildConfiguration> GCOV =
new LateBoundLabelList<BuildConfiguration>(ImmutableList.of(COVERAGE_SUPPORT_LABEL)) {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.isCodeCoverageEnabled()
? ImmutableList.copyOf(configuration.getGcovLabels())
Expand All @@ -141,7 +141,7 @@ public List<Label> getDefault(Rule rule, AttributeMap attributes,
private static final LateBoundLabelList<BuildConfiguration> COVERAGE_REPORT_GENERATOR =
new LateBoundLabelList<BuildConfiguration>(ImmutableList.of(COVERAGE_SUPPORT_LABEL)) {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.isCodeCoverageEnabled()
? ImmutableList.copyOf(configuration.getCoverageReportGeneratorLabels())
Expand All @@ -152,7 +152,7 @@ public List<Label> getDefault(Rule rule, AttributeMap attributes,
private static final LateBoundLabelList<BuildConfiguration> COVERAGE_SUPPORT =
new LateBoundLabelList<BuildConfiguration>(ImmutableList.of(COVERAGE_SUPPORT_LABEL)) {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.isCodeCoverageEnabled()
? ImmutableList.copyOf(configuration.getCoverageLabels())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public final class AndroidRuleClasses {
public static final LateBoundLabel<BuildConfiguration> ANDROID_SDK =
new LateBoundLabel<BuildConfiguration>(DEFAULT_ANDROID_SDK, AndroidConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(AndroidConfiguration.class).getSdk();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static class RequiresXcodeConfigRule implements RuleDefinition {
new LateBoundLabel<BuildConfiguration>(
AppleCommandLineOptions.DEFAULT_XCODE_VERSION_CONFIG_LABEL, AppleConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(AppleConfiguration.class).getXcodeConfigLabel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static boolean isCcToolchain(Target target) {
private static final LateBoundLabel<BuildConfiguration> LIBC_TOP =
new LateBoundLabel<BuildConfiguration>(CppConfiguration.class) {
@Override
public Label getDefault(
public Label resolve(
Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
return configuration.getFragment(CppConfiguration.class).getLibcLabel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public interface JavaSemantics {
LateBoundLabel<BuildConfiguration> JAVA_TOOLCHAIN =
new LateBoundLabel<BuildConfiguration>(JAVA_TOOLCHAIN_LABEL, JavaConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(JavaConfiguration.class).getToolchainLabel();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
LateBoundLabel<BuildConfiguration> JVM =
new LateBoundLabel<BuildConfiguration>(JavaImplicitAttributes.JDK_LABEL, Jvm.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(Jvm.class).getJvmLabel();
}
Expand All @@ -140,7 +140,7 @@ public boolean useHostConfiguration() {
}

@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(Jvm.class).getJvmLabel();
}
Expand All @@ -153,7 +153,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
LateBoundLabel<BuildConfiguration> JAVA_LAUNCHER =
new LateBoundLabel<BuildConfiguration>(JavaConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(JavaConfiguration.class).getJavaLauncherLabel();
}
Expand All @@ -162,7 +162,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
LateBoundLabelList<BuildConfiguration> JAVA_PLUGINS =
new LateBoundLabelList<BuildConfiguration>() {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return ImmutableList.copyOf(configuration.getPlugins());
}
Expand All @@ -174,7 +174,7 @@ public List<Label> getDefault(Rule rule, AttributeMap attributes,
LateBoundLabel<BuildConfiguration> PROGUARD =
new LateBoundLabel<BuildConfiguration>(JavaConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return configuration.getFragment(JavaConfiguration.class).getProguardBinary();
}
Expand All @@ -183,7 +183,7 @@ public Label getDefault(Rule rule, AttributeMap attributes,
LateBoundLabelList<BuildConfiguration> EXTRA_PROGUARD_SPECS =
new LateBoundLabelList<BuildConfiguration>() {
@Override
public List<Label> getDefault(Rule rule, AttributeMap attributes,
public List<Label> resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return ImmutableList.copyOf(
configuration.getFragment(JavaConfiguration.class).getExtraProguardSpecs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public Object getDefault(AttributeMap rule) {
.value(
new LateBoundLabelList<BuildConfiguration>(gcov) {
@Override
public List<Label> getDefault(
public List<Label> resolve(
Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
if (!configuration.isCodeCoverageEnabled()) {
return ImmutableList.of();
Expand All @@ -162,7 +162,7 @@ public List<Label> getDefault(
.value(
new LateBoundLabel<BuildConfiguration>(mcov) {
@Override
public Label getDefault(
public Label resolve(
Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
if (!configuration.isCodeCoverageEnabled()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static boolean isInstrumentable(Artifact sourceArtifact) {
public static final LateBoundLabel<BuildConfiguration> APPLE_TOOLCHAIN =
new LateBoundLabel<BuildConfiguration>(CROSSTOOL_LABEL, CppConfiguration.class) {
@Override
public Label getDefault(
public Label resolve(
Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
return configuration.getFragment(CppConfiguration.class).getCcToolchainRuleLabel();
}
Expand All @@ -162,7 +162,7 @@ public Label getDefault(
public static final LateBoundLabel<BuildConfiguration> NULL_LIPO_CONTEXT_COLLECTOR =
new LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(
public Label resolve(
Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
return null;
}
Expand Down Expand Up @@ -927,7 +927,7 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
.value(
new LateBoundLabel<BuildConfiguration>(ObjcConfiguration.class) {
@Override
public Label getDefault(
public Label resolve(
Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
return configuration
.getFragment(ObjcConfiguration.class)
Expand All @@ -953,7 +953,7 @@ The provisioning profile (.mobileprovision file) to use when bundling
.value(
new LateBoundLabel<BuildConfiguration>(ObjcConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
AppleConfiguration appleConfiguration =
configuration.getFragment(AppleConfiguration.class);
Expand Down Expand Up @@ -1250,7 +1250,7 @@ The provisioning profile (.mobileprovision file) to use when bundling
.value(
new LateBoundLabel<BuildConfiguration>(ObjcConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
AppleConfiguration appleConfiguration =
configuration.getFragment(AppleConfiguration.class);
Expand Down Expand Up @@ -1433,7 +1433,7 @@ The provisioning profile (.mobileprovision file) to use when bundling
.value(
new LateBoundLabel<BuildConfiguration>(ObjcConfiguration.class) {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
AppleConfiguration appleConfiguration =
configuration.getFragment(AppleConfiguration.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void testAspectWithImplicitOrLateboundAttribute_AddsToAttributeMap() thro
.build();
LateBoundLabel<String> latebound = new LateBoundLabel<String>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes, String configuration) {
public Label resolve(Rule rule, AttributeMap attributes, String configuration) {
return Label.parseAbsoluteUnchecked("//run:away");
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
.value(
new Attribute.LateBoundLabel<BuildConfiguration>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes,
public Label resolve(Rule rule, AttributeMap attributes,
BuildConfiguration configuration) {
return Label.parseAbsoluteUnchecked("//helpers:latebound");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class TestAspects {

public static final LateBoundLabel EMPTY_LATE_BOUND_LABEL = new LateBoundLabel<Object>() {
@Override
public Label getDefault(Rule rule, AttributeMap attributes, Object configuration) {
public Label resolve(Rule rule, AttributeMap attributes, Object configuration) {
return null;
}
};
Expand Down

0 comments on commit 0dbe07f

Please sign in to comment.