From 3fa2e46f73802412772b0182e1e38e9dbbcda638 Mon Sep 17 00:00:00 2001 From: jcater Date: Fri, 10 Nov 2017 01:31:20 +0100 Subject: Add getAttributeLocation to AttributeMap and related classes. PiperOrigin-RevId: 175230893 --- .../lib/analysis/AspectAwareAttributeMapper.java | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/analysis') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapper.java index db7d6f0f3c..c866cbd84b 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapper.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AspectAwareAttributeMapper.java @@ -17,23 +17,24 @@ package com.google.devtools.build.lib.analysis; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.RuleClass; import com.google.devtools.build.lib.syntax.Type; /** - * An {@link AttributeMap} that supports attribute type queries on both a rule - * and its aspects and attribute value queries on the rule. + * An {@link AttributeMap} that supports attribute type queries on both a rule and its aspects and + * attribute value queries on the rule. * - *

An attribute type query is anything accessible from {@link Attribute} (i.e. - * anything about how the attribute is integrated into the {@link RuleClass}). An - * attribute value query is anything related to the actual value an attribute takes. + *

An attribute type query is anything accessible from {@link Attribute} (i.e. anything about how + * the attribute is integrated into the {@link RuleClass}). An attribute value query is anything + * related to the actual value an attribute takes. * - *

For example, given {@code deps = [":adep"]}, checking that {@code deps} exists - * or that it's type is {@link BuildType.LABEL_LIST} are type queries. Checking that - * its value is explicitly set in the BUILD File or that its value - * {@code [":adep"]} are value queries.. + *

For example, given {@code deps = [":adep"]}, checking that {@code deps} exists or that it's + * type is {@link com.google.devtools.build.lib.packages.BuildType#LABEL_LIST} are type queries. + * Checking that its value is explicitly set in the BUILD File or that its value {@code [":adep"]} + * are value queries.. * *

Value queries on aspect attributes trigger {@link UnsupportedOperationException}. */ @@ -167,4 +168,13 @@ class AspectAwareAttributeMapper implements AttributeMap { && aspectAttributes.get(attrName).getType() == type; } } + + @Override + public Location getAttributeLocation(String attrName) { + if (ruleAttributes.has(attrName)) { + return ruleAttributes.getAttributeLocation(attrName); + } else { + return Location.BUILTIN; + } + } } \ No newline at end of file -- cgit v1.2.3