diff options
author | Francois-Rene Rideau <tunes@google.com> | 2015-10-20 15:39:33 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2015-10-20 16:38:43 +0000 |
commit | 93ed7f114ee9be35f41eff5476963745baae4c12 (patch) | |
tree | dacfd5648430e8c1349a573f80d077f6f0e76f5a /src/main/java/com/google/devtools/build/lib/packages/RuleClass.java | |
parent | 67f14b82563757a79c92b79a49e8ade63a92ec3e (diff) |
Unify Skylark and BUILD lists
Use SkylarkList everywhere rather than either List or GlobList.
Keep a GlobList underneath a MutableList, where applicable.
--
MOS_MIGRATED_REVID=105864035
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages/RuleClass.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/RuleClass.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java index f356f25d16..65517309fb 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java @@ -44,6 +44,7 @@ import com.google.devtools.build.lib.syntax.FragmentClassNameResolver; import com.google.devtools.build.lib.syntax.FuncallExpression; import com.google.devtools.build.lib.syntax.GlobList; import com.google.devtools.build.lib.syntax.Runtime; +import com.google.devtools.build.lib.syntax.SkylarkList; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.StringUtil; import com.google.devtools.build.lib.vfs.PathFragment; @@ -1350,13 +1351,22 @@ public final class RuleClass { private void checkAttrValNonEmpty( Rule rule, EventHandler eventHandler, Object attributeValue, Integer attrIndex) { - if (attributeValue instanceof List<?>) { - Attribute attr = getAttribute(attrIndex); - if (attr.isNonEmpty() && ((List<?>) attributeValue).isEmpty()) { - rule.reportError(rule.getLabel() + ": non empty " + "attribute '" + attr.getName() - + "' in '" + name + "' rule '" + rule.getLabel() + "' has to have at least one value", - eventHandler); - } + List<?> list; + + if (attributeValue instanceof SkylarkList) { + list = ((SkylarkList) attributeValue).getList(); + } else if (attributeValue instanceof List<?>) { + list = (List<?>) attributeValue; + } else { + // TODO(bazel-team): Test maps, not just lists, as being non-empty. + return; + } + + Attribute attr = getAttribute(attrIndex); + if (attr.isNonEmpty() && list.isEmpty()) { + rule.reportError(rule.getLabel() + ": non empty " + "attribute '" + attr.getName() + + "' in '" + name + "' rule '" + rule.getLabel() + "' has to have at least one value", + eventHandler); } } |