diff options
author | 2016-07-01 21:17:42 +0000 | |
---|---|---|
committer | 2016-07-04 07:19:18 +0000 | |
commit | 073d2fd4ae47254aacf43dfdbac463828b7729a2 (patch) | |
tree | 94da58a0cfc8a53754c12be770733656b419925e /src/main/java/com/google/devtools/build/lib/syntax | |
parent | bc1ff69be434da258b2ef24fda3d4290e0a66d75 (diff) |
Skylark: Removed support for attribute map parameters in callback functions.
Such functions have to list their required attributes as parameters.
def _callback_func(attr_map):
do_something(attr_map.my_attr)
becomes
def _callback_func(my_attr):
do_something(my_attr)
RELNOTES[INC]:Skylark rules: if you set "outputs" or an attribute to a function, this function must now list its required attributes as parameters (instead of an attribute map).
--
MOS_MIGRATED_REVID=126445849
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java index b8835f21d2..ba88b8b024 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java @@ -15,7 +15,6 @@ package com.google.devtools.build.lib.syntax; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; -import com.google.common.collect.ImmutableSet; /** * A helper class for calling Skylark functions from Java. @@ -51,12 +50,6 @@ public class SkylarkCallbackFunction { } } - // For legacy reasons: these names are used in the depot to signal that the first parameter of - // the callback function should be an attribute map. - // TODO(fwe): remove once this CL is part of a Blaze release and the depot is clean. - private static final ImmutableSet<String> LEGACY_ATTR_MAP_NAMES = - ImmutableSet.<String>of("attr_map", "attrs", "attr"); - /** * Creates a list of actual arguments that contains the given arguments and all attribute values * required from the specified context. @@ -69,14 +62,7 @@ public class SkylarkCallbackFunction { String name = names.get(pos); Object value = ctx.getValue(name); if (value == null) { - if (requiredParameters == 1 && LEGACY_ATTR_MAP_NAMES.contains(name)) { - // Legacy mode: some bzl files still expect the attribute map as the first parameter. - // TODO(fwe): remove this branch once this CL is part of a Blaze release and the depot - // is clean. - value = ctx; - } else { throw new IllegalArgumentException(ctx.errorMessage(name)); - } } builder.add(value); } |