diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java b/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java index 0feb423453..5e72aedcd5 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java @@ -17,8 +17,10 @@ import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; +import com.google.devtools.build.lib.util.Preconditions; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; /** @@ -97,6 +99,19 @@ public final class SelectorList implements SkylarkValue { return new SelectorList(type1, builder.build()); } + /** + * Creates a list consisting of the given selects. + */ + public static SelectorList of(List<SelectorValue> selectors) throws EvalException { + Preconditions.checkArgument(!selectors.isEmpty()); + Iterator<SelectorValue> it = selectors.iterator(); + SelectorList list = SelectorList.of(it.next()); + while (it.hasNext()) { + list = SelectorList.concat(null, list, it.next()); + } + return list; + } + // TODO(bazel-team): match on the List interface, not the actual implementation. For now, // we verify this is the right class through test coverage. private static final Class<?> NATIVE_LIST_TYPE = ArrayList.class; |