本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.TypeOracle.getType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeOracle.getType方法的具体用法?Java TypeOracle.getType怎么用?Java TypeOracle.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.core.ext.typeinfo.TypeOracle
的用法示例。
在下文中一共展示了TypeOracle.getType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReflectedType
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
private JClassType getReflectedType( TypeOracle typeOracle, String askedTypeName ) throws UnableToCompleteException
{
JClassType askedType;
try
{
askedType = typeOracle.getType( askedTypeName );
}
catch( NotFoundException e )
{
throw new UnableToCompleteException();
}
for( JClassType classType : askedType.getImplementedInterfaces() )
{
if( !classType.getQualifiedSourceName().equals( "fr.lteconsulting.hexa.classinfo.Clazz" ) )
continue;
JParameterizedType parametrized = classType.isParameterized();
JClassType[] typeArgs = parametrized.getTypeArgs();
return typeArgs[0];
}
throw new UnableToCompleteException();
}
示例2: generate
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
try {
TypeOracle typeOracle = context.getTypeOracle();
JClassType eventBinderType = typeOracle.getType(typeName);
JClassType targetType = getTargetType(eventBinderType, typeOracle);
SourceWriter writer = createSourceWriter(logger, context, eventBinderType, targetType);
if (writer != null) {
write_doBindEventHandlers(targetType, typeOracle, writer, logger);
writer.commit(logger);
}
return getFullyQualifiedGeneratedClassName(eventBinderType);
} catch (NotFoundException e) {
logger.log(Type.ERROR, "Error generating " + typeName, e);
throw new UnableToCompleteException();
}
}
示例3: generate
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext generatorContext, String typeName)
throws UnableToCompleteException
{
TypeOracle types = generatorContext.getTypeOracle();
ClassName componentTypeName = ClassName.bestGuess(typeName.substring(0,
typeName.length() - COMPONENT_TEMPLATE_SUFFIX.length()));
JClassType componentJsType;
try
{
componentJsType =
types.getType(componentJsTypeName(componentTypeName).reflectionName());
}
catch (NotFoundException nfe)
{
logger.log(Type.ERROR, "Not Found", nfe);
throw new UnableToCompleteException();
}
ClassName templateImplTypeName = componentTemplateImplName(componentTypeName);
PrintWriter printWriter = generatorContext.tryCreate(logger,
templateImplTypeName.packageName(),
templateImplTypeName.simpleName());
if (printWriter != null)
{
generateOnce(printWriter, logger, generatorContext, componentJsType, componentTypeName);
}
return templateImplTypeName.reflectionName();
}
示例4: getClassType
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
protected JClassType getClassType(GeneratorContext context, String qualifiedClassName) throws RebindException {
final String METHOD = "getClassType(GeneratorContext, String)";
JClassType classType = null;
try {
TypeOracle typeOracle = context.getTypeOracle();
classType = typeOracle.getType(qualifiedClassName);
} catch (NotFoundException e) {
String m = qualifiedClassName + " was not found";
LOG.logp(Level.SEVERE, CLASS, METHOD, m);
throw new RebindException(m);
}
return classType;
}
示例5: generate
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext genCtx,
String fqInterfaceName) throws UnableToCompleteException {
TypeOracle oracle = genCtx.getTypeOracle();
JClassType interfaceType;
try {
interfaceType = oracle.getType(fqInterfaceName);
} catch (NotFoundException e) {
throw new RuntimeException(e);
}
DesignTimeUtils designTime;
if (DesignTimeUtilsImpl.isDesignTime(fqInterfaceName)) {
designTime = new DesignTimeUtilsImpl();
} else {
designTime = DesignTimeUtilsStub.EMPTY;
}
String implName = interfaceType.getName().replace('.', '_') + "Impl";
implName = designTime.getImplName(implName);
String packageName = interfaceType.getPackage().getName();
PrintWriterManager writers = new PrintWriterManager(genCtx, logger,
packageName);
PrintWriter printWriter = writers.tryToMakePrintWriterFor(implName);
if (printWriter != null) {
generateOnce(interfaceType, implName, printWriter, logger, oracle,
genCtx.getResourcesOracle(), genCtx.getPropertyOracle(), writers, designTime);
}
return packageName + "." + implName;
}
示例6: injectMagic
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public JExpression injectMagic(final TreeLogger logger, final JMethodCall methodCall,
final JMethod enclosingMethod, final Context context, final UnifyAstView ast)
throws UnableToCompleteException {
final List<JExpression> args = methodCall.getArgs();
final JClassLiteral typeLiteral = ReflectionUtilAst.extractClassLiteral(logger, args.get(0), ast, true);
logger.log(Type.TRACE, "Injecting css for "+typeLiteral.getRefType().getName());
// Ensure the type is loaded by the type oracle.
final TypeOracle oracle = ast.getTypeOracle();
final JType translated = ast.translate(typeLiteral.getRefType());
// Load the type from the type oracle
com.google.gwt.core.ext.typeinfo.JClassType templateType;
try {
templateType = oracle.getType(typeLiteral.getRefType().getName().replace('$', '.'));
} catch (final NotFoundException e) {
logger.log(Type.ERROR, "Unable to load "+typeLiteral.getRefType()+" from the type oracle");
throw new UnableToCompleteException();
}
logger.log(TreeLogger.TRACE, "Template translated : " + translated.toSource());
HtmlGeneratorResult provider;
provider = CssInjectorGenerator.generateSnippetProvider(logger, ast, templateType);
// Force load the type, to ensure it is parsed into AST
ast.getTypeOracle().findType(provider.getFinalName());
// Grab the type from the jjs ast
final JClassType injectorType = (JClassType) ast.searchForTypeBySource(provider.getFinalName());
final SourceInfo info = methodCall.getSourceInfo().makeChild();
for (final JMethod method : injectorType.getMethods()) {
if (method.getName().equals("inject")) {
JExpression arg;
if (args.size() > 1) {
// The X_Html method receives a reference to the StyleService to use
arg = args.get(1);
} else {
// The X_Element method does not take a StyleService, and instead uses it's own default
final JDeclaredType elemental = ast.searchForTypeBySource("xapi.elemental.X_Elemental");
final String serviceType = "Lxapi/elemental/api/ElementalService;";
final JMethod getService = elemental.findMethod("getElementalService()"+serviceType, false);
arg = new JMethodCall(method.getSourceInfo(), null, getService);
}
return new JMethodCall(info, null, method, arg);
}
}
logger.log(Type.ERROR, "Unable to find method inject in generated UI provider "+provider);
throw new UnableToCompleteException();
}