id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
53,700 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java | BytecodeUtils.numericConversion | public static Expression numericConversion(final Expression expr, final Type to) {
if (to.equals(expr.resultType())) {
return expr;
}
if (!isNumericPrimitive(to) || !isNumericPrimitive(expr.resultType())) {
throw new IllegalArgumentException("Cannot convert from " + expr.resultType() + " to " + ... | java | public static Expression numericConversion(final Expression expr, final Type to) {
if (to.equals(expr.resultType())) {
return expr;
}
if (!isNumericPrimitive(to) || !isNumericPrimitive(expr.resultType())) {
throw new IllegalArgumentException("Cannot convert from " + expr.resultType() + " to " + ... | [
"public",
"static",
"Expression",
"numericConversion",
"(",
"final",
"Expression",
"expr",
",",
"final",
"Type",
"to",
")",
"{",
"if",
"(",
"to",
".",
"equals",
"(",
"expr",
".",
"resultType",
"(",
")",
")",
")",
"{",
"return",
"expr",
";",
"}",
"if",
... | Returns an expression that does a numeric conversion cast from the given expression to the
given type.
@throws IllegalArgumentException if either the expression or the target type is not a numeric
primitive | [
"Returns",
"an",
"expression",
"that",
"does",
"a",
"numeric",
"conversion",
"cast",
"from",
"the",
"given",
"expression",
"to",
"the",
"given",
"type",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java#L409-L423 |
53,701 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java | BytecodeUtils.compare | public static Expression compare(
final int comparisonOpcode, final Expression left, final Expression right) {
checkArgument(
left.resultType().equals(right.resultType()),
"left and right must have matching types, found %s and %s",
left.resultType(),
right.resultType());
ch... | java | public static Expression compare(
final int comparisonOpcode, final Expression left, final Expression right) {
checkArgument(
left.resultType().equals(right.resultType()),
"left and right must have matching types, found %s and %s",
left.resultType(),
right.resultType());
ch... | [
"public",
"static",
"Expression",
"compare",
"(",
"final",
"int",
"comparisonOpcode",
",",
"final",
"Expression",
"left",
",",
"final",
"Expression",
"right",
")",
"{",
"checkArgument",
"(",
"left",
".",
"resultType",
"(",
")",
".",
"equals",
"(",
"right",
"... | Compares the two primitive valued expressions using the provided comparison operation. | [
"Compares",
"the",
"two",
"primitive",
"valued",
"expressions",
"using",
"the",
"provided",
"comparison",
"operation",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java#L502-L527 |
53,702 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java | BytecodeUtils.logicalNot | public static Expression logicalNot(final Expression baseExpr) {
baseExpr.checkAssignableTo(Type.BOOLEAN_TYPE);
checkArgument(baseExpr.resultType().equals(Type.BOOLEAN_TYPE), "not a boolean expression");
return new Expression(Type.BOOLEAN_TYPE, baseExpr.features()) {
@Override
protected void doG... | java | public static Expression logicalNot(final Expression baseExpr) {
baseExpr.checkAssignableTo(Type.BOOLEAN_TYPE);
checkArgument(baseExpr.resultType().equals(Type.BOOLEAN_TYPE), "not a boolean expression");
return new Expression(Type.BOOLEAN_TYPE, baseExpr.features()) {
@Override
protected void doG... | [
"public",
"static",
"Expression",
"logicalNot",
"(",
"final",
"Expression",
"baseExpr",
")",
"{",
"baseExpr",
".",
"checkAssignableTo",
"(",
"Type",
".",
"BOOLEAN_TYPE",
")",
";",
"checkArgument",
"(",
"baseExpr",
".",
"resultType",
"(",
")",
".",
"equals",
"(... | Returns an expression that evaluates to the logical negation of the given boolean valued
expression. | [
"Returns",
"an",
"expression",
"that",
"evaluates",
"to",
"the",
"logical",
"negation",
"of",
"the",
"given",
"boolean",
"valued",
"expression",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java#L553-L573 |
53,703 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java | BytecodeUtils.doEqualsString | private static Expression doEqualsString(SoyExpression stringExpr, SoyExpression other) {
// This is compatible with SharedRuntime.compareString, which interestingly makes == break
// transitivity. See b/21461181
SoyRuntimeType otherRuntimeType = other.soyRuntimeType();
if (otherRuntimeType.isKnownStri... | java | private static Expression doEqualsString(SoyExpression stringExpr, SoyExpression other) {
// This is compatible with SharedRuntime.compareString, which interestingly makes == break
// transitivity. See b/21461181
SoyRuntimeType otherRuntimeType = other.soyRuntimeType();
if (otherRuntimeType.isKnownStri... | [
"private",
"static",
"Expression",
"doEqualsString",
"(",
"SoyExpression",
"stringExpr",
",",
"SoyExpression",
"other",
")",
"{",
"// This is compatible with SharedRuntime.compareString, which interestingly makes == break",
"// transitivity. See b/21461181",
"SoyRuntimeType",
"otherRu... | Compare a string valued expression to another expression using soy == semantics.
@param stringExpr An expression that is known to be an unboxed string
@param other An expression to compare it to. | [
"Compare",
"a",
"string",
"valued",
"expression",
"to",
"another",
"expression",
"using",
"soy",
"==",
"semantics",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java#L611-L629 |
53,704 | google/closure-templates | java/src/com/google/template/soy/pysrc/restricted/PyFunctionExprBuilder.java | PyFunctionExprBuilder.setUnpackedKwargs | public PyFunctionExprBuilder setUnpackedKwargs(PyExpr mapping) {
if (unpackedKwargs != null) {
throw new UnsupportedOperationException("Only one kwarg unpacking allowed per expression.");
}
StringBuilder expr = new StringBuilder("**");
if (mapping.getPrecedence() < Integer.MAX_VALUE) {
expr.... | java | public PyFunctionExprBuilder setUnpackedKwargs(PyExpr mapping) {
if (unpackedKwargs != null) {
throw new UnsupportedOperationException("Only one kwarg unpacking allowed per expression.");
}
StringBuilder expr = new StringBuilder("**");
if (mapping.getPrecedence() < Integer.MAX_VALUE) {
expr.... | [
"public",
"PyFunctionExprBuilder",
"setUnpackedKwargs",
"(",
"PyExpr",
"mapping",
")",
"{",
"if",
"(",
"unpackedKwargs",
"!=",
"null",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Only one kwarg unpacking allowed per expression.\"",
")",
";",
"}",
... | Unpacking keyword arguments will expand a dictionary into a series of keyword arguments.
<p>NOTE: Keyword unpacking behavior is only guaranteed for mapping expressions. Non-mapping
expressions which attempt to unpack will result in Python runtime errors.
@param mapping The mapping expression to unpack.
@return This P... | [
"Unpacking",
"keyword",
"arguments",
"will",
"expand",
"a",
"dictionary",
"into",
"a",
"series",
"of",
"keyword",
"arguments",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/restricted/PyFunctionExprBuilder.java#L124-L136 |
53,705 | google/closure-templates | java/src/com/google/template/soy/pysrc/restricted/PyFunctionExprBuilder.java | PyFunctionExprBuilder.build | public String build() {
StringBuilder sb = new StringBuilder(funcName + "(");
// Join args and kwargs into simple strings.
String args =
argList.stream()
.map(PyExpr::getText)
.filter(Objects::nonNull)
.collect(Collectors.joining(", "));
String kwargs =
... | java | public String build() {
StringBuilder sb = new StringBuilder(funcName + "(");
// Join args and kwargs into simple strings.
String args =
argList.stream()
.map(PyExpr::getText)
.filter(Objects::nonNull)
.collect(Collectors.joining(", "));
String kwargs =
... | [
"public",
"String",
"build",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"funcName",
"+",
"\"(\"",
")",
";",
"// Join args and kwargs into simple strings.",
"String",
"args",
"=",
"argList",
".",
"stream",
"(",
")",
".",
"map",
"(",... | Returns a valid Python function call as a String. | [
"Returns",
"a",
"valid",
"Python",
"function",
"call",
"as",
"a",
"String",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/restricted/PyFunctionExprBuilder.java#L139-L163 |
53,706 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.createHelperInstance | protected RenderVisitor createHelperInstance(Appendable outputBuf, SoyRecord data) {
return new RenderVisitor(
evalVisitorFactory,
outputBuf,
basicTemplates,
deltemplates,
data,
ijData,
activeDelPackageSelector,
msgBundle,
xidRenamingMap,
... | java | protected RenderVisitor createHelperInstance(Appendable outputBuf, SoyRecord data) {
return new RenderVisitor(
evalVisitorFactory,
outputBuf,
basicTemplates,
deltemplates,
data,
ijData,
activeDelPackageSelector,
msgBundle,
xidRenamingMap,
... | [
"protected",
"RenderVisitor",
"createHelperInstance",
"(",
"Appendable",
"outputBuf",
",",
"SoyRecord",
"data",
")",
"{",
"return",
"new",
"RenderVisitor",
"(",
"evalVisitorFactory",
",",
"outputBuf",
",",
"basicTemplates",
",",
"deltemplates",
",",
"data",
",",
"ij... | Creates a helper instance for rendering a subtemplate.
@param outputBuf The Appendable to append the output to.
@param data The template data.
@return The newly created RenderVisitor instance. | [
"Creates",
"a",
"helper",
"instance",
"for",
"rendering",
"a",
"subtemplate",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L239-L253 |
53,707 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.renderTemplate | private void renderTemplate(TemplateNode template, Predicate<String> paramsToTypeCheck) {
env = Environment.create(template, data, ijData);
checkStrictParamTypes(template, paramsToTypeCheck);
visitChildren(template);
env = null; // unpin for gc
} | java | private void renderTemplate(TemplateNode template, Predicate<String> paramsToTypeCheck) {
env = Environment.create(template, data, ijData);
checkStrictParamTypes(template, paramsToTypeCheck);
visitChildren(template);
env = null; // unpin for gc
} | [
"private",
"void",
"renderTemplate",
"(",
"TemplateNode",
"template",
",",
"Predicate",
"<",
"String",
">",
"paramsToTypeCheck",
")",
"{",
"env",
"=",
"Environment",
".",
"create",
"(",
"template",
",",
"data",
",",
"ijData",
")",
";",
"checkStrictParamTypes",
... | A private helper to render templates with optimized type checking. | [
"A",
"private",
"helper",
"to",
"render",
"templates",
"with",
"optimized",
"type",
"checking",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L264-L269 |
53,708 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.eval | private SoyValue eval(ExprNode expr, SoyNode node) {
if (expr == null) {
throw RenderException.create("Cannot evaluate expression in V1 syntax.")
.addStackTraceElement(node);
}
// Lazily initialize evalVisitor.
if (evalVisitor == null) {
evalVisitor =
evalVisitorFactory... | java | private SoyValue eval(ExprNode expr, SoyNode node) {
if (expr == null) {
throw RenderException.create("Cannot evaluate expression in V1 syntax.")
.addStackTraceElement(node);
}
// Lazily initialize evalVisitor.
if (evalVisitor == null) {
evalVisitor =
evalVisitorFactory... | [
"private",
"SoyValue",
"eval",
"(",
"ExprNode",
"expr",
",",
"SoyNode",
"node",
")",
"{",
"if",
"(",
"expr",
"==",
"null",
")",
"{",
"throw",
"RenderException",
".",
"create",
"(",
"\"Cannot evaluate expression in V1 syntax.\"",
")",
".",
"addStackTraceElement",
... | Private helper to evaluate an expression. Always use this helper instead of using evalVisitor
directly, because this helper creates and throws a RenderException if there's an error. | [
"Private",
"helper",
"to",
"evaluate",
"an",
"expression",
".",
"Always",
"use",
"this",
"helper",
"instead",
"of",
"using",
"evalVisitor",
"directly",
"because",
"this",
"helper",
"creates",
"and",
"throws",
"a",
"RenderException",
"if",
"there",
"s",
"an",
"... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L767-L796 |
53,709 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.append | static void append(Appendable outputBuf, CharSequence cs) {
try {
outputBuf.append(cs);
} catch (IOException e) {
throw new RuntimeException(e);
}
} | java | static void append(Appendable outputBuf, CharSequence cs) {
try {
outputBuf.append(cs);
} catch (IOException e) {
throw new RuntimeException(e);
}
} | [
"static",
"void",
"append",
"(",
"Appendable",
"outputBuf",
",",
"CharSequence",
"cs",
")",
"{",
"try",
"{",
"outputBuf",
".",
"append",
"(",
"cs",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
... | Helper to append text to the output, propagating any exceptions. | [
"Helper",
"to",
"append",
"text",
"to",
"the",
"output",
"propagating",
"any",
"exceptions",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L827-L833 |
53,710 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.append | static void append(Appendable outputBuf, SoyValue value, SoyNode node) {
try {
value.render(outputBuf);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (RenderException e) {
throw e.addStackTraceElement(node);
}
} | java | static void append(Appendable outputBuf, SoyValue value, SoyNode node) {
try {
value.render(outputBuf);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (RenderException e) {
throw e.addStackTraceElement(node);
}
} | [
"static",
"void",
"append",
"(",
"Appendable",
"outputBuf",
",",
"SoyValue",
"value",
",",
"SoyNode",
"node",
")",
"{",
"try",
"{",
"value",
".",
"render",
"(",
"outputBuf",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"Ru... | Helper to append a SoyValue to the output, propagating any exceptions. | [
"Helper",
"to",
"append",
"a",
"SoyValue",
"to",
"the",
"output",
"propagating",
"any",
"exceptions",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L836-L844 |
53,711 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.applyDirective | private SoyValue applyDirective(
SoyPrintDirective directive, SoyValue value, List<SoyValue> args, SoyNode node) {
// Get directive.
if (!(directive instanceof SoyJavaPrintDirective)) {
throw RenderException.createWithSource(
"Failed to find Soy print directive with name '"
... | java | private SoyValue applyDirective(
SoyPrintDirective directive, SoyValue value, List<SoyValue> args, SoyNode node) {
// Get directive.
if (!(directive instanceof SoyJavaPrintDirective)) {
throw RenderException.createWithSource(
"Failed to find Soy print directive with name '"
... | [
"private",
"SoyValue",
"applyDirective",
"(",
"SoyPrintDirective",
"directive",
",",
"SoyValue",
"value",
",",
"List",
"<",
"SoyValue",
">",
"args",
",",
"SoyNode",
"node",
")",
"{",
"// Get directive.",
"if",
"(",
"!",
"(",
"directive",
"instanceof",
"SoyJavaPr... | Protected helper to apply a print directive.
@param directive The directive to apply
@param value The value to apply the directive on.
@param args The arguments to the directive.
@param node The node with the escaping. Only used for error reporting.
@return The result of applying the directive with the given arguments... | [
"Protected",
"helper",
"to",
"apply",
"a",
"print",
"directive",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L855-L891 |
53,712 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.checkValueType | private void checkValueType(TemplateParam param, SoyValue value, TemplateNode node) {
if (!TofuTypeChecks.isInstance(param.type(), value, node.getSourceLocation())) {
// should this be a soydataexception?
throw RenderException.createWithSource(
"Parameter type mismatch: attempt to bind value '... | java | private void checkValueType(TemplateParam param, SoyValue value, TemplateNode node) {
if (!TofuTypeChecks.isInstance(param.type(), value, node.getSourceLocation())) {
// should this be a soydataexception?
throw RenderException.createWithSource(
"Parameter type mismatch: attempt to bind value '... | [
"private",
"void",
"checkValueType",
"(",
"TemplateParam",
"param",
",",
"SoyValue",
"value",
",",
"TemplateNode",
"node",
")",
"{",
"if",
"(",
"!",
"TofuTypeChecks",
".",
"isInstance",
"(",
"param",
".",
"type",
"(",
")",
",",
"value",
",",
"node",
".",
... | Check that the value matches the given param type. | [
"Check",
"that",
"the",
"value",
"matches",
"the",
"given",
"param",
"type",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L936-L951 |
53,713 | google/closure-templates | java/src/com/google/template/soy/types/SoyProtoType.java | SoyProtoType.getDescriptorExpression | public String getDescriptorExpression() {
// We only need to import the outermost descriptor.
Descriptor descriptor = typeDescriptor;
while (descriptor.getContainingType() != null) {
descriptor = descriptor.getContainingType();
}
return JavaQualifiedNames.getQualifiedName(descriptor) + ".getDe... | java | public String getDescriptorExpression() {
// We only need to import the outermost descriptor.
Descriptor descriptor = typeDescriptor;
while (descriptor.getContainingType() != null) {
descriptor = descriptor.getContainingType();
}
return JavaQualifiedNames.getQualifiedName(descriptor) + ".getDe... | [
"public",
"String",
"getDescriptorExpression",
"(",
")",
"{",
"// We only need to import the outermost descriptor.",
"Descriptor",
"descriptor",
"=",
"typeDescriptor",
";",
"while",
"(",
"descriptor",
".",
"getContainingType",
"(",
")",
"!=",
"null",
")",
"{",
"descript... | For ParseInfo generation, return a string that represents the Java source expression for the
static descriptor constant.
@return The Java source expression for this type's descriptor. | [
"For",
"ParseInfo",
"generation",
"return",
"a",
"string",
"that",
"represents",
"the",
"Java",
"source",
"expression",
"for",
"the",
"static",
"descriptor",
"constant",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/types/SoyProtoType.java#L242-L249 |
53,714 | google/closure-templates | java/src/com/google/template/soy/types/SoyProtoType.java | SoyProtoType.getNameForBackend | public String getNameForBackend(SoyBackendKind backend) {
switch (backend) {
case JS_SRC:
// The 'proto' prefix is JSPB-specific. If we ever support some other
// JavaScript proto implementation, we'll need some way to determine which
// proto implementation the user wants to use at th... | java | public String getNameForBackend(SoyBackendKind backend) {
switch (backend) {
case JS_SRC:
// The 'proto' prefix is JSPB-specific. If we ever support some other
// JavaScript proto implementation, we'll need some way to determine which
// proto implementation the user wants to use at th... | [
"public",
"String",
"getNameForBackend",
"(",
"SoyBackendKind",
"backend",
")",
"{",
"switch",
"(",
"backend",
")",
"{",
"case",
"JS_SRC",
":",
"// The 'proto' prefix is JSPB-specific. If we ever support some other",
"// JavaScript proto implementation, we'll need some way to deter... | Returns this proto's type name for the given backend. | [
"Returns",
"this",
"proto",
"s",
"type",
"name",
"for",
"the",
"given",
"backend",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/types/SoyProtoType.java#L269-L283 |
53,715 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/VeLogInstrumentationVisitor.java | VeLogInstrumentationVisitor.visitHtmlAttributeNode | @Override
protected void visitHtmlAttributeNode(HtmlAttributeNode node) {
// Skip attributes that do not have a value.
if (!node.hasValue()) {
return;
}
SourceLocation insertionLocation = node.getSourceLocation();
for (FunctionNode function : SoyTreeUtils.getAllNodesOfType(node, FunctionNode... | java | @Override
protected void visitHtmlAttributeNode(HtmlAttributeNode node) {
// Skip attributes that do not have a value.
if (!node.hasValue()) {
return;
}
SourceLocation insertionLocation = node.getSourceLocation();
for (FunctionNode function : SoyTreeUtils.getAllNodesOfType(node, FunctionNode... | [
"@",
"Override",
"protected",
"void",
"visitHtmlAttributeNode",
"(",
"HtmlAttributeNode",
"node",
")",
"{",
"// Skip attributes that do not have a value.",
"if",
"(",
"!",
"node",
".",
"hasValue",
"(",
")",
")",
"{",
"return",
";",
"}",
"SourceLocation",
"insertionL... | For HtmlAttributeNode that has a logging function as its value, replace the logging function
with its place holder, and append a new data attribute that contains all the desired
information that are used later by the runtime library. | [
"For",
"HtmlAttributeNode",
"that",
"has",
"a",
"logging",
"function",
"as",
"its",
"value",
"replace",
"the",
"logging",
"function",
"with",
"its",
"place",
"holder",
"and",
"append",
"a",
"new",
"data",
"attribute",
"that",
"contains",
"all",
"the",
"desired... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/VeLogInstrumentationVisitor.java#L111-L189 |
53,716 | google/closure-templates | java/src/com/google/template/soy/data/UnsafeSanitizedContentOrdainer.java | UnsafeSanitizedContentOrdainer.ordainAsSafe | public static SanitizedContent ordainAsSafe(String value, ContentKind kind) {
return ordainAsSafe(value, kind, kind.getDefaultDir());
} | java | public static SanitizedContent ordainAsSafe(String value, ContentKind kind) {
return ordainAsSafe(value, kind, kind.getDefaultDir());
} | [
"public",
"static",
"SanitizedContent",
"ordainAsSafe",
"(",
"String",
"value",
",",
"ContentKind",
"kind",
")",
"{",
"return",
"ordainAsSafe",
"(",
"value",
",",
"kind",
",",
"kind",
".",
"getDefaultDir",
"(",
")",
")",
";",
"}"
] | Faithfully assumes the provided value is "safe" and marks it not to be re-escaped. The value's
direction is assumed to be LTR for JS, URI, ATTRIBUTES, and CSS content, and otherwise unknown.
<p>When you "ordain" a string as safe content, it means that Soy will NOT re-escape or validate
the contents if printed in the r... | [
"Faithfully",
"assumes",
"the",
"provided",
"value",
"is",
"safe",
"and",
"marks",
"it",
"not",
"to",
"be",
"re",
"-",
"escaped",
".",
"The",
"value",
"s",
"direction",
"is",
"assumed",
"to",
"be",
"LTR",
"for",
"JS",
"URI",
"ATTRIBUTES",
"and",
"CSS",
... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/UnsafeSanitizedContentOrdainer.java#L60-L62 |
53,717 | google/closure-templates | java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java | GenerateParseInfoVisitor.findProtoTypesRecurse | private void findProtoTypesRecurse(SoyType type, SortedSet<String> protoTypes) {
switch (type.getKind()) {
case PROTO:
protoTypes.add(((SoyProtoType) type).getDescriptorExpression());
break;
case PROTO_ENUM:
protoTypes.add(((SoyProtoEnumType) type).getDescriptorExpression());
... | java | private void findProtoTypesRecurse(SoyType type, SortedSet<String> protoTypes) {
switch (type.getKind()) {
case PROTO:
protoTypes.add(((SoyProtoType) type).getDescriptorExpression());
break;
case PROTO_ENUM:
protoTypes.add(((SoyProtoEnumType) type).getDescriptorExpression());
... | [
"private",
"void",
"findProtoTypesRecurse",
"(",
"SoyType",
"type",
",",
"SortedSet",
"<",
"String",
">",
"protoTypes",
")",
"{",
"switch",
"(",
"type",
".",
"getKind",
"(",
")",
")",
"{",
"case",
"PROTO",
":",
"protoTypes",
".",
"add",
"(",
"(",
"(",
... | Recursively search for protocol buffer types within the given type.
@param type The type to search.
@param protoTypes Output set. | [
"Recursively",
"search",
"for",
"protocol",
"buffer",
"types",
"within",
"the",
"given",
"type",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java#L748-L818 |
53,718 | google/closure-templates | java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java | GenerateParseInfoVisitor.buildTemplateNameForJavadoc | private static String buildTemplateNameForJavadoc(
SoyFileNode currSoyFile, TemplateMetadata template) {
StringBuilder resultSb = new StringBuilder();
if (template.getSourceLocation().getFilePath().equals(currSoyFile.getFilePath())
&& template.getTemplateKind() != TemplateMetadata.Kind.DELTEMPLA... | java | private static String buildTemplateNameForJavadoc(
SoyFileNode currSoyFile, TemplateMetadata template) {
StringBuilder resultSb = new StringBuilder();
if (template.getSourceLocation().getFilePath().equals(currSoyFile.getFilePath())
&& template.getTemplateKind() != TemplateMetadata.Kind.DELTEMPLA... | [
"private",
"static",
"String",
"buildTemplateNameForJavadoc",
"(",
"SoyFileNode",
"currSoyFile",
",",
"TemplateMetadata",
"template",
")",
"{",
"StringBuilder",
"resultSb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"template",
".",
"getSourceLocation",
... | Private helper to build the human-readable string for referring to a template in the generated
code's javadoc.
@param currSoyFile The current Soy file for which we're generating parse-info code.
@param template The template that we want to refer to in the generated javadoc. Note that this
template may not be in the cu... | [
"Private",
"helper",
"to",
"build",
"the",
"human",
"-",
"readable",
"string",
"for",
"referring",
"to",
"a",
"template",
"in",
"the",
"generated",
"code",
"s",
"javadoc",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java#L886-L919 |
53,719 | google/closure-templates | java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java | GenerateParseInfoVisitor.appendImmutableList | private static void appendImmutableList(
IndentedLinesBuilder ilb, String typeParamSnippet, Collection<String> itemSnippets) {
appendListOrSetHelper(ilb, "ImmutableList." + typeParamSnippet + "of", itemSnippets);
} | java | private static void appendImmutableList(
IndentedLinesBuilder ilb, String typeParamSnippet, Collection<String> itemSnippets) {
appendListOrSetHelper(ilb, "ImmutableList." + typeParamSnippet + "of", itemSnippets);
} | [
"private",
"static",
"void",
"appendImmutableList",
"(",
"IndentedLinesBuilder",
"ilb",
",",
"String",
"typeParamSnippet",
",",
"Collection",
"<",
"String",
">",
"itemSnippets",
")",
"{",
"appendListOrSetHelper",
"(",
"ilb",
",",
"\"ImmutableList.\"",
"+",
"typeParamS... | Private helper to append an ImmutableList to the code.
@param ilb The builder for the code.
@param typeParamSnippet The type parameter for the ImmutableList.
@param itemSnippets Code snippets for the items to put into the ImmutableList. | [
"Private",
"helper",
"to",
"append",
"an",
"ImmutableList",
"to",
"the",
"code",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java#L928-L931 |
53,720 | google/closure-templates | java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java | GenerateParseInfoVisitor.appendImmutableMap | private static void appendImmutableMap(
IndentedLinesBuilder ilb, String typeParamSnippet, Map<String, String> entrySnippetPairs) {
if (entrySnippetPairs.isEmpty()) {
ilb.appendLineStart("ImmutableMap.", typeParamSnippet, "of()");
} else {
ilb.appendLine("ImmutableMap.", typeParamSnippet, "bu... | java | private static void appendImmutableMap(
IndentedLinesBuilder ilb, String typeParamSnippet, Map<String, String> entrySnippetPairs) {
if (entrySnippetPairs.isEmpty()) {
ilb.appendLineStart("ImmutableMap.", typeParamSnippet, "of()");
} else {
ilb.appendLine("ImmutableMap.", typeParamSnippet, "bu... | [
"private",
"static",
"void",
"appendImmutableMap",
"(",
"IndentedLinesBuilder",
"ilb",
",",
"String",
"typeParamSnippet",
",",
"Map",
"<",
"String",
",",
"String",
">",
"entrySnippetPairs",
")",
"{",
"if",
"(",
"entrySnippetPairs",
".",
"isEmpty",
"(",
")",
")",... | Private helper to append an ImmutableMap to the code.
@param ilb The builder for the code.
@param typeParamSnippet The type parameter for the ImmutableMap.
@param entrySnippetPairs Pairs of (key, value) code snippets for the entries to put into the
ImmutableMap. | [
"Private",
"helper",
"to",
"append",
"an",
"ImmutableMap",
"to",
"the",
"code",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/parseinfo/passes/GenerateParseInfoVisitor.java#L969-L982 |
53,721 | google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/Environment.java | Environment.create | static Environment create(TemplateNode template, SoyRecord data, SoyRecord ijData) {
return new Impl(template, data, ijData);
} | java | static Environment create(TemplateNode template, SoyRecord data, SoyRecord ijData) {
return new Impl(template, data, ijData);
} | [
"static",
"Environment",
"create",
"(",
"TemplateNode",
"template",
",",
"SoyRecord",
"data",
",",
"SoyRecord",
"ijData",
")",
"{",
"return",
"new",
"Impl",
"(",
"template",
",",
"data",
",",
"ijData",
")",
";",
"}"
] | The main way to create an environment.
<p>Allocates the local variable table for the template and prepopulates it with data from the
given SoyRecords. | [
"The",
"main",
"way",
"to",
"create",
"an",
"environment",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/Environment.java#L55-L57 |
53,722 | google/closure-templates | java/src/com/google/template/soy/shared/internal/EscapingConventions.java | EscapingConventions.getAllEscapers | public static Iterable<CrossLanguageStringXform> getAllEscapers() {
// This list is hard coded but is checked by unittests for the contextual auto-escaper.
return ImmutableList.of(
EscapeHtml.INSTANCE,
NormalizeHtml.INSTANCE,
EscapeHtmlNospace.INSTANCE,
NormalizeHtmlNospace.INSTA... | java | public static Iterable<CrossLanguageStringXform> getAllEscapers() {
// This list is hard coded but is checked by unittests for the contextual auto-escaper.
return ImmutableList.of(
EscapeHtml.INSTANCE,
NormalizeHtml.INSTANCE,
EscapeHtmlNospace.INSTANCE,
NormalizeHtmlNospace.INSTA... | [
"public",
"static",
"Iterable",
"<",
"CrossLanguageStringXform",
">",
"getAllEscapers",
"(",
")",
"{",
"// This list is hard coded but is checked by unittests for the contextual auto-escaper.",
"return",
"ImmutableList",
".",
"of",
"(",
"EscapeHtml",
".",
"INSTANCE",
",",
"No... | An accessor for all string transforms defined above. | [
"An",
"accessor",
"for",
"all",
"string",
"transforms",
"defined",
"above",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/EscapingConventions.java#L1247-L1268 |
53,723 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Statement.java | Statement.returnExpression | public static Statement returnExpression(final Expression expression) {
// TODO(lukes): it would be nice to do a checkType operation here to make sure that expression
// is compatible with the return type of the method, but i don't know how to get that
// information here (reasonably). So it is the caller'... | java | public static Statement returnExpression(final Expression expression) {
// TODO(lukes): it would be nice to do a checkType operation here to make sure that expression
// is compatible with the return type of the method, but i don't know how to get that
// information here (reasonably). So it is the caller'... | [
"public",
"static",
"Statement",
"returnExpression",
"(",
"final",
"Expression",
"expression",
")",
"{",
"// TODO(lukes): it would be nice to do a checkType operation here to make sure that expression",
"// is compatible with the return type of the method, but i don't know how to get that",
... | Generates a statement that returns the value produced by the given expression.
<p>This does not validate that the return type is appropriate. It is our callers responsibility
to do that. | [
"Generates",
"a",
"statement",
"that",
"returns",
"the",
"value",
"produced",
"by",
"the",
"given",
"expression",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Statement.java#L62-L73 |
53,724 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Statement.java | Statement.throwExpression | public static Statement throwExpression(final Expression expression) {
expression.checkAssignableTo(THROWABLE_TYPE);
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
expression.gen(adapter);
adapter.throwException();
}
};
} | java | public static Statement throwExpression(final Expression expression) {
expression.checkAssignableTo(THROWABLE_TYPE);
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
expression.gen(adapter);
adapter.throwException();
}
};
} | [
"public",
"static",
"Statement",
"throwExpression",
"(",
"final",
"Expression",
"expression",
")",
"{",
"expression",
".",
"checkAssignableTo",
"(",
"THROWABLE_TYPE",
")",
";",
"return",
"new",
"Statement",
"(",
")",
"{",
"@",
"Override",
"protected",
"void",
"d... | Generates a statement that throws the throwable produced by the given expression.
<p>This does not validate that the throwable is compatible with the methods throws clause. | [
"Generates",
"a",
"statement",
"that",
"throws",
"the",
"throwable",
"produced",
"by",
"the",
"given",
"expression",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Statement.java#L80-L89 |
53,725 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Statement.java | Statement.concat | public static Statement concat(final Iterable<? extends Statement> statements) {
checkNotNull(statements);
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
for (Statement statement : statements) {
statement.gen(adapter);
}
}
};
} | java | public static Statement concat(final Iterable<? extends Statement> statements) {
checkNotNull(statements);
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
for (Statement statement : statements) {
statement.gen(adapter);
}
}
};
} | [
"public",
"static",
"Statement",
"concat",
"(",
"final",
"Iterable",
"<",
"?",
"extends",
"Statement",
">",
"statements",
")",
"{",
"checkNotNull",
"(",
"statements",
")",
";",
"return",
"new",
"Statement",
"(",
")",
"{",
"@",
"Override",
"protected",
"void"... | Returns a statement that concatenates all the provided statements. | [
"Returns",
"a",
"statement",
"that",
"concatenates",
"all",
"the",
"provided",
"statements",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Statement.java#L97-L107 |
53,726 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Statement.java | Statement.labelStart | public final Statement labelStart(final Label label) {
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
adapter.mark(label);
Statement.this.gen(adapter);
}
};
} | java | public final Statement labelStart(final Label label) {
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
adapter.mark(label);
Statement.this.gen(adapter);
}
};
} | [
"public",
"final",
"Statement",
"labelStart",
"(",
"final",
"Label",
"label",
")",
"{",
"return",
"new",
"Statement",
"(",
")",
"{",
"@",
"Override",
"protected",
"void",
"doGen",
"(",
"CodeBuilder",
"adapter",
")",
"{",
"adapter",
".",
"mark",
"(",
"label... | Returns a new statement identical to this one but with the given label applied at the start of
the statement. | [
"Returns",
"a",
"new",
"statement",
"identical",
"to",
"this",
"one",
"but",
"with",
"the",
"given",
"label",
"applied",
"at",
"the",
"start",
"of",
"the",
"statement",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Statement.java#L155-L163 |
53,727 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Statement.java | Statement.then | final Expression then(final Expression expression) {
return new Expression(expression.resultType(), expression.features()) {
@Override
protected void doGen(CodeBuilder adapter) {
Statement.this.gen(adapter);
expression.gen(adapter);
}
};
} | java | final Expression then(final Expression expression) {
return new Expression(expression.resultType(), expression.features()) {
@Override
protected void doGen(CodeBuilder adapter) {
Statement.this.gen(adapter);
expression.gen(adapter);
}
};
} | [
"final",
"Expression",
"then",
"(",
"final",
"Expression",
"expression",
")",
"{",
"return",
"new",
"Expression",
"(",
"expression",
".",
"resultType",
"(",
")",
",",
"expression",
".",
"features",
"(",
")",
")",
"{",
"@",
"Override",
"protected",
"void",
... | Returns an Expression that evaluates this statement followed by the given expression. | [
"Returns",
"an",
"Expression",
"that",
"evaluates",
"this",
"statement",
"followed",
"by",
"the",
"given",
"expression",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Statement.java#L180-L188 |
53,728 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/RenderResult.java | RenderResult.future | public Future<?> future() {
Future<?> f = future;
if (f == null) {
throw new IllegalStateException(
"Result.future() can only be called if type() is DETACH, type was: " + type);
}
return f;
} | java | public Future<?> future() {
Future<?> f = future;
if (f == null) {
throw new IllegalStateException(
"Result.future() can only be called if type() is DETACH, type was: " + type);
}
return f;
} | [
"public",
"Future",
"<",
"?",
">",
"future",
"(",
")",
"{",
"Future",
"<",
"?",
">",
"f",
"=",
"future",
";",
"if",
"(",
"f",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Result.future() can only be called if type() is DETACH, type ... | Returns the future that soy is waiting for.
@throws IllegalStateException if {@link #type()} is not {@link Type#DETACH}. | [
"Returns",
"the",
"future",
"that",
"soy",
"is",
"waiting",
"for",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/RenderResult.java#L97-L104 |
53,729 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java | AnnotationRef.write | public void write(T instance, ClassVisitor visitor) {
doWrite(instance, visitor.visitAnnotation(typeDescriptor, isRuntimeVisible));
} | java | public void write(T instance, ClassVisitor visitor) {
doWrite(instance, visitor.visitAnnotation(typeDescriptor, isRuntimeVisible));
} | [
"public",
"void",
"write",
"(",
"T",
"instance",
",",
"ClassVisitor",
"visitor",
")",
"{",
"doWrite",
"(",
"instance",
",",
"visitor",
".",
"visitAnnotation",
"(",
"typeDescriptor",
",",
"isRuntimeVisible",
")",
")",
";",
"}"
] | Writes the given annotation to the visitor. | [
"Writes",
"the",
"given",
"annotation",
"to",
"the",
"visitor",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java#L101-L103 |
53,730 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java | AnnotationRef.annotationFieldWriter | private static <T extends Annotation> FieldWriter annotationFieldWriter(
final String name, final AnnotationRef<T> ref) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
ref.doWrite(ref.annType.cast(value), visitor.visitAnnotation(name, ref... | java | private static <T extends Annotation> FieldWriter annotationFieldWriter(
final String name, final AnnotationRef<T> ref) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
ref.doWrite(ref.annType.cast(value), visitor.visitAnnotation(name, ref... | [
"private",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"FieldWriter",
"annotationFieldWriter",
"(",
"final",
"String",
"name",
",",
"final",
"AnnotationRef",
"<",
"T",
">",
"ref",
")",
"{",
"return",
"new",
"FieldWriter",
"(",
")",
"{",
"@",
"Override"... | Writes an annotation valued field to the writer. | [
"Writes",
"an",
"annotation",
"valued",
"field",
"to",
"the",
"writer",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java#L130-L138 |
53,731 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java | AnnotationRef.simpleFieldWriter | private static FieldWriter simpleFieldWriter(final String name) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
visitor.visit(name, value);
}
};
} | java | private static FieldWriter simpleFieldWriter(final String name) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
visitor.visit(name, value);
}
};
} | [
"private",
"static",
"FieldWriter",
"simpleFieldWriter",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"FieldWriter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"write",
"(",
"AnnotationVisitor",
"visitor",
",",
"Object",
"value",
")",
"{",... | Writes an primitive valued field to the writer.
<p>See {@link AnnotationVisitor#visit(String, Object)} for the valid types. | [
"Writes",
"an",
"primitive",
"valued",
"field",
"to",
"the",
"writer",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java#L145-L152 |
53,732 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java | AnnotationRef.simpleArrayFieldWriter | private static FieldWriter simpleArrayFieldWriter(final String name) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
int len = Array.getLength(value);
AnnotationVisitor arrayVisitor = visitor.visitArray(name);
for (int i = 0; i ... | java | private static FieldWriter simpleArrayFieldWriter(final String name) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
int len = Array.getLength(value);
AnnotationVisitor arrayVisitor = visitor.visitArray(name);
for (int i = 0; i ... | [
"private",
"static",
"FieldWriter",
"simpleArrayFieldWriter",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"FieldWriter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"write",
"(",
"AnnotationVisitor",
"visitor",
",",
"Object",
"value",
")",
... | Writes an simple array valued field to the annotation visitor. | [
"Writes",
"an",
"simple",
"array",
"valued",
"field",
"to",
"the",
"annotation",
"visitor",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java#L155-L167 |
53,733 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java | AnnotationRef.annotationArrayFieldWriter | private static <T extends Annotation> FieldWriter annotationArrayFieldWriter(
final String name, final AnnotationRef<T> ref) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
int len = Array.getLength(value);
AnnotationVisitor array... | java | private static <T extends Annotation> FieldWriter annotationArrayFieldWriter(
final String name, final AnnotationRef<T> ref) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
int len = Array.getLength(value);
AnnotationVisitor array... | [
"private",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"FieldWriter",
"annotationArrayFieldWriter",
"(",
"final",
"String",
"name",
",",
"final",
"AnnotationRef",
"<",
"T",
">",
"ref",
")",
"{",
"return",
"new",
"FieldWriter",
"(",
")",
"{",
"@",
"Over... | Writes an annotation array valued field to the annotation visitor. | [
"Writes",
"an",
"annotation",
"array",
"valued",
"field",
"to",
"the",
"annotation",
"visitor",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java#L170-L185 |
53,734 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/LocalVariable.java | LocalVariable.createThisVar | public static LocalVariable createThisVar(TypeInfo owner, Label start, Label end) {
return new LocalVariable("this", owner.type(), 0, start, end, Feature.NON_NULLABLE);
} | java | public static LocalVariable createThisVar(TypeInfo owner, Label start, Label end) {
return new LocalVariable("this", owner.type(), 0, start, end, Feature.NON_NULLABLE);
} | [
"public",
"static",
"LocalVariable",
"createThisVar",
"(",
"TypeInfo",
"owner",
",",
"Label",
"start",
",",
"Label",
"end",
")",
"{",
"return",
"new",
"LocalVariable",
"(",
"\"this\"",
",",
"owner",
".",
"type",
"(",
")",
",",
"0",
",",
"start",
",",
"en... | parameters to tableEntry? | [
"parameters",
"to",
"tableEntry?"
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/LocalVariable.java#L53-L55 |
53,735 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/LocalVariable.java | LocalVariable.tableEntry | public void tableEntry(CodeBuilder mv) {
mv.visitLocalVariable(
variableName(),
resultType().getDescriptor(),
null, // no generic signature
start(),
end(),
index());
} | java | public void tableEntry(CodeBuilder mv) {
mv.visitLocalVariable(
variableName(),
resultType().getDescriptor(),
null, // no generic signature
start(),
end(),
index());
} | [
"public",
"void",
"tableEntry",
"(",
"CodeBuilder",
"mv",
")",
"{",
"mv",
".",
"visitLocalVariable",
"(",
"variableName",
"(",
")",
",",
"resultType",
"(",
")",
".",
"getDescriptor",
"(",
")",
",",
"null",
",",
"// no generic signature",
"start",
"(",
")",
... | Write a local variable table entry for this variable. This informs debuggers about variable
names, types and lifetime. | [
"Write",
"a",
"local",
"variable",
"table",
"entry",
"for",
"this",
"variable",
".",
"This",
"informs",
"debuggers",
"about",
"variable",
"names",
"types",
"and",
"lifetime",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/LocalVariable.java#L113-L121 |
53,736 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/LocalVariable.java | LocalVariable.store | private Statement store(final Expression expr, final Optional<Label> firstVarInstruction) {
expr.checkAssignableTo(resultType());
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
expr.gen(adapter);
if (firstVarInstruction.isPresent()) {
adapter... | java | private Statement store(final Expression expr, final Optional<Label> firstVarInstruction) {
expr.checkAssignableTo(resultType());
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
expr.gen(adapter);
if (firstVarInstruction.isPresent()) {
adapter... | [
"private",
"Statement",
"store",
"(",
"final",
"Expression",
"expr",
",",
"final",
"Optional",
"<",
"Label",
">",
"firstVarInstruction",
")",
"{",
"expr",
".",
"checkAssignableTo",
"(",
"resultType",
"(",
")",
")",
";",
"return",
"new",
"Statement",
"(",
")"... | Writes the value at the top of the stack to the local variable. | [
"Writes",
"the",
"value",
"at",
"the",
"top",
"of",
"the",
"stack",
"to",
"the",
"local",
"variable",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/LocalVariable.java#L146-L158 |
53,737 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java | JbcSrcRuntime.resolveSoyValueProvider | public static SoyValue resolveSoyValueProvider(SoyValueProvider provider) {
SoyValue value = provider.resolve();
return handleTofuNull(value);
} | java | public static SoyValue resolveSoyValueProvider(SoyValueProvider provider) {
SoyValue value = provider.resolve();
return handleTofuNull(value);
} | [
"public",
"static",
"SoyValue",
"resolveSoyValueProvider",
"(",
"SoyValueProvider",
"provider",
")",
"{",
"SoyValue",
"value",
"=",
"provider",
".",
"resolve",
"(",
")",
";",
"return",
"handleTofuNull",
"(",
"value",
")",
";",
"}"
] | Helper function to translate NullData -> null when resolving a SoyValueProvider. | [
"Helper",
"function",
"to",
"translate",
"NullData",
"-",
">",
"null",
"when",
"resolving",
"a",
"SoyValueProvider",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java#L137-L140 |
53,738 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java | JbcSrcRuntime.checkSoyString | public static SoyString checkSoyString(Object o) {
// if it isn't a sanitized content we don't want to warn and if it isn't a soystring we should
// always fail.
if (o instanceof SoyString
&& o instanceof SanitizedContent
&& ((SanitizedContent) o).getContentKind() != ContentKind.TEXT
... | java | public static SoyString checkSoyString(Object o) {
// if it isn't a sanitized content we don't want to warn and if it isn't a soystring we should
// always fail.
if (o instanceof SoyString
&& o instanceof SanitizedContent
&& ((SanitizedContent) o).getContentKind() != ContentKind.TEXT
... | [
"public",
"static",
"SoyString",
"checkSoyString",
"(",
"Object",
"o",
")",
"{",
"// if it isn't a sanitized content we don't want to warn and if it isn't a soystring we should",
"// always fail.",
"if",
"(",
"o",
"instanceof",
"SoyString",
"&&",
"o",
"instanceof",
"SanitizedCo... | Casts the given type to SoyString or throws a ClassCastException. | [
"Casts",
"the",
"given",
"type",
"to",
"SoyString",
"or",
"throws",
"a",
"ClassCastException",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java#L186-L202 |
53,739 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java | JbcSrcRuntime.callLegacySoyFunction | public static SoyValue callLegacySoyFunction(
LegacyFunctionAdapter fnAdapter, List<SoyValue> args) {
for (int i = 0; i < args.size(); i++) {
if (args.get(i) == null) {
args.set(i, NullData.INSTANCE);
}
}
return handleTofuNull(fnAdapter.computeForJava(args));
} | java | public static SoyValue callLegacySoyFunction(
LegacyFunctionAdapter fnAdapter, List<SoyValue> args) {
for (int i = 0; i < args.size(); i++) {
if (args.get(i) == null) {
args.set(i, NullData.INSTANCE);
}
}
return handleTofuNull(fnAdapter.computeForJava(args));
} | [
"public",
"static",
"SoyValue",
"callLegacySoyFunction",
"(",
"LegacyFunctionAdapter",
"fnAdapter",
",",
"List",
"<",
"SoyValue",
">",
"args",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"size",
"(",
")",
";",
"i",
"++",
")"... | Helper function to translate null -> NullData when calling LegacyFunctionAdapters that may
expect it.
<p>In the long run we should either fix ToFu (and all SoyJavaFunctions) to not use NullData or
we should introduce custom SoyFunction implementations for have come from SoyValueProvider. | [
"Helper",
"function",
"to",
"translate",
"null",
"-",
">",
"NullData",
"when",
"calling",
"LegacyFunctionAdapters",
"that",
"may",
"expect",
"it",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java#L211-L219 |
53,740 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java | JbcSrcRuntime.applyPrintDirective | public static SoyValue applyPrintDirective(
SoyJavaPrintDirective directive, SoyValue value, List<SoyValue> args) {
value = value == null ? NullData.INSTANCE : value;
for (int i = 0; i < args.size(); i++) {
if (args.get(i) == null) {
args.set(i, NullData.INSTANCE);
}
}
return d... | java | public static SoyValue applyPrintDirective(
SoyJavaPrintDirective directive, SoyValue value, List<SoyValue> args) {
value = value == null ? NullData.INSTANCE : value;
for (int i = 0; i < args.size(); i++) {
if (args.get(i) == null) {
args.set(i, NullData.INSTANCE);
}
}
return d... | [
"public",
"static",
"SoyValue",
"applyPrintDirective",
"(",
"SoyJavaPrintDirective",
"directive",
",",
"SoyValue",
"value",
",",
"List",
"<",
"SoyValue",
">",
"args",
")",
"{",
"value",
"=",
"value",
"==",
"null",
"?",
"NullData",
".",
"INSTANCE",
":",
"value"... | Helper function to translate null -> NullData when calling SoyJavaPrintDirectives that may
expect it. | [
"Helper",
"function",
"to",
"translate",
"null",
"-",
">",
"NullData",
"when",
"calling",
"SoyJavaPrintDirectives",
"that",
"may",
"expect",
"it",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java#L225-L234 |
53,741 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java | JbcSrcRuntime.applyEscapers | public static CompiledTemplate applyEscapers(
CompiledTemplate delegate, ImmutableList<SoyJavaPrintDirective> directives) {
ContentKind kind = delegate.kind();
if (canSkipEscaping(directives, kind)) {
return delegate;
}
return new EscapedCompiledTemplate(delegate, directives, kind);
} | java | public static CompiledTemplate applyEscapers(
CompiledTemplate delegate, ImmutableList<SoyJavaPrintDirective> directives) {
ContentKind kind = delegate.kind();
if (canSkipEscaping(directives, kind)) {
return delegate;
}
return new EscapedCompiledTemplate(delegate, directives, kind);
} | [
"public",
"static",
"CompiledTemplate",
"applyEscapers",
"(",
"CompiledTemplate",
"delegate",
",",
"ImmutableList",
"<",
"SoyJavaPrintDirective",
">",
"directives",
")",
"{",
"ContentKind",
"kind",
"=",
"delegate",
".",
"kind",
"(",
")",
";",
"if",
"(",
"canSkipEs... | Wraps a given template with a collection of escapers to apply.
@param delegate The delegate template to render
@param directives The set of directives to apply | [
"Wraps",
"a",
"given",
"template",
"with",
"a",
"collection",
"of",
"escapers",
"to",
"apply",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/runtime/JbcSrcRuntime.java#L242-L249 |
53,742 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/MsgFuncGenerator.java | MsgFuncGenerator.getPyExpr | PyStringExpr getPyExpr() {
if (this.msgNode.isPlrselMsg()) {
return this.msgNode.isPluralMsg() ? pyFuncForPluralMsg() : pyFuncForSelectMsg();
} else {
return this.msgNode.isRawTextMsg() ? pyFuncForRawTextMsg() : pyFuncForGeneralMsg();
}
} | java | PyStringExpr getPyExpr() {
if (this.msgNode.isPlrselMsg()) {
return this.msgNode.isPluralMsg() ? pyFuncForPluralMsg() : pyFuncForSelectMsg();
} else {
return this.msgNode.isRawTextMsg() ? pyFuncForRawTextMsg() : pyFuncForGeneralMsg();
}
} | [
"PyStringExpr",
"getPyExpr",
"(",
")",
"{",
"if",
"(",
"this",
".",
"msgNode",
".",
"isPlrselMsg",
"(",
")",
")",
"{",
"return",
"this",
".",
"msgNode",
".",
"isPluralMsg",
"(",
")",
"?",
"pyFuncForPluralMsg",
"(",
")",
":",
"pyFuncForSelectMsg",
"(",
")... | Return the PyStringExpr for the render function call, because we know render always return a
string in Python runtime. | [
"Return",
"the",
"PyStringExpr",
"for",
"the",
"render",
"function",
"call",
"because",
"we",
"know",
"render",
"always",
"return",
"a",
"string",
"in",
"Python",
"runtime",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/MsgFuncGenerator.java#L117-L123 |
53,743 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/MsgFuncGenerator.java | MsgFuncGenerator.collectVarNameListAndToPyExprMap | private Map<PyExpr, PyExpr> collectVarNameListAndToPyExprMap() {
Map<PyExpr, PyExpr> nodePyVarToPyExprMap = new LinkedHashMap<>();
for (Map.Entry<String, MsgSubstUnitNode> entry : msgNode.getVarNameToRepNodeMap().entrySet()) {
MsgSubstUnitNode substUnitNode = entry.getValue();
PyExpr substPyExpr = n... | java | private Map<PyExpr, PyExpr> collectVarNameListAndToPyExprMap() {
Map<PyExpr, PyExpr> nodePyVarToPyExprMap = new LinkedHashMap<>();
for (Map.Entry<String, MsgSubstUnitNode> entry : msgNode.getVarNameToRepNodeMap().entrySet()) {
MsgSubstUnitNode substUnitNode = entry.getValue();
PyExpr substPyExpr = n... | [
"private",
"Map",
"<",
"PyExpr",
",",
"PyExpr",
">",
"collectVarNameListAndToPyExprMap",
"(",
")",
"{",
"Map",
"<",
"PyExpr",
",",
"PyExpr",
">",
"nodePyVarToPyExprMap",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<"... | Private helper to process and collect all variables used within this msg node for code
generation.
@return A Map populated with all the variables used with in this message node, using {@link
MsgPlaceholderInitialNode#genBasePhName}. | [
"Private",
"helper",
"to",
"process",
"and",
"collect",
"all",
"variables",
"used",
"within",
"this",
"msg",
"node",
"for",
"code",
"generation",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/MsgFuncGenerator.java#L201-L239 |
53,744 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/TranslateExprNodeVisitor.java | TranslateExprNodeVisitor.genCodeForParamAccess | Expression genCodeForParamAccess(String paramName, VarDefn varDefn) {
Expression source = OPT_DATA;
if (varDefn.isInjected()) {
// Special case for csp_nonce. It is created by the compiler itself, and users should not need
// to set it. So, instead of generating opt_ij_data.csp_nonce, we generate op... | java | Expression genCodeForParamAccess(String paramName, VarDefn varDefn) {
Expression source = OPT_DATA;
if (varDefn.isInjected()) {
// Special case for csp_nonce. It is created by the compiler itself, and users should not need
// to set it. So, instead of generating opt_ij_data.csp_nonce, we generate op... | [
"Expression",
"genCodeForParamAccess",
"(",
"String",
"paramName",
",",
"VarDefn",
"varDefn",
")",
"{",
"Expression",
"source",
"=",
"OPT_DATA",
";",
"if",
"(",
"varDefn",
".",
"isInjected",
"(",
")",
")",
"{",
"// Special case for csp_nonce. It is created by the comp... | Method that returns code to access a named parameter.
@param paramName the name of the parameter.
@param varDefn The variable definition of the parameter
@return The code to access the value of that parameter. | [
"Method",
"that",
"returns",
"code",
"to",
"access",
"a",
"named",
"parameter",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/TranslateExprNodeVisitor.java#L198-L213 |
53,745 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/TranslateExprNodeVisitor.java | TranslateExprNodeVisitor.visitVarRefNode | @Override
protected Expression visitVarRefNode(VarRefNode node) {
Expression translation = variableMappings.maybeGet(node.getName());
if (translation != null) {
// Case 1: In-scope local var.
return translation;
} else {
// Case 2: Data reference.
return genCodeForParamAccess(node.... | java | @Override
protected Expression visitVarRefNode(VarRefNode node) {
Expression translation = variableMappings.maybeGet(node.getName());
if (translation != null) {
// Case 1: In-scope local var.
return translation;
} else {
// Case 2: Data reference.
return genCodeForParamAccess(node.... | [
"@",
"Override",
"protected",
"Expression",
"visitVarRefNode",
"(",
"VarRefNode",
"node",
")",
"{",
"Expression",
"translation",
"=",
"variableMappings",
".",
"maybeGet",
"(",
"node",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"translation",
"!=",
"null",
... | Implementations for data references. | [
"Implementations",
"for",
"data",
"references",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/TranslateExprNodeVisitor.java#L323-L333 |
53,746 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java | NullSafeAccumulator.dotAccess | NullSafeAccumulator dotAccess(FieldAccess access, boolean nullSafe) {
if (access instanceof ProtoCall) {
ProtoCall protoCall = (ProtoCall) access;
Expression maybeUnpack = protoCall.unpackFunction();
if (maybeUnpack != null) {
Preconditions.checkState(
unpackFunction == null, "... | java | NullSafeAccumulator dotAccess(FieldAccess access, boolean nullSafe) {
if (access instanceof ProtoCall) {
ProtoCall protoCall = (ProtoCall) access;
Expression maybeUnpack = protoCall.unpackFunction();
if (maybeUnpack != null) {
Preconditions.checkState(
unpackFunction == null, "... | [
"NullSafeAccumulator",
"dotAccess",
"(",
"FieldAccess",
"access",
",",
"boolean",
"nullSafe",
")",
"{",
"if",
"(",
"access",
"instanceof",
"ProtoCall",
")",
"{",
"ProtoCall",
"protoCall",
"=",
"(",
"ProtoCall",
")",
"access",
";",
"Expression",
"maybeUnpack",
"=... | Extends the access chain with a dot access to the given value.
@param nullSafe If true, code will be generated to ensure the chain is non-null before
dereferencing {@code access}. | [
"Extends",
"the",
"access",
"chain",
"with",
"a",
"dot",
"access",
"to",
"the",
"given",
"value",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java#L85-L98 |
53,747 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java | NullSafeAccumulator.bracketAccess | NullSafeAccumulator bracketAccess(Expression arg, boolean nullSafe) {
chain.add(new Bracket(arg, nullSafe));
// With a bracket access we no longer need to unpack the entire list, just a singular object.
accessType = AccessType.SINGULAR;
return this;
} | java | NullSafeAccumulator bracketAccess(Expression arg, boolean nullSafe) {
chain.add(new Bracket(arg, nullSafe));
// With a bracket access we no longer need to unpack the entire list, just a singular object.
accessType = AccessType.SINGULAR;
return this;
} | [
"NullSafeAccumulator",
"bracketAccess",
"(",
"Expression",
"arg",
",",
"boolean",
"nullSafe",
")",
"{",
"chain",
".",
"add",
"(",
"new",
"Bracket",
"(",
"arg",
",",
"nullSafe",
")",
")",
";",
"// With a bracket access we no longer need to unpack the entire list, just a ... | Extends the access chain with a bracket access to the given value.
@param nullSafe If true, code will be generated to ensure the chain is non-null before
dereferencing {@code arg}. | [
"Extends",
"the",
"access",
"chain",
"with",
"a",
"bracket",
"access",
"to",
"the",
"given",
"value",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java#L113-L118 |
53,748 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java | NullSafeAccumulator.result | Expression result(CodeChunk.Generator codeGenerator) {
Expression accessChain = buildAccessChain(base, codeGenerator, chain.iterator());
if (unpackFunction == null) {
return accessChain;
} else {
return accessType.unpackResult(accessChain, unpackFunction);
}
} | java | Expression result(CodeChunk.Generator codeGenerator) {
Expression accessChain = buildAccessChain(base, codeGenerator, chain.iterator());
if (unpackFunction == null) {
return accessChain;
} else {
return accessType.unpackResult(accessChain, unpackFunction);
}
} | [
"Expression",
"result",
"(",
"CodeChunk",
".",
"Generator",
"codeGenerator",
")",
"{",
"Expression",
"accessChain",
"=",
"buildAccessChain",
"(",
"base",
",",
"codeGenerator",
",",
"chain",
".",
"iterator",
"(",
")",
")",
";",
"if",
"(",
"unpackFunction",
"=="... | Returns a code chunk representing the entire access chain. Null-safe accesses in the chain
generate code to make sure the chain is non-null before performing the access. | [
"Returns",
"a",
"code",
"chunk",
"representing",
"the",
"entire",
"access",
"chain",
".",
"Null",
"-",
"safe",
"accesses",
"in",
"the",
"chain",
"generate",
"code",
"to",
"make",
"sure",
"the",
"chain",
"is",
"non",
"-",
"null",
"before",
"performing",
"th... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java#L124-L132 |
53,749 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java | NullSafeAccumulator.buildAccessChain | private static Expression buildAccessChain(
Expression base, CodeChunk.Generator generator, Iterator<ChainAccess> chain) {
if (!chain.hasNext()) {
return base; // base case
}
ChainAccess link = chain.next();
if (link.nullSafe) {
if (!base.isCheap()) {
base = generator.declarati... | java | private static Expression buildAccessChain(
Expression base, CodeChunk.Generator generator, Iterator<ChainAccess> chain) {
if (!chain.hasNext()) {
return base; // base case
}
ChainAccess link = chain.next();
if (link.nullSafe) {
if (!base.isCheap()) {
base = generator.declarati... | [
"private",
"static",
"Expression",
"buildAccessChain",
"(",
"Expression",
"base",
",",
"CodeChunk",
".",
"Generator",
"generator",
",",
"Iterator",
"<",
"ChainAccess",
">",
"chain",
")",
"{",
"if",
"(",
"!",
"chain",
".",
"hasNext",
"(",
")",
")",
"{",
"re... | Builds the access chain.
<p>For chains with no null-safe accessses this is a simple and direct approach. However, for
null safe accesses we will stash base expressions into a temporary variable so we can generate
multiple references to it.
<p>For example:
<ol>
<li>{@code $a.b} -> {@code a.b}
<li>{@code $a?.b} -> {@c... | [
"Builds",
"the",
"access",
"chain",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/NullSafeAccumulator.java#L152-L167 |
53,750 | google/closure-templates | java/src/com/google/template/soy/internal/i18n/BidiUtils.java | BidiUtils.isRtlLanguage | public static boolean isRtlLanguage(String locale) {
try {
return UScript.isRightToLeft(
UCharacter.getPropertyValueEnum(
UProperty.SCRIPT, ULocale.addLikelySubtags(new ULocale(locale)).getScript()));
} catch (IllegalArgumentException e) {
return false;
}
} | java | public static boolean isRtlLanguage(String locale) {
try {
return UScript.isRightToLeft(
UCharacter.getPropertyValueEnum(
UProperty.SCRIPT, ULocale.addLikelySubtags(new ULocale(locale)).getScript()));
} catch (IllegalArgumentException e) {
return false;
}
} | [
"public",
"static",
"boolean",
"isRtlLanguage",
"(",
"String",
"locale",
")",
"{",
"try",
"{",
"return",
"UScript",
".",
"isRightToLeft",
"(",
"UCharacter",
".",
"getPropertyValueEnum",
"(",
"UProperty",
".",
"SCRIPT",
",",
"ULocale",
".",
"addLikelySubtags",
"(... | Returns whether a locale, given as a string in the ICU syntax, is RTL. | [
"Returns",
"whether",
"a",
"locale",
"given",
"as",
"a",
"string",
"in",
"the",
"ICU",
"syntax",
"is",
"RTL",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/internal/i18n/BidiUtils.java#L54-L62 |
53,751 | google/closure-templates | java/src/com/google/template/soy/incrementaldomsrc/IncrementalDomSrcMain.java | IncrementalDomSrcMain.genJsSrc | public List<String> genJsSrc(
SoyFileSetNode soyTree,
TemplateRegistry registry,
SoyIncrementalDomSrcOptions options,
ErrorReporter errorReporter) {
SoyJsSrcOptions incrementalJSSrcOptions = options.toJsSrcOptions();
BidiGlobalDir bidiGlobalDir =
SoyBidiUtils.decodeBidiGlobalDi... | java | public List<String> genJsSrc(
SoyFileSetNode soyTree,
TemplateRegistry registry,
SoyIncrementalDomSrcOptions options,
ErrorReporter errorReporter) {
SoyJsSrcOptions incrementalJSSrcOptions = options.toJsSrcOptions();
BidiGlobalDir bidiGlobalDir =
SoyBidiUtils.decodeBidiGlobalDi... | [
"public",
"List",
"<",
"String",
">",
"genJsSrc",
"(",
"SoyFileSetNode",
"soyTree",
",",
"TemplateRegistry",
"registry",
",",
"SoyIncrementalDomSrcOptions",
"options",
",",
"ErrorReporter",
"errorReporter",
")",
"{",
"SoyJsSrcOptions",
"incrementalJSSrcOptions",
"=",
"o... | Generates Incremental DOM JS source code given a Soy parse tree, an options object, and an
optional bundle of translated messages.
@param soyTree The Soy parse tree to generate JS source code for.
@param registry The template registry that contains all the template information.
@param options The compilation options r... | [
"Generates",
"Incremental",
"DOM",
"JS",
"source",
"code",
"given",
"a",
"Soy",
"parse",
"tree",
"an",
"options",
"object",
"and",
"an",
"optional",
"bundle",
"of",
"translated",
"messages",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/incrementaldomsrc/IncrementalDomSrcMain.java#L63-L98 |
53,752 | google/closure-templates | java/src/com/google/template/soy/data/ordainers/GsonOrdainer.java | GsonOrdainer.serializeObject | public static SanitizedContent serializeObject(Gson gson, Object obj) {
return ordainJson(gson.toJson(obj));
} | java | public static SanitizedContent serializeObject(Gson gson, Object obj) {
return ordainJson(gson.toJson(obj));
} | [
"public",
"static",
"SanitizedContent",
"serializeObject",
"(",
"Gson",
"gson",
",",
"Object",
"obj",
")",
"{",
"return",
"ordainJson",
"(",
"gson",
".",
"toJson",
"(",
"obj",
")",
")",
";",
"}"
] | Generate sanitized js content with provided Gson serializer.
@param gson A Gson serializer.
@param obj The object to render as gson.
@return SanitizedContent containing the object rendered as a json string. | [
"Generate",
"sanitized",
"js",
"content",
"with",
"provided",
"Gson",
"serializer",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/ordainers/GsonOrdainer.java#L58-L60 |
53,753 | google/closure-templates | java/src/com/google/template/soy/data/ordainers/GsonOrdainer.java | GsonOrdainer.serializeElement | public static SanitizedContent serializeElement(JsonElement element) {
// NOTE: Because JsonElement doesn't have any particular mechanism preventing random classes
// from impersonating it, this low-tech check prevents at least obvious misuse.
Preconditions.checkArgument(
element instanceof JsonArra... | java | public static SanitizedContent serializeElement(JsonElement element) {
// NOTE: Because JsonElement doesn't have any particular mechanism preventing random classes
// from impersonating it, this low-tech check prevents at least obvious misuse.
Preconditions.checkArgument(
element instanceof JsonArra... | [
"public",
"static",
"SanitizedContent",
"serializeElement",
"(",
"JsonElement",
"element",
")",
"{",
"// NOTE: Because JsonElement doesn't have any particular mechanism preventing random classes",
"// from impersonating it, this low-tech check prevents at least obvious misuse.",
"Preconditions... | Serializes a JsonElement to string.
@param element A Gson element.
@return SanitizedContent containing the object rendered as a json string. | [
"Serializes",
"a",
"JsonElement",
"to",
"string",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/ordainers/GsonOrdainer.java#L80-L91 |
53,754 | google/closure-templates | java/src/com/google/template/soy/base/SourceLocation.java | SourceLocation.isJustBefore | public boolean isJustBefore(SourceLocation that) {
if (!this.filePath.equals(that.filePath)) {
return false;
}
return this.getEndLine() == that.getBeginLine()
&& this.getEndColumn() + 1 == that.getBeginColumn();
} | java | public boolean isJustBefore(SourceLocation that) {
if (!this.filePath.equals(that.filePath)) {
return false;
}
return this.getEndLine() == that.getBeginLine()
&& this.getEndColumn() + 1 == that.getBeginColumn();
} | [
"public",
"boolean",
"isJustBefore",
"(",
"SourceLocation",
"that",
")",
"{",
"if",
"(",
"!",
"this",
".",
"filePath",
".",
"equals",
"(",
"that",
".",
"filePath",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"this",
".",
"getEndLine",
"(",
")... | Returns true if this location ends one character before the other location starts. | [
"Returns",
"true",
"if",
"this",
"location",
"ends",
"one",
"character",
"before",
"the",
"other",
"location",
"starts",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/base/SourceLocation.java#L126-L133 |
53,755 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/CodeChunk.java | CodeChunk.getStatementsForInsertingIntoForeignCodeAtIndent | public final String getStatementsForInsertingIntoForeignCodeAtIndent(int startingIndent) {
String code = getCode(startingIndent);
return code.endsWith("\n") ? code : code + "\n";
} | java | public final String getStatementsForInsertingIntoForeignCodeAtIndent(int startingIndent) {
String code = getCode(startingIndent);
return code.endsWith("\n") ? code : code + "\n";
} | [
"public",
"final",
"String",
"getStatementsForInsertingIntoForeignCodeAtIndent",
"(",
"int",
"startingIndent",
")",
"{",
"String",
"code",
"=",
"getCode",
"(",
"startingIndent",
")",
";",
"return",
"code",
".",
"endsWith",
"(",
"\"\\n\"",
")",
"?",
"code",
":",
... | Returns a sequence of JavaScript statements suitable for inserting into JS code that is not
managed by the CodeChunk DSL. The string is guaranteed to end in a newline.
<p>Callers should use {@link #getCode()} when the CodeChunk DSL is managing the entire code
generation. getCode may drop variable declarations if there... | [
"Returns",
"a",
"sequence",
"of",
"JavaScript",
"statements",
"suitable",
"for",
"inserting",
"into",
"JS",
"code",
"that",
"is",
"not",
"managed",
"by",
"the",
"CodeChunk",
"DSL",
".",
"The",
"string",
"is",
"guaranteed",
"to",
"end",
"in",
"a",
"newline",
... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/CodeChunk.java#L141-L144 |
53,756 | google/closure-templates | java/src/com/google/template/soy/passes/htmlmatcher/HtmlMatcherGraph.java | HtmlMatcherGraph.addNode | public void addNode(HtmlMatcherGraphNode node) {
checkNotNull(node);
if (graphCursor.isPresent()) {
graphCursor.get().linkActiveEdgeToNode(node);
}
setGraphCursorNode(node);
} | java | public void addNode(HtmlMatcherGraphNode node) {
checkNotNull(node);
if (graphCursor.isPresent()) {
graphCursor.get().linkActiveEdgeToNode(node);
}
setGraphCursorNode(node);
} | [
"public",
"void",
"addNode",
"(",
"HtmlMatcherGraphNode",
"node",
")",
"{",
"checkNotNull",
"(",
"node",
")",
";",
"if",
"(",
"graphCursor",
".",
"isPresent",
"(",
")",
")",
"{",
"graphCursor",
".",
"get",
"(",
")",
".",
"linkActiveEdgeToNode",
"(",
"node"... | Attaches a new HTML tag node to the graph at the current cursor position.
@param node the node to add | [
"Attaches",
"a",
"new",
"HTML",
"tag",
"node",
"to",
"the",
"graph",
"at",
"the",
"current",
"cursor",
"position",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/passes/htmlmatcher/HtmlMatcherGraph.java#L74-L80 |
53,757 | google/closure-templates | java/src/com/google/template/soy/examples/SimpleUsage.java | SimpleUsage.main | public static void main(String[] args) {
// Compile the template.
SoyFileSet sfs = SoyFileSet.builder().add(Resources.getResource("simple.soy")).build();
SoyTofu tofu = sfs.compileToTofu();
// Example 1.
writeExampleHeader();
System.out.println(tofu.newRenderer("soy.examples.simple.helloWorld"... | java | public static void main(String[] args) {
// Compile the template.
SoyFileSet sfs = SoyFileSet.builder().add(Resources.getResource("simple.soy")).build();
SoyTofu tofu = sfs.compileToTofu();
// Example 1.
writeExampleHeader();
System.out.println(tofu.newRenderer("soy.examples.simple.helloWorld"... | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"// Compile the template.",
"SoyFileSet",
"sfs",
"=",
"SoyFileSet",
".",
"builder",
"(",
")",
".",
"add",
"(",
"Resources",
".",
"getResource",
"(",
"\"simple.soy\"",
")",
")",
... | Prints the generated HTML to stdout.
@param args Not used. | [
"Prints",
"the",
"generated",
"HTML",
"to",
"stdout",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/examples/SimpleUsage.java#L41-L66 |
53,758 | google/closure-templates | java/src/com/google/template/soy/soytree/TemplateDelegateNode.java | TemplateDelegateNode.resolveVariantExpression | private DelTemplateKey resolveVariantExpression() {
if (delTemplateVariantExpr == null) {
delTemplateKey = DelTemplateKey.create(delTemplateName, "");
return delTemplateKey;
}
ExprNode exprNode = delTemplateVariantExpr.getRoot();
if (exprNode instanceof GlobalNode) {
GlobalNode globalN... | java | private DelTemplateKey resolveVariantExpression() {
if (delTemplateVariantExpr == null) {
delTemplateKey = DelTemplateKey.create(delTemplateName, "");
return delTemplateKey;
}
ExprNode exprNode = delTemplateVariantExpr.getRoot();
if (exprNode instanceof GlobalNode) {
GlobalNode globalN... | [
"private",
"DelTemplateKey",
"resolveVariantExpression",
"(",
")",
"{",
"if",
"(",
"delTemplateVariantExpr",
"==",
"null",
")",
"{",
"delTemplateKey",
"=",
"DelTemplateKey",
".",
"create",
"(",
"delTemplateName",
",",
"\"\"",
")",
";",
"return",
"delTemplateKey",
... | Calculate a DeltemplateKey for the variant.
<p>This is done lazily so that global references can be resolved. This is not ideal since
nothing guarantees that resolution happens before access.
<p>Note we don't do validation of the variant values since that is handled by the
TemplateDelegateNodeBuilder during construct... | [
"Calculate",
"a",
"DeltemplateKey",
"for",
"the",
"variant",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/TemplateDelegateNode.java#L175-L208 |
53,759 | google/closure-templates | java/src/com/google/template/soy/soytree/NamespaceDeclaration.java | NamespaceDeclaration.toSourceString | public String toSourceString() {
return "{namespace "
+ namespace.identifier()
+ (attrs.isEmpty() ? "" : " " + Joiner.on(' ').join(attrs))
+ "}\n";
} | java | public String toSourceString() {
return "{namespace "
+ namespace.identifier()
+ (attrs.isEmpty() ? "" : " " + Joiner.on(' ').join(attrs))
+ "}\n";
} | [
"public",
"String",
"toSourceString",
"(",
")",
"{",
"return",
"\"{namespace \"",
"+",
"namespace",
".",
"identifier",
"(",
")",
"+",
"(",
"attrs",
".",
"isEmpty",
"(",
")",
"?",
"\"\"",
":",
"\" \"",
"+",
"Joiner",
".",
"on",
"(",
"'",
"'",
")",
"."... | Returns an approximation of what the original source for this namespace looked like. | [
"Returns",
"an",
"approximation",
"of",
"what",
"the",
"original",
"source",
"for",
"this",
"namespace",
"looked",
"like",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/NamespaceDeclaration.java#L81-L86 |
53,760 | google/closure-templates | java/src/com/google/template/soy/data/internalutils/NodeContentKinds.java | NodeContentKinds.toJsUnpackFunction | public static String toJsUnpackFunction(Descriptor protoDescriptor) {
return Preconditions.checkNotNull(PROTO_TO_JS_UNPACK_FN.get(protoDescriptor.getFullName()));
} | java | public static String toJsUnpackFunction(Descriptor protoDescriptor) {
return Preconditions.checkNotNull(PROTO_TO_JS_UNPACK_FN.get(protoDescriptor.getFullName()));
} | [
"public",
"static",
"String",
"toJsUnpackFunction",
"(",
"Descriptor",
"protoDescriptor",
")",
"{",
"return",
"Preconditions",
".",
"checkNotNull",
"(",
"PROTO_TO_JS_UNPACK_FN",
".",
"get",
"(",
"protoDescriptor",
".",
"getFullName",
"(",
")",
")",
")",
";",
"}"
] | Returns the unpack function for converting safe protos to JS SanitizedContent. | [
"Returns",
"the",
"unpack",
"function",
"for",
"converting",
"safe",
"protos",
"to",
"JS",
"SanitizedContent",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/internalutils/NodeContentKinds.java#L223-L225 |
53,761 | google/closure-templates | java/src/com/google/template/soy/soytree/MsgHtmlTagNode.java | MsgHtmlTagNode.getFullTagText | @Nullable
private static String getFullTagText(HtmlTagNode openTagNode) {
class Visitor implements NodeVisitor<Node, VisitDirective> {
boolean isConstantContent = true;
@Override
public VisitDirective exec(Node node) {
if (node instanceof RawTextNode
|| node instanceof HtmlA... | java | @Nullable
private static String getFullTagText(HtmlTagNode openTagNode) {
class Visitor implements NodeVisitor<Node, VisitDirective> {
boolean isConstantContent = true;
@Override
public VisitDirective exec(Node node) {
if (node instanceof RawTextNode
|| node instanceof HtmlA... | [
"@",
"Nullable",
"private",
"static",
"String",
"getFullTagText",
"(",
"HtmlTagNode",
"openTagNode",
")",
"{",
"class",
"Visitor",
"implements",
"NodeVisitor",
"<",
"Node",
",",
"VisitDirective",
">",
"{",
"boolean",
"isConstantContent",
"=",
"true",
";",
"@",
"... | This method calculates a string that can be used to tell if two tags that were turned into
placeholders are equivalent and thus could be turned into identical placeholders.
<p>In theory we should use something like {@link ExprEquivalence} to see if two nodes would
render the same thing. However, for backwards compatib... | [
"This",
"method",
"calculates",
"a",
"string",
"that",
"can",
"be",
"used",
"to",
"tell",
"if",
"two",
"tags",
"that",
"were",
"turned",
"into",
"placeholders",
"are",
"equivalent",
"and",
"thus",
"could",
"be",
"turned",
"into",
"identical",
"placeholders",
... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/MsgHtmlTagNode.java#L113-L138 |
53,762 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/SoyJsPluginUtils.java | SoyJsPluginUtils.genJsExprUsingSoySyntax | public static JsExpr genJsExprUsingSoySyntax(Operator op, List<JsExpr> operandJsExprs) {
List<Expression> operands =
Lists.transform(operandJsExprs, input -> fromExpr(input, ImmutableList.<GoogRequire>of()));
return Expression.operation(op, operands).assertExpr();
} | java | public static JsExpr genJsExprUsingSoySyntax(Operator op, List<JsExpr> operandJsExprs) {
List<Expression> operands =
Lists.transform(operandJsExprs, input -> fromExpr(input, ImmutableList.<GoogRequire>of()));
return Expression.operation(op, operands).assertExpr();
} | [
"public",
"static",
"JsExpr",
"genJsExprUsingSoySyntax",
"(",
"Operator",
"op",
",",
"List",
"<",
"JsExpr",
">",
"operandJsExprs",
")",
"{",
"List",
"<",
"Expression",
">",
"operands",
"=",
"Lists",
".",
"transform",
"(",
"operandJsExprs",
",",
"input",
"->",
... | Generates a JS expression for the given operator and operands. | [
"Generates",
"a",
"JS",
"expression",
"for",
"the",
"given",
"operator",
"and",
"operands",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/SoyJsPluginUtils.java#L57-L61 |
53,763 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/SoyRuntimeType.java | SoyRuntimeType.protoType | public static Type protoType(Descriptor descriptor) {
return Type.getType('L' + JavaQualifiedNames.getClassName(descriptor).replace('.', '/') + ';');
} | java | public static Type protoType(Descriptor descriptor) {
return Type.getType('L' + JavaQualifiedNames.getClassName(descriptor).replace('.', '/') + ';');
} | [
"public",
"static",
"Type",
"protoType",
"(",
"Descriptor",
"descriptor",
")",
"{",
"return",
"Type",
".",
"getType",
"(",
"'",
"'",
"+",
"JavaQualifiedNames",
".",
"getClassName",
"(",
"descriptor",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")"... | Returns the runtime type for the message correspdoning to the given descriptor.. | [
"Returns",
"the",
"runtime",
"type",
"for",
"the",
"message",
"correspdoning",
"to",
"the",
"given",
"descriptor",
".."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/SoyRuntimeType.java#L255-L257 |
53,764 | google/closure-templates | java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java | BasicFunctionsRuntime.concatLists | public static List<SoyValueProvider> concatLists(List<SoyList> args) {
ImmutableList.Builder<SoyValueProvider> flattened = ImmutableList.builder();
for (SoyList soyList : args) {
flattened.addAll(soyList.asJavaList());
}
return flattened.build();
} | java | public static List<SoyValueProvider> concatLists(List<SoyList> args) {
ImmutableList.Builder<SoyValueProvider> flattened = ImmutableList.builder();
for (SoyList soyList : args) {
flattened.addAll(soyList.asJavaList());
}
return flattened.build();
} | [
"public",
"static",
"List",
"<",
"SoyValueProvider",
">",
"concatLists",
"(",
"List",
"<",
"SoyList",
">",
"args",
")",
"{",
"ImmutableList",
".",
"Builder",
"<",
"SoyValueProvider",
">",
"flattened",
"=",
"ImmutableList",
".",
"builder",
"(",
")",
";",
"for... | Concatenates its arguments. | [
"Concatenates",
"its",
"arguments",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java#L71-L77 |
53,765 | google/closure-templates | java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java | BasicFunctionsRuntime.join | public static String join(SoyList list, String separator) {
List<String> stringList = new ArrayList<>();
for (SoyValue value : list.asResolvedJavaList()) {
stringList.add(value.coerceToString());
}
return Joiner.on(separator).join(stringList);
} | java | public static String join(SoyList list, String separator) {
List<String> stringList = new ArrayList<>();
for (SoyValue value : list.asResolvedJavaList()) {
stringList.add(value.coerceToString());
}
return Joiner.on(separator).join(stringList);
} | [
"public",
"static",
"String",
"join",
"(",
"SoyList",
"list",
",",
"String",
"separator",
")",
"{",
"List",
"<",
"String",
">",
"stringList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"SoyValue",
"value",
":",
"list",
".",
"asResolvedJava... | Joins the list elements by a separator. | [
"Joins",
"the",
"list",
"elements",
"by",
"a",
"separator",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java#L85-L91 |
53,766 | google/closure-templates | java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java | BasicFunctionsRuntime.keys | public static List<SoyValue> keys(SoyValue sv) {
SoyLegacyObjectMap map = (SoyLegacyObjectMap) sv;
List<SoyValue> list = new ArrayList<>(map.getItemCnt());
Iterables.addAll(list, map.getItemKeys());
return list;
} | java | public static List<SoyValue> keys(SoyValue sv) {
SoyLegacyObjectMap map = (SoyLegacyObjectMap) sv;
List<SoyValue> list = new ArrayList<>(map.getItemCnt());
Iterables.addAll(list, map.getItemKeys());
return list;
} | [
"public",
"static",
"List",
"<",
"SoyValue",
">",
"keys",
"(",
"SoyValue",
"sv",
")",
"{",
"SoyLegacyObjectMap",
"map",
"=",
"(",
"SoyLegacyObjectMap",
")",
"sv",
";",
"List",
"<",
"SoyValue",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
"map",
".",
... | Returns a list of all the keys in the given map. For the JavaSource variant, while the function
signature is ? instead of legacy_object_map. | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"keys",
"in",
"the",
"given",
"map",
".",
"For",
"the",
"JavaSource",
"variant",
"while",
"the",
"function",
"signature",
"is",
"?",
"instead",
"of",
"legacy_object_map",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java#L109-L114 |
53,767 | google/closure-templates | java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java | BasicFunctionsRuntime.max | public static NumberData max(SoyValue arg0, SoyValue arg1) {
if (arg0 instanceof IntegerData && arg1 instanceof IntegerData) {
return IntegerData.forValue(Math.max(arg0.longValue(), arg1.longValue()));
} else {
return FloatData.forValue(Math.max(arg0.numberValue(), arg1.numberValue()));
}
} | java | public static NumberData max(SoyValue arg0, SoyValue arg1) {
if (arg0 instanceof IntegerData && arg1 instanceof IntegerData) {
return IntegerData.forValue(Math.max(arg0.longValue(), arg1.longValue()));
} else {
return FloatData.forValue(Math.max(arg0.numberValue(), arg1.numberValue()));
}
} | [
"public",
"static",
"NumberData",
"max",
"(",
"SoyValue",
"arg0",
",",
"SoyValue",
"arg1",
")",
"{",
"if",
"(",
"arg0",
"instanceof",
"IntegerData",
"&&",
"arg1",
"instanceof",
"IntegerData",
")",
"{",
"return",
"IntegerData",
".",
"forValue",
"(",
"Math",
"... | Returns the numeric maximum of the two arguments. | [
"Returns",
"the",
"numeric",
"maximum",
"of",
"the",
"two",
"arguments",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java#L132-L138 |
53,768 | google/closure-templates | java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java | BasicFunctionsRuntime.round | public static long round(SoyValue value) {
if (value instanceof IntegerData) {
return value.longValue();
} else {
return Math.round(value.numberValue());
}
} | java | public static long round(SoyValue value) {
if (value instanceof IntegerData) {
return value.longValue();
} else {
return Math.round(value.numberValue());
}
} | [
"public",
"static",
"long",
"round",
"(",
"SoyValue",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"IntegerData",
")",
"{",
"return",
"value",
".",
"longValue",
"(",
")",
";",
"}",
"else",
"{",
"return",
"Math",
".",
"round",
"(",
"value",
".",... | Rounds the given value to the closest integer. | [
"Rounds",
"the",
"given",
"value",
"to",
"the",
"closest",
"integer",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/basicfunctions/BasicFunctionsRuntime.java#L184-L190 |
53,769 | google/closure-templates | java/src/com/google/template/soy/soytree/CallDelegateNode.java | CallDelegateNode.setParamsToRuntimeCheck | public void setParamsToRuntimeCheck(
ImmutableMap<String, Predicate<String>> paramsToRuntimeCheck) {
checkState(this.paramsToRuntimeCheckByDelegate == null);
this.paramsToRuntimeCheckByDelegate = checkNotNull(paramsToRuntimeCheck);
} | java | public void setParamsToRuntimeCheck(
ImmutableMap<String, Predicate<String>> paramsToRuntimeCheck) {
checkState(this.paramsToRuntimeCheckByDelegate == null);
this.paramsToRuntimeCheckByDelegate = checkNotNull(paramsToRuntimeCheck);
} | [
"public",
"void",
"setParamsToRuntimeCheck",
"(",
"ImmutableMap",
"<",
"String",
",",
"Predicate",
"<",
"String",
">",
">",
"paramsToRuntimeCheck",
")",
"{",
"checkState",
"(",
"this",
".",
"paramsToRuntimeCheckByDelegate",
"==",
"null",
")",
";",
"this",
".",
"... | Sets the params that require runtime type checking for each possible delegate target.
<p>This mechanism is used by the TOFU runtime only to save some work when calling templates. | [
"Sets",
"the",
"params",
"that",
"require",
"runtime",
"type",
"checking",
"for",
"each",
"possible",
"delegate",
"target",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/CallDelegateNode.java#L176-L180 |
53,770 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/ExpressionCompiler.java | ExpressionCompiler.createBasicCompiler | static BasicExpressionCompiler createBasicCompiler(
TemplateParameterLookup parameters,
TemplateVariableManager varManager,
ErrorReporter reporter,
SoyTypeRegistry registry) {
return new BasicExpressionCompiler(parameters, varManager, reporter, registry);
} | java | static BasicExpressionCompiler createBasicCompiler(
TemplateParameterLookup parameters,
TemplateVariableManager varManager,
ErrorReporter reporter,
SoyTypeRegistry registry) {
return new BasicExpressionCompiler(parameters, varManager, reporter, registry);
} | [
"static",
"BasicExpressionCompiler",
"createBasicCompiler",
"(",
"TemplateParameterLookup",
"parameters",
",",
"TemplateVariableManager",
"varManager",
",",
"ErrorReporter",
"reporter",
",",
"SoyTypeRegistry",
"registry",
")",
"{",
"return",
"new",
"BasicExpressionCompiler",
... | Create a basic compiler with trivial detaching logic.
<p>All generated detach points are implemented as {@code return} statements and the returned
value is boxed, so it is only valid for use by the {@link LazyClosureCompiler}. | [
"Create",
"a",
"basic",
"compiler",
"with",
"trivial",
"detaching",
"logic",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/ExpressionCompiler.java#L190-L196 |
53,771 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/ExpressionCompiler.java | ExpressionCompiler.compile | SoyExpression compile(ExprNode node, Label reattachPoint) {
return asBasicCompiler(reattachPoint).compile(node);
} | java | SoyExpression compile(ExprNode node, Label reattachPoint) {
return asBasicCompiler(reattachPoint).compile(node);
} | [
"SoyExpression",
"compile",
"(",
"ExprNode",
"node",
",",
"Label",
"reattachPoint",
")",
"{",
"return",
"asBasicCompiler",
"(",
"reattachPoint",
")",
".",
"compile",
"(",
"node",
")",
";",
"}"
] | Compiles the given expression tree to a sequence of bytecode.
<p>The reattachPoint should be {@link CodeBuilder#mark(Label) marked} by the caller at a
location where the stack depth is 0 and will be used to 'reattach' execution if the compiled
expression needs to perform a detach operation. | [
"Compiles",
"the",
"given",
"expression",
"tree",
"to",
"a",
"sequence",
"of",
"bytecode",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/ExpressionCompiler.java#L224-L226 |
53,772 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/ExpressionCompiler.java | ExpressionCompiler.compileWithNoDetaches | Optional<SoyExpression> compileWithNoDetaches(ExprNode node) {
checkNotNull(node);
if (RequiresDetachVisitor.INSTANCE.exec(node)) {
return Optional.absent();
}
Supplier<ExpressionDetacher> throwingSupplier =
() -> {
throw new AssertionError();
};
return Optional.of(
... | java | Optional<SoyExpression> compileWithNoDetaches(ExprNode node) {
checkNotNull(node);
if (RequiresDetachVisitor.INSTANCE.exec(node)) {
return Optional.absent();
}
Supplier<ExpressionDetacher> throwingSupplier =
() -> {
throw new AssertionError();
};
return Optional.of(
... | [
"Optional",
"<",
"SoyExpression",
">",
"compileWithNoDetaches",
"(",
"ExprNode",
"node",
")",
"{",
"checkNotNull",
"(",
"node",
")",
";",
"if",
"(",
"RequiresDetachVisitor",
".",
"INSTANCE",
".",
"exec",
"(",
"node",
")",
")",
"{",
"return",
"Optional",
".",... | Compiles the given expression tree to a sequence of bytecode if it can be done without
generating any detach operations. | [
"Compiles",
"the",
"given",
"expression",
"tree",
"to",
"a",
"sequence",
"of",
"bytecode",
"if",
"it",
"can",
"be",
"done",
"without",
"generating",
"any",
"detach",
"operations",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/ExpressionCompiler.java#L245-L257 |
53,773 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/GenPyExprsVisitor.java | GenPyExprsVisitor.visitPrintNode | @Override
protected void visitPrintNode(PrintNode node) {
TranslateToPyExprVisitor translator =
new TranslateToPyExprVisitor(localVarExprs, pluginValueFactory, errorReporter);
PyExpr pyExpr = translator.exec(node.getExpr());
// Process directives.
for (PrintDirectiveNode directiveNode : node... | java | @Override
protected void visitPrintNode(PrintNode node) {
TranslateToPyExprVisitor translator =
new TranslateToPyExprVisitor(localVarExprs, pluginValueFactory, errorReporter);
PyExpr pyExpr = translator.exec(node.getExpr());
// Process directives.
for (PrintDirectiveNode directiveNode : node... | [
"@",
"Override",
"protected",
"void",
"visitPrintNode",
"(",
"PrintNode",
"node",
")",
"{",
"TranslateToPyExprVisitor",
"translator",
"=",
"new",
"TranslateToPyExprVisitor",
"(",
"localVarExprs",
",",
"pluginValueFactory",
",",
"errorReporter",
")",
";",
"PyExpr",
"py... | Visiting a print node accomplishes 3 basic tasks. It loads data, it performs any operations
needed, and it executes the appropriate print directives.
<p>TODO(dcphillips): Add support for local variables once LetNode are supported.
<p>Example:
<pre>
{$boo |changeNewlineToBr}
{$goo + 5}
</pre>
might generate
<pre>
s... | [
"Visiting",
"a",
"print",
"node",
"accomplishes",
"3",
"basic",
"tasks",
".",
"It",
"loads",
"data",
"it",
"performs",
"any",
"operations",
"needed",
"and",
"it",
"executes",
"the",
"appropriate",
"print",
"directives",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/GenPyExprsVisitor.java#L180-L213 |
53,774 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/GenPyExprsVisitor.java | GenPyExprsVisitor.visitIfNode | @Override
protected void visitIfNode(IfNode node) {
// Create another instance of this visitor for generating Python expressions from children.
GenPyExprsVisitor genPyExprsVisitor =
genPyExprsVisitorFactory.create(localVarExprs, errorReporter);
TranslateToPyExprVisitor translator =
new Tra... | java | @Override
protected void visitIfNode(IfNode node) {
// Create another instance of this visitor for generating Python expressions from children.
GenPyExprsVisitor genPyExprsVisitor =
genPyExprsVisitorFactory.create(localVarExprs, errorReporter);
TranslateToPyExprVisitor translator =
new Tra... | [
"@",
"Override",
"protected",
"void",
"visitIfNode",
"(",
"IfNode",
"node",
")",
"{",
"// Create another instance of this visitor for generating Python expressions from children.",
"GenPyExprsVisitor",
"genPyExprsVisitor",
"=",
"genPyExprsVisitorFactory",
".",
"create",
"(",
"loc... | If all the children are computable as expressions, the IfNode can be written as a ternary
conditional expression. | [
"If",
"all",
"the",
"children",
"are",
"computable",
"as",
"expressions",
"the",
"IfNode",
"can",
"be",
"written",
"as",
"a",
"ternary",
"conditional",
"expression",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/GenPyExprsVisitor.java#L269-L328 |
53,775 | google/closure-templates | java/src/com/google/template/soy/soytree/HtmlTagNode.java | HtmlTagNode.getDirectAttributeNamed | @Nullable
public HtmlAttributeNode getDirectAttributeNamed(String attrName) {
// the child at index 0 is the tag name
for (int i = 1; i < numChildren(); i++) {
StandaloneNode child = getChild(i);
if (child instanceof HtmlAttributeNode) {
HtmlAttributeNode attr = (HtmlAttributeNode) child;
... | java | @Nullable
public HtmlAttributeNode getDirectAttributeNamed(String attrName) {
// the child at index 0 is the tag name
for (int i = 1; i < numChildren(); i++) {
StandaloneNode child = getChild(i);
if (child instanceof HtmlAttributeNode) {
HtmlAttributeNode attr = (HtmlAttributeNode) child;
... | [
"@",
"Nullable",
"public",
"HtmlAttributeNode",
"getDirectAttributeNamed",
"(",
"String",
"attrName",
")",
"{",
"// the child at index 0 is the tag name",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"numChildren",
"(",
")",
";",
"i",
"++",
")",
"{",
"Stan... | Returns an attribute with the given static name if it is a direct child. | [
"Returns",
"an",
"attribute",
"with",
"the",
"given",
"static",
"name",
"if",
"it",
"is",
"a",
"direct",
"child",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/HtmlTagNode.java#L128-L141 |
53,776 | google/closure-templates | java/src/com/google/template/soy/data/SoyValueConverter.java | SoyValueConverter.newListFromIterable | private SoyList newListFromIterable(Iterable<?> items) {
// Create a list backed by a Java list which has eagerly converted each value into a lazy
// value provider. Specifically, the list iteration is done eagerly so that the lazy value
// provider can cache its value.
ImmutableList.Builder<SoyValuePro... | java | private SoyList newListFromIterable(Iterable<?> items) {
// Create a list backed by a Java list which has eagerly converted each value into a lazy
// value provider. Specifically, the list iteration is done eagerly so that the lazy value
// provider can cache its value.
ImmutableList.Builder<SoyValuePro... | [
"private",
"SoyList",
"newListFromIterable",
"(",
"Iterable",
"<",
"?",
">",
"items",
")",
"{",
"// Create a list backed by a Java list which has eagerly converted each value into a lazy",
"// value provider. Specifically, the list iteration is done eagerly so that the lazy value",
"// pro... | Creates a SoyList from a Java Iterable.
<p>Values are converted into Soy types lazily and only once.
@param items The collection of Java values
@return A new SoyList initialized from the given Java Collection. | [
"Creates",
"a",
"SoyList",
"from",
"a",
"Java",
"Iterable",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/SoyValueConverter.java#L420-L429 |
53,777 | google/closure-templates | java/src/com/google/template/soy/msgs/internal/MsgUtils.java | MsgUtils.buildMsgPartsAndComputeMsgIdForDualFormat | public static MsgPartsAndIds buildMsgPartsAndComputeMsgIdForDualFormat(MsgNode msgNode) {
if (msgNode.isPlrselMsg()) {
MsgPartsAndIds mpai = buildMsgPartsAndComputeMsgIds(msgNode, true);
return new MsgPartsAndIds(mpai.parts, mpai.idUsingBracedPhs, -1L);
} else {
return buildMsgPartsAndCompute... | java | public static MsgPartsAndIds buildMsgPartsAndComputeMsgIdForDualFormat(MsgNode msgNode) {
if (msgNode.isPlrselMsg()) {
MsgPartsAndIds mpai = buildMsgPartsAndComputeMsgIds(msgNode, true);
return new MsgPartsAndIds(mpai.parts, mpai.idUsingBracedPhs, -1L);
} else {
return buildMsgPartsAndCompute... | [
"public",
"static",
"MsgPartsAndIds",
"buildMsgPartsAndComputeMsgIdForDualFormat",
"(",
"MsgNode",
"msgNode",
")",
"{",
"if",
"(",
"msgNode",
".",
"isPlrselMsg",
"(",
")",
")",
"{",
"MsgPartsAndIds",
"mpai",
"=",
"buildMsgPartsAndComputeMsgIds",
"(",
"msgNode",
",",
... | Builds the list of SoyMsgParts and computes the unique message id for the given MsgNode,
assuming a specific dual format.
<p>Note: The field {@code idUsingBracedPhs} in the return value is simply set to -1L.
@param msgNode The message parsed from the Soy source.
@return A {@code MsgPartsAndIds} object, assuming a spe... | [
"Builds",
"the",
"list",
"of",
"SoyMsgParts",
"and",
"computes",
"the",
"unique",
"message",
"id",
"for",
"the",
"given",
"MsgNode",
"assuming",
"a",
"specific",
"dual",
"format",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/internal/MsgUtils.java#L77-L85 |
53,778 | google/closure-templates | java/src/com/google/template/soy/msgs/internal/MsgUtils.java | MsgUtils.computeMsgId | private static long computeMsgId(MsgNode msgNode) {
return SoyMsgIdComputer.computeMsgId(
buildMsgParts(msgNode), msgNode.getMeaning(), msgNode.getContentType());
} | java | private static long computeMsgId(MsgNode msgNode) {
return SoyMsgIdComputer.computeMsgId(
buildMsgParts(msgNode), msgNode.getMeaning(), msgNode.getContentType());
} | [
"private",
"static",
"long",
"computeMsgId",
"(",
"MsgNode",
"msgNode",
")",
"{",
"return",
"SoyMsgIdComputer",
".",
"computeMsgId",
"(",
"buildMsgParts",
"(",
"msgNode",
")",
",",
"msgNode",
".",
"getMeaning",
"(",
")",
",",
"msgNode",
".",
"getContentType",
... | Computes the unique message id for the given MsgNode.
@param msgNode The message parsed from the Soy source.
@return The message id. | [
"Computes",
"the",
"unique",
"message",
"id",
"for",
"the",
"given",
"MsgNode",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/internal/MsgUtils.java#L146-L149 |
53,779 | google/closure-templates | java/src/com/google/template/soy/msgs/internal/MsgUtils.java | MsgUtils.computeMsgIdUsingBracedPhs | private static long computeMsgIdUsingBracedPhs(MsgNode msgNode) {
return SoyMsgIdComputer.computeMsgIdUsingBracedPhs(
buildMsgParts(msgNode), msgNode.getMeaning(), msgNode.getContentType());
} | java | private static long computeMsgIdUsingBracedPhs(MsgNode msgNode) {
return SoyMsgIdComputer.computeMsgIdUsingBracedPhs(
buildMsgParts(msgNode), msgNode.getMeaning(), msgNode.getContentType());
} | [
"private",
"static",
"long",
"computeMsgIdUsingBracedPhs",
"(",
"MsgNode",
"msgNode",
")",
"{",
"return",
"SoyMsgIdComputer",
".",
"computeMsgIdUsingBracedPhs",
"(",
"buildMsgParts",
"(",
"msgNode",
")",
",",
"msgNode",
".",
"getMeaning",
"(",
")",
",",
"msgNode",
... | Computes the alternate unique id for this message. Only use this if you use braced
placeholders.
@param msgNode The message parsed from the Soy source.
@return The alternate message id using braced placeholders. | [
"Computes",
"the",
"alternate",
"unique",
"id",
"for",
"this",
"message",
".",
"Only",
"use",
"this",
"if",
"you",
"use",
"braced",
"placeholders",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/internal/MsgUtils.java#L158-L161 |
53,780 | google/closure-templates | java/src/com/google/template/soy/msgs/internal/MsgUtils.java | MsgUtils.buildMsgPartsForChildren | private static ImmutableList<SoyMsgPart> buildMsgPartsForChildren(
MsgBlockNode parent, MsgNode msgNode) {
ImmutableList.Builder<SoyMsgPart> msgParts = ImmutableList.builder();
doBuildMsgPartsForChildren(parent, msgNode, msgParts);
return msgParts.build();
} | java | private static ImmutableList<SoyMsgPart> buildMsgPartsForChildren(
MsgBlockNode parent, MsgNode msgNode) {
ImmutableList.Builder<SoyMsgPart> msgParts = ImmutableList.builder();
doBuildMsgPartsForChildren(parent, msgNode, msgParts);
return msgParts.build();
} | [
"private",
"static",
"ImmutableList",
"<",
"SoyMsgPart",
">",
"buildMsgPartsForChildren",
"(",
"MsgBlockNode",
"parent",
",",
"MsgNode",
"msgNode",
")",
"{",
"ImmutableList",
".",
"Builder",
"<",
"SoyMsgPart",
">",
"msgParts",
"=",
"ImmutableList",
".",
"builder",
... | Builds the list of SoyMsgParts for all the children of a given parent node.
@param parent Can be MsgNode, MsgPluralCaseNode, MsgPluralDefaultNode, MsgSelectCaseNode, or
MsgSelectDefaultNode.
@param msgNode The MsgNode containing 'parent'. | [
"Builds",
"the",
"list",
"of",
"SoyMsgParts",
"for",
"all",
"the",
"children",
"of",
"a",
"given",
"parent",
"node",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/internal/MsgUtils.java#L173-L179 |
53,781 | google/closure-templates | java/src/com/google/template/soy/msgs/internal/MsgUtils.java | MsgUtils.buildMsgPartForPlural | private static SoyMsgPluralPart buildMsgPartForPlural(
MsgPluralNode msgPluralNode, MsgNode msgNode) {
// This is the list of the cases.
ImmutableList.Builder<SoyMsgPart.Case<SoyMsgPluralCaseSpec>> pluralCases =
ImmutableList.builder();
for (CaseOrDefaultNode child : msgPluralNode.getChildre... | java | private static SoyMsgPluralPart buildMsgPartForPlural(
MsgPluralNode msgPluralNode, MsgNode msgNode) {
// This is the list of the cases.
ImmutableList.Builder<SoyMsgPart.Case<SoyMsgPluralCaseSpec>> pluralCases =
ImmutableList.builder();
for (CaseOrDefaultNode child : msgPluralNode.getChildre... | [
"private",
"static",
"SoyMsgPluralPart",
"buildMsgPartForPlural",
"(",
"MsgPluralNode",
"msgPluralNode",
",",
"MsgNode",
"msgNode",
")",
"{",
"// This is the list of the cases.",
"ImmutableList",
".",
"Builder",
"<",
"SoyMsgPart",
".",
"Case",
"<",
"SoyMsgPluralCaseSpec",
... | Builds the list of SoyMsgParts for the given MsgPluralNode.
@param msgPluralNode The plural node parsed from the Soy source.
@param msgNode The MsgNode containing 'msgPluralNode'.
@return A SoyMsgPluralPart. | [
"Builds",
"the",
"list",
"of",
"SoyMsgParts",
"for",
"the",
"given",
"MsgPluralNode",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/internal/MsgUtils.java#L209-L237 |
53,782 | google/closure-templates | java/src/com/google/template/soy/msgs/internal/MsgUtils.java | MsgUtils.buildMsgPartForSelect | private static SoyMsgSelectPart buildMsgPartForSelect(
MsgSelectNode msgSelectNode, MsgNode msgNode) {
// This is the list of the cases.
ImmutableList.Builder<SoyMsgPart.Case<String>> selectCases = ImmutableList.builder();
for (CaseOrDefaultNode child : msgSelectNode.getChildren()) {
Immutable... | java | private static SoyMsgSelectPart buildMsgPartForSelect(
MsgSelectNode msgSelectNode, MsgNode msgNode) {
// This is the list of the cases.
ImmutableList.Builder<SoyMsgPart.Case<String>> selectCases = ImmutableList.builder();
for (CaseOrDefaultNode child : msgSelectNode.getChildren()) {
Immutable... | [
"private",
"static",
"SoyMsgSelectPart",
"buildMsgPartForSelect",
"(",
"MsgSelectNode",
"msgSelectNode",
",",
"MsgNode",
"msgNode",
")",
"{",
"// This is the list of the cases.",
"ImmutableList",
".",
"Builder",
"<",
"SoyMsgPart",
".",
"Case",
"<",
"String",
">>",
"sele... | Builds the list of SoyMsgParts for the given MsgSelectNode.
@param msgSelectNode The select node parsed from the Soy source.
@param msgNode The MsgNode containing 'msgSelectNode'.
@return A SoyMsgSelectPart. | [
"Builds",
"the",
"list",
"of",
"SoyMsgParts",
"for",
"the",
"given",
"MsgSelectNode",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/internal/MsgUtils.java#L246-L267 |
53,783 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/GenCallCodeUtils.java | GenCallCodeUtils.gen | public Expression gen(
CallNode callNode,
TemplateAliases templateAliases,
TranslationContext translationContext,
ErrorReporter errorReporter,
TranslateExprNodeVisitor exprTranslator) {
// Build the JS CodeChunk for the callee's name.
Expression callee = genCallee(callNode, templa... | java | public Expression gen(
CallNode callNode,
TemplateAliases templateAliases,
TranslationContext translationContext,
ErrorReporter errorReporter,
TranslateExprNodeVisitor exprTranslator) {
// Build the JS CodeChunk for the callee's name.
Expression callee = genCallee(callNode, templa... | [
"public",
"Expression",
"gen",
"(",
"CallNode",
"callNode",
",",
"TemplateAliases",
"templateAliases",
",",
"TranslationContext",
"translationContext",
",",
"ErrorReporter",
"errorReporter",
",",
"TranslateExprNodeVisitor",
"exprTranslator",
")",
"{",
"// Build the JS CodeChu... | Generates the JS expression for a given call.
<p>Important: If there are CallParamContentNode children whose contents are not computable as
JS expressions, then this function assumes that, elsewhere, code has been generated to define
their respective 'param<n>' temporary variables.
<p>Here are five example call... | [
"Generates",
"the",
"JS",
"expression",
"for",
"a",
"given",
"call",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/GenCallCodeUtils.java#L122-L141 |
53,784 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/GenCallCodeUtils.java | GenCallCodeUtils.genObjToPass | public Expression genObjToPass(
CallNode callNode,
TemplateAliases templateAliases,
TranslationContext translationContext,
ErrorReporter errorReporter,
TranslateExprNodeVisitor exprTranslator) {
// ------ Generate the expression for the original data to pass ------
Expression data... | java | public Expression genObjToPass(
CallNode callNode,
TemplateAliases templateAliases,
TranslationContext translationContext,
ErrorReporter errorReporter,
TranslateExprNodeVisitor exprTranslator) {
// ------ Generate the expression for the original data to pass ------
Expression data... | [
"public",
"Expression",
"genObjToPass",
"(",
"CallNode",
"callNode",
",",
"TemplateAliases",
"templateAliases",
",",
"TranslationContext",
"translationContext",
",",
"ErrorReporter",
"errorReporter",
",",
"TranslateExprNodeVisitor",
"exprTranslator",
")",
"{",
"// ------ Gene... | Generates the JS expression for the object to pass in a given call.
<p>Important: If there are CallParamContentNode children whose contents are not computable as
JS expressions, then this function assumes that, elsewhere, code has been generated to define
their respective 'param<n>' temporary variables.
<p>Here... | [
"Generates",
"the",
"JS",
"expression",
"for",
"the",
"object",
"to",
"pass",
"in",
"a",
"given",
"call",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/GenCallCodeUtils.java#L261-L331 |
53,785 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/GenCallCodeUtils.java | GenCallCodeUtils.maybeWrapContent | protected Expression maybeWrapContent(
CodeChunk.Generator generator, CallParamContentNode node, Expression content) {
if (node.getContentKind() == null) {
return content;
}
// Use the internal blocks wrapper, to maintain falsiness of empty string
return sanitizedContentOrdainerFunctionForI... | java | protected Expression maybeWrapContent(
CodeChunk.Generator generator, CallParamContentNode node, Expression content) {
if (node.getContentKind() == null) {
return content;
}
// Use the internal blocks wrapper, to maintain falsiness of empty string
return sanitizedContentOrdainerFunctionForI... | [
"protected",
"Expression",
"maybeWrapContent",
"(",
"CodeChunk",
".",
"Generator",
"generator",
",",
"CallParamContentNode",
"node",
",",
"Expression",
"content",
")",
"{",
"if",
"(",
"node",
".",
"getContentKind",
"(",
")",
"==",
"null",
")",
"{",
"return",
"... | If the param node had a content kind specified, it was autoescaped in the corresponding
context. Hence the result of evaluating the param block is wrapped in a SanitizedContent
instance of the appropriate kind.
<p>The expression for the constructor of SanitizedContent of the appropriate kind (e.g., "new
SanitizedHtml"... | [
"If",
"the",
"param",
"node",
"had",
"a",
"content",
"kind",
"specified",
"it",
"was",
"autoescaped",
"in",
"the",
"corresponding",
"context",
".",
"Hence",
"the",
"result",
"of",
"evaluating",
"the",
"param",
"block",
"is",
"wrapped",
"in",
"a",
"SanitizedC... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/GenCallCodeUtils.java#L360-L368 |
53,786 | google/closure-templates | java/src/com/google/template/soy/types/SoyTypeRegistry.java | SoyTypeRegistry.getType | @Nullable
public SoyType getType(String typeName) {
SoyType result = BUILTIN_TYPES.get(typeName);
if (result != null) {
return result;
}
synchronized (lock) {
result = protoTypeCache.get(typeName);
if (result == null) {
GenericDescriptor descriptor = descriptors.get(typeName)... | java | @Nullable
public SoyType getType(String typeName) {
SoyType result = BUILTIN_TYPES.get(typeName);
if (result != null) {
return result;
}
synchronized (lock) {
result = protoTypeCache.get(typeName);
if (result == null) {
GenericDescriptor descriptor = descriptors.get(typeName)... | [
"@",
"Nullable",
"public",
"SoyType",
"getType",
"(",
"String",
"typeName",
")",
"{",
"SoyType",
"result",
"=",
"BUILTIN_TYPES",
".",
"get",
"(",
"typeName",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"synchroniz... | Look up a type by name. Returns null if there is no such type.
@param typeName The fully-qualified name of the type.
@return The type object, or {@code null}. | [
"Look",
"up",
"a",
"type",
"by",
"name",
".",
"Returns",
"null",
"if",
"there",
"is",
"no",
"such",
"type",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/types/SoyTypeRegistry.java#L176-L198 |
53,787 | google/closure-templates | java/src/com/google/template/soy/types/SoyTypeRegistry.java | SoyTypeRegistry.findTypeWithMatchingNamespace | public String findTypeWithMatchingNamespace(String prefix) {
prefix = prefix + ".";
// This must be sorted so that errors are deterministic, or we'll break integration tests.
for (String name : getAllSortedTypeNames()) {
if (name.startsWith(prefix)) {
return name;
}
}
return null... | java | public String findTypeWithMatchingNamespace(String prefix) {
prefix = prefix + ".";
// This must be sorted so that errors are deterministic, or we'll break integration tests.
for (String name : getAllSortedTypeNames()) {
if (name.startsWith(prefix)) {
return name;
}
}
return null... | [
"public",
"String",
"findTypeWithMatchingNamespace",
"(",
"String",
"prefix",
")",
"{",
"prefix",
"=",
"prefix",
"+",
"\".\"",
";",
"// This must be sorted so that errors are deterministic, or we'll break integration tests.",
"for",
"(",
"String",
"name",
":",
"getAllSortedTy... | Finds a type whose top-level namespace is a specified prefix, or null if there are none. | [
"Finds",
"a",
"type",
"whose",
"top",
"-",
"level",
"namespace",
"is",
"a",
"specified",
"prefix",
"or",
"null",
"if",
"there",
"are",
"none",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/types/SoyTypeRegistry.java#L201-L210 |
53,788 | google/closure-templates | java/src/com/google/template/soy/types/SoyTypeRegistry.java | SoyTypeRegistry.getAllSortedTypeNames | public Iterable<String> getAllSortedTypeNames() {
synchronized (lock) {
if (lazyAllSortedTypeNames == null) {
lazyAllSortedTypeNames =
Stream.concat(BUILTIN_TYPES.keySet().stream(), descriptors.keySet().stream())
.sorted()
.collect(toImmutableList());
... | java | public Iterable<String> getAllSortedTypeNames() {
synchronized (lock) {
if (lazyAllSortedTypeNames == null) {
lazyAllSortedTypeNames =
Stream.concat(BUILTIN_TYPES.keySet().stream(), descriptors.keySet().stream())
.sorted()
.collect(toImmutableList());
... | [
"public",
"Iterable",
"<",
"String",
">",
"getAllSortedTypeNames",
"(",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"lazyAllSortedTypeNames",
"==",
"null",
")",
"{",
"lazyAllSortedTypeNames",
"=",
"Stream",
".",
"concat",
"(",
"BUILTIN_TYPES",
... | Gets all known types, sorted alphabetically. | [
"Gets",
"all",
"known",
"types",
"sorted",
"alphabetically",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/types/SoyTypeRegistry.java#L213-L223 |
53,789 | google/closure-templates | java/src/com/google/template/soy/types/SoyTypeRegistry.java | SoyTypeRegistry.getOrCreateUnionType | public SoyType getOrCreateUnionType(Collection<SoyType> members) {
SoyType type = UnionType.of(members);
if (type.getKind() == SoyType.Kind.UNION) {
type = unionTypes.intern((UnionType) type);
}
return type;
} | java | public SoyType getOrCreateUnionType(Collection<SoyType> members) {
SoyType type = UnionType.of(members);
if (type.getKind() == SoyType.Kind.UNION) {
type = unionTypes.intern((UnionType) type);
}
return type;
} | [
"public",
"SoyType",
"getOrCreateUnionType",
"(",
"Collection",
"<",
"SoyType",
">",
"members",
")",
"{",
"SoyType",
"type",
"=",
"UnionType",
".",
"of",
"(",
"members",
")",
";",
"if",
"(",
"type",
".",
"getKind",
"(",
")",
"==",
"SoyType",
".",
"Kind",... | Factory function which creates a union type, given the member types. This folds identical union
types together.
@param members The members of the union.
@return The union type. | [
"Factory",
"function",
"which",
"creates",
"a",
"union",
"type",
"given",
"the",
"member",
"types",
".",
"This",
"folds",
"identical",
"union",
"types",
"together",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/types/SoyTypeRegistry.java#L270-L276 |
53,790 | google/closure-templates | java/src/com/google/template/soy/msgs/restricted/SoyMsgRawTextPart.java | SoyMsgRawTextPart.of | public static SoyMsgRawTextPart of(String rawText) {
int utf8Length = Utf8.encodedLength(rawText);
// Determine whether UTF8 or UTF16 uses less memory, and choose between one of the two internal
// implementations. char[] is preferred if the sizes are equal because it is faster to turn
// back into a S... | java | public static SoyMsgRawTextPart of(String rawText) {
int utf8Length = Utf8.encodedLength(rawText);
// Determine whether UTF8 or UTF16 uses less memory, and choose between one of the two internal
// implementations. char[] is preferred if the sizes are equal because it is faster to turn
// back into a S... | [
"public",
"static",
"SoyMsgRawTextPart",
"of",
"(",
"String",
"rawText",
")",
"{",
"int",
"utf8Length",
"=",
"Utf8",
".",
"encodedLength",
"(",
"rawText",
")",
";",
"// Determine whether UTF8 or UTF16 uses less memory, and choose between one of the two internal",
"// implemen... | Returns a SoyMsgRawTextPart representing the specified raw text string. | [
"Returns",
"a",
"SoyMsgRawTextPart",
"representing",
"the",
"specified",
"raw",
"text",
"string",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/restricted/SoyMsgRawTextPart.java#L37-L54 |
53,791 | google/closure-templates | java/src/com/google/template/soy/exprtree/FunctionNode.java | FunctionNode.isPure | public boolean isPure() {
if (soyFunction instanceof BuiltinFunction) {
return ((BuiltinFunction) soyFunction).isPure();
}
return soyFunction.getClass().isAnnotationPresent(SoyPureFunction.class);
} | java | public boolean isPure() {
if (soyFunction instanceof BuiltinFunction) {
return ((BuiltinFunction) soyFunction).isPure();
}
return soyFunction.getClass().isAnnotationPresent(SoyPureFunction.class);
} | [
"public",
"boolean",
"isPure",
"(",
")",
"{",
"if",
"(",
"soyFunction",
"instanceof",
"BuiltinFunction",
")",
"{",
"return",
"(",
"(",
"BuiltinFunction",
")",
"soyFunction",
")",
".",
"isPure",
"(",
")",
";",
"}",
"return",
"soyFunction",
".",
"getClass",
... | Whether or not this function is pure.
<p>See {@link SoyPureFunction} for the definition of a pure function. | [
"Whether",
"or",
"not",
"this",
"function",
"is",
"pure",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/exprtree/FunctionNode.java#L156-L161 |
53,792 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/PyCodeBuilder.java | PyCodeBuilder.addToOutputVar | void addToOutputVar(PyExpr pyExpr) {
boolean isList = pyExpr instanceof PyListExpr;
if (isList && !getOutputVarIsInited()) {
appendLine(getOutputVarName(), " = ", pyExpr.getText());
} else {
initOutputVarIfNecessary();
String function = isList ? ".extend(" : ".append(";
appendLine(ge... | java | void addToOutputVar(PyExpr pyExpr) {
boolean isList = pyExpr instanceof PyListExpr;
if (isList && !getOutputVarIsInited()) {
appendLine(getOutputVarName(), " = ", pyExpr.getText());
} else {
initOutputVarIfNecessary();
String function = isList ? ".extend(" : ".append(";
appendLine(ge... | [
"void",
"addToOutputVar",
"(",
"PyExpr",
"pyExpr",
")",
"{",
"boolean",
"isList",
"=",
"pyExpr",
"instanceof",
"PyListExpr",
";",
"if",
"(",
"isList",
"&&",
"!",
"getOutputVarIsInited",
"(",
")",
")",
"{",
"appendLine",
"(",
"getOutputVarName",
"(",
")",
","... | Add a single PyExpr object to the output variable. | [
"Add",
"a",
"single",
"PyExpr",
"object",
"to",
"the",
"output",
"variable",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/PyCodeBuilder.java#L118-L128 |
53,793 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/PyCodeBuilder.java | PyCodeBuilder.getOutputAsString | PyStringExpr getOutputAsString() {
Preconditions.checkState(getOutputVarName() != null);
initOutputVarIfNecessary();
return new PyListExpr(getOutputVarName(), Integer.MAX_VALUE).toPyString();
} | java | PyStringExpr getOutputAsString() {
Preconditions.checkState(getOutputVarName() != null);
initOutputVarIfNecessary();
return new PyListExpr(getOutputVarName(), Integer.MAX_VALUE).toPyString();
} | [
"PyStringExpr",
"getOutputAsString",
"(",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"getOutputVarName",
"(",
")",
"!=",
"null",
")",
";",
"initOutputVarIfNecessary",
"(",
")",
";",
"return",
"new",
"PyListExpr",
"(",
"getOutputVarName",
"(",
")",
",",
... | Provide the output object as a string. Since we store all data in the output variables as a
list for concatenation performance, this step does the joining to convert the output into a
String.
@return A PyExpr object of the output joined into a String. | [
"Provide",
"the",
"output",
"object",
"as",
"a",
"string",
".",
"Since",
"we",
"store",
"all",
"data",
"in",
"the",
"output",
"variables",
"as",
"a",
"list",
"for",
"concatenation",
"performance",
"this",
"step",
"does",
"the",
"joining",
"to",
"convert",
... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/PyCodeBuilder.java#L137-L142 |
53,794 | google/closure-templates | java/src/com/google/template/soy/soytree/MsgNode.java | MsgNode.getAndRemoveGenderExprs | @Nullable
public List<ExprRootNode> getAndRemoveGenderExprs() {
List<ExprRootNode> genderExprs = this.genderExprs;
this.genderExprs = null;
return genderExprs;
} | java | @Nullable
public List<ExprRootNode> getAndRemoveGenderExprs() {
List<ExprRootNode> genderExprs = this.genderExprs;
this.genderExprs = null;
return genderExprs;
} | [
"@",
"Nullable",
"public",
"List",
"<",
"ExprRootNode",
">",
"getAndRemoveGenderExprs",
"(",
")",
"{",
"List",
"<",
"ExprRootNode",
">",
"genderExprs",
"=",
"this",
".",
"genderExprs",
";",
"this",
".",
"genderExprs",
"=",
"null",
";",
"return",
"genderExprs",... | Returns the list of expressions for gender values and sets that field to null.
<p>Note that this node's command text will still contain the substring genders="...". We think
this is okay since the command text is only used for reporting errors (in fact, it might be
good as a reminder of how the msg was originally writ... | [
"Returns",
"the",
"list",
"of",
"expressions",
"for",
"gender",
"values",
"and",
"sets",
"that",
"field",
"to",
"null",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/MsgNode.java#L265-L270 |
53,795 | google/closure-templates | java/src/com/google/template/soy/error/ErrorReporter.java | ErrorReporter.create | public static ErrorReporter create(Map<String, SoyFileSupplier> filePathsToSuppliers) {
return new ErrorReporterImpl(ImmutableMap.copyOf(filePathsToSuppliers));
} | java | public static ErrorReporter create(Map<String, SoyFileSupplier> filePathsToSuppliers) {
return new ErrorReporterImpl(ImmutableMap.copyOf(filePathsToSuppliers));
} | [
"public",
"static",
"ErrorReporter",
"create",
"(",
"Map",
"<",
"String",
",",
"SoyFileSupplier",
">",
"filePathsToSuppliers",
")",
"{",
"return",
"new",
"ErrorReporterImpl",
"(",
"ImmutableMap",
".",
"copyOf",
"(",
"filePathsToSuppliers",
")",
")",
";",
"}"
] | Creates a new ErrorReporter which can create source snippets from the given files. | [
"Creates",
"a",
"new",
"ErrorReporter",
"which",
"can",
"create",
"source",
"snippets",
"from",
"the",
"given",
"files",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/error/ErrorReporter.java#L34-L36 |
53,796 | google/closure-templates | java/src/com/google/template/soy/shared/internal/SharedRuntime.java | SharedRuntime.equal | public static boolean equal(SoyValue operand0, SoyValue operand1) {
// Treat the case where either is a string specially.
// TODO(gboyer): This should probably handle SanitizedContent == SanitizedContent, even though
// Javascript doesn't handle that case properly. http://b/21461181
if (operand0 instanc... | java | public static boolean equal(SoyValue operand0, SoyValue operand1) {
// Treat the case where either is a string specially.
// TODO(gboyer): This should probably handle SanitizedContent == SanitizedContent, even though
// Javascript doesn't handle that case properly. http://b/21461181
if (operand0 instanc... | [
"public",
"static",
"boolean",
"equal",
"(",
"SoyValue",
"operand0",
",",
"SoyValue",
"operand1",
")",
"{",
"// Treat the case where either is a string specially.",
"// TODO(gboyer): This should probably handle SanitizedContent == SanitizedContent, even though",
"// Javascript doesn't ha... | Custom equality operator that smooths out differences between different Soy runtimes.
<p>This approximates Javascript's behavior, but is much easier to understand. | [
"Custom",
"equality",
"operator",
"that",
"smooths",
"out",
"differences",
"between",
"different",
"Soy",
"runtimes",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/SharedRuntime.java#L39-L50 |
53,797 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/GoogRequire.java | GoogRequire.reference | public Expression reference() {
if (chunk() instanceof VariableDeclaration) {
return id(((VariableDeclaration) chunk()).varName(), ImmutableSet.of(this));
} else {
return dottedIdWithRequires(symbol(), ImmutableSet.of(this));
}
} | java | public Expression reference() {
if (chunk() instanceof VariableDeclaration) {
return id(((VariableDeclaration) chunk()).varName(), ImmutableSet.of(this));
} else {
return dottedIdWithRequires(symbol(), ImmutableSet.of(this));
}
} | [
"public",
"Expression",
"reference",
"(",
")",
"{",
"if",
"(",
"chunk",
"(",
")",
"instanceof",
"VariableDeclaration",
")",
"{",
"return",
"id",
"(",
"(",
"(",
"VariableDeclaration",
")",
"chunk",
"(",
")",
")",
".",
"varName",
"(",
")",
",",
"ImmutableS... | Returns a code chunk that can act as a reference to the required symbol. | [
"Returns",
"a",
"code",
"chunk",
"that",
"can",
"act",
"as",
"a",
"reference",
"to",
"the",
"required",
"symbol",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/GoogRequire.java#L89-L95 |
53,798 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/GoogRequire.java | GoogRequire.merge | public GoogRequire merge(GoogRequire other) {
checkArgument(other.symbol().equals(symbol()));
if (other.equals(this)) {
return this;
}
// if symbols are equal and the references are, then they must differ only by requireType or not
// prefer the non requireType symbol
if ((other.chunk() in... | java | public GoogRequire merge(GoogRequire other) {
checkArgument(other.symbol().equals(symbol()));
if (other.equals(this)) {
return this;
}
// if symbols are equal and the references are, then they must differ only by requireType or not
// prefer the non requireType symbol
if ((other.chunk() in... | [
"public",
"GoogRequire",
"merge",
"(",
"GoogRequire",
"other",
")",
"{",
"checkArgument",
"(",
"other",
".",
"symbol",
"(",
")",
".",
"equals",
"(",
"symbol",
"(",
")",
")",
")",
";",
"if",
"(",
"other",
".",
"equals",
"(",
"this",
")",
")",
"{",
"... | For 2 goog requires with the same symbol. Return the perfered one. | [
"For",
"2",
"goog",
"requires",
"with",
"the",
"same",
"symbol",
".",
"Return",
"the",
"perfered",
"one",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/GoogRequire.java#L116-L140 |
53,799 | google/closure-templates | java/src/com/google/template/soy/incrementaldomsrc/GenIncrementalDomCodeVisitor.java | GenIncrementalDomCodeVisitor.incrementKeyForTemplate | private Expression incrementKeyForTemplate(TemplateNode template) {
Holder<Integer> keyCounter = keyCounterStack.peek();
return JsRuntime.XID.call(
Expression.stringLiteral(template.getTemplateName() + "-" + keyCounter.value++));
} | java | private Expression incrementKeyForTemplate(TemplateNode template) {
Holder<Integer> keyCounter = keyCounterStack.peek();
return JsRuntime.XID.call(
Expression.stringLiteral(template.getTemplateName() + "-" + keyCounter.value++));
} | [
"private",
"Expression",
"incrementKeyForTemplate",
"(",
"TemplateNode",
"template",
")",
"{",
"Holder",
"<",
"Integer",
">",
"keyCounter",
"=",
"keyCounterStack",
".",
"peek",
"(",
")",
";",
"return",
"JsRuntime",
".",
"XID",
".",
"call",
"(",
"Expression",
"... | Returns a unique key for the template. This has the side-effect of incrementing the current
keyCounter at the top of the stack. | [
"Returns",
"a",
"unique",
"key",
"for",
"the",
"template",
".",
"This",
"has",
"the",
"side",
"-",
"effect",
"of",
"incrementing",
"the",
"current",
"keyCounter",
"at",
"the",
"top",
"of",
"the",
"stack",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/incrementaldomsrc/GenIncrementalDomCodeVisitor.java#L1026-L1030 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.