本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.TypeOracle.findType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeOracle.findType方法的具体用法?Java TypeOracle.findType怎么用?Java TypeOracle.findType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.core.ext.typeinfo.TypeOracle
的用法示例。
在下文中一共展示了TypeOracle.findType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMethodNames
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
private Set<String> getMethodNames(String className, TreeLogger logger,
TypeOracle typeOracle) throws UnableToCompleteException {
JClassType baseClass = typeOracle.findType(className);
if (baseClass == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + baseClass + "'", null);
throw new UnableToCompleteException();
}
Set<String> result = new HashSet<String>();
for (JMethod method : baseClass.getMethods()) {
if (!method.isPrivate()) {
result.add(method.getName());
}
}
return result;
}
示例2: addAnnotations_AnnotationImpl
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
public static void addAnnotations_AnnotationImpl(TypeOracle typeOracle,
String dest, SourceWriter source, Annotation[] annotations, TreeLogger logger){
if (annotations.length <= 0)
return;
for (Annotation annotation : annotations) {
JClassType classType = typeOracle.findType(ReflectionUtils.getQualifiedSourceName(annotation.annotationType()));
if (classType != null){
source.print(dest + ".addAnnotation(" + createAnnotationValues(typeOracle, annotation, logger) + ");");
}else{
logger.log(Type.ERROR, "Annotation (" + ReflectionUtils.getQualifiedSourceName(annotation.annotationType()) + ") not exists in compiled client source code, please ensure this class is exists and included in your module(.gwt.xml) file. GWTENT reflection process will ignore it and continue. ");
}
}
}
示例3: getTestCases
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
public static List<TestCase> getTestCases(TreeLogger logger, GeneratorContext context)
throws UnableToCompleteException {
if (DEBUG) logger = logger.branch(TreeLogger.WARN, "Getting test cases", null, null);
TypeOracle oracle = context.getTypeOracle();
JClassType jsTestCaseClass = oracle.findType(JsTestCase.class.getName());
List<TestCase> testCases = new ArrayList<TestCase>();
for (JClassType classType : oracle.getTypes()) {
if (classType.equals(jsTestCaseClass) || !classType.isAssignableTo(jsTestCaseClass)) {
continue;
}
if (classType.getEnclosingType() != null) {
if (DEBUG) logger.log(TreeLogger.WARN, "Skipping nested class: " +
classType.getEnclosingType().getName() + "." + classType.getName());
continue;
}
if (DEBUG) logger.log(TreeLogger.WARN, "Found class: " + classType.getName());
testCases.add(new TestCase(classType, findTests(logger, context, classType)));
}
return testCases;
}
示例4: getAllInstantiableClassesByThisfactory
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
/**
* Filter all classes visible to GWT client side and return only those deemed instantiable
* through the factory class we are generating (that is EntityInputFactoryImpl).
* <p>
* Allowing all classes to be instantiable would potentially generate too huge class method
* perhaps even too huge to compile. There must be some sub-selection. Classes can be filtered
* based on marker interface, or class annotation see {@link JClassType#getAnnotation(Class)},
* or some regex matching based on package or class name.
*
* @param context
* @return Filter all classes visible to GWT client side and return only those deemed
* instantiable
*/
private List<JClassType> getAllInstantiableClassesByThisfactory(GeneratorContext context) {
TypeOracle oracle = context.getTypeOracle();
JClassType markerInterface1 = oracle.findType(IEntityInput.class.getName());
JClassType markerInterface2 = oracle.findType(Entity.class.getName());
List<JClassType> allInstantiableClasses = new LinkedList<JClassType>();
for (JClassType classType : oracle.getTypes()) {
if (!classType.equals(markerInterface1) && classType.isAssignableTo(markerInterface1)) {
allInstantiableClasses.add(classType);
}
else if (!classType.equals(markerInterface2) && classType.isAssignableTo(markerInterface2)) {
allInstantiableClasses.add(classType);
}
}
return allInstantiableClasses;
}
示例5: generate
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public String generate (TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
TypeOracle oracle = context.getTypeOracle();
assert (oracle != null);
JClassType type = oracle.findType(typeName);
if (type == null) {
logger.log(ERROR, "Couldn't find type '" + typeName + "'");
throw new UnableToCompleteException();
}
if (type.isInterface() == null) {
logger.log(ERROR, "Type '" + typeName + "' must be an interface");
throw new UnableToCompleteException();
}
ReflectionCacheSourceCreator source = new ReflectionCacheSourceCreator(logger, context, type);
return source.create();
}
示例6: JacksonTypeOracle
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
/**
* <p>Constructor for JacksonTypeOracle.</p>
*
* @param logger a {@link com.google.gwt.core.ext.TreeLogger} object.
* @param typeOracle a {@link com.google.gwt.core.ext.typeinfo.TypeOracle} object.
*/
public JacksonTypeOracle( TreeLogger logger, TypeOracle typeOracle ) {
this.logger = logger;
this.typeOracle = typeOracle;
this.objectReaderType = typeOracle.findType( ObjectReader.class.getCanonicalName() );
this.objectWriterType = typeOracle.findType( ObjectWriter.class.getCanonicalName() );
this.keySerializerType = typeOracle.findType( KeySerializer.class.getCanonicalName() );
this.keyDeserializerType = typeOracle.findType( KeyDeserializer.class.getCanonicalName() );
this.jsonSerializerType = typeOracle.findType( JsonSerializer.class.getCanonicalName() );
this.jsonDeserializerType = typeOracle.findType( JsonDeserializer.class.getCanonicalName() );
this.mapType = typeOracle.findType( Map.class.getCanonicalName() );
this.iterableType = typeOracle.findType( Iterable.class.getCanonicalName() );
this.jsoType = typeOracle.findType( JavaScriptObject.class.getCanonicalName() );
this.enumType = typeOracle.findType( Enum.class.getCanonicalName() );
this.stringType = typeOracle.findType( String.class.getCanonicalName() );
}
示例7: createAnnotationValues
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
public static String createAnnotationValues(TypeOracle typeOracle,
Annotation annotation, TreeLogger logger){
StringBuilder sb = new StringBuilder();
JClassType classType = typeOracle.findType(ReflectionUtils.getQualifiedSourceName(annotation.annotationType()));
if (classType != null){
sb.append("org.lirazs.gbackbone.reflection.client.impl.AnnotationValues.toAnnotation(new org.lirazs.gbackbone.reflection.client.impl.AnnotationValues(");
sb.append("\"" + classType.getQualifiedSourceName() + "\", new Object[]{");
JAnnotationType annoType = classType.isAnnotation();
// JAnnotationMethod[] methods = annoType.getMethods();
JAnnotationMethod[] methods = (JAnnotationMethod[]) annoType.getMethods();
int index = 0;
for (JAnnotationMethod method : methods) {
Object value = null;
try {
value = annotation.annotationType().getMethod(method.getName(), new Class[]{}).invoke(annotation);
if (index > 0)
sb.append(", ");
sb.append(annoValueToCode(typeOracle, value, logger));
index ++;
} catch (Exception e){
throw new CheckedExceptionWrapper(e);
}
}
sb.append("}))");
}else{
logger.log(Type.ERROR, "Annotation (" + ReflectionUtils.getQualifiedSourceName(annotation.annotationType()) + ") not exists in compiled client source code, please ensure this class is exists and included in your module(.gwt.xml) file. GWTENT reflection process will ignore it and continue. ");
}
return sb.toString();
}
示例8: generate
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
JClassType extensionManager = typeOracle.findType(typeName);
if (extensionManager == null) {
logger.log(TreeLogger.ERROR, "Can't find interface type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
if (extensionManager.isInterface() == null) {
logger.log(
TreeLogger.ERROR,
extensionManager.getQualifiedSourceName() + " is not an interface",
null);
throw new UnableToCompleteException();
}
List<JClassType> extensions = new ArrayList<>();
for (JClassType type : typeOracle.getTypes()) {
if (type.isAnnotationPresent(Extension.class)) {
extensions.add(type);
}
}
String packageName = extensionManager.getPackage().getName();
String className = extensionManager.getSimpleSourceName() + "Impl";
generateClass(logger, context, packageName, className, extensions);
return packageName + "." + className;
}
示例9: generateIncrementally
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public RebindResult generateIncrementally(TreeLogger logger,
GeneratorContext generatorContext,
String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = generatorContext.getTypeOracle();
assert (typeOracle != null);
JClassType originalType = typeOracle.findType(typeName);
if (originalType == null) {
logger.log(TreeLogger.ERROR,
"Unable to find metadata for type '" + typeName + "'");
throw new UnableToCompleteException();
}
if (originalType.isInterface() == null) {
logger.log(TreeLogger.ERROR,
"'" + typeName + "' is not a interface");
throw new UnableToCompleteException();
}
TreeLogger moduleLogger = logger.branch(TreeLogger.DEBUG,
"Generating client proxy for remote service interface '" + originalType.getQualifiedSourceName() + "'",
null);
return create(originalType,
moduleLogger,
generatorContext,
typeName);
}
示例10: generateIncrementally
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public RebindResult generateIncrementally(TreeLogger logger,
GeneratorContext generatorContext,
String moduleClass)
throws UnableToCompleteException {
TypeOracle typeOracle = generatorContext.getTypeOracle();
assert (typeOracle != null);
JClassType module = typeOracle.findType(moduleClass);
if (module == null) {
logger.log(TreeLogger.ERROR,
"Unable to find metadata for module class '" + moduleClass + "'");
throw new UnableToCompleteException();
}
if (module.isInterface() == null) {
logger.log(TreeLogger.ERROR,
"'" + moduleClass + "' is not a interface");
throw new UnableToCompleteException();
}
TreeLogger moduleLogger = logger.branch(TreeLogger.DEBUG,
"Generating mvp4g configuration for module class '" + module.getQualifiedSourceName() + "'",
null);
return create(moduleLogger,
generatorContext,
moduleClass);
}
示例11: generate
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
JClassType subsystemExtensionManager = typeOracle.findType(typeName);
if (subsystemExtensionManager == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
if (subsystemExtensionManager.isInterface() == null) {
logger.log(TreeLogger.ERROR, subsystemExtensionManager.getQualifiedSourceName() + " is not an interface",
null);
throw new UnableToCompleteException();
}
List<SubsystemExtension> subsystemExtensions = new ArrayList<SubsystemExtension>();
for (JClassType type : typeOracle.getTypes()) {
if (type.isAnnotationPresent(SubsystemExtension.class)) {
subsystemExtensions.add(type.getAnnotation(SubsystemExtension.class));
}
}
String packageName = subsystemExtensionManager.getPackage().getName();
String className = subsystemExtensionManager.getSimpleSourceName() + "Impl";
generateClass(logger, context, packageName, className, subsystemExtensions);
return packageName + "." + className;
}
示例12: findType
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
private JClassType findType(final TreeLogger logger, final TypeOracle typeOracle,
final String typeName) throws UnableToCompleteException {
final JClassType result = typeOracle.findType(typeName);
if (result == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
return result;
}
示例13: findType
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
/**
* lets find the type of the class.
*
* @param plogger logger
* @param ptypeOracle type oracle
* @param ptypeName type name
* @return class type
* @throws UnableToCompleteException if type can't be detected
*/
private JClassType findType(final TreeLogger plogger, final TypeOracle ptypeOracle,
final String ptypeName) throws UnableToCompleteException {
final JClassType result = ptypeOracle.findType(ptypeName);
if (result == null) {
plogger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + ptypeName + "'", null);
throw new UnableToCompleteException();
}
return result;
}
示例14: generateIncrementally
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
@Override
public RebindResult generateIncrementally(TreeLogger logger,
GeneratorContext context,
String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
assert (typeOracle != null);
JClassType templatesInterface = typeOracle.findType(Name.getSourceNameForClass(Gwt4eTemplates.class));
JClassType toGenerate = typeOracle.findType(typeName)
.isInterface();
if (toGenerate == null) {
logger.log(TreeLogger.Type.ERROR,
typeName + " is not an interface");
throw new UnableToCompleteException();
}
if (!toGenerate.isAssignableTo(templatesInterface)) {
logger.log(TreeLogger.Type.ERROR,
"This isn't a HossTemplates subtype...");
throw new UnableToCompleteException();
}
TreeLogger propertyLogger = logger.branch(TreeLogger.DEBUG,
"gwt4e template generator",
null);
return create(propertyLogger,
context,
toGenerate);
}
示例15: HandlerEvaluator
import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入方法依赖的package包/类
/**
* The verbose testable constructor.
*
* @param ownerClass a descriptor of the UI owner class
* @param logger the logger for warnings and errors
* @param oracle the type oracle
*/
HandlerEvaluator(OwnerClass ownerClass, MortalLogger logger,
TypeOracle oracle, boolean useLazyWidgetBuilders) {
this.ownerClass = ownerClass;
this.logger = logger;
this.useLazyWidgetBuilders = useLazyWidgetBuilders;
handlerRegistrationJClass = oracle.findType(HandlerRegistration.class.getName());
eventHandlerJClass = oracle.findType(EventHandler.class.getName());
}