use of com.google.template.soy.jbcsrc.restricted.Expression in project closure-templates by google.
the class AugmentMapFunction method computeForJbcSrc.
@Override
public SoyExpression computeForJbcSrc(JbcSrcPluginContext context, List<SoyExpression> args) {
SoyExpression arg0 = args.get(0);
SoyExpression arg1 = args.get(1);
Expression first = arg0.checkedCast(SoyDict.class);
Expression second = arg1.checkedCast(SoyDict.class);
// TODO(lukes): this logic should move into the ResolveExpressionTypesVisitor
LegacyObjectMapType mapType = LegacyObjectMapType.of(StringType.getInstance(), UnionType.of(getMapValueType(arg0.soyType()), getMapValueType(arg1.soyType())));
return SoyExpression.forSoyValue(mapType, JbcSrcMethods.AUGMENT_MAP_FN.invoke(first, second));
}
use of com.google.template.soy.jbcsrc.restricted.Expression in project closure-templates by google.
the class BasicEscapeDirective method applyForJbcSrcStreaming.
/**
* Default implementation for {@link Streamable}.
*
* <p>Subclasses can simply add {@code implements Streamable} if they have an implementation in
* Sanitizers.<name>Streaming. If they don't, this method will throw while trying to find it.
*/
public final AppendableAndOptions applyForJbcSrcStreaming(JbcSrcPluginContext context, Expression delegateAppendable, List<SoyExpression> args) {
MethodRef sanitizerMethod = javaStreamingSanitizer;
if (sanitizerMethod == null) {
// lazily allocated
sanitizerMethod = MethodRef.create(Sanitizers.class, name.substring(1) + "Streaming", LoggingAdvisingAppendable.class).asNonNullable();
javaStreamingSanitizer = sanitizerMethod;
}
Expression streamingSanitizersExpr = sanitizerMethod.invoke(delegateAppendable);
if (isCloseable()) {
return AppendableAndOptions.createCloseable(streamingSanitizersExpr);
} else {
return AppendableAndOptions.create(streamingSanitizersExpr);
}
}
Aggregations