use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class TemplateSubject method isNotWellFormed.
public void isNotWellFormed() {
ErrorReporter errorReporter = doParse();
Truth.assertThat(errorReporter.hasErrors()).isTrue();
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class TemplateParserTest method assertInvalidTemplate.
private static void assertInvalidTemplate(String input) {
ErrorReporter errorReporter = ErrorReporter.createForTest();
parseTemplateContent(input, errorReporter);
assertThat(errorReporter.getErrors()).isNotEmpty();
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class MsgHtmlTagNodeTest method testErrorNodeReturnedWhenPhNameAttrIsMalformed.
@Test
public void testErrorNodeReturnedWhenPhNameAttrIsMalformed() {
ErrorReporter errorReporter = ErrorReporter.createForTest();
parseMsgHtmlTagNode("<div phname=\".+\" />", errorReporter);
assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).isEqualTo("'phname' is not a valid identifier.");
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class BytecodeCompiler method compileToJar.
/**
* Compiles all the templates in the given registry to a jar file written to the given output
* stream.
*
* <p>If errors are encountered, the error reporter will be updated and we will return. The
* contents of any data written to the sink at that point are undefined.
*
* @param registry All the templates to compile
* @param reporter The error reporter
* @param sink The output sink to write the JAR to.
*/
public static void compileToJar(TemplateRegistry registry, ErrorReporter reporter, ByteSink sink) throws IOException {
ErrorReporter.Checkpoint checkpoint = reporter.checkpoint();
if (reporter.errorsSince(checkpoint)) {
return;
}
CompiledTemplateRegistry compilerRegistry = new CompiledTemplateRegistry(registry);
if (reporter.errorsSince(checkpoint)) {
return;
}
try (final SoyJarFileWriter writer = new SoyJarFileWriter(sink.openStream())) {
compileTemplates(compilerRegistry, reporter, new CompilerListener<Void>() {
@Override
void onCompile(ClassData clazz) throws IOException {
writer.writeEntry(clazz.type().internalName() + ".class", ByteSource.wrap(clazz.data()));
}
});
}
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class SoyDeprecatedTest method testSoyDeprecated.
@Test
public void testSoyDeprecated() throws Exception {
ErrorReporter reporter = ErrorReporter.createForTest();
SoyFileSetParserBuilder.forTemplateContents("{deprecated() |deprecated}").addSoyFunction(new DeprecatedFunction()).addPrintDirective(new DeprecatedPrintDirective()).errorReporter(reporter).parse();
assertThat(reporter.getErrors()).isEmpty();
assertThat(reporter.getWarnings()).hasSize(2);
assertThat(reporter.getWarnings().get(0).message()).isEqualTo("deprecated is deprecated: please stop using this function.");
assertThat(reporter.getWarnings().get(1).message()).isEqualTo("|deprecated is deprecated: please stop using this directive.");
}
Aggregations