use of com.google.template.soy.jbcsrc.restricted.TypeInfo in project closure-templates by google.
the class TemplateFactoryCompiler method compile.
/**
* Compiles the factory.
*/
void compile() {
TypeInfo factoryType = innerClasses.registerInnerClass(FACTORY_CLASS, FACTORY_ACCESS);
SoyClassWriter cw = SoyClassWriter.builder(factoryType).implementing(FACTORY_TYPE).setAccess(FACTORY_ACCESS).sourceFileName(template.node().getSourceLocation().getFileName()).build();
innerClasses.registerAsInnerClass(cw, factoryType);
generateStaticInitializer(cw);
defineDefaultConstructor(cw, factoryType);
generateCreateMethod(cw, factoryType);
cw.visitEnd();
innerClasses.add(cw.toClassData());
}
use of com.google.template.soy.jbcsrc.restricted.TypeInfo in project closure-templates by google.
the class InnerClasses method registerAllInnerClasses.
/**
* Registers all inner classes to the given outer class.
*/
public void registerAllInnerClasses(ClassVisitor visitor) {
for (Map.Entry<TypeInfo, Integer> entry : innerClassesAccessModifiers.entrySet()) {
TypeInfo innerClass = entry.getKey();
doRegister(visitor, innerClass);
}
}
use of com.google.template.soy.jbcsrc.restricted.TypeInfo in project closure-templates by google.
the class LazyClosureCompiler method compileLazyContent.
Expression compileLazyContent(String namePrefix, RenderUnitNode renderUnit, String varName) {
Optional<Expression> asRawText = asRawTextOnly(renderUnit);
if (asRawText.isPresent()) {
return asRawText.get();
}
TypeInfo type = innerClasses.registerInnerClassWithGeneratedName(getProposedName(namePrefix, varName), LAZY_CLOSURE_ACCESS);
SoyClassWriter writer = SoyClassWriter.builder(type).setAccess(LAZY_CLOSURE_ACCESS).extending(DETACHABLE_CONTENT_PROVIDER_TYPE).sourceFileName(renderUnit.getSourceLocation().getFileName()).build();
Expression expr = new CompilationUnit(writer, type, DETACHABLE_CONTENT_PROVIDER_TYPE, renderUnit).compileRenderable(renderUnit);
innerClasses.registerAsInnerClass(writer, type);
writer.visitEnd();
innerClasses.add(writer.toClassData());
return expr;
}
use of com.google.template.soy.jbcsrc.restricted.TypeInfo in project closure-templates by google.
the class ProtoUtils method getGetterMethod.
/**
* Returns the {@link MethodRef} for the generated getter method.
*/
private static MethodRef getGetterMethod(FieldDescriptor descriptor) {
Preconditions.checkArgument(!descriptor.isExtension(), "extensions do not have getter methods. %s", descriptor);
TypeInfo message = messageRuntimeType(descriptor.getContainingType());
boolean isProto3Enum = isProto3EnumField(descriptor);
return MethodRef.createInstanceMethod(message, new Method("get" + getFieldName(descriptor, true) + // For proto3 enums we access the Value field
(isProto3Enum ? "Value" : ""), isProto3Enum ? Type.INT_TYPE : getRuntimeType(descriptor), NO_METHOD_ARGS)).asNonNullable().asCheap();
}
use of com.google.template.soy.jbcsrc.restricted.TypeInfo in project closure-templates by google.
the class ProtoUtils method getBuildMethod.
/**
* Returns the {@link MethodRef} for the generated build method.
*/
private static MethodRef getBuildMethod(Descriptor descriptor) {
TypeInfo message = messageRuntimeType(descriptor);
TypeInfo builder = builderRuntimeType(descriptor);
return MethodRef.createInstanceMethod(builder, new Method("build", message.type(), NO_METHOD_ARGS)).asNonNullable();
}
Aggregations