use of com.google.devtools.build.lib.syntax.SkylarkList.MutableList in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testResolveCommandInputs.
@Test
public void testResolveCommandInputs() throws Exception {
evalRuleContextCode(createRuleContext("//foo:resolve_me"), "inputs, argv, input_manifests = ruleContext.resolve_command(", " tools=ruleContext.attr.tools)");
@SuppressWarnings("unchecked") List<Artifact> inputs = (List<Artifact>) (List<?>) (MutableList) lookup("inputs");
assertArtifactFilenames(inputs, "mytool.sh", "mytool", "foo_Smytool-runfiles", "t.exe");
@SuppressWarnings("unchecked") CompositeRunfilesSupplier runfilesSupplier = new CompositeRunfilesSupplier((List<RunfilesSupplier>) lookup("input_manifests"));
assertThat(runfilesSupplier.getMappings()).hasSize(1);
}
use of com.google.devtools.build.lib.syntax.SkylarkList.MutableList in project bazel by bazelbuild.
the class BinaryOperatorExpression method plus.
/** Implements Operator.PLUS. */
private static Object plus(Object lval, Object rval, Environment env, Location location) throws EvalException {
// int + int
if (lval instanceof Integer && rval instanceof Integer) {
return ((Integer) lval).intValue() + ((Integer) rval).intValue();
}
// string + string
if (lval instanceof String && rval instanceof String) {
return (String) lval + (String) rval;
}
if (lval instanceof SelectorValue || rval instanceof SelectorValue || lval instanceof SelectorList || rval instanceof SelectorList) {
return SelectorList.concat(location, lval, rval);
}
if ((lval instanceof Tuple) && (rval instanceof Tuple)) {
return Tuple.copyOf(Iterables.concat((Tuple) lval, (Tuple) rval));
}
if ((lval instanceof MutableList) && (rval instanceof MutableList)) {
return MutableList.concat((MutableList) lval, (MutableList) rval, env);
}
if (lval instanceof SkylarkDict && rval instanceof SkylarkDict) {
return SkylarkDict.plus((SkylarkDict<?, ?>) lval, (SkylarkDict<?, ?>) rval, env);
}
if (lval instanceof Concatable && rval instanceof Concatable) {
Concatable lobj = (Concatable) lval;
Concatable robj = (Concatable) rval;
Concatter concatter = lobj.getConcatter();
if (concatter != null && concatter.equals(robj.getConcatter())) {
return concatter.concat(lobj, robj, location);
} else {
throw typeException(lval, rval, Operator.PLUS, location);
}
}
// TODO(bazel-team): Remove this case. Union of sets should use '|' instead of '+'.
if (lval instanceof SkylarkNestedSet) {
return new SkylarkNestedSet((SkylarkNestedSet) lval, rval, location);
}
throw typeException(lval, rval, Operator.PLUS, location);
}
Aggregations