Add more configuration fragment annotations, and a runtime check.
--
MOS_MIGRATED_REVID=99819719
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
index fad5cd4..92b3dbd 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
@@ -259,12 +259,15 @@
public <T extends Fragment> T getFragment(Class<T> fragment) {
// TODO(bazel-team): The fragments can also be accessed directly through BuildConfiguration.
// Can we lock that down somehow?
- Preconditions.checkArgument(
- rule.getRuleClassObject().isLegalConfigurationFragment(fragment),
+ Preconditions.checkArgument(isLegalFragment(fragment),
"%s does not have access to %s", rule.getRuleClass(), fragment);
return getConfiguration().getFragment(fragment);
}
+ public <T extends Fragment> boolean isLegalFragment(Class<T> fragment) {
+ return rule.getRuleClassObject().isLegalConfigurationFragment(fragment);
+ }
+
@Override
public ArtifactOwner getOwner() {
return getAnalysisEnvironment().getOwner();