本文整理汇总了Java中com.google.template.soy.types.SoyTypeRegistry类的典型用法代码示例。如果您正苦于以下问题:Java SoyTypeRegistry类的具体用法?Java SoyTypeRegistry怎么用?Java SoyTypeRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoyTypeRegistry类属于com.google.template.soy.types包,在下文中一共展示了SoyTypeRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGetType
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
private SoyType doGetType(String name, SoyTypeRegistry typeRegistry,
GenericDescriptor descriptor) {
SoyType type;
synchronized (lock) {
type = typeCache.get(name);
if (type == null) {
if (descriptor instanceof EnumDescriptor) {
type = new SoyProtoEnumType((EnumDescriptor) descriptor);
} else {
type = new SoyProtoType(typeRegistry, (Descriptor) descriptor, extensions.get(name));
}
typeCache.put(name, type);
}
}
return type;
}
示例2: parseSoyFileHelper
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
/**
* Private helper for {@code parseWithVersions()} to parse one Soy file.
*
* @param soyFileSupplier Supplier of the Soy file content and path.
* @param nodeIdGen The generator of node ids.
* @return The resulting parse tree for one Soy file and the version from which it was parsed.
*/
private SoyFileNode parseSoyFileHelper(
SoyFileSupplier soyFileSupplier, IdGenerator nodeIdGen, SoyTypeRegistry typeRegistry)
throws IOException {
try (Reader soyFileReader = soyFileSupplier.open()) {
String filePath = soyFileSupplier.getFilePath();
int lastBangIndex = filePath.lastIndexOf('!');
if (lastBangIndex != -1) {
// This is a resource in a JAR file. Only keep everything after the bang.
filePath = filePath.substring(lastBangIndex + 1);
}
return new SoyFileParser(
typeRegistry,
pluginResolver(),
nodeIdGen,
soyFileReader,
soyFileSupplier.getSoyFileKind(),
filePath,
errorReporter(),
generalOptions() == null
? ImmutableSet.of()
: generalOptions().getExperimentalFeatures())
.parseSoyFile();
}
}
示例3: build
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
/**
* Builds the new {@code SoyFileSet}.
*
* @return The new {@code SoyFileSet}.
*/
public SoyFileSet build() {
try {
if (!protoTypeProviderBuilder.isEmpty()) {
Set<SoyTypeProvider> typeProviders =
ImmutableSet.<SoyTypeProvider>of(protoTypeProviderBuilder.build());
localTypeRegistry = new SoyTypeRegistry(typeProviders);
}
} catch (DescriptorValidationException | IOException ex) {
throw new RuntimeException("Malformed descriptor set", ex);
}
return new SoyFileSet(
coreDependencies.apiCallScope,
coreDependencies.soyValueConverter,
localTypeRegistry == null ? coreDependencies.typeRegistry : localTypeRegistry,
coreDependencies.soyFunctionMap,
coreDependencies.printDirectives,
filesBuilder.build(),
getGeneralOptions(),
cache,
conformanceConfig,
loggingConfig,
warningSink);
}
示例4: doExtractMsgs
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
/** Performs the parsing and extraction logic. */
private SoyMsgBundle doExtractMsgs() {
// extractMsgs disables a bunch of passes since it is typically not configured with things
// like global definitions, type definitions, etc.
SoyFileSetNode soyTree =
parse(
passManagerBuilder(SyntaxVersion.V1_0)
.allowUnknownGlobals()
.setTypeRegistry(SoyTypeRegistry.DEFAULT_UNKNOWN)
.disableAllTypeChecking(),
// override the type registry so that the parser doesn't report errors when it
// can't resolve strict types
SoyTypeRegistry.DEFAULT_UNKNOWN,
new PluginResolver(
PluginResolver.Mode.ALLOW_UNDEFINED,
printDirectives,
soyFunctionMap,
errorReporter))
.fileSet();
throwIfErrorsPresent();
SoyMsgBundle bundle = new ExtractMsgsVisitor().exec(soyTree);
throwIfErrorsPresent();
return bundle;
}
示例5: GenJsCodeVisitor
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
protected GenJsCodeVisitor(
SoyJsSrcOptions jsSrcOptions,
JsExprTranslator jsExprTranslator,
DelTemplateNamer delTemplateNamer,
GenCallCodeUtils genCallCodeUtils,
IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor,
CanInitOutputVarVisitor canInitOutputVarVisitor,
GenJsExprsVisitorFactory genJsExprsVisitorFactory,
SoyTypeRegistry typeRegistry) {
this.jsSrcOptions = jsSrcOptions;
this.jsExprTranslator = jsExprTranslator;
this.delTemplateNamer = delTemplateNamer;
this.genCallCodeUtils = genCallCodeUtils;
this.isComputableAsJsExprsVisitor = isComputableAsJsExprsVisitor;
this.canInitOutputVarVisitor = canInitOutputVarVisitor;
this.genJsExprsVisitorFactory = genJsExprsVisitorFactory;
this.typeRegistry = typeRegistry;
}
示例6: GenIncrementalDomCodeVisitor
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
GenIncrementalDomCodeVisitor(
SoyJsSrcOptions jsSrcOptions,
JsExprTranslator jsExprTranslator,
IncrementalDomDelTemplateNamer incrementalDomDelTemplateNamer,
IncrementalDomGenCallCodeUtils genCallCodeUtils,
IsComputableAsIncrementalDomExprsVisitor isComputableAsJsExprsVisitor,
CanInitOutputVarVisitor canInitOutputVarVisitor,
GenIncrementalDomExprsVisitorFactory genIncrementalDomExprsVisitorFactory,
SoyTypeRegistry typeRegistry) {
super(
jsSrcOptions,
jsExprTranslator,
incrementalDomDelTemplateNamer,
genCallCodeUtils,
isComputableAsJsExprsVisitor,
canInitOutputVarVisitor,
genIncrementalDomExprsVisitorFactory,
typeRegistry);
}
示例7: testProtoInitTyping
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
@Test
public void testProtoInitTyping() {
SoyTypeRegistry typeRegistry =
new SoyTypeRegistry(
ImmutableSet.<SoyTypeProvider>of(
new SoyProtoTypeProvider.Builder()
.addDescriptors(ExampleExtendable.getDescriptor())
.buildNoFiles()));
SoyFileSetNode soyTree =
SoyFileSetParserBuilder.forFileContents(
constructTemplateSource(
"{let $proto: example.ExampleExtendable() /}",
"{assertType('example.ExampleExtendable', $proto)}"))
.addSoyFunction(ASSERT_TYPE_FUNCTION)
.typeRegistry(typeRegistry)
.parse()
.fileSet();
assertTypes(soyTree);
}
示例8: parseVeLog
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
private VeLogNode parseVeLog(String fooLog, ErrorReporter reporter) {
return Iterables.getOnlyElement(
SoyTreeUtils.getAllNodesOfType(
SoyFileSetParserBuilder.forTemplateContents(AutoEscapingType.STRICT, true, fooLog)
.typeRegistry(
new SoyTypeRegistry(
ImmutableSet.<SoyTypeProvider>of(
new SoyProtoTypeProvider.Builder()
.addDescriptors(com.google.template.soy.testing.Foo.getDescriptor())
.buildNoFiles())))
.setLoggingConfig(
ValidatedLoggingConfig.create(
LoggingConfig.newBuilder()
.addElement(
LoggableElement.newBuilder()
.setName("Bar")
.setId(1L)
.setProtoType("soy.test.Foo")
.build())
.build()))
.errorReporter(reporter)
.parse()
.fileSet(),
VeLogNode.class));
}
示例9: runPass
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
/** Parses the given input as a template content. */
private static SoyFileSetNode runPass(String input) {
String soyFile =
Joiner.on('\n').join("{namespace ns}", "", "{template .t}", input, "{/template}");
ParseResult result =
SoyFileSetParserBuilder.forFileContents(soyFile)
// Disable desguaring pass and manually run it later
.desugarHtmlNodes(false)
.typeRegistry(
new SoyTypeRegistry(
ImmutableSet.<SoyTypeProvider>of(
new SoyProtoTypeProvider.Builder()
.addDescriptors(com.google.template.soy.testing.Foo.getDescriptor())
.buildNoFiles())))
.setLoggingConfig(LOGGING_CONFIG)
.addSoyFunction(new TestLoggingFunction())
.errorReporter(ErrorReporter.exploding())
.parse();
TemplateRegistry templateRegistry = result.registry();
SoyFileSetNode soyTree = result.fileSet();
new VeLogInstrumentationVisitor(templateRegistry).exec(soyTree);
return soyTree;
}
示例10: Renderer
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
@Inject
Renderer(
Provider<SoyFileSet.Builder> filesetBuilderProvider,
SoyTypeProvider typeProvider,
JsonRenderer jsonRenderer) {
this.filesetBuilderProvider = filesetBuilderProvider;
this.tofu =
filesetBuilderProvider
.get()
.add(Renderer.class.getResource("resources/types.soy"))
.add(Renderer.class.getResource("resources/dossier.soy"))
.setLocalTypeRegistry(new SoyTypeRegistry(ImmutableSet.of(typeProvider)))
.build()
.compileToTofu();
this.jsonRenderer = jsonRenderer;
}
示例11: configure
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
@Override
protected void configure() {
// This module is mostly available for configuring the compiler (SoyFileSet). Consider
// splitting SoyFileSet into a smaller number of objects and backend specific apis so this isn't
// so monolithic (compiling JS shouldn't require Tofu and python backends).
// eliminating injection points from the backends would help with this effort also.
install(new SharedModule());
Multibinder.newSetBinder(binder(), SoyTypeProvider.class);
bind(SoyTypeRegistry.class).in(Singleton.class);
}
示例12: NormalField
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
NormalField(@Nullable SoyTypeRegistry typeRegistry, FieldDescriptor desc) {
this.typeRegistry = typeRegistry;
this.fieldDescriptor = desc;
this.name = computeSoyName(desc);
this.shouldCheckFieldPresenceToEmulateJspbNullability =
ProtoUtils.shouldCheckFieldPresenceToEmulateJspbNullability(desc);
}
示例13: getType
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
@Override
public SoyType getType(String name, SoyTypeRegistry typeRegistry) {
GenericDescriptor descriptor = descriptors.get(name);
if (descriptor == null) {
return null;
}
return doGetType(name, typeRegistry, descriptor);
}
示例14: RewriteGlobalsPass
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
RewriteGlobalsPass(
SoyTypeRegistry typeRegistry,
ImmutableMap<String, PrimitiveData> compileTimeGlobals,
ErrorReporter errorReporter) {
this.typeRegistry = typeRegistry;
this.compileTimeGlobals = compileTimeGlobals;
this.errorReporter = errorReporter;
}
示例15: ResolveExpressionTypesVisitor
import com.google.template.soy.types.SoyTypeRegistry; //导入依赖的package包/类
ResolveExpressionTypesVisitor(
SoyTypeRegistry typeRegistry,
SyntaxVersion declaredSyntaxVersion,
SoyGeneralOptions generalOptions,
ErrorReporter errorReporter) {
this.errorReporter = errorReporter;
this.typeRegistry = typeRegistry;
this.generalOptions = generalOptions;
this.declaredSyntaxVersion = declaredSyntaxVersion;
}