aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java
index c4c47b4b7a..4f67d959e0 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java
@@ -15,7 +15,6 @@ package com.google.devtools.build.lib.packages;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.BuildType.SelectorList;
import com.google.devtools.build.lib.syntax.Type;
@@ -149,15 +148,20 @@ public abstract class AbstractAttributeMapper implements AttributeMap {
}
/** Visits all labels reachable from the given attribute. */
- protected void visitLabels(Attribute attribute, AcceptsLabelAttribute observer)
+ protected void visitLabels(final Attribute attribute, final AcceptsLabelAttribute observer)
throws InterruptedException {
Type<?> type = attribute.getType();
Object value = get(attribute.getName(), type);
if (value != null) { // null values are particularly possible for computed defaults.
- for (Label label : extractLabels(type, value)) {
- Label absoluteLabel = ruleLabel.resolveRepositoryRelative(label);
- observer.acceptLabelAttribute(absoluteLabel, attribute);
- }
+ type.visitLabels(new Type.LabelVisitor() {
+ @Override
+ public void visit(@Nullable Object object) throws InterruptedException {
+ if (object != null) {
+ Label absoluteLabel = ruleLabel.resolveRepositoryRelative((Label) object);
+ observer.acceptLabelAttribute(absoluteLabel, attribute);
+ }
+ }
+ }, value);
}
}
@@ -244,10 +248,4 @@ public abstract class AbstractAttributeMapper implements AttributeMap {
Attribute attribute = ruleClass.getAttributeByNameMaybe(attrName);
return attribute != null && attribute.getType() == type;
}
-
- protected static Iterable<Label> extractLabels(Type<?> type, Object value) {
- return value == null
- ? ImmutableList.<Label>of()
- : Iterables.filter(type.extractLabels(value), Label.class);
- }
}