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,500 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java | GenPyCallExprVisitor.genObjToPass | public String genObjToPass(CallNode callNode) {
TranslateToPyExprVisitor translator =
new TranslateToPyExprVisitor(localVarStack, pluginValueFactory, errorReporter);
// Generate the expression for the original data to pass.
String dataToPass;
if (callNode.isPassingAllData()) {
dataToPass ... | java | public String genObjToPass(CallNode callNode) {
TranslateToPyExprVisitor translator =
new TranslateToPyExprVisitor(localVarStack, pluginValueFactory, errorReporter);
// Generate the expression for the original data to pass.
String dataToPass;
if (callNode.isPassingAllData()) {
dataToPass ... | [
"public",
"String",
"genObjToPass",
"(",
"CallNode",
"callNode",
")",
"{",
"TranslateToPyExprVisitor",
"translator",
"=",
"new",
"TranslateToPyExprVisitor",
"(",
"localVarStack",
",",
"pluginValueFactory",
",",
"errorReporter",
")",
";",
"// Generate the expression for the ... | Generates the Python expression for the object to pass in a given call. This expression will be
a combination of passed data and additional content params. If both are passed, they'll be
combined into one dictionary.
@param callNode The call to generate code for.
@return The Python expression for the object to pass in... | [
"Generates",
"the",
"Python",
"expression",
"for",
"the",
"object",
"to",
"pass",
"in",
"a",
"given",
"call",
".",
"This",
"expression",
"will",
"be",
"a",
"combination",
"of",
"passed",
"data",
"and",
"additional",
"content",
"params",
".",
"If",
"both",
... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java#L189-L270 |
53,501 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java | GenPyCallExprVisitor.escapeCall | private PyExpr escapeCall(String callExpr, ImmutableList<SoyPrintDirective> directives) {
PyExpr escapedExpr = new PyExpr(callExpr, Integer.MAX_VALUE);
if (directives.isEmpty()) {
return escapedExpr;
}
// Successively wrap each escapedExpr in various directives.
for (SoyPrintDirective directi... | java | private PyExpr escapeCall(String callExpr, ImmutableList<SoyPrintDirective> directives) {
PyExpr escapedExpr = new PyExpr(callExpr, Integer.MAX_VALUE);
if (directives.isEmpty()) {
return escapedExpr;
}
// Successively wrap each escapedExpr in various directives.
for (SoyPrintDirective directi... | [
"private",
"PyExpr",
"escapeCall",
"(",
"String",
"callExpr",
",",
"ImmutableList",
"<",
"SoyPrintDirective",
">",
"directives",
")",
"{",
"PyExpr",
"escapedExpr",
"=",
"new",
"PyExpr",
"(",
"callExpr",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"if",
"(",
... | Escaping directives might apply to the output of the call node, so wrap the output with all
required directives.
@param callExpr The expression text of the call itself.
@param directives The list of the directives to be applied to the call.
@return A PyExpr containing the call expression with all directives applied. | [
"Escaping",
"directives",
"might",
"apply",
"to",
"the",
"output",
"of",
"the",
"call",
"node",
"so",
"wrap",
"the",
"output",
"with",
"all",
"required",
"directives",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java#L280-L296 |
53,502 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java | GenPyCallExprVisitor.getLocalTemplateName | static String getLocalTemplateName(TemplateNode node) {
String templateName = node.getPartialTemplateName().substring(1);
if (node.getVisibility() == Visibility.PRIVATE) {
return "__" + templateName;
}
return templateName;
} | java | static String getLocalTemplateName(TemplateNode node) {
String templateName = node.getPartialTemplateName().substring(1);
if (node.getVisibility() == Visibility.PRIVATE) {
return "__" + templateName;
}
return templateName;
} | [
"static",
"String",
"getLocalTemplateName",
"(",
"TemplateNode",
"node",
")",
"{",
"String",
"templateName",
"=",
"node",
".",
"getPartialTemplateName",
"(",
")",
".",
"substring",
"(",
"1",
")",
";",
"if",
"(",
"node",
".",
"getVisibility",
"(",
")",
"==",
... | Returns the python name for the template. Suitable for calling within the same module. | [
"Returns",
"the",
"python",
"name",
"for",
"the",
"template",
".",
"Suitable",
"for",
"calling",
"within",
"the",
"same",
"module",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java#L299-L305 |
53,503 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.checkConformance | void checkConformance() {
resetErrorReporter();
// to check conformance we only need to run as much as it takes to execute the SoyConformance
// pass.
parse(
passManagerBuilder()
// We have to set disableAllTypeChecking to make sure default parameter types don't
// break ... | java | void checkConformance() {
resetErrorReporter();
// to check conformance we only need to run as much as it takes to execute the SoyConformance
// pass.
parse(
passManagerBuilder()
// We have to set disableAllTypeChecking to make sure default parameter types don't
// break ... | [
"void",
"checkConformance",
"(",
")",
"{",
"resetErrorReporter",
"(",
")",
";",
"// to check conformance we only need to run as much as it takes to execute the SoyConformance",
"// pass.",
"parse",
"(",
"passManagerBuilder",
"(",
")",
"// We have to set disableAllTypeChecking to make... | A simple tool to enforce conformance and only conformance. | [
"A",
"simple",
"tool",
"to",
"enforce",
"conformance",
"and",
"only",
"conformance",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L642-L660 |
53,504 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.extractAndWriteMsgs | public void extractAndWriteMsgs(
SoyMsgBundleHandler msgBundleHandler, OutputFileOptions options, ByteSink output)
throws IOException {
resetErrorReporter();
SoyMsgBundle bundle = doExtractMsgs();
msgBundleHandler.writeExtractedMsgs(bundle, options, output, errorReporter);
throwIfErrorsPrese... | java | public void extractAndWriteMsgs(
SoyMsgBundleHandler msgBundleHandler, OutputFileOptions options, ByteSink output)
throws IOException {
resetErrorReporter();
SoyMsgBundle bundle = doExtractMsgs();
msgBundleHandler.writeExtractedMsgs(bundle, options, output, errorReporter);
throwIfErrorsPrese... | [
"public",
"void",
"extractAndWriteMsgs",
"(",
"SoyMsgBundleHandler",
"msgBundleHandler",
",",
"OutputFileOptions",
"options",
",",
"ByteSink",
"output",
")",
"throws",
"IOException",
"{",
"resetErrorReporter",
"(",
")",
";",
"SoyMsgBundle",
"bundle",
"=",
"doExtractMsgs... | Extracts all messages from this Soy file set and writes the messages to an output sink.
@param msgBundleHandler Handler to write the messages.
@param options Options to configure how to write the extracted messages.
@param output Where to write the extracted messages.
@throws IOException If there are errors writing to... | [
"Extracts",
"all",
"messages",
"from",
"this",
"Soy",
"file",
"set",
"and",
"writes",
"the",
"messages",
"to",
"an",
"output",
"sink",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L684-L692 |
53,505 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.doExtractMsgs | private SoyMsgBundle doExtractMsgs() {
// extractMsgs disables a bunch of passes since it is typically not configured with things
// like global definitions, type definitions, plugins, etc.
SoyFileSetNode soyTree =
parse(
passManagerBuilder()
.allowUnknownGlobals(... | java | private SoyMsgBundle doExtractMsgs() {
// extractMsgs disables a bunch of passes since it is typically not configured with things
// like global definitions, type definitions, plugins, etc.
SoyFileSetNode soyTree =
parse(
passManagerBuilder()
.allowUnknownGlobals(... | [
"private",
"SoyMsgBundle",
"doExtractMsgs",
"(",
")",
"{",
"// extractMsgs disables a bunch of passes since it is typically not configured with things",
"// like global definitions, type definitions, plugins, etc.",
"SoyFileSetNode",
"soyTree",
"=",
"parse",
"(",
"passManagerBuilder",
"(... | Performs the parsing and extraction logic. | [
"Performs",
"the",
"parsing",
"and",
"extraction",
"logic",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L695-L722 |
53,506 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.compileForServerRendering | private ServerCompilationPrimitives compileForServerRendering() {
ParseResult result = parse();
throwIfErrorsPresent();
SoyFileSetNode soyTree = result.fileSet();
TemplateRegistry registry = result.registry();
// Clear the SoyDoc strings because they use unnecessary memory, unless we have a cache, ... | java | private ServerCompilationPrimitives compileForServerRendering() {
ParseResult result = parse();
throwIfErrorsPresent();
SoyFileSetNode soyTree = result.fileSet();
TemplateRegistry registry = result.registry();
// Clear the SoyDoc strings because they use unnecessary memory, unless we have a cache, ... | [
"private",
"ServerCompilationPrimitives",
"compileForServerRendering",
"(",
")",
"{",
"ParseResult",
"result",
"=",
"parse",
"(",
")",
";",
"throwIfErrorsPresent",
"(",
")",
";",
"SoyFileSetNode",
"soyTree",
"=",
"result",
".",
"fileSet",
"(",
")",
";",
"TemplateR... | Runs common compiler logic shared by tofu and jbcsrc backends. | [
"Runs",
"common",
"compiler",
"logic",
"shared",
"by",
"tofu",
"and",
"jbcsrc",
"backends",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L857-L871 |
53,507 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.compileToIncrementalDomSrc | public List<String> compileToIncrementalDomSrc(SoyIncrementalDomSrcOptions jsSrcOptions) {
resetErrorReporter();
// For incremental dom backend, we don't desugar HTML nodes since it requires HTML context.
ParseResult result = parse(passManagerBuilder().desugarHtmlNodes(false));
throwIfErrorsPresent();
... | java | public List<String> compileToIncrementalDomSrc(SoyIncrementalDomSrcOptions jsSrcOptions) {
resetErrorReporter();
// For incremental dom backend, we don't desugar HTML nodes since it requires HTML context.
ParseResult result = parse(passManagerBuilder().desugarHtmlNodes(false));
throwIfErrorsPresent();
... | [
"public",
"List",
"<",
"String",
">",
"compileToIncrementalDomSrc",
"(",
"SoyIncrementalDomSrcOptions",
"jsSrcOptions",
")",
"{",
"resetErrorReporter",
"(",
")",
";",
"// For incremental dom backend, we don't desugar HTML nodes since it requires HTML context.",
"ParseResult",
"resu... | Compiles this Soy file set into iDOM source code files and returns these JS files as a list of
strings, one per file.
@param jsSrcOptions The compilation options for the JS Src output target.
@return A list of strings where each string represents the JS source code that belongs in one
JS file. The generated JS files c... | [
"Compiles",
"this",
"Soy",
"file",
"set",
"into",
"iDOM",
"source",
"code",
"files",
"and",
"returns",
"these",
"JS",
"files",
"as",
"a",
"list",
"of",
"strings",
"one",
"per",
"file",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L927-L938 |
53,508 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.compileToPySrcFiles | void compileToPySrcFiles(String outputPathFormat, SoyPySrcOptions pySrcOptions)
throws IOException {
resetErrorReporter();
ParseResult result = parse();
throwIfErrorsPresent();
new PySrcMain(scopedData.enterable())
.genPyFiles(result.fileSet(), pySrcOptions, outputPathFormat, errorReporter... | java | void compileToPySrcFiles(String outputPathFormat, SoyPySrcOptions pySrcOptions)
throws IOException {
resetErrorReporter();
ParseResult result = parse();
throwIfErrorsPresent();
new PySrcMain(scopedData.enterable())
.genPyFiles(result.fileSet(), pySrcOptions, outputPathFormat, errorReporter... | [
"void",
"compileToPySrcFiles",
"(",
"String",
"outputPathFormat",
",",
"SoyPySrcOptions",
"pySrcOptions",
")",
"throws",
"IOException",
"{",
"resetErrorReporter",
"(",
")",
";",
"ParseResult",
"result",
"=",
"parse",
"(",
")",
";",
"throwIfErrorsPresent",
"(",
")",
... | Compiles this Soy file set into Python source code files and writes these Python files to disk.
@param outputPathFormat The format string defining how to build the output file path
corresponding to an input file path.
@param pySrcOptions The compilation options for the Python Src output target.
@throws SoyCompilationE... | [
"Compiles",
"this",
"Soy",
"file",
"set",
"into",
"Python",
"source",
"code",
"files",
"and",
"writes",
"these",
"Python",
"files",
"to",
"disk",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L950-L960 |
53,509 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.compileMinimallyForHeaders | ParseResult compileMinimallyForHeaders() {
resetErrorReporter();
ParseResult result =
parse(
passManagerBuilder()
// ResolveExpressionTypesPass resolve types (specifically on default parameter
// values) which is necessary for template metadatas
... | java | ParseResult compileMinimallyForHeaders() {
resetErrorReporter();
ParseResult result =
parse(
passManagerBuilder()
// ResolveExpressionTypesPass resolve types (specifically on default parameter
// values) which is necessary for template metadatas
... | [
"ParseResult",
"compileMinimallyForHeaders",
"(",
")",
"{",
"resetErrorReporter",
"(",
")",
";",
"ParseResult",
"result",
"=",
"parse",
"(",
"passManagerBuilder",
"(",
")",
"// ResolveExpressionTypesPass resolve types (specifically on default parameter",
"// values) which is nece... | Performs the minimal amount of work needed to calculate TemplateMetadata objects for header
compilation. | [
"Performs",
"the",
"minimal",
"amount",
"of",
"work",
"needed",
"to",
"calculate",
"TemplateMetadata",
"objects",
"for",
"header",
"compilation",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L966-L981 |
53,510 | google/closure-templates | java/src/com/google/template/soy/SoyFileSet.java | SoyFileSet.reportWarnings | private void reportWarnings() {
ImmutableList<SoyError> warnings = errorReporter.getWarnings();
if (warnings.isEmpty()) {
return;
}
// this is a custom feature used by the integration test suite.
if (generalOptions.getExperimentalFeatures().contains("testonly_throw_on_warnings")) {
error... | java | private void reportWarnings() {
ImmutableList<SoyError> warnings = errorReporter.getWarnings();
if (warnings.isEmpty()) {
return;
}
// this is a custom feature used by the integration test suite.
if (generalOptions.getExperimentalFeatures().contains("testonly_throw_on_warnings")) {
error... | [
"private",
"void",
"reportWarnings",
"(",
")",
"{",
"ImmutableList",
"<",
"SoyError",
">",
"warnings",
"=",
"errorReporter",
".",
"getWarnings",
"(",
")",
";",
"if",
"(",
"warnings",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"// this is a cus... | Reports warnings ot the user configured warning sink. Should be called at the end of successful
compiles. | [
"Reports",
"warnings",
"ot",
"the",
"user",
"configured",
"warning",
"sink",
".",
"Should",
"be",
"called",
"at",
"the",
"end",
"of",
"successful",
"compiles",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyFileSet.java#L1058-L1079 |
53,511 | google/closure-templates | java/src/com/google/template/soy/msgs/restricted/CompactInterner.java | CompactInterner.intern | @SuppressWarnings("unchecked") // If a.equals(b) then a and b have the same type.
public synchronized <T> T intern(T value) {
Preconditions.checkNotNull(value);
// Use a pseudo-random number generator to mix up the high and low bits of the hash code.
Random generator = new java.util.Random(value.hashCode... | java | @SuppressWarnings("unchecked") // If a.equals(b) then a and b have the same type.
public synchronized <T> T intern(T value) {
Preconditions.checkNotNull(value);
// Use a pseudo-random number generator to mix up the high and low bits of the hash code.
Random generator = new java.util.Random(value.hashCode... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// If a.equals(b) then a and b have the same type.",
"public",
"synchronized",
"<",
"T",
">",
"T",
"intern",
"(",
"T",
"value",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"value",
")",
";",
"// Use a pse... | Returns either the input, or an instance that equals it that was previously passed to this
method.
<p>This operation performs in amortized constant time. | [
"Returns",
"either",
"the",
"input",
"or",
"an",
"instance",
"that",
"equals",
"it",
"that",
"was",
"previously",
"passed",
"to",
"this",
"method",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/restricted/CompactInterner.java#L87-L119 |
53,512 | google/closure-templates | java/src/com/google/template/soy/msgs/restricted/CompactInterner.java | CompactInterner.rehashIfNeeded | @GuardedBy("this")
private void rehashIfNeeded() {
int currentSize = table.length;
if (currentSize - count >= currentSize / (MAX_EXPECTED_COLLISION_COUNT + 1)) {
// Still enough overhead.
return;
}
Object[] oldTable = table;
// Grow the table so it increases by 1 / GROWTH_DENOMINATOR.... | java | @GuardedBy("this")
private void rehashIfNeeded() {
int currentSize = table.length;
if (currentSize - count >= currentSize / (MAX_EXPECTED_COLLISION_COUNT + 1)) {
// Still enough overhead.
return;
}
Object[] oldTable = table;
// Grow the table so it increases by 1 / GROWTH_DENOMINATOR.... | [
"@",
"GuardedBy",
"(",
"\"this\"",
")",
"private",
"void",
"rehashIfNeeded",
"(",
")",
"{",
"int",
"currentSize",
"=",
"table",
".",
"length",
";",
"if",
"(",
"currentSize",
"-",
"count",
">=",
"currentSize",
"/",
"(",
"MAX_EXPECTED_COLLISION_COUNT",
"+",
"1... | Doubles the table size. | [
"Doubles",
"the",
"table",
"size",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/restricted/CompactInterner.java#L122-L142 |
53,513 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/MsgCompiler.java | MsgCompiler.handleBasicTranslation | private Statement handleBasicTranslation(
List<SoyPrintDirective> escapingDirectives, Expression soyMsgParts) {
// optimize for simple constant translations (very common)
// this becomes: renderContext.getSoyMessge(<id>).getParts().get(0).getRawText()
SoyExpression text =
SoyExpression.forStri... | java | private Statement handleBasicTranslation(
List<SoyPrintDirective> escapingDirectives, Expression soyMsgParts) {
// optimize for simple constant translations (very common)
// this becomes: renderContext.getSoyMessge(<id>).getParts().get(0).getRawText()
SoyExpression text =
SoyExpression.forStri... | [
"private",
"Statement",
"handleBasicTranslation",
"(",
"List",
"<",
"SoyPrintDirective",
">",
"escapingDirectives",
",",
"Expression",
"soyMsgParts",
")",
"{",
"// optimize for simple constant translations (very common)",
"// this becomes: renderContext.getSoyMessge(<id>).getParts().ge... | Handles a translation consisting of a single raw text node. | [
"Handles",
"a",
"translation",
"consisting",
"of",
"a",
"single",
"raw",
"text",
"node",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/MsgCompiler.java#L263-L279 |
53,514 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/MsgCompiler.java | MsgCompiler.handleTranslationWithPlaceholders | private Statement handleTranslationWithPlaceholders(
MsgNode msg,
ImmutableList<SoyPrintDirective> escapingDirectives,
Expression soyMsgParts,
Expression locale,
MsgPartsAndIds partsAndId) {
// We need to render placeholders into a buffer and then pack them into a map to pass to
//... | java | private Statement handleTranslationWithPlaceholders(
MsgNode msg,
ImmutableList<SoyPrintDirective> escapingDirectives,
Expression soyMsgParts,
Expression locale,
MsgPartsAndIds partsAndId) {
// We need to render placeholders into a buffer and then pack them into a map to pass to
//... | [
"private",
"Statement",
"handleTranslationWithPlaceholders",
"(",
"MsgNode",
"msg",
",",
"ImmutableList",
"<",
"SoyPrintDirective",
">",
"escapingDirectives",
",",
"Expression",
"soyMsgParts",
",",
"Expression",
"locale",
",",
"MsgPartsAndIds",
"partsAndId",
")",
"{",
"... | Handles a complex message with placeholders. | [
"Handles",
"a",
"complex",
"message",
"with",
"placeholders",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/MsgCompiler.java#L282-L376 |
53,515 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/MsgCompiler.java | MsgCompiler.addNodeToPlaceholderMap | private Function<Expression, Statement> addNodeToPlaceholderMap(
String mapKey, StandaloneNode node) {
return putToMapFunction(
mapKey,
placeholderCompiler.compileToSoyValueProvider(
mapKey,
node,
/* prefix= */ ExtraCodeCompiler.NO_OP,
/* suffix=... | java | private Function<Expression, Statement> addNodeToPlaceholderMap(
String mapKey, StandaloneNode node) {
return putToMapFunction(
mapKey,
placeholderCompiler.compileToSoyValueProvider(
mapKey,
node,
/* prefix= */ ExtraCodeCompiler.NO_OP,
/* suffix=... | [
"private",
"Function",
"<",
"Expression",
",",
"Statement",
">",
"addNodeToPlaceholderMap",
"(",
"String",
"mapKey",
",",
"StandaloneNode",
"node",
")",
"{",
"return",
"putToMapFunction",
"(",
"mapKey",
",",
"placeholderCompiler",
".",
"compileToSoyValueProvider",
"("... | Returns a statement that adds the content rendered by the call to the map.
@param mapKey The map key
@param node The node | [
"Returns",
"a",
"statement",
"that",
"adds",
"the",
"content",
"rendered",
"by",
"the",
"call",
"to",
"the",
"map",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/MsgCompiler.java#L554-L563 |
53,516 | google/closure-templates | java/src/com/google/template/soy/jssrc/restricted/JsExprUtils.java | JsExprUtils.concatJsExprs | public static JsExpr concatJsExprs(List<? extends JsExpr> jsExprs) {
if (jsExprs.isEmpty()) {
return EMPTY_STRING;
}
if (jsExprs.size() == 1) {
return jsExprs.get(0);
}
int plusOpPrec = Operator.PLUS.getPrecedence();
StringBuilder resultSb = new StringBuilder();
boolean isFirs... | java | public static JsExpr concatJsExprs(List<? extends JsExpr> jsExprs) {
if (jsExprs.isEmpty()) {
return EMPTY_STRING;
}
if (jsExprs.size() == 1) {
return jsExprs.get(0);
}
int plusOpPrec = Operator.PLUS.getPrecedence();
StringBuilder resultSb = new StringBuilder();
boolean isFirs... | [
"public",
"static",
"JsExpr",
"concatJsExprs",
"(",
"List",
"<",
"?",
"extends",
"JsExpr",
">",
"jsExprs",
")",
"{",
"if",
"(",
"jsExprs",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"EMPTY_STRING",
";",
"}",
"if",
"(",
"jsExprs",
".",
"size",
"(",
... | Builds one JS expression that computes the concatenation of the given JS expressions. The '+'
operator is used for concatenation. Operands will be protected with an extra pair of
parentheses if and only if needed.
<p>The resulting expression is not guaranteed to be a string if the operands do not produce
strings when ... | [
"Builds",
"one",
"JS",
"expression",
"that",
"computes",
"the",
"concatenation",
"of",
"the",
"given",
"JS",
"expressions",
".",
"The",
"+",
"operator",
"is",
"used",
"for",
"concatenation",
".",
"Operands",
"will",
"be",
"protected",
"with",
"an",
"extra",
... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/restricted/JsExprUtils.java#L53-L88 |
53,517 | google/closure-templates | java/src/com/google/template/soy/jssrc/restricted/JsExprUtils.java | JsExprUtils.wrapWithFunction | @VisibleForTesting
static JsExpr wrapWithFunction(String functionExprText, JsExpr jsExpr) {
Preconditions.checkNotNull(functionExprText);
return new JsExpr(functionExprText + "(" + jsExpr.getText() + ")", Integer.MAX_VALUE);
} | java | @VisibleForTesting
static JsExpr wrapWithFunction(String functionExprText, JsExpr jsExpr) {
Preconditions.checkNotNull(functionExprText);
return new JsExpr(functionExprText + "(" + jsExpr.getText() + ")", Integer.MAX_VALUE);
} | [
"@",
"VisibleForTesting",
"static",
"JsExpr",
"wrapWithFunction",
"(",
"String",
"functionExprText",
",",
"JsExpr",
"jsExpr",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"functionExprText",
")",
";",
"return",
"new",
"JsExpr",
"(",
"functionExprText",
"+",
... | Wraps an expression in a function call.
@param functionExprText expression for the function to invoke, such as a function name or
constructor phrase (such as "new SomeClass").
@param jsExpr the expression to compute the argument to the function
@return a JS expression consisting of a call to the specified function, ap... | [
"Wraps",
"an",
"expression",
"in",
"a",
"function",
"call",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/restricted/JsExprUtils.java#L135-L139 |
53,518 | google/closure-templates | java/src/com/google/template/soy/passes/CombineConsecutiveRawTextNodesPass.java | CombineConsecutiveRawTextNodesPass.mergeRange | @SuppressWarnings("unchecked")
private int mergeRange(ParentSoyNode<?> parent, int start, int lastNonEmptyRawTextNode, int end) {
checkArgument(start < end);
if (start == -1 || end == start + 1) {
return end;
}
// general case, there are N rawtextnodes to merge where n > 1
// merge all the n... | java | @SuppressWarnings("unchecked")
private int mergeRange(ParentSoyNode<?> parent, int start, int lastNonEmptyRawTextNode, int end) {
checkArgument(start < end);
if (start == -1 || end == start + 1) {
return end;
}
// general case, there are N rawtextnodes to merge where n > 1
// merge all the n... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"int",
"mergeRange",
"(",
"ParentSoyNode",
"<",
"?",
">",
"parent",
",",
"int",
"start",
",",
"int",
"lastNonEmptyRawTextNode",
",",
"int",
"end",
")",
"{",
"checkArgument",
"(",
"start",
"<",
"e... | RawTextNodes and if we can remove a RawTextNode, we can also add one. | [
"RawTextNodes",
"and",
"if",
"we",
"can",
"remove",
"a",
"RawTextNode",
"we",
"can",
"also",
"add",
"one",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/passes/CombineConsecutiveRawTextNodesPass.java#L96-L112 |
53,519 | google/closure-templates | java/src/com/google/template/soy/base/internal/SoyJarFileWriter.java | SoyJarFileWriter.writeEntry | public void writeEntry(String path, ByteSource contents) throws IOException {
stream.putNextEntry(new ZipEntry(path));
contents.copyTo(stream);
stream.closeEntry();
} | java | public void writeEntry(String path, ByteSource contents) throws IOException {
stream.putNextEntry(new ZipEntry(path));
contents.copyTo(stream);
stream.closeEntry();
} | [
"public",
"void",
"writeEntry",
"(",
"String",
"path",
",",
"ByteSource",
"contents",
")",
"throws",
"IOException",
"{",
"stream",
".",
"putNextEntry",
"(",
"new",
"ZipEntry",
"(",
"path",
")",
")",
";",
"contents",
".",
"copyTo",
"(",
"stream",
")",
";",
... | Writes a single entry to the jar. | [
"Writes",
"a",
"single",
"entry",
"to",
"the",
"jar",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/base/internal/SoyJarFileWriter.java#L40-L44 |
53,520 | google/closure-templates | java/src/com/google/template/soy/base/internal/SoyJarFileWriter.java | SoyJarFileWriter.standardSoyJarManifest | private static Manifest standardSoyJarManifest() {
Manifest mf = new Manifest();
mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
mf.getMainAttributes().put(new Attributes.Name("Created-By"), "soy");
return mf;
} | java | private static Manifest standardSoyJarManifest() {
Manifest mf = new Manifest();
mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
mf.getMainAttributes().put(new Attributes.Name("Created-By"), "soy");
return mf;
} | [
"private",
"static",
"Manifest",
"standardSoyJarManifest",
"(",
")",
"{",
"Manifest",
"mf",
"=",
"new",
"Manifest",
"(",
")",
";",
"mf",
".",
"getMainAttributes",
"(",
")",
".",
"put",
"(",
"Attributes",
".",
"Name",
".",
"MANIFEST_VERSION",
",",
"\"1.0\"",
... | Returns a simple jar manifest. | [
"Returns",
"a",
"simple",
"jar",
"manifest",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/base/internal/SoyJarFileWriter.java#L64-L69 |
53,521 | google/closure-templates | java/src/com/google/template/soy/passes/ResolveExpressionTypesPass.java | ResolveExpressionTypesPass.addTypeSubstitutions | private void addTypeSubstitutions(Map<Wrapper<ExprNode>, SoyType> substitutionsToAdd) {
for (Map.Entry<Wrapper<ExprNode>, SoyType> entry : substitutionsToAdd.entrySet()) {
ExprNode expr = entry.getKey().get();
// Get the existing type
SoyType previousType = expr.getType();
for (TypeSubstitut... | java | private void addTypeSubstitutions(Map<Wrapper<ExprNode>, SoyType> substitutionsToAdd) {
for (Map.Entry<Wrapper<ExprNode>, SoyType> entry : substitutionsToAdd.entrySet()) {
ExprNode expr = entry.getKey().get();
// Get the existing type
SoyType previousType = expr.getType();
for (TypeSubstitut... | [
"private",
"void",
"addTypeSubstitutions",
"(",
"Map",
"<",
"Wrapper",
"<",
"ExprNode",
">",
",",
"SoyType",
">",
"substitutionsToAdd",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Wrapper",
"<",
"ExprNode",
">",
",",
"SoyType",
">",
"entry",
":",
"s... | active substitutions. | [
"active",
"substitutions",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/passes/ResolveExpressionTypesPass.java#L478-L495 |
53,522 | google/closure-templates | java/src/com/google/template/soy/passes/ResolveExpressionTypesPass.java | ResolveExpressionTypesPass.getElementType | private SoyType getElementType(SoyType collectionType, ForNonemptyNode node) {
Preconditions.checkNotNull(collectionType);
switch (collectionType.getKind()) {
case UNKNOWN:
// If we don't know anything about the base type, then make no assumptions
// about the field type.
return Un... | java | private SoyType getElementType(SoyType collectionType, ForNonemptyNode node) {
Preconditions.checkNotNull(collectionType);
switch (collectionType.getKind()) {
case UNKNOWN:
// If we don't know anything about the base type, then make no assumptions
// about the field type.
return Un... | [
"private",
"SoyType",
"getElementType",
"(",
"SoyType",
"collectionType",
",",
"ForNonemptyNode",
"node",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"collectionType",
")",
";",
"switch",
"(",
"collectionType",
".",
"getKind",
"(",
")",
")",
"{",
"case"... | Given a collection type, compute the element type.
@param collectionType The base type.
@param node The ForNonemptyNode being iterated.
@return The type of the elements of the collection. | [
"Given",
"a",
"collection",
"type",
"compute",
"the",
"element",
"type",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/passes/ResolveExpressionTypesPass.java#L511-L550 |
53,523 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java | SoySauceBuilder.withPluginInstances | public SoySauceBuilder withPluginInstances(Map<String, Supplier<Object>> pluginInstances) {
this.userPluginInstances = ImmutableMap.copyOf(pluginInstances);
return this;
} | java | public SoySauceBuilder withPluginInstances(Map<String, Supplier<Object>> pluginInstances) {
this.userPluginInstances = ImmutableMap.copyOf(pluginInstances);
return this;
} | [
"public",
"SoySauceBuilder",
"withPluginInstances",
"(",
"Map",
"<",
"String",
",",
"Supplier",
"<",
"Object",
">",
">",
"pluginInstances",
")",
"{",
"this",
".",
"userPluginInstances",
"=",
"ImmutableMap",
".",
"copyOf",
"(",
"pluginInstances",
")",
";",
"retur... | Sets the plugin instance factories, to be used when constructing the SoySauce.
<p>These are used to supply the runtime instances needed by SoyJavaSourceFunction
implementations which use the {@code callInstanceMethod} API. | [
"Sets",
"the",
"plugin",
"instance",
"factories",
"to",
"be",
"used",
"when",
"constructing",
"the",
"SoySauce",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java#L55-L58 |
53,524 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java | SoySauceBuilder.withFunctions | SoySauceBuilder withFunctions(Map<String, ? extends SoyFunction> userFunctions) {
this.userFunctions = ImmutableMap.copyOf(userFunctions);
return this;
} | java | SoySauceBuilder withFunctions(Map<String, ? extends SoyFunction> userFunctions) {
this.userFunctions = ImmutableMap.copyOf(userFunctions);
return this;
} | [
"SoySauceBuilder",
"withFunctions",
"(",
"Map",
"<",
"String",
",",
"?",
"extends",
"SoyFunction",
">",
"userFunctions",
")",
"{",
"this",
".",
"userFunctions",
"=",
"ImmutableMap",
".",
"copyOf",
"(",
"userFunctions",
")",
";",
"return",
"this",
";",
"}"
] | Sets the user functions. | [
"Sets",
"the",
"user",
"functions",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java#L74-L77 |
53,525 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java | SoySauceBuilder.withDirectives | SoySauceBuilder withDirectives(Map<String, ? extends SoyPrintDirective> userDirectives) {
this.userDirectives = ImmutableMap.copyOf(userDirectives);
return this;
} | java | SoySauceBuilder withDirectives(Map<String, ? extends SoyPrintDirective> userDirectives) {
this.userDirectives = ImmutableMap.copyOf(userDirectives);
return this;
} | [
"SoySauceBuilder",
"withDirectives",
"(",
"Map",
"<",
"String",
",",
"?",
"extends",
"SoyPrintDirective",
">",
"userDirectives",
")",
"{",
"this",
".",
"userDirectives",
"=",
"ImmutableMap",
".",
"copyOf",
"(",
"userDirectives",
")",
";",
"return",
"this",
";",
... | Sets user directives. Not exposed externally because internal directives should be enough, and
additional functionality can be built as SoySourceFunctions. | [
"Sets",
"user",
"directives",
".",
"Not",
"exposed",
"externally",
"because",
"internal",
"directives",
"should",
"be",
"enough",
"and",
"additional",
"functionality",
"can",
"be",
"built",
"as",
"SoySourceFunctions",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java#L83-L86 |
53,526 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java | SoySauceBuilder.build | public SoySauce build() {
if (scopedData == null) {
scopedData = new SoySimpleScope();
}
if (loader == null) {
loader = SoySauceBuilder.class.getClassLoader();
}
return new SoySauceImpl(
new CompiledTemplates(readDelTemplatesFromMetaInf(loader), loader),
scopedData.entera... | java | public SoySauce build() {
if (scopedData == null) {
scopedData = new SoySimpleScope();
}
if (loader == null) {
loader = SoySauceBuilder.class.getClassLoader();
}
return new SoySauceImpl(
new CompiledTemplates(readDelTemplatesFromMetaInf(loader), loader),
scopedData.entera... | [
"public",
"SoySauce",
"build",
"(",
")",
"{",
"if",
"(",
"scopedData",
"==",
"null",
")",
"{",
"scopedData",
"=",
"new",
"SoySimpleScope",
"(",
")",
";",
"}",
"if",
"(",
"loader",
"==",
"null",
")",
"{",
"loader",
"=",
"SoySauceBuilder",
".",
"class",
... | Creates a SoySauce. | [
"Creates",
"a",
"SoySauce",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java#L95-L113 |
53,527 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java | SoySauceBuilder.readDelTemplatesFromMetaInf | private static ImmutableSet<String> readDelTemplatesFromMetaInf(ClassLoader loader) {
try {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
Enumeration<URL> resources = loader.getResources(Names.META_INF_DELTEMPLATE_PATH);
while (resources.hasMoreElements()) {
URL url = reso... | java | private static ImmutableSet<String> readDelTemplatesFromMetaInf(ClassLoader loader) {
try {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
Enumeration<URL> resources = loader.getResources(Names.META_INF_DELTEMPLATE_PATH);
while (resources.hasMoreElements()) {
URL url = reso... | [
"private",
"static",
"ImmutableSet",
"<",
"String",
">",
"readDelTemplatesFromMetaInf",
"(",
"ClassLoader",
"loader",
")",
"{",
"try",
"{",
"ImmutableSet",
".",
"Builder",
"<",
"String",
">",
"builder",
"=",
"ImmutableSet",
".",
"builder",
"(",
")",
";",
"Enum... | Walks all resources with the META_INF_DELTEMPLATE_PATH and collects the deltemplates. | [
"Walks",
"all",
"resources",
"with",
"the",
"META_INF_DELTEMPLATE_PATH",
"and",
"collects",
"the",
"deltemplates",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java#L116-L133 |
53,528 | google/closure-templates | java/src/com/google/template/soy/passes/ShouldEnsureDataIsDefinedVisitor.java | ShouldEnsureDataIsDefinedVisitor.exec | public boolean exec(TemplateNode template) {
boolean hasOptional = false;
for (TemplateParam param : template.getParams()) {
if (param.isRequired()) {
// If there exists a required param, then data should already be defined (no need to
// ensure).
return false;
} else {
... | java | public boolean exec(TemplateNode template) {
boolean hasOptional = false;
for (TemplateParam param : template.getParams()) {
if (param.isRequired()) {
// If there exists a required param, then data should already be defined (no need to
// ensure).
return false;
} else {
... | [
"public",
"boolean",
"exec",
"(",
"TemplateNode",
"template",
")",
"{",
"boolean",
"hasOptional",
"=",
"false",
";",
"for",
"(",
"TemplateParam",
"param",
":",
"template",
".",
"getParams",
"(",
")",
")",
"{",
"if",
"(",
"param",
".",
"isRequired",
"(",
... | Runs this pass on the given template. | [
"Runs",
"this",
"pass",
"on",
"the",
"given",
"template",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/passes/ShouldEnsureDataIsDefinedVisitor.java#L39-L109 |
53,529 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/CodeChunkUtils.java | CodeChunkUtils.checkId | static void checkId(String id) {
if (!ID.matcher(id).matches()) {
throw new IllegalArgumentException(String.format("not a valid js identifier: %s", id));
}
} | java | static void checkId(String id) {
if (!ID.matcher(id).matches()) {
throw new IllegalArgumentException(String.format("not a valid js identifier: %s", id));
}
} | [
"static",
"void",
"checkId",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"!",
"ID",
".",
"matcher",
"(",
"id",
")",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"not a valid js identif... | Validates that the given string is a valid javascript identifier. | [
"Validates",
"that",
"the",
"given",
"string",
"is",
"a",
"valid",
"javascript",
"identifier",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/CodeChunkUtils.java#L44-L48 |
53,530 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/TemplateCompiler.java | TemplateCompiler.compile | Iterable<ClassData> compile() {
List<ClassData> classes = new ArrayList<>();
// first generate the factory
if (templateNode.getVisibility() != Visibility.PRIVATE) {
// Don't generate factory if the template is private. The factories are only
// useful to instantiate templates for calls from ja... | java | Iterable<ClassData> compile() {
List<ClassData> classes = new ArrayList<>();
// first generate the factory
if (templateNode.getVisibility() != Visibility.PRIVATE) {
// Don't generate factory if the template is private. The factories are only
// useful to instantiate templates for calls from ja... | [
"Iterable",
"<",
"ClassData",
">",
"compile",
"(",
")",
"{",
"List",
"<",
"ClassData",
">",
"classes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// first generate the factory",
"if",
"(",
"templateNode",
".",
"getVisibility",
"(",
")",
"!=",
"Visibility... | Returns the list of classes needed to implement this template.
<p>For each template, we generate:
<ul>
<li>A {@link com.google.template.soy.jbcsrc.shared.CompiledTemplate.Factory}
<li>A {@link CompiledTemplate}
<li>A DetachableSoyValueProvider subclass for each {@link LetValueNode} and {@link
CallParamValueNode}
<li>... | [
"Returns",
"the",
"list",
"of",
"classes",
"needed",
"to",
"implement",
"this",
"template",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/TemplateCompiler.java#L157-L194 |
53,531 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/TemplateCompiler.java | TemplateCompiler.generateConstructor | private void generateConstructor(
ImmutableMap<TemplateParam, SoyExpression> defaultParamInitializers) {
final Label start = new Label();
final Label end = new Label();
final LocalVariable thisVar = createThisVar(template.typeInfo(), start, end);
final LocalVariable paramsVar = createLocal("params... | java | private void generateConstructor(
ImmutableMap<TemplateParam, SoyExpression> defaultParamInitializers) {
final Label start = new Label();
final Label end = new Label();
final LocalVariable thisVar = createThisVar(template.typeInfo(), start, end);
final LocalVariable paramsVar = createLocal("params... | [
"private",
"void",
"generateConstructor",
"(",
"ImmutableMap",
"<",
"TemplateParam",
",",
"SoyExpression",
">",
"defaultParamInitializers",
")",
"{",
"final",
"Label",
"start",
"=",
"new",
"Label",
"(",
")",
";",
"final",
"Label",
"end",
"=",
"new",
"Label",
"... | Generate a public constructor that assigns our final field and checks for missing required
params.
<p>This constructor is called by the generate factory classes. | [
"Generate",
"a",
"public",
"constructor",
"that",
"assigns",
"our",
"final",
"field",
"and",
"checks",
"for",
"missing",
"required",
"params",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/TemplateCompiler.java#L381-L415 |
53,532 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Expression.java | Expression.checkTypes | static void checkTypes(ImmutableList<Type> types, Iterable<? extends Expression> exprs) {
int size = Iterables.size(exprs);
checkArgument(
size == types.size(),
"Supplied the wrong number of parameters. Expected %s, got %s",
types.size(),
size);
// checkIsAssignableTo is an n... | java | static void checkTypes(ImmutableList<Type> types, Iterable<? extends Expression> exprs) {
int size = Iterables.size(exprs);
checkArgument(
size == types.size(),
"Supplied the wrong number of parameters. Expected %s, got %s",
types.size(),
size);
// checkIsAssignableTo is an n... | [
"static",
"void",
"checkTypes",
"(",
"ImmutableList",
"<",
"Type",
">",
"types",
",",
"Iterable",
"<",
"?",
"extends",
"Expression",
">",
"exprs",
")",
"{",
"int",
"size",
"=",
"Iterables",
".",
"size",
"(",
"exprs",
")",
";",
"checkArgument",
"(",
"size... | Checks that the given expressions are compatible with the given types. | [
"Checks",
"that",
"the",
"given",
"expressions",
"are",
"compatible",
"with",
"the",
"given",
"types",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java#L167-L182 |
53,533 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Expression.java | Expression.toStatement | public Statement toStatement() {
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
Expression.this.gen(adapter);
switch (resultType().getSize()) {
case 0:
throw new AssertionError("void expressions are not allowed");
case 1:
... | java | public Statement toStatement() {
return new Statement() {
@Override
protected void doGen(CodeBuilder adapter) {
Expression.this.gen(adapter);
switch (resultType().getSize()) {
case 0:
throw new AssertionError("void expressions are not allowed");
case 1:
... | [
"public",
"Statement",
"toStatement",
"(",
")",
"{",
"return",
"new",
"Statement",
"(",
")",
"{",
"@",
"Override",
"protected",
"void",
"doGen",
"(",
"CodeBuilder",
"adapter",
")",
"{",
"Expression",
".",
"this",
".",
"gen",
"(",
"adapter",
")",
";",
"sw... | Convert this expression to a statement, by executing it and throwing away the result.
<p>This is useful for invoking non-void methods when we don't care about the result. | [
"Convert",
"this",
"expression",
"to",
"a",
"statement",
"by",
"executing",
"it",
"and",
"throwing",
"away",
"the",
"result",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java#L277-L296 |
53,534 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Expression.java | Expression.checkedCast | public Expression checkedCast(final Type target) {
checkArgument(
target.getSort() == Type.OBJECT,
"cast targets must be reference types. (%s)",
target.getClassName());
checkArgument(
resultType().getSort() == Type.OBJECT,
"you may only cast from reference types. (%s)",
... | java | public Expression checkedCast(final Type target) {
checkArgument(
target.getSort() == Type.OBJECT,
"cast targets must be reference types. (%s)",
target.getClassName());
checkArgument(
resultType().getSort() == Type.OBJECT,
"you may only cast from reference types. (%s)",
... | [
"public",
"Expression",
"checkedCast",
"(",
"final",
"Type",
"target",
")",
"{",
"checkArgument",
"(",
"target",
".",
"getSort",
"(",
")",
"==",
"Type",
".",
"OBJECT",
",",
"\"cast targets must be reference types. (%s)\"",
",",
"target",
".",
"getClassName",
"(",
... | Returns an expression that performs a checked cast from the current type to the target type.
@throws IllegalArgumentException if either type is not a reference type. | [
"Returns",
"an",
"expression",
"that",
"performs",
"a",
"checked",
"cast",
"from",
"the",
"current",
"type",
"to",
"the",
"target",
"type",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java#L341-L369 |
53,535 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Expression.java | Expression.labelStart | public Expression labelStart(final Label label) {
return new Expression(resultType(), features) {
@Override
protected void doGen(CodeBuilder adapter) {
adapter.mark(label);
Expression.this.gen(adapter);
}
};
} | java | public Expression labelStart(final Label label) {
return new Expression(resultType(), features) {
@Override
protected void doGen(CodeBuilder adapter) {
adapter.mark(label);
Expression.this.gen(adapter);
}
};
} | [
"public",
"Expression",
"labelStart",
"(",
"final",
"Label",
"label",
")",
"{",
"return",
"new",
"Expression",
"(",
"resultType",
"(",
")",
",",
"features",
")",
"{",
"@",
"Override",
"protected",
"void",
"doGen",
"(",
"CodeBuilder",
"adapter",
")",
"{",
"... | Returns a new expression identical to this one but with the given label applied at the start of
the expression. | [
"Returns",
"a",
"new",
"expression",
"identical",
"to",
"this",
"one",
"but",
"with",
"the",
"given",
"label",
"applied",
"at",
"the",
"start",
"of",
"the",
"expression",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java#L400-L408 |
53,536 | google/closure-templates | java/src/com/google/template/soy/soytree/CallBasicNode.java | CallBasicNode.setParamsToRuntimeCheck | public void setParamsToRuntimeCheck(Predicate<String> paramNames) {
checkState(this.paramsToRuntimeTypeCheck == null);
this.paramsToRuntimeTypeCheck = checkNotNull(paramNames);
} | java | public void setParamsToRuntimeCheck(Predicate<String> paramNames) {
checkState(this.paramsToRuntimeTypeCheck == null);
this.paramsToRuntimeTypeCheck = checkNotNull(paramNames);
} | [
"public",
"void",
"setParamsToRuntimeCheck",
"(",
"Predicate",
"<",
"String",
">",
"paramNames",
")",
"{",
"checkState",
"(",
"this",
".",
"paramsToRuntimeTypeCheck",
"==",
"null",
")",
";",
"this",
".",
"paramsToRuntimeTypeCheck",
"=",
"checkNotNull",
"(",
"param... | Sets the names of the params that require runtime type checking against callee's types.
<p>This mechanism is used by the TOFU runtime only to save some work when calling templates. | [
"Sets",
"the",
"names",
"of",
"the",
"params",
"that",
"require",
"runtime",
"type",
"checking",
"against",
"callee",
"s",
"types",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/CallBasicNode.java#L131-L134 |
53,537 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.cleanHtml | public static SanitizedContent cleanHtml(
SoyValue value, Collection<? extends OptionalSafeTag> optionalSafeTags) {
value = normalizeNull(value);
Dir valueDir = null;
if (value instanceof SanitizedContent) {
SanitizedContent sanitizedContent = (SanitizedContent) value;
if (sanitizedContent... | java | public static SanitizedContent cleanHtml(
SoyValue value, Collection<? extends OptionalSafeTag> optionalSafeTags) {
value = normalizeNull(value);
Dir valueDir = null;
if (value instanceof SanitizedContent) {
SanitizedContent sanitizedContent = (SanitizedContent) value;
if (sanitizedContent... | [
"public",
"static",
"SanitizedContent",
"cleanHtml",
"(",
"SoyValue",
"value",
",",
"Collection",
"<",
"?",
"extends",
"OptionalSafeTag",
">",
"optionalSafeTags",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"Dir",
"valueDir",
"=",
"null",
... | Normalizes the input HTML while preserving "safe" tags and the known directionality.
@param optionalSafeTags to add to the basic whitelist of formatting safe tags
@return the normalized input, in the form of {@link SanitizedContent} of {@link
ContentKind#HTML} | [
"Normalizes",
"the",
"input",
"HTML",
"while",
"preserving",
"safe",
"tags",
"and",
"the",
"known",
"directionality",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L99-L111 |
53,538 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.cleanHtml | public static SanitizedContent cleanHtml(
String value, Collection<? extends OptionalSafeTag> optionalSafeTags) {
return cleanHtml(value, null, optionalSafeTags);
} | java | public static SanitizedContent cleanHtml(
String value, Collection<? extends OptionalSafeTag> optionalSafeTags) {
return cleanHtml(value, null, optionalSafeTags);
} | [
"public",
"static",
"SanitizedContent",
"cleanHtml",
"(",
"String",
"value",
",",
"Collection",
"<",
"?",
"extends",
"OptionalSafeTag",
">",
"optionalSafeTags",
")",
"{",
"return",
"cleanHtml",
"(",
"value",
",",
"null",
",",
"optionalSafeTags",
")",
";",
"}"
] | Normalizes the input HTML while preserving "safe" tags. The content directionality is unknown.
@param optionalSafeTags to add to the basic whitelist of formatting safe tags
@return the normalized input, in the form of {@link SanitizedContent} of {@link
ContentKind#HTML} | [
"Normalizes",
"the",
"input",
"HTML",
"while",
"preserving",
"safe",
"tags",
".",
"The",
"content",
"directionality",
"is",
"unknown",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L211-L214 |
53,539 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.cleanHtml | public static SanitizedContent cleanHtml(
String value, Dir contentDir, Collection<? extends OptionalSafeTag> optionalSafeTags) {
return UnsafeSanitizedContentOrdainer.ordainAsSafe(
stripHtmlTags(value, TagWhitelist.FORMATTING.withOptionalSafeTags(optionalSafeTags), true),
ContentKind.HTML,
... | java | public static SanitizedContent cleanHtml(
String value, Dir contentDir, Collection<? extends OptionalSafeTag> optionalSafeTags) {
return UnsafeSanitizedContentOrdainer.ordainAsSafe(
stripHtmlTags(value, TagWhitelist.FORMATTING.withOptionalSafeTags(optionalSafeTags), true),
ContentKind.HTML,
... | [
"public",
"static",
"SanitizedContent",
"cleanHtml",
"(",
"String",
"value",
",",
"Dir",
"contentDir",
",",
"Collection",
"<",
"?",
"extends",
"OptionalSafeTag",
">",
"optionalSafeTags",
")",
"{",
"return",
"UnsafeSanitizedContentOrdainer",
".",
"ordainAsSafe",
"(",
... | Normalizes the input HTML of a given directionality while preserving "safe" tags.
@param optionalSafeTags to add to the basic whitelist of formatting safe tags
@return the normalized input, in the form of {@link SanitizedContent} of {@link
ContentKind#HTML} | [
"Normalizes",
"the",
"input",
"HTML",
"of",
"a",
"given",
"directionality",
"while",
"preserving",
"safe",
"tags",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L223-L229 |
53,540 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.normalizeHtml | public static String normalizeHtml(SoyValue value) {
value = normalizeNull(value);
return normalizeHtml(value.coerceToString());
} | java | public static String normalizeHtml(SoyValue value) {
value = normalizeNull(value);
return normalizeHtml(value.coerceToString());
} | [
"public",
"static",
"String",
"normalizeHtml",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"return",
"normalizeHtml",
"(",
"value",
".",
"coerceToString",
"(",
")",
")",
";",
"}"
] | Normalizes HTML to HTML making sure quotes and other specials are entity encoded. | [
"Normalizes",
"HTML",
"to",
"HTML",
"making",
"sure",
"quotes",
"and",
"other",
"specials",
"are",
"entity",
"encoded",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L283-L286 |
53,541 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.normalizeHtmlNospace | public static String normalizeHtmlNospace(SoyValue value) {
value = normalizeNull(value);
return normalizeHtmlNospace(value.coerceToString());
} | java | public static String normalizeHtmlNospace(SoyValue value) {
value = normalizeNull(value);
return normalizeHtmlNospace(value.coerceToString());
} | [
"public",
"static",
"String",
"normalizeHtmlNospace",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"return",
"normalizeHtmlNospace",
"(",
"value",
".",
"coerceToString",
"(",
")",
")",
";",
"}"
] | Normalizes HTML to HTML making sure quotes, spaces and other specials are entity encoded so
that the result can be safely embedded in a valueless attribute. | [
"Normalizes",
"HTML",
"to",
"HTML",
"making",
"sure",
"quotes",
"spaces",
"and",
"other",
"specials",
"are",
"entity",
"encoded",
"so",
"that",
"the",
"result",
"can",
"be",
"safely",
"embedded",
"in",
"a",
"valueless",
"attribute",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L302-L305 |
53,542 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.escapeHtmlAttribute | public static String escapeHtmlAttribute(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.HTML)) {
// |escapeHtmlAttribute should only be used on attribute values that cannot have tags.
return stripHtmlTags(value.coerceToString(), null,... | java | public static String escapeHtmlAttribute(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.HTML)) {
// |escapeHtmlAttribute should only be used on attribute values that cannot have tags.
return stripHtmlTags(value.coerceToString(), null,... | [
"public",
"static",
"String",
"escapeHtmlAttribute",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"if",
"(",
"isSanitizedContentOfKind",
"(",
"value",
",",
"SanitizedContent",
".",
"ContentKind",
".",
"HTML",
")",
... | Converts the input to HTML by entity escaping, stripping tags in sanitized content so the
result can safely be embedded in an HTML attribute value. | [
"Converts",
"the",
"input",
"to",
"HTML",
"by",
"entity",
"escaping",
"stripping",
"tags",
"in",
"sanitized",
"content",
"so",
"the",
"result",
"can",
"safely",
"be",
"embedded",
"in",
"an",
"HTML",
"attribute",
"value",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L319-L326 |
53,543 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.escapeHtmlAttributeNospace | public static String escapeHtmlAttributeNospace(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.HTML)) {
// |escapeHtmlAttributeNospace should only be used on attribute values that cannot have tags.
return stripHtmlTags(value.coerceToS... | java | public static String escapeHtmlAttributeNospace(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.HTML)) {
// |escapeHtmlAttributeNospace should only be used on attribute values that cannot have tags.
return stripHtmlTags(value.coerceToS... | [
"public",
"static",
"String",
"escapeHtmlAttributeNospace",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"if",
"(",
"isSanitizedContentOfKind",
"(",
"value",
",",
"SanitizedContent",
".",
"ContentKind",
".",
"HTML",
... | Converts plain text to HTML by entity escaping, stripping tags in sanitized content so the
result can safely be embedded in an unquoted HTML attribute value. | [
"Converts",
"plain",
"text",
"to",
"HTML",
"by",
"entity",
"escaping",
"stripping",
"tags",
"in",
"sanitized",
"content",
"so",
"the",
"result",
"can",
"safely",
"be",
"embedded",
"in",
"an",
"unquoted",
"HTML",
"attribute",
"value",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L356-L363 |
53,544 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.escapeUri | public static String escapeUri(SoyValue value) {
value = normalizeNull(value);
return escapeUri(value.coerceToString());
} | java | public static String escapeUri(SoyValue value) {
value = normalizeNull(value);
return escapeUri(value.coerceToString());
} | [
"public",
"static",
"String",
"escapeUri",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"return",
"escapeUri",
"(",
"value",
".",
"coerceToString",
"(",
")",
")",
";",
"}"
] | Converts the input to a piece of a URI by percent encoding the value as UTF-8 bytes. | [
"Converts",
"the",
"input",
"to",
"a",
"piece",
"of",
"a",
"URI",
"by",
"percent",
"encoding",
"the",
"value",
"as",
"UTF",
"-",
"8",
"bytes",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L503-L506 |
53,545 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.filterNormalizeMediaUri | public static String filterNormalizeMediaUri(String value) {
if (EscapingConventions.FilterNormalizeMediaUri.INSTANCE
.getValueFilter()
.matcher(value)
.find()) {
return EscapingConventions.FilterNormalizeMediaUri.INSTANCE.escape(value);
}
logger.log(Level.WARNING, "|filterNorm... | java | public static String filterNormalizeMediaUri(String value) {
if (EscapingConventions.FilterNormalizeMediaUri.INSTANCE
.getValueFilter()
.matcher(value)
.find()) {
return EscapingConventions.FilterNormalizeMediaUri.INSTANCE.escape(value);
}
logger.log(Level.WARNING, "|filterNorm... | [
"public",
"static",
"String",
"filterNormalizeMediaUri",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"EscapingConventions",
".",
"FilterNormalizeMediaUri",
".",
"INSTANCE",
".",
"getValueFilter",
"(",
")",
".",
"matcher",
"(",
"value",
")",
".",
"find",
"(",
... | Checks that a URI is safe to be an image source.
<p>Does not return SanitizedContent as there isn't an appropriate type for this. | [
"Checks",
"that",
"a",
"URI",
"is",
"safe",
"to",
"be",
"an",
"image",
"source",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L582-L591 |
53,546 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.filterTrustedResourceUri | public static String filterTrustedResourceUri(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI)) {
return value.coerceToString();
}
logger.log(Level.WARNING, "|filterTrustedResourceUri received bad value ''{0}''",... | java | public static String filterTrustedResourceUri(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI)) {
return value.coerceToString();
}
logger.log(Level.WARNING, "|filterTrustedResourceUri received bad value ''{0}''",... | [
"public",
"static",
"String",
"filterTrustedResourceUri",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"if",
"(",
"isSanitizedContentOfKind",
"(",
"value",
",",
"SanitizedContent",
".",
"ContentKind",
".",
"TRUSTED_RES... | Makes sure the given input is an instance of either trustedResourceUrl or trustedString. | [
"Makes",
"sure",
"the",
"given",
"input",
"is",
"an",
"instance",
"of",
"either",
"trustedResourceUrl",
"or",
"trustedString",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L607-L614 |
53,547 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.filterImageDataUri | public static SanitizedContent filterImageDataUri(SoyValue value) {
value = normalizeNull(value);
return filterImageDataUri(value.coerceToString());
} | java | public static SanitizedContent filterImageDataUri(SoyValue value) {
value = normalizeNull(value);
return filterImageDataUri(value.coerceToString());
} | [
"public",
"static",
"SanitizedContent",
"filterImageDataUri",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"return",
"filterImageDataUri",
"(",
"value",
".",
"coerceToString",
"(",
")",
")",
";",
"}"
] | Makes sure that the given input is a data URI corresponding to an image.
<p>SanitizedContent kind does not apply -- the directive is also used to ensure no foreign
resources are loaded. | [
"Makes",
"sure",
"that",
"the",
"given",
"input",
"is",
"a",
"data",
"URI",
"corresponding",
"to",
"an",
"image",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L652-L655 |
53,548 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.filterSipUri | public static SanitizedContent filterSipUri(SoyValue value) {
value = normalizeNull(value);
return filterSipUri(value.coerceToString());
} | java | public static SanitizedContent filterSipUri(SoyValue value) {
value = normalizeNull(value);
return filterSipUri(value.coerceToString());
} | [
"public",
"static",
"SanitizedContent",
"filterSipUri",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"return",
"filterSipUri",
"(",
"value",
".",
"coerceToString",
"(",
")",
")",
";",
"}"
] | Makes sure that the given input is a sip URI. | [
"Makes",
"sure",
"that",
"the",
"given",
"input",
"is",
"a",
"sip",
"URI",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L670-L673 |
53,549 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.filterTelUri | public static SanitizedContent filterTelUri(SoyValue value) {
value = normalizeNull(value);
return filterTelUri(value.coerceToString());
} | java | public static SanitizedContent filterTelUri(SoyValue value) {
value = normalizeNull(value);
return filterTelUri(value.coerceToString());
} | [
"public",
"static",
"SanitizedContent",
"filterTelUri",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"return",
"filterTelUri",
"(",
"value",
".",
"coerceToString",
"(",
")",
")",
";",
"}"
] | Makes sure that the given input is a tel URI. | [
"Makes",
"sure",
"that",
"the",
"given",
"input",
"is",
"a",
"tel",
"URI",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L706-L709 |
53,550 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.filterHtmlAttributes | public static String filterHtmlAttributes(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.ATTRIBUTES)) {
// We're guaranteed to be in a case where key=value pairs are expected. However, if it would
// cause issues to directly abut this... | java | public static String filterHtmlAttributes(SoyValue value) {
value = normalizeNull(value);
if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.ATTRIBUTES)) {
// We're guaranteed to be in a case where key=value pairs are expected. However, if it would
// cause issues to directly abut this... | [
"public",
"static",
"String",
"filterHtmlAttributes",
"(",
"SoyValue",
"value",
")",
"{",
"value",
"=",
"normalizeNull",
"(",
"value",
")",
";",
"if",
"(",
"isSanitizedContentOfKind",
"(",
"value",
",",
"SanitizedContent",
".",
"ContentKind",
".",
"ATTRIBUTES",
... | Checks that the input is a valid HTML attribute name with normal keyword or textual content or
known safe attribute content. | [
"Checks",
"that",
"the",
"input",
"is",
"a",
"valid",
"HTML",
"attribute",
"name",
"with",
"normal",
"keyword",
"or",
"textual",
"content",
"or",
"known",
"safe",
"attribute",
"content",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L727-L745 |
53,551 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.filterHtmlAttributes | public static String filterHtmlAttributes(String value) {
if (EscapingConventions.FilterHtmlAttributes.INSTANCE.getValueFilter().matcher(value).find()) {
return value;
}
logger.log(Level.WARNING, "|filterHtmlAttributes received bad value ''{0}''", value);
return EscapingConventions.FilterHtmlAttri... | java | public static String filterHtmlAttributes(String value) {
if (EscapingConventions.FilterHtmlAttributes.INSTANCE.getValueFilter().matcher(value).find()) {
return value;
}
logger.log(Level.WARNING, "|filterHtmlAttributes received bad value ''{0}''", value);
return EscapingConventions.FilterHtmlAttri... | [
"public",
"static",
"String",
"filterHtmlAttributes",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"EscapingConventions",
".",
"FilterHtmlAttributes",
".",
"INSTANCE",
".",
"getValueFilter",
"(",
")",
".",
"matcher",
"(",
"value",
")",
".",
"find",
"(",
")",
... | Checks that the input is a valid HTML attribute name with normal keyword or textual content. | [
"Checks",
"that",
"the",
"input",
"is",
"a",
"valid",
"HTML",
"attribute",
"name",
"with",
"normal",
"keyword",
"or",
"textual",
"content",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L754-L760 |
53,552 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.isSanitizedContentOfKind | private static boolean isSanitizedContentOfKind(
SoyValue value, SanitizedContent.ContentKind kind) {
return value instanceof SanitizedContent && kind == ((SanitizedContent) value).getContentKind();
} | java | private static boolean isSanitizedContentOfKind(
SoyValue value, SanitizedContent.ContentKind kind) {
return value instanceof SanitizedContent && kind == ((SanitizedContent) value).getContentKind();
} | [
"private",
"static",
"boolean",
"isSanitizedContentOfKind",
"(",
"SoyValue",
"value",
",",
"SanitizedContent",
".",
"ContentKind",
"kind",
")",
"{",
"return",
"value",
"instanceof",
"SanitizedContent",
"&&",
"kind",
"==",
"(",
"(",
"SanitizedContent",
")",
"value",
... | True iff the given value is sanitized content of the given kind. | [
"True",
"iff",
"the",
"given",
"value",
"is",
"sanitized",
"content",
"of",
"the",
"given",
"kind",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L877-L880 |
53,553 | google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.embedCssIntoHtmlSlow | private static String embedCssIntoHtmlSlow(
String css, int nextReplacement, boolean searchForEndCData, boolean searchForEndTag) {
// use an array instead of a stringbuilder so we can take advantage of the bulk copying
// routine (String.getChars). For some reason StringBuilder doesn't do this.
char[... | java | private static String embedCssIntoHtmlSlow(
String css, int nextReplacement, boolean searchForEndCData, boolean searchForEndTag) {
// use an array instead of a stringbuilder so we can take advantage of the bulk copying
// routine (String.getChars). For some reason StringBuilder doesn't do this.
char[... | [
"private",
"static",
"String",
"embedCssIntoHtmlSlow",
"(",
"String",
"css",
",",
"int",
"nextReplacement",
",",
"boolean",
"searchForEndCData",
",",
"boolean",
"searchForEndTag",
")",
"{",
"// use an array instead of a stringbuilder so we can take advantage of the bulk copying",... | Called when we know we need to make a replacement.
<p>At least one of {@code searchForEndCData} or {@code searchForEndTag} will be {@code true}.
@param css The css string to modify
@param nextReplacement The location of the first replacement
@param searchForEndCData Whether there are any sequences of {@code ]]>}
@par... | [
"Called",
"when",
"we",
"know",
"we",
"need",
"to",
"make",
"a",
"replacement",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L1156-L1208 |
53,554 | google/closure-templates | java/src/com/google/template/soy/msgs/SoyMsgBundle.java | SoyMsgBundle.getMsgParts | public ImmutableList<SoyMsgPart> getMsgParts(long msgId) {
SoyMsg msg = getMsg(msgId);
return msg == null ? ImmutableList.of() : msg.getParts();
} | java | public ImmutableList<SoyMsgPart> getMsgParts(long msgId) {
SoyMsg msg = getMsg(msgId);
return msg == null ? ImmutableList.of() : msg.getParts();
} | [
"public",
"ImmutableList",
"<",
"SoyMsgPart",
">",
"getMsgParts",
"(",
"long",
"msgId",
")",
"{",
"SoyMsg",
"msg",
"=",
"getMsg",
"(",
"msgId",
")",
";",
"return",
"msg",
"==",
"null",
"?",
"ImmutableList",
".",
"of",
"(",
")",
":",
"msg",
".",
"getPar... | Returns the message parts, or an empty array if there is no such message.
<p>This is useful for rendering only usecases when the rest of the {@link SoyMsg} doesn't
matter. The default implementation is just {@link SoyMsg#getParts} but some subclasses may have
more efficient implementations | [
"Returns",
"the",
"message",
"parts",
"or",
"an",
"empty",
"array",
"if",
"there",
"is",
"no",
"such",
"message",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/SoyMsgBundle.java#L64-L67 |
53,555 | google/closure-templates | java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java | PyExprUtils.concatPyExprs | public static PyExpr concatPyExprs(List<? extends PyExpr> pyExprs) {
if (pyExprs.isEmpty()) {
return EMPTY_STRING;
}
if (pyExprs.size() == 1) {
// If there's only one element, simply return the expression as a String.
return pyExprs.get(0).toPyString();
}
StringBuilder resultSb ... | java | public static PyExpr concatPyExprs(List<? extends PyExpr> pyExprs) {
if (pyExprs.isEmpty()) {
return EMPTY_STRING;
}
if (pyExprs.size() == 1) {
// If there's only one element, simply return the expression as a String.
return pyExprs.get(0).toPyString();
}
StringBuilder resultSb ... | [
"public",
"static",
"PyExpr",
"concatPyExprs",
"(",
"List",
"<",
"?",
"extends",
"PyExpr",
">",
"pyExprs",
")",
"{",
"if",
"(",
"pyExprs",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"EMPTY_STRING",
";",
"}",
"if",
"(",
"pyExprs",
".",
"size",
"(",
... | Builds one Python expression that computes the concatenation of the given Python expressions.
<p>Python doesn't allow arbitrary concatentation between types, so to ensure type safety and
consistent behavior, coerce all expressions to Strings before joining them. Python's array
joining mechanism is used in place of tra... | [
"Builds",
"one",
"Python",
"expression",
"that",
"computes",
"the",
"concatenation",
"of",
"the",
"given",
"Python",
"expressions",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java#L96-L126 |
53,556 | google/closure-templates | java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java | PyExprUtils.maybeProtect | public static PyExpr maybeProtect(PyExpr expr, int minSafePrecedence) {
// all python operators are left associative, so if this has equivalent precedence we don't need
// to wrap
if (expr.getPrecedence() >= minSafePrecedence) {
return expr;
} else {
return new PyExpr("(" + expr.getText() + ... | java | public static PyExpr maybeProtect(PyExpr expr, int minSafePrecedence) {
// all python operators are left associative, so if this has equivalent precedence we don't need
// to wrap
if (expr.getPrecedence() >= minSafePrecedence) {
return expr;
} else {
return new PyExpr("(" + expr.getText() + ... | [
"public",
"static",
"PyExpr",
"maybeProtect",
"(",
"PyExpr",
"expr",
",",
"int",
"minSafePrecedence",
")",
"{",
"// all python operators are left associative, so if this has equivalent precedence we don't need",
"// to wrap",
"if",
"(",
"expr",
".",
"getPrecedence",
"(",
")",... | Wraps an expression with parenthesis if it's not above the minimum safe precedence.
<p>NOTE: For the sake of brevity, this implementation loses typing information in the
expressions.
@param expr The expression to wrap.
@param minSafePrecedence The minimum safe precedence (not inclusive).
@return The PyExpr potentiall... | [
"Wraps",
"an",
"expression",
"with",
"parenthesis",
"if",
"it",
"s",
"not",
"above",
"the",
"minimum",
"safe",
"precedence",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java#L154-L162 |
53,557 | google/closure-templates | java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java | PyExprUtils.convertMapToOrderedDict | public static PyExpr convertMapToOrderedDict(Map<PyExpr, PyExpr> dict) {
List<String> values = new ArrayList<>();
for (Map.Entry<PyExpr, PyExpr> entry : dict.entrySet()) {
values.add("(" + entry.getKey().getText() + ", " + entry.getValue().getText() + ")");
}
Joiner joiner = Joiner.on(", ");
... | java | public static PyExpr convertMapToOrderedDict(Map<PyExpr, PyExpr> dict) {
List<String> values = new ArrayList<>();
for (Map.Entry<PyExpr, PyExpr> entry : dict.entrySet()) {
values.add("(" + entry.getKey().getText() + ", " + entry.getValue().getText() + ")");
}
Joiner joiner = Joiner.on(", ");
... | [
"public",
"static",
"PyExpr",
"convertMapToOrderedDict",
"(",
"Map",
"<",
"PyExpr",
",",
"PyExpr",
">",
"dict",
")",
"{",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PyExpr"... | Convert a java Map to valid PyExpr as dict.
@param dict A Map to be converted to PyExpr as a dictionary, both key and value should be
PyExpr. | [
"Convert",
"a",
"java",
"Map",
"to",
"valid",
"PyExpr",
"as",
"dict",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java#L222-L231 |
53,558 | google/closure-templates | java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java | PyExprUtils.genExprWithNewToken | public static String genExprWithNewToken(
Operator op, List<? extends TargetExpr> operandExprs, String newToken) {
int opPrec = op.getPrecedence();
boolean isLeftAssociative = op.getAssociativity() == Associativity.LEFT;
StringBuilder exprSb = new StringBuilder();
// Iterate through the operato... | java | public static String genExprWithNewToken(
Operator op, List<? extends TargetExpr> operandExprs, String newToken) {
int opPrec = op.getPrecedence();
boolean isLeftAssociative = op.getAssociativity() == Associativity.LEFT;
StringBuilder exprSb = new StringBuilder();
// Iterate through the operato... | [
"public",
"static",
"String",
"genExprWithNewToken",
"(",
"Operator",
"op",
",",
"List",
"<",
"?",
"extends",
"TargetExpr",
">",
"operandExprs",
",",
"String",
"newToken",
")",
"{",
"int",
"opPrec",
"=",
"op",
".",
"getPrecedence",
"(",
")",
";",
"boolean",
... | Generates an expression for the given operator and operands assuming that the expression for
the operator uses the same syntax format as the Soy operator, with the exception that the of a
different token. Associativity, spacing, and precedence are maintained from the original
operator.
<p>Examples:
<pre>
NOT, ["$a"],... | [
"Generates",
"an",
"expression",
"for",
"the",
"given",
"operator",
"and",
"operands",
"assuming",
"that",
"the",
"expression",
"for",
"the",
"operator",
"uses",
"the",
"same",
"syntax",
"format",
"as",
"the",
"Soy",
"operator",
"with",
"the",
"exception",
"th... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/restricted/PyExprUtils.java#L300-L349 |
53,559 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/TemplateAnalysis.java | TemplateAnalysis.isListExpressionEmpty | private static StaticAnalysisResult isListExpressionEmpty(ForNode node) {
Optional<RangeArgs> rangeArgs = RangeArgs.createFromNode(node);
if (rangeArgs.isPresent()) {
return isRangeExpressionEmpty(rangeArgs.get());
}
ExprNode expr = node.getExpr().getRoot();
if (expr instanceof ListLiteralNode... | java | private static StaticAnalysisResult isListExpressionEmpty(ForNode node) {
Optional<RangeArgs> rangeArgs = RangeArgs.createFromNode(node);
if (rangeArgs.isPresent()) {
return isRangeExpressionEmpty(rangeArgs.get());
}
ExprNode expr = node.getExpr().getRoot();
if (expr instanceof ListLiteralNode... | [
"private",
"static",
"StaticAnalysisResult",
"isListExpressionEmpty",
"(",
"ForNode",
"node",
")",
"{",
"Optional",
"<",
"RangeArgs",
">",
"rangeArgs",
"=",
"RangeArgs",
".",
"createFromNode",
"(",
"node",
")",
";",
"if",
"(",
"rangeArgs",
".",
"isPresent",
"(",... | consider moving this to SoyTreeUtils or some similar place. | [
"consider",
"moving",
"this",
"to",
"SoyTreeUtils",
"or",
"some",
"similar",
"place",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/TemplateAnalysis.java#L537-L549 |
53,560 | google/closure-templates | java/src/com/google/template/soy/msgs/SoyMsgBundleHandler.java | SoyMsgBundleHandler.createFromFile | public SoyMsgBundle createFromFile(File inputFile) throws IOException {
// TODO: This is for backwards-compatibility. Figure out how to get rid of this.
// We special-case English locales because they often don't have translated files and falling
// back to the Soy source should be fine.
if (!inputFile... | java | public SoyMsgBundle createFromFile(File inputFile) throws IOException {
// TODO: This is for backwards-compatibility. Figure out how to get rid of this.
// We special-case English locales because they often don't have translated files and falling
// back to the Soy source should be fine.
if (!inputFile... | [
"public",
"SoyMsgBundle",
"createFromFile",
"(",
"File",
"inputFile",
")",
"throws",
"IOException",
"{",
"// TODO: This is for backwards-compatibility. Figure out how to get rid of this.",
"// We special-case English locales because they often don't have translated files and falling",
"// ba... | Reads a translated messages file and creates a SoyMsgBundle.
@param inputFile The input file to read from.
@return The message bundle created from the messages file.
@throws IOException If there's an error while accessing the file.
@throws SoyMsgException If there's an error while processing the messages. | [
"Reads",
"a",
"translated",
"messages",
"file",
"and",
"creates",
"a",
"SoyMsgBundle",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/SoyMsgBundleHandler.java#L112-L132 |
53,561 | google/closure-templates | java/src/com/google/template/soy/msgs/SoyMsgBundleHandler.java | SoyMsgBundleHandler.createFromResource | public SoyMsgBundle createFromResource(URL inputResource) throws IOException {
try {
String inputFileContent = Resources.asCharSource(inputResource, UTF_8).read();
return msgPlugin.parseTranslatedMsgsFile(inputFileContent);
} catch (SoyMsgException sme) {
sme.setFileOrResourceName(inputResou... | java | public SoyMsgBundle createFromResource(URL inputResource) throws IOException {
try {
String inputFileContent = Resources.asCharSource(inputResource, UTF_8).read();
return msgPlugin.parseTranslatedMsgsFile(inputFileContent);
} catch (SoyMsgException sme) {
sme.setFileOrResourceName(inputResou... | [
"public",
"SoyMsgBundle",
"createFromResource",
"(",
"URL",
"inputResource",
")",
"throws",
"IOException",
"{",
"try",
"{",
"String",
"inputFileContent",
"=",
"Resources",
".",
"asCharSource",
"(",
"inputResource",
",",
"UTF_8",
")",
".",
"read",
"(",
")",
";",
... | Reads a translated messages resource and creates a SoyMsgBundle.
@param inputResource The resource to read from.
@return The message bundle created from the messages resource.
@throws IOException If there's an error while accessing the resource.
@throws SoyMsgException If there's an error while processing the messages... | [
"Reads",
"a",
"translated",
"messages",
"resource",
"and",
"creates",
"a",
"SoyMsgBundle",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/SoyMsgBundleHandler.java#L142-L152 |
53,562 | google/closure-templates | java/src/com/google/template/soy/soytree/VeLogNode.java | VeLogNode.getCloseTagNode | @Nullable
public HtmlCloseTagNode getCloseTagNode() {
if (numChildren() > 1) {
return (HtmlCloseTagNode)
getNodeAsHtmlTagNode(getChild(numChildren() - 1), /*openTag=*/ false);
}
return null;
} | java | @Nullable
public HtmlCloseTagNode getCloseTagNode() {
if (numChildren() > 1) {
return (HtmlCloseTagNode)
getNodeAsHtmlTagNode(getChild(numChildren() - 1), /*openTag=*/ false);
}
return null;
} | [
"@",
"Nullable",
"public",
"HtmlCloseTagNode",
"getCloseTagNode",
"(",
")",
"{",
"if",
"(",
"numChildren",
"(",
")",
">",
"1",
")",
"{",
"return",
"(",
"HtmlCloseTagNode",
")",
"getNodeAsHtmlTagNode",
"(",
"getChild",
"(",
"numChildren",
"(",
")",
"-",
"1",
... | Returns the close tag node if it exists. | [
"Returns",
"the",
"close",
"tag",
"node",
"if",
"it",
"exists",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/VeLogNode.java#L148-L155 |
53,563 | google/closure-templates | java/src/com/google/template/soy/i18ndirectives/I18nUtils.java | I18nUtils.parseLocale | public static Locale parseLocale(String localeString) {
if (localeString == null) {
return Locale.US;
}
String[] groups = localeString.split("[-_]");
switch (groups.length) {
case 1:
return new Locale(groups[0]);
case 2:
return new Locale(groups[0], Ascii.toUpperCase(gr... | java | public static Locale parseLocale(String localeString) {
if (localeString == null) {
return Locale.US;
}
String[] groups = localeString.split("[-_]");
switch (groups.length) {
case 1:
return new Locale(groups[0]);
case 2:
return new Locale(groups[0], Ascii.toUpperCase(gr... | [
"public",
"static",
"Locale",
"parseLocale",
"(",
"String",
"localeString",
")",
"{",
"if",
"(",
"localeString",
"==",
"null",
")",
"{",
"return",
"Locale",
".",
"US",
";",
"}",
"String",
"[",
"]",
"groups",
"=",
"localeString",
".",
"split",
"(",
"\"[-_... | Given a string representing a Locale, returns the Locale object for that string.
@return A Locale object built from the string provided | [
"Given",
"a",
"string",
"representing",
"a",
"Locale",
"returns",
"the",
"Locale",
"object",
"for",
"that",
"string",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/i18ndirectives/I18nUtils.java#L37-L52 |
53,564 | google/closure-templates | java/src/com/google/template/soy/basetree/CopyState.java | CopyState.updateRefs | public <T> void updateRefs(T oldObject, T newObject) {
checkNotNull(oldObject);
checkNotNull(newObject);
checkArgument(!(newObject instanceof Listener));
Object previousMapping = mappings.put(oldObject, newObject);
if (previousMapping != null) {
if (previousMapping instanceof Listener) {
... | java | public <T> void updateRefs(T oldObject, T newObject) {
checkNotNull(oldObject);
checkNotNull(newObject);
checkArgument(!(newObject instanceof Listener));
Object previousMapping = mappings.put(oldObject, newObject);
if (previousMapping != null) {
if (previousMapping instanceof Listener) {
... | [
"public",
"<",
"T",
">",
"void",
"updateRefs",
"(",
"T",
"oldObject",
",",
"T",
"newObject",
")",
"{",
"checkNotNull",
"(",
"oldObject",
")",
";",
"checkNotNull",
"(",
"newObject",
")",
";",
"checkArgument",
"(",
"!",
"(",
"newObject",
"instanceof",
"Liste... | Registers that the old object has been remapped to the new object.
<p>This is useful for auxiliary AST datastructures which may contain back-edges in the AST.
When being copied, the auxiliary data structure is registered with this method then AST nodes
which have references to the old copy can register via {@link #reg... | [
"Registers",
"that",
"the",
"old",
"object",
"has",
"been",
"remapped",
"to",
"the",
"new",
"object",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/basetree/CopyState.java#L54-L68 |
53,565 | google/closure-templates | java/src/com/google/template/soy/basetree/CopyState.java | CopyState.checkAllListenersFired | public void checkAllListenersFired() {
for (Map.Entry<Object, Object> entry : mappings.entrySet()) {
if (entry.getValue() instanceof Listener) {
throw new IllegalStateException(
"Listener for " + entry.getKey() + " never fired: " + entry.getValue());
}
}
} | java | public void checkAllListenersFired() {
for (Map.Entry<Object, Object> entry : mappings.entrySet()) {
if (entry.getValue() instanceof Listener) {
throw new IllegalStateException(
"Listener for " + entry.getKey() + " never fired: " + entry.getValue());
}
}
} | [
"public",
"void",
"checkAllListenersFired",
"(",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"mappings",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
"instanceof",
... | Asserts that there are no pending listeners.
<p>This can be useful in a test environment to ensure that the copy worked correctly. N.B. it
is possible for a copy to be 'correct' and for not all listeners to fire, this is common when
copying small parts of the AST (anything below a template). | [
"Asserts",
"that",
"there",
"are",
"no",
"pending",
"listeners",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/basetree/CopyState.java#L103-L110 |
53,566 | google/closure-templates | java/src/com/google/template/soy/internal/base/UnescapeUtils.java | UnescapeUtils.unescapeHtml | public static String unescapeHtml(String s) {
int amp = s.indexOf('&');
if (amp < 0) { // Fast path.
return s;
}
int n = s.length();
StringBuilder sb = new StringBuilder(n);
int pos = 0;
do {
// All numeric entities and all named entities can be represented in less than 12 chars,... | java | public static String unescapeHtml(String s) {
int amp = s.indexOf('&');
if (amp < 0) { // Fast path.
return s;
}
int n = s.length();
StringBuilder sb = new StringBuilder(n);
int pos = 0;
do {
// All numeric entities and all named entities can be represented in less than 12 chars,... | [
"public",
"static",
"String",
"unescapeHtml",
"(",
"String",
"s",
")",
"{",
"int",
"amp",
"=",
"s",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"amp",
"<",
"0",
")",
"{",
"// Fast path.",
"return",
"s",
";",
"}",
"int",
"n",
"=",
"s",
"... | Replace all the occurrences of HTML entities with the appropriate code-points.
@param s HTML.
@return Plain text. | [
"Replace",
"all",
"the",
"occurrences",
"of",
"HTML",
"entities",
"with",
"the",
"appropriate",
"code",
"-",
"points",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/internal/base/UnescapeUtils.java#L35-L93 |
53,567 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/PySrcMain.java | PySrcMain.genPySrc | private List<String> genPySrc(
SoyFileSetNode soyTree,
SoyPySrcOptions pySrcOptions,
ImmutableMap<String, String> currentManifest,
ErrorReporter errorReporter) {
BidiGlobalDir bidiGlobalDir =
SoyBidiUtils.decodeBidiGlobalDirFromPyOptions(pySrcOptions.getBidiIsRtlFn());
try (SoyS... | java | private List<String> genPySrc(
SoyFileSetNode soyTree,
SoyPySrcOptions pySrcOptions,
ImmutableMap<String, String> currentManifest,
ErrorReporter errorReporter) {
BidiGlobalDir bidiGlobalDir =
SoyBidiUtils.decodeBidiGlobalDirFromPyOptions(pySrcOptions.getBidiIsRtlFn());
try (SoyS... | [
"private",
"List",
"<",
"String",
">",
"genPySrc",
"(",
"SoyFileSetNode",
"soyTree",
",",
"SoyPySrcOptions",
"pySrcOptions",
",",
"ImmutableMap",
"<",
"String",
",",
"String",
">",
"currentManifest",
",",
"ErrorReporter",
"errorReporter",
")",
"{",
"BidiGlobalDir",
... | Generates Python source code given a Soy parse tree and an options object.
@param soyTree The Soy parse tree to generate Python source code for.
@param pySrcOptions The compilation options relevant to this backend.
@param currentManifest The namespace manifest for current sources.
@param errorReporter The Soy error re... | [
"Generates",
"Python",
"source",
"code",
"given",
"a",
"Soy",
"parse",
"tree",
"and",
"an",
"options",
"object",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/PySrcMain.java#L70-L82 |
53,568 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/PySrcMain.java | PySrcMain.genPyFiles | public void genPyFiles(
SoyFileSetNode soyTree,
SoyPySrcOptions pySrcOptions,
String outputPathFormat,
ErrorReporter errorReporter)
throws IOException {
ImmutableList<SoyFileNode> srcsToCompile = ImmutableList.copyOf(soyTree.getChildren());
// Determine the output paths.
List... | java | public void genPyFiles(
SoyFileSetNode soyTree,
SoyPySrcOptions pySrcOptions,
String outputPathFormat,
ErrorReporter errorReporter)
throws IOException {
ImmutableList<SoyFileNode> srcsToCompile = ImmutableList.copyOf(soyTree.getChildren());
// Determine the output paths.
List... | [
"public",
"void",
"genPyFiles",
"(",
"SoyFileSetNode",
"soyTree",
",",
"SoyPySrcOptions",
"pySrcOptions",
",",
"String",
"outputPathFormat",
",",
"ErrorReporter",
"errorReporter",
")",
"throws",
"IOException",
"{",
"ImmutableList",
"<",
"SoyFileNode",
">",
"srcsToCompil... | Generates Python source files given a Soy parse tree, an options object, and information on
where to put the output files.
@param soyTree The Soy parse tree to generate Python source code for.
@param pySrcOptions The compilation options relevant to this backend.
@param outputPathFormat The format string defining how t... | [
"Generates",
"Python",
"source",
"files",
"given",
"a",
"Soy",
"parse",
"tree",
"an",
"options",
"object",
"and",
"information",
"on",
"where",
"to",
"put",
"the",
"output",
"files",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/PySrcMain.java#L95-L142 |
53,569 | google/closure-templates | java/src/com/google/template/soy/pysrc/internal/PySrcMain.java | PySrcMain.generateManifest | private static ImmutableMap<String, String> generateManifest(
List<String> soyNamespaces, Multimap<String, Integer> outputs) {
ImmutableMap.Builder<String, String> manifest = new ImmutableMap.Builder<>();
for (String outputFilePath : outputs.keySet()) {
for (int inputFileIndex : outputs.get(outputFi... | java | private static ImmutableMap<String, String> generateManifest(
List<String> soyNamespaces, Multimap<String, Integer> outputs) {
ImmutableMap.Builder<String, String> manifest = new ImmutableMap.Builder<>();
for (String outputFilePath : outputs.keySet()) {
for (int inputFileIndex : outputs.get(outputFi... | [
"private",
"static",
"ImmutableMap",
"<",
"String",
",",
"String",
">",
"generateManifest",
"(",
"List",
"<",
"String",
">",
"soyNamespaces",
",",
"Multimap",
"<",
"String",
",",
"Integer",
">",
"outputs",
")",
"{",
"ImmutableMap",
".",
"Builder",
"<",
"Stri... | Generate the manifest file by finding the output file paths and converting them into a Python
import format. | [
"Generate",
"the",
"manifest",
"file",
"by",
"finding",
"the",
"output",
"file",
"paths",
"and",
"converting",
"them",
"into",
"a",
"Python",
"import",
"format",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/PySrcMain.java#L148-L159 |
53,570 | google/closure-templates | java/src/com/google/template/soy/conformance/SoyConformance.java | SoyConformance.check | public void check(SoyFileNode file, final ErrorReporter errorReporter) {
// first filter to only the rules that need to be checked for this file.
final List<Rule<?>> rulesForFile = new ArrayList<>(rules.size());
String filePath = file.getFilePath();
for (RuleWithWhitelists rule : rules) {
if (rule... | java | public void check(SoyFileNode file, final ErrorReporter errorReporter) {
// first filter to only the rules that need to be checked for this file.
final List<Rule<?>> rulesForFile = new ArrayList<>(rules.size());
String filePath = file.getFilePath();
for (RuleWithWhitelists rule : rules) {
if (rule... | [
"public",
"void",
"check",
"(",
"SoyFileNode",
"file",
",",
"final",
"ErrorReporter",
"errorReporter",
")",
"{",
"// first filter to only the rules that need to be checked for this file.",
"final",
"List",
"<",
"Rule",
"<",
"?",
">",
">",
"rulesForFile",
"=",
"new",
"... | Performs the overall check. | [
"Performs",
"the",
"overall",
"check",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/conformance/SoyConformance.java#L53-L77 |
53,571 | google/closure-templates | java/src/com/google/template/soy/types/SanitizedType.java | SanitizedType.getTypeForContentKind | public static SoyType getTypeForContentKind(SanitizedContentKind contentKind) {
switch (contentKind) {
case ATTRIBUTES:
return AttributesType.getInstance();
case CSS:
return StyleType.getInstance();
case HTML:
return HtmlType.getInstance();
case JS:
return ... | java | public static SoyType getTypeForContentKind(SanitizedContentKind contentKind) {
switch (contentKind) {
case ATTRIBUTES:
return AttributesType.getInstance();
case CSS:
return StyleType.getInstance();
case HTML:
return HtmlType.getInstance();
case JS:
return ... | [
"public",
"static",
"SoyType",
"getTypeForContentKind",
"(",
"SanitizedContentKind",
"contentKind",
")",
"{",
"switch",
"(",
"contentKind",
")",
"{",
"case",
"ATTRIBUTES",
":",
"return",
"AttributesType",
".",
"getInstance",
"(",
")",
";",
"case",
"CSS",
":",
"r... | Given a content kind, return the corresponding soy type.
<p>For {@link SanitizedContentKind#TEXT} this returns {@link StringType}, for all other types
it is a {@link SanitizedType}. | [
"Given",
"a",
"content",
"kind",
"return",
"the",
"corresponding",
"soy",
"type",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/types/SanitizedType.java#L44-L68 |
53,572 | google/closure-templates | java/src/com/google/template/soy/SoyCmdLineParser.java | SoyCmdLineParser.instantiateObject | private static <T> T instantiateObject(
String flagName,
String objectType,
Class<T> clazz,
PluginLoader loader,
String instanceClassName) {
try {
return loader.loadPlugin(instanceClassName).asSubclass(clazz).getConstructor().newInstance();
} catch (ClassCastException cce) {
... | java | private static <T> T instantiateObject(
String flagName,
String objectType,
Class<T> clazz,
PluginLoader loader,
String instanceClassName) {
try {
return loader.loadPlugin(instanceClassName).asSubclass(clazz).getConstructor().newInstance();
} catch (ClassCastException cce) {
... | [
"private",
"static",
"<",
"T",
">",
"T",
"instantiateObject",
"(",
"String",
"flagName",
",",
"String",
"objectType",
",",
"Class",
"<",
"T",
">",
"clazz",
",",
"PluginLoader",
"loader",
",",
"String",
"instanceClassName",
")",
"{",
"try",
"{",
"return",
"... | Private helper for creating objects from flags.
@param instanceClassName The name of the class to instantiate.
@return A new instance of the specified plugin module. | [
"Private",
"helper",
"for",
"creating",
"objects",
"from",
"flags",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/SoyCmdLineParser.java#L335-L377 |
53,573 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/JsCodeBuilder.java | JsCodeBuilder.addChunksToOutputVar | public JsCodeBuilder addChunksToOutputVar(List<? extends Expression> codeChunks) {
if (currOutputVarIsInited) {
Expression rhs = CodeChunkUtils.concatChunks(codeChunks);
rhs.collectRequires(requireCollector);
appendLine(currOutputVar.plusEquals(rhs).getCode());
} else {
Expression rhs = ... | java | public JsCodeBuilder addChunksToOutputVar(List<? extends Expression> codeChunks) {
if (currOutputVarIsInited) {
Expression rhs = CodeChunkUtils.concatChunks(codeChunks);
rhs.collectRequires(requireCollector);
appendLine(currOutputVar.plusEquals(rhs).getCode());
} else {
Expression rhs = ... | [
"public",
"JsCodeBuilder",
"addChunksToOutputVar",
"(",
"List",
"<",
"?",
"extends",
"Expression",
">",
"codeChunks",
")",
"{",
"if",
"(",
"currOutputVarIsInited",
")",
"{",
"Expression",
"rhs",
"=",
"CodeChunkUtils",
".",
"concatChunks",
"(",
"codeChunks",
")",
... | Appends one or more lines representing the concatenation of the values of the given code chunks
saved to the current output variable. | [
"Appends",
"one",
"or",
"more",
"lines",
"representing",
"the",
"concatenation",
"of",
"the",
"values",
"of",
"the",
"given",
"code",
"chunks",
"saved",
"to",
"the",
"current",
"output",
"variable",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/JsCodeBuilder.java#L164-L179 |
53,574 | google/closure-templates | java/src/com/google/template/soy/jssrc/internal/JsCodeBuilder.java | JsCodeBuilder.changeIndentHelper | private JsCodeBuilder changeIndentHelper(int chg) {
int newIndentDepth = indent.length() + chg * INDENT_SIZE;
Preconditions.checkState(newIndentDepth >= 0);
indent = Strings.repeat(" ", newIndentDepth);
return this;
} | java | private JsCodeBuilder changeIndentHelper(int chg) {
int newIndentDepth = indent.length() + chg * INDENT_SIZE;
Preconditions.checkState(newIndentDepth >= 0);
indent = Strings.repeat(" ", newIndentDepth);
return this;
} | [
"private",
"JsCodeBuilder",
"changeIndentHelper",
"(",
"int",
"chg",
")",
"{",
"int",
"newIndentDepth",
"=",
"indent",
".",
"length",
"(",
")",
"+",
"chg",
"*",
"INDENT_SIZE",
";",
"Preconditions",
".",
"checkState",
"(",
"newIndentDepth",
">=",
"0",
")",
";... | Helper for the various indent methods.
@param chg The number of indent levels to change. | [
"Helper",
"for",
"the",
"various",
"indent",
"methods",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/JsCodeBuilder.java#L205-L210 |
53,575 | google/closure-templates | java/src/com/google/template/soy/data/SanitizedContent.java | SanitizedContent.create | static SanitizedContent create(String content, ContentKind kind) {
checkArgument(
kind != ContentKind.TEXT, "Use UnsanitizedString for SanitizedContent with a kind of TEXT");
if (Flags.stringIsNotSanitizedContent()) {
return new SanitizedContent(content, kind, kind.getDefaultDir());
}
retu... | java | static SanitizedContent create(String content, ContentKind kind) {
checkArgument(
kind != ContentKind.TEXT, "Use UnsanitizedString for SanitizedContent with a kind of TEXT");
if (Flags.stringIsNotSanitizedContent()) {
return new SanitizedContent(content, kind, kind.getDefaultDir());
}
retu... | [
"static",
"SanitizedContent",
"create",
"(",
"String",
"content",
",",
"ContentKind",
"kind",
")",
"{",
"checkArgument",
"(",
"kind",
"!=",
"ContentKind",
".",
"TEXT",
",",
"\"Use UnsanitizedString for SanitizedContent with a kind of TEXT\"",
")",
";",
"if",
"(",
"Fla... | Creates a SanitizedContent object with default direction. | [
"Creates",
"a",
"SanitizedContent",
"object",
"with",
"default",
"direction",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/SanitizedContent.java#L77-L84 |
53,576 | google/closure-templates | java/src/com/google/template/soy/shared/internal/StreamingEscaper.java | StreamingEscaper.create | public static StreamingEscaper create(
LoggingAdvisingAppendable delegate, CrossLanguageStringXform transform) {
if (delegate instanceof StreamingEscaper) {
StreamingEscaper delegateAsStreamingEscaper = (StreamingEscaper) delegate;
if (delegateAsStreamingEscaper.transform == transform) {
r... | java | public static StreamingEscaper create(
LoggingAdvisingAppendable delegate, CrossLanguageStringXform transform) {
if (delegate instanceof StreamingEscaper) {
StreamingEscaper delegateAsStreamingEscaper = (StreamingEscaper) delegate;
if (delegateAsStreamingEscaper.transform == transform) {
r... | [
"public",
"static",
"StreamingEscaper",
"create",
"(",
"LoggingAdvisingAppendable",
"delegate",
",",
"CrossLanguageStringXform",
"transform",
")",
"{",
"if",
"(",
"delegate",
"instanceof",
"StreamingEscaper",
")",
"{",
"StreamingEscaper",
"delegateAsStreamingEscaper",
"=",
... | Creates a streaming escaper, or returns the delegate if it is already escaping with the same
settings. | [
"Creates",
"a",
"streaming",
"escaper",
"or",
"returns",
"the",
"delegate",
"if",
"it",
"is",
"already",
"escaping",
"with",
"the",
"same",
"settings",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/StreamingEscaper.java#L37-L46 |
53,577 | google/closure-templates | java/src/com/google/template/soy/exprtree/GlobalNode.java | GlobalNode.onResolve | public void onResolve(ResolutionCallback callback) {
checkState(this.resolveCallback == null, "callback has already been set.");
checkState(this.value == null, "value is resolved.");
this.resolveCallback = checkNotNull(callback);
} | java | public void onResolve(ResolutionCallback callback) {
checkState(this.resolveCallback == null, "callback has already been set.");
checkState(this.value == null, "value is resolved.");
this.resolveCallback = checkNotNull(callback);
} | [
"public",
"void",
"onResolve",
"(",
"ResolutionCallback",
"callback",
")",
"{",
"checkState",
"(",
"this",
".",
"resolveCallback",
"==",
"null",
",",
"\"callback has already been set.\"",
")",
";",
"checkState",
"(",
"this",
".",
"value",
"==",
"null",
",",
"\"v... | Registers a callback that is invoked when this global is resolved to its actual value.
<p>NOTE: there is no guarantee that this will ever be called. | [
"Registers",
"a",
"callback",
"that",
"is",
"invoked",
"when",
"this",
"global",
"is",
"resolved",
"to",
"its",
"actual",
"value",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/exprtree/GlobalNode.java#L103-L107 |
53,578 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/Statement.java | Statement.assign | public static Statement assign(Expression lhs, Expression rhs) {
return Assignment.create(lhs, rhs, null);
} | java | public static Statement assign(Expression lhs, Expression rhs) {
return Assignment.create(lhs, rhs, null);
} | [
"public",
"static",
"Statement",
"assign",
"(",
"Expression",
"lhs",
",",
"Expression",
"rhs",
")",
"{",
"return",
"Assignment",
".",
"create",
"(",
"lhs",
",",
"rhs",
",",
"null",
")",
";",
"}"
] | Creates a code chunk that assigns value to a preexisting variable with the given name. | [
"Creates",
"a",
"code",
"chunk",
"that",
"assigns",
"value",
"to",
"a",
"preexisting",
"variable",
"with",
"the",
"given",
"name",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/Statement.java#L47-L49 |
53,579 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/Statement.java | Statement.assign | public static Statement assign(Expression lhs, Expression rhs, JsDoc jsDoc) {
return Assignment.create(lhs, rhs, jsDoc);
} | java | public static Statement assign(Expression lhs, Expression rhs, JsDoc jsDoc) {
return Assignment.create(lhs, rhs, jsDoc);
} | [
"public",
"static",
"Statement",
"assign",
"(",
"Expression",
"lhs",
",",
"Expression",
"rhs",
",",
"JsDoc",
"jsDoc",
")",
"{",
"return",
"Assignment",
".",
"create",
"(",
"lhs",
",",
"rhs",
",",
"jsDoc",
")",
";",
"}"
] | Creates a code chunk that assigns and prints jsDoc above the assignment. | [
"Creates",
"a",
"code",
"chunk",
"that",
"assigns",
"and",
"prints",
"jsDoc",
"above",
"the",
"assignment",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/Statement.java#L52-L54 |
53,580 | google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/Statement.java | Statement.forLoop | public static Statement forLoop(String localVar, Expression limit, Statement body) {
return For.create(localVar, Expression.number(0), limit, Expression.number(1), body);
} | java | public static Statement forLoop(String localVar, Expression limit, Statement body) {
return For.create(localVar, Expression.number(0), limit, Expression.number(1), body);
} | [
"public",
"static",
"Statement",
"forLoop",
"(",
"String",
"localVar",
",",
"Expression",
"limit",
",",
"Statement",
"body",
")",
"{",
"return",
"For",
".",
"create",
"(",
"localVar",
",",
"Expression",
".",
"number",
"(",
"0",
")",
",",
"limit",
",",
"E... | Creates a code chunk representing a for loop, with default values for initial & increment. | [
"Creates",
"a",
"code",
"chunk",
"representing",
"a",
"for",
"loop",
"with",
"default",
"values",
"for",
"initial",
"&",
"increment",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/Statement.java#L73-L75 |
53,581 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/BytecodeCompiler.java | BytecodeCompiler.compile | public static Optional<CompiledTemplates> compile(
final TemplateRegistry registry,
final SoyFileSetNode fileSet,
boolean developmentMode,
ErrorReporter reporter,
ImmutableMap<String, SoyFileSupplier> filePathsToSuppliers,
SoyTypeRegistry typeRegistry) {
final Stopwatch stopwatch... | java | public static Optional<CompiledTemplates> compile(
final TemplateRegistry registry,
final SoyFileSetNode fileSet,
boolean developmentMode,
ErrorReporter reporter,
ImmutableMap<String, SoyFileSupplier> filePathsToSuppliers,
SoyTypeRegistry typeRegistry) {
final Stopwatch stopwatch... | [
"public",
"static",
"Optional",
"<",
"CompiledTemplates",
">",
"compile",
"(",
"final",
"TemplateRegistry",
"registry",
",",
"final",
"SoyFileSetNode",
"fileSet",
",",
"boolean",
"developmentMode",
",",
"ErrorReporter",
"reporter",
",",
"ImmutableMap",
"<",
"String",
... | Compiles all the templates in the given registry.
@param registry All the templates to compile
@param developmentMode Whether or not we are in development mode. In development mode we
compile classes lazily
@param reporter The error reporter
@return CompiledTemplates or {@code absent()} if compilation fails, in which ... | [
"Compiles",
"all",
"the",
"templates",
"in",
"the",
"given",
"registry",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/BytecodeCompiler.java#L78-L157 |
53,582 | google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/MethodRef.java | MethodRef.invokeUnchecked | public void invokeUnchecked(CodeBuilder cb) {
cb.visitMethodInsn(
opcode(),
owner().internalName(),
method().getName(),
method().getDescriptor(),
// This is for whether the methods owner is an interface. This is mostly to handle java8
// default methods on interfaces... | java | public void invokeUnchecked(CodeBuilder cb) {
cb.visitMethodInsn(
opcode(),
owner().internalName(),
method().getName(),
method().getDescriptor(),
// This is for whether the methods owner is an interface. This is mostly to handle java8
// default methods on interfaces... | [
"public",
"void",
"invokeUnchecked",
"(",
"CodeBuilder",
"cb",
")",
"{",
"cb",
".",
"visitMethodInsn",
"(",
"opcode",
"(",
")",
",",
"owner",
"(",
")",
".",
"internalName",
"(",
")",
",",
"method",
"(",
")",
".",
"getName",
"(",
")",
",",
"method",
"... | Writes an invoke instruction for this method to the given adapter. Useful when the expression
is not useful for representing operations. For example, explicit dup operations are awkward in
the Expression api. | [
"Writes",
"an",
"invoke",
"instruction",
"for",
"this",
"method",
"to",
"the",
"given",
"adapter",
".",
"Useful",
"when",
"the",
"expression",
"is",
"not",
"useful",
"for",
"representing",
"operations",
".",
"For",
"example",
"explicit",
"dup",
"operations",
"... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/MethodRef.java#L576-L586 |
53,583 | google/closure-templates | java/src/com/google/template/soy/data/SoyData.java | SoyData.createFromExistingData | @Deprecated
protected static SoyData createFromExistingData(Object obj) {
if (obj instanceof SoyData) {
return (SoyData) obj;
} else if (obj instanceof Map<?, ?>) {
@SuppressWarnings("unchecked")
Map<String, ?> objCast = (Map<String, ?>) obj;
return new SoyMapData(objCast);
} else ... | java | @Deprecated
protected static SoyData createFromExistingData(Object obj) {
if (obj instanceof SoyData) {
return (SoyData) obj;
} else if (obj instanceof Map<?, ?>) {
@SuppressWarnings("unchecked")
Map<String, ?> objCast = (Map<String, ?>) obj;
return new SoyMapData(objCast);
} else ... | [
"@",
"Deprecated",
"protected",
"static",
"SoyData",
"createFromExistingData",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"SoyData",
")",
"{",
"return",
"(",
"SoyData",
")",
"obj",
";",
"}",
"else",
"if",
"(",
"obj",
"instanceof",
"Map... | Creates deprecated SoyData objects from standard Java data structures.
@param obj The existing object or data structure to convert.
@return A SoyData object or tree that corresponds to the given object.
@throws SoyDataException If the given object cannot be converted to SoyData.
@deprecated It's best to pass whatever ... | [
"Creates",
"deprecated",
"SoyData",
"objects",
"from",
"standard",
"Java",
"data",
"structures",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/SoyData.java#L42-L74 |
53,584 | google/closure-templates | java/src/com/google/template/soy/msgs/restricted/MsgPartUtils.java | MsgPartUtils.hasPlrselPart | public static boolean hasPlrselPart(List<SoyMsgPart> msgParts) {
for (SoyMsgPart origMsgPart : msgParts) {
if (origMsgPart instanceof SoyMsgPluralPart || origMsgPart instanceof SoyMsgSelectPart) {
return true;
}
}
return false;
} | java | public static boolean hasPlrselPart(List<SoyMsgPart> msgParts) {
for (SoyMsgPart origMsgPart : msgParts) {
if (origMsgPart instanceof SoyMsgPluralPart || origMsgPart instanceof SoyMsgSelectPart) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasPlrselPart",
"(",
"List",
"<",
"SoyMsgPart",
">",
"msgParts",
")",
"{",
"for",
"(",
"SoyMsgPart",
"origMsgPart",
":",
"msgParts",
")",
"{",
"if",
"(",
"origMsgPart",
"instanceof",
"SoyMsgPluralPart",
"||",
"origMsgPart",
"insta... | Checks whether a given list of msg parts has any plural or select parts.
@param msgParts The msg parts to check.
@return Whether there are any plural or select parts. | [
"Checks",
"whether",
"a",
"given",
"list",
"of",
"msg",
"parts",
"has",
"any",
"plural",
"or",
"select",
"parts",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/restricted/MsgPartUtils.java#L35-L42 |
53,585 | google/closure-templates | java/src/com/google/template/soy/data/SoyListData.java | SoyListData.set | public void set(int index, SoyData value) {
if (index == list.size()) {
list.add(ensureValidValue(value));
} else {
list.set(index, ensureValidValue(value));
}
} | java | public void set(int index, SoyData value) {
if (index == list.size()) {
list.add(ensureValidValue(value));
} else {
list.set(index, ensureValidValue(value));
}
} | [
"public",
"void",
"set",
"(",
"int",
"index",
",",
"SoyData",
"value",
")",
"{",
"if",
"(",
"index",
"==",
"list",
".",
"size",
"(",
")",
")",
"{",
"list",
".",
"add",
"(",
"ensureValidValue",
"(",
"value",
")",
")",
";",
"}",
"else",
"{",
"list"... | Sets a data value at a given index.
@param index The index.
@param value The data to set. | [
"Sets",
"a",
"data",
"value",
"at",
"a",
"given",
"index",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/SoyListData.java#L240-L246 |
53,586 | google/closure-templates | java/src/com/google/template/soy/data/SoyListData.java | SoyListData.get | @Override
public SoyData get(int index) {
try {
return list.get(index);
} catch (IndexOutOfBoundsException ioobe) {
return null;
}
} | java | @Override
public SoyData get(int index) {
try {
return list.get(index);
} catch (IndexOutOfBoundsException ioobe) {
return null;
}
} | [
"@",
"Override",
"public",
"SoyData",
"get",
"(",
"int",
"index",
")",
"{",
"try",
"{",
"return",
"list",
".",
"get",
"(",
"index",
")",
";",
"}",
"catch",
"(",
"IndexOutOfBoundsException",
"ioobe",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Gets the data value at a given index.
@param index The index.
@return The data at the given index, or null of the index is undefined. | [
"Gets",
"the",
"data",
"value",
"at",
"a",
"given",
"index",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/SoyListData.java#L307-L314 |
53,587 | google/closure-templates | java/src/com/google/template/soy/error/SoyErrors.java | SoyErrors.getDidYouMeanMessage | public static String getDidYouMeanMessage(Iterable<String> allNames, String wrongName) {
String closestName = getClosest(allNames, wrongName);
if (closestName != null) {
return String.format(" Did you mean '%s'?", closestName);
}
return "";
} | java | public static String getDidYouMeanMessage(Iterable<String> allNames, String wrongName) {
String closestName = getClosest(allNames, wrongName);
if (closestName != null) {
return String.format(" Did you mean '%s'?", closestName);
}
return "";
} | [
"public",
"static",
"String",
"getDidYouMeanMessage",
"(",
"Iterable",
"<",
"String",
">",
"allNames",
",",
"String",
"wrongName",
")",
"{",
"String",
"closestName",
"=",
"getClosest",
"(",
"allNames",
",",
"wrongName",
")",
";",
"if",
"(",
"closestName",
"!="... | Given a collection of strings and a name that isn't contained in it. Return a message that
suggests one of the names.
<p>Returns the empty string if {@code allNames} is empty or there is no close match. | [
"Given",
"a",
"collection",
"of",
"strings",
"and",
"a",
"name",
"that",
"isn",
"t",
"contained",
"in",
"it",
".",
"Return",
"a",
"message",
"that",
"suggests",
"one",
"of",
"the",
"names",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/error/SoyErrors.java#L37-L43 |
53,588 | google/closure-templates | java/src/com/google/template/soy/error/SoyErrors.java | SoyErrors.distance | private static int distance(String s, String t, int maxDistance) {
// create two work vectors of integer distances
// it is possible to reduce this to only one array, but performance isn't that important here.
// We could also avoid calculating a lot of the entries by taking maxDistance into account in
... | java | private static int distance(String s, String t, int maxDistance) {
// create two work vectors of integer distances
// it is possible to reduce this to only one array, but performance isn't that important here.
// We could also avoid calculating a lot of the entries by taking maxDistance into account in
... | [
"private",
"static",
"int",
"distance",
"(",
"String",
"s",
",",
"String",
"t",
",",
"int",
"maxDistance",
")",
"{",
"// create two work vectors of integer distances",
"// it is possible to reduce this to only one array, but performance isn't that important here.",
"// We could als... | Performs a case insensitive Levenshtein edit distance based on the 2 rows implementation.
@param s The first string
@param t The second string
@param maxDistance The distance to beat, if we can't do better, stop trying
@return an integer describing the number of edits needed to transform s into t
@see "https://en.wiki... | [
"Performs",
"a",
"case",
"insensitive",
"Levenshtein",
"edit",
"distance",
"based",
"on",
"the",
"2",
"rows",
"implementation",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/error/SoyErrors.java#L101-L148 |
53,589 | google/closure-templates | java/src/com/google/template/soy/error/SoyErrors.java | SoyErrors.formatErrors | public static String formatErrors(Iterable<SoyError> errors) {
int numErrors = 0;
int numWarnings = 0;
for (SoyError error : errors) {
if (error.isWarning()) {
numWarnings++;
} else {
numErrors++;
}
}
if (numErrors + numWarnings == 0) {
throw new IllegalArgume... | java | public static String formatErrors(Iterable<SoyError> errors) {
int numErrors = 0;
int numWarnings = 0;
for (SoyError error : errors) {
if (error.isWarning()) {
numWarnings++;
} else {
numErrors++;
}
}
if (numErrors + numWarnings == 0) {
throw new IllegalArgume... | [
"public",
"static",
"String",
"formatErrors",
"(",
"Iterable",
"<",
"SoyError",
">",
"errors",
")",
"{",
"int",
"numErrors",
"=",
"0",
";",
"int",
"numWarnings",
"=",
"0",
";",
"for",
"(",
"SoyError",
"error",
":",
"errors",
")",
"{",
"if",
"(",
"error... | Formats the errors in a standard way for displaying to a user. | [
"Formats",
"the",
"errors",
"in",
"a",
"standard",
"way",
"for",
"displaying",
"to",
"a",
"user",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/error/SoyErrors.java#L151-L178 |
53,590 | google/closure-templates | java/src/com/google/template/soy/data/SoyDataException.java | SoyDataException.prependKeyToDataPath | public void prependKeyToDataPath(String key) {
if (dataPath == null) {
dataPath = key;
} else {
dataPath = key + ((dataPath.charAt(0) == '[') ? "" : ".") + dataPath;
}
} | java | public void prependKeyToDataPath(String key) {
if (dataPath == null) {
dataPath = key;
} else {
dataPath = key + ((dataPath.charAt(0) == '[') ? "" : ".") + dataPath;
}
} | [
"public",
"void",
"prependKeyToDataPath",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"dataPath",
"==",
"null",
")",
"{",
"dataPath",
"=",
"key",
";",
"}",
"else",
"{",
"dataPath",
"=",
"key",
"+",
"(",
"(",
"dataPath",
".",
"charAt",
"(",
"0",
")",
... | Prepends a key to the data path where this error occurred. E.g. if the dataPath was previously
'foo.goo' and the key to prepend is 'boo', then the new data path will be 'boo.foo.goo'.
@param key The key to prepend. | [
"Prepends",
"a",
"key",
"to",
"the",
"data",
"path",
"where",
"this",
"error",
"occurred",
".",
"E",
".",
"g",
".",
"if",
"the",
"dataPath",
"was",
"previously",
"foo",
".",
"goo",
"and",
"the",
"key",
"to",
"prepend",
"is",
"boo",
"then",
"the",
"ne... | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/SoyDataException.java#L66-L72 |
53,591 | google/closure-templates | java/src/com/google/template/soy/base/internal/Identifier.java | Identifier.type | @Memoized
public Type type() {
int dotIndex = identifier().indexOf('.');
if (dotIndex == 0) {
checkArgument(BaseUtils.isIdentifierWithLeadingDot(identifier()));
return Type.DOT_IDENT;
} else {
checkArgument(BaseUtils.isDottedIdentifier(identifier()));
return dotIndex == -1 ? Type.S... | java | @Memoized
public Type type() {
int dotIndex = identifier().indexOf('.');
if (dotIndex == 0) {
checkArgument(BaseUtils.isIdentifierWithLeadingDot(identifier()));
return Type.DOT_IDENT;
} else {
checkArgument(BaseUtils.isDottedIdentifier(identifier()));
return dotIndex == -1 ? Type.S... | [
"@",
"Memoized",
"public",
"Type",
"type",
"(",
")",
"{",
"int",
"dotIndex",
"=",
"identifier",
"(",
")",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"dotIndex",
"==",
"0",
")",
"{",
"checkArgument",
"(",
"BaseUtils",
".",
"isIdentifierWithLead... | This field is only rarely accessed, memoize it. | [
"This",
"field",
"is",
"only",
"rarely",
"accessed",
"memoize",
"it",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/base/internal/Identifier.java#L69-L79 |
53,592 | google/closure-templates | java/src/com/google/template/soy/base/internal/Identifier.java | Identifier.extractPartAfterLastDot | public Identifier extractPartAfterLastDot() {
String part = BaseUtils.extractPartAfterLastDot(identifier());
return Identifier.create(
part, location().offsetStartCol(identifier().length() - part.length()));
} | java | public Identifier extractPartAfterLastDot() {
String part = BaseUtils.extractPartAfterLastDot(identifier());
return Identifier.create(
part, location().offsetStartCol(identifier().length() - part.length()));
} | [
"public",
"Identifier",
"extractPartAfterLastDot",
"(",
")",
"{",
"String",
"part",
"=",
"BaseUtils",
".",
"extractPartAfterLastDot",
"(",
"identifier",
"(",
")",
")",
";",
"return",
"Identifier",
".",
"create",
"(",
"part",
",",
"location",
"(",
")",
".",
"... | Gets the part after the last dot in a dotted identifier. If there are no dots, returns the
whole identifier.
<p><b>Important:</b> The input must be a dotted identifier. This is not checked. | [
"Gets",
"the",
"part",
"after",
"the",
"last",
"dot",
"in",
"a",
"dotted",
"identifier",
".",
"If",
"there",
"are",
"no",
"dots",
"returns",
"the",
"whole",
"identifier",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/base/internal/Identifier.java#L87-L91 |
53,593 | google/closure-templates | java/src/com/google/template/soy/data/internalutils/InternalValueUtils.java | InternalValueUtils.convertPrimitiveDataToExpr | @Nullable
public static PrimitiveNode convertPrimitiveDataToExpr(
PrimitiveData primitiveData, SourceLocation location) {
if (primitiveData instanceof StringData) {
return new StringNode(primitiveData.stringValue(), QuoteStyle.SINGLE, location);
} else if (primitiveData instanceof BooleanData) {
... | java | @Nullable
public static PrimitiveNode convertPrimitiveDataToExpr(
PrimitiveData primitiveData, SourceLocation location) {
if (primitiveData instanceof StringData) {
return new StringNode(primitiveData.stringValue(), QuoteStyle.SINGLE, location);
} else if (primitiveData instanceof BooleanData) {
... | [
"@",
"Nullable",
"public",
"static",
"PrimitiveNode",
"convertPrimitiveDataToExpr",
"(",
"PrimitiveData",
"primitiveData",
",",
"SourceLocation",
"location",
")",
"{",
"if",
"(",
"primitiveData",
"instanceof",
"StringData",
")",
"{",
"return",
"new",
"StringNode",
"("... | Converts a primitive data object into a primitive expression node.
@param primitiveData The primitive data object to convert. Must not be undefined.
@param location The node's source location.
@return The resulting primitive expression node. | [
"Converts",
"a",
"primitive",
"data",
"object",
"into",
"a",
"primitive",
"expression",
"node",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/internalutils/InternalValueUtils.java#L57-L78 |
53,594 | google/closure-templates | java/src/com/google/template/soy/data/internalutils/InternalValueUtils.java | InternalValueUtils.convertPrimitiveExprToData | public static PrimitiveData convertPrimitiveExprToData(PrimitiveNode primitiveNode) {
if (primitiveNode instanceof StringNode) {
return StringData.forValue(((StringNode) primitiveNode).getValue());
} else if (primitiveNode instanceof BooleanNode) {
return BooleanData.forValue(((BooleanNode) primiti... | java | public static PrimitiveData convertPrimitiveExprToData(PrimitiveNode primitiveNode) {
if (primitiveNode instanceof StringNode) {
return StringData.forValue(((StringNode) primitiveNode).getValue());
} else if (primitiveNode instanceof BooleanNode) {
return BooleanData.forValue(((BooleanNode) primiti... | [
"public",
"static",
"PrimitiveData",
"convertPrimitiveExprToData",
"(",
"PrimitiveNode",
"primitiveNode",
")",
"{",
"if",
"(",
"primitiveNode",
"instanceof",
"StringNode",
")",
"{",
"return",
"StringData",
".",
"forValue",
"(",
"(",
"(",
"StringNode",
")",
"primitiv... | Converts a primitive expression node into a primitive data object.
@param primitiveNode The primitive expression node to convert.
@return The resulting primitive data object. | [
"Converts",
"a",
"primitive",
"expression",
"node",
"into",
"a",
"primitive",
"data",
"object",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/internalutils/InternalValueUtils.java#L86-L101 |
53,595 | google/closure-templates | java/src/com/google/template/soy/data/internalutils/InternalValueUtils.java | InternalValueUtils.convertCompileTimeGlobalsMap | public static ImmutableMap<String, PrimitiveData> convertCompileTimeGlobalsMap(
Map<String, ?> compileTimeGlobalsMap) {
ImmutableMap.Builder<String, PrimitiveData> resultMapBuilder = ImmutableMap.builder();
for (Map.Entry<String, ?> entry : compileTimeGlobalsMap.entrySet()) {
Object valueObj = en... | java | public static ImmutableMap<String, PrimitiveData> convertCompileTimeGlobalsMap(
Map<String, ?> compileTimeGlobalsMap) {
ImmutableMap.Builder<String, PrimitiveData> resultMapBuilder = ImmutableMap.builder();
for (Map.Entry<String, ?> entry : compileTimeGlobalsMap.entrySet()) {
Object valueObj = en... | [
"public",
"static",
"ImmutableMap",
"<",
"String",
",",
"PrimitiveData",
">",
"convertCompileTimeGlobalsMap",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"compileTimeGlobalsMap",
")",
"{",
"ImmutableMap",
".",
"Builder",
"<",
"String",
",",
"PrimitiveData",
">",
"... | Converts a compile-time globals map in user-provided format into one in the internal format.
<p>The returned map will have the same iteration order as the provided map.
@param compileTimeGlobalsMap Map from compile-time global name to value. The values can be any
of the Soy primitive types: null, boolean, integer, fl... | [
"Converts",
"a",
"compile",
"-",
"time",
"globals",
"map",
"in",
"user",
"-",
"provided",
"format",
"into",
"one",
"in",
"the",
"internal",
"format",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/data/internalutils/InternalValueUtils.java#L113-L145 |
53,596 | google/closure-templates | java/src/com/google/template/soy/conformance/RuleWithWhitelists.java | RuleWithWhitelists.shouldCheckConformanceFor | boolean shouldCheckConformanceFor(String filePath) {
for (String whitelistedPath : getWhitelistedPaths()) {
if (filePath.contains(whitelistedPath)) {
return false;
}
}
ImmutableList<String> onlyApplyToPaths = getOnlyApplyToPaths();
if (onlyApplyToPaths.isEmpty()) {
return true;... | java | boolean shouldCheckConformanceFor(String filePath) {
for (String whitelistedPath : getWhitelistedPaths()) {
if (filePath.contains(whitelistedPath)) {
return false;
}
}
ImmutableList<String> onlyApplyToPaths = getOnlyApplyToPaths();
if (onlyApplyToPaths.isEmpty()) {
return true;... | [
"boolean",
"shouldCheckConformanceFor",
"(",
"String",
"filePath",
")",
"{",
"for",
"(",
"String",
"whitelistedPath",
":",
"getWhitelistedPaths",
"(",
")",
")",
"{",
"if",
"(",
"filePath",
".",
"contains",
"(",
"whitelistedPath",
")",
")",
"{",
"return",
"fals... | A file should be checked against a rule unless it contains one of the whitelisted paths. | [
"A",
"file",
"should",
"be",
"checked",
"against",
"a",
"rule",
"unless",
"it",
"contains",
"one",
"of",
"the",
"whitelisted",
"paths",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/conformance/RuleWithWhitelists.java#L44-L61 |
53,597 | google/closure-templates | java/src/com/google/template/soy/passes/CheckNonEmptyMsgNodesPass.java | CheckNonEmptyMsgNodesPass.isEmpty | private static boolean isEmpty(MsgNode msg) {
for (SoyNode child : msg.getChildren()) {
if (child instanceof RawTextNode && ((RawTextNode) child).getRawText().isEmpty()) {
continue;
}
return false;
}
return true;
} | java | private static boolean isEmpty(MsgNode msg) {
for (SoyNode child : msg.getChildren()) {
if (child instanceof RawTextNode && ((RawTextNode) child).getRawText().isEmpty()) {
continue;
}
return false;
}
return true;
} | [
"private",
"static",
"boolean",
"isEmpty",
"(",
"MsgNode",
"msg",
")",
"{",
"for",
"(",
"SoyNode",
"child",
":",
"msg",
".",
"getChildren",
"(",
")",
")",
"{",
"if",
"(",
"child",
"instanceof",
"RawTextNode",
"&&",
"(",
"(",
"RawTextNode",
")",
"child",
... | If the only children are empty raw text nodes, then the node is empty.
<p>Empty raw text nodes are inserted by the parser to keep track of trimmed whitespace for the
html parser and removed later in the compiler. | [
"If",
"the",
"only",
"children",
"are",
"empty",
"raw",
"text",
"nodes",
"then",
"the",
"node",
"is",
"empty",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/passes/CheckNonEmptyMsgNodesPass.java#L68-L76 |
53,598 | google/closure-templates | java/src/com/google/template/soy/parsepasses/contextautoesc/Inferences.java | Inferences.setEscapingDirectives | public void setEscapingDirectives(
SoyNode node, Context context, List<EscapingMode> escapingModes) {
Preconditions.checkArgument(
(node instanceof PrintNode)
|| (node instanceof CallNode)
|| (node instanceof MsgFallbackGroupNode),
"Escaping directives may only be set f... | java | public void setEscapingDirectives(
SoyNode node, Context context, List<EscapingMode> escapingModes) {
Preconditions.checkArgument(
(node instanceof PrintNode)
|| (node instanceof CallNode)
|| (node instanceof MsgFallbackGroupNode),
"Escaping directives may only be set f... | [
"public",
"void",
"setEscapingDirectives",
"(",
"SoyNode",
"node",
",",
"Context",
"context",
",",
"List",
"<",
"EscapingMode",
">",
"escapingModes",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"(",
"node",
"instanceof",
"PrintNode",
")",
"||",
"(",
... | Records inferred escaping modes so a directive can be later added to the Soy parse tree. | [
"Records",
"inferred",
"escaping",
"modes",
"so",
"a",
"directive",
"can",
"be",
"later",
"added",
"to",
"the",
"Soy",
"parse",
"tree",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/parsepasses/contextautoesc/Inferences.java#L100-L111 |
53,599 | google/closure-templates | java/src/com/google/template/soy/parsepasses/contextautoesc/Inferences.java | Inferences.getEscapingModesForNode | public ImmutableList<EscapingMode> getEscapingModesForNode(SoyNode node) {
ImmutableList<EscapingMode> modes = nodeToEscapingModes.get(node);
if (modes == null) {
modes = ImmutableList.of();
}
return modes;
} | java | public ImmutableList<EscapingMode> getEscapingModesForNode(SoyNode node) {
ImmutableList<EscapingMode> modes = nodeToEscapingModes.get(node);
if (modes == null) {
modes = ImmutableList.of();
}
return modes;
} | [
"public",
"ImmutableList",
"<",
"EscapingMode",
">",
"getEscapingModesForNode",
"(",
"SoyNode",
"node",
")",
"{",
"ImmutableList",
"<",
"EscapingMode",
">",
"modes",
"=",
"nodeToEscapingModes",
".",
"get",
"(",
"node",
")",
";",
"if",
"(",
"modes",
"==",
"null... | The escaping modes for the print command with the given ID in the order in which they should be
applied.
@param node a node instance | [
"The",
"escaping",
"modes",
"for",
"the",
"print",
"command",
"with",
"the",
"given",
"ID",
"in",
"the",
"order",
"in",
"which",
"they",
"should",
"be",
"applied",
"."
] | cc61e1dff70ae97f24f417a57410081bc498bd56 | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/parsepasses/contextautoesc/Inferences.java#L119-L125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.