当前位置: 首页>>代码示例>>Java>>正文


Java TypeOracle.getTypes方法代码示例

本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.TypeOracle.getTypes方法的典型用法代码示例。如果您正苦于以下问题:Java TypeOracle.getTypes方法的具体用法?Java TypeOracle.getTypes怎么用?Java TypeOracle.getTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.core.ext.typeinfo.TypeOracle的用法示例。


在下文中一共展示了TypeOracle.getTypes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:25,代码来源:JsTestEntryGenerator.java

示例2: 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;
}
 
开发者ID:KnowledgeCaptureAndDiscovery,项目名称:ontosoft,代码行数:31,代码来源:EntityGenerator.java

示例3: 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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:ExtensionRegistryGenerator.java

示例4: 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;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:30,代码来源:SubsystemExtensionProcessorGenerator.java

示例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( );

    JClassType instantiableType = oracle.findType( Reflectable.class.getName( ) );

    List<JClassType> clazzes = new ArrayList<JClassType>( );

    PropertyOracle propertyOracle = context.getPropertyOracle( );

    for ( JClassType classType : oracle.getTypes( ) )
    {
        if ( !classType.equals( instantiableType ) && classType.isAssignableTo( instantiableType ) )
            clazzes.add( classType );
    }

    final String genPackageName = "org.lirazs.gbackbone.client.generator";
    final String genClassName = "ReflectionImpl";

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory( genPackageName, genClassName );
    composer.addImplementedInterface( Reflection.class.getCanonicalName( ) );

    composer.addImport( "org.lirazs.gbackbone.client.generator.*" );
    composer.addImport( "org.lirazs.gbackbone.client.core.data.Options" );
    composer.addImport( "com.google.gwt.json.client.JSONObject" );

    PrintWriter printWriter = context.tryCreate( logger, genPackageName, genClassName );

    if ( printWriter != null )
    {
        SourceWriter sourceWriter = composer.createSourceWriter( context, printWriter );
        sourceWriter.println( "ReflectionImpl( ) {" );
        sourceWriter.println( "}" );

        printFactoryMethod(clazzes, sourceWriter);
        printJSONFactoryMethod(clazzes, sourceWriter);
        printArrayFactoryMethod( clazzes, sourceWriter );

        sourceWriter.commit( logger );
    }

    return composer.getCreatedClassName( );
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:45,代码来源:ReflectionGenerator.java

示例6: 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 componentExtensionManager = typeOracle.findType(typeName);
    if (componentExtensionManager == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
        throw new UnableToCompleteException();
    }
    if (componentExtensionManager.isInterface() == null) {
        logger.log(TreeLogger.ERROR, componentExtensionManager.getQualifiedSourceName() + " is not an interface",
                null);
        throw new UnableToCompleteException();
    }

    JClassType componentProvider = typeOracle.findType(ComponentProvider.class.getCanonicalName());
    if (componentProvider == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type 'ComponentProvider'", null);
        throw new UnableToCompleteException();
    }

    List<JClassType> componentExtensionClasses = new ArrayList<JClassType>();
    for (JClassType type : typeOracle.getTypes()) {
        if (type.isAnnotationPresent(ComponentExtension.class)) {
            if (type.isClass() == null || type.isAbstract()) {
                // type must be a class that can be instantiated
                logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
                        + "' cannot be instantiated.", null);
                throw new UnableToCompleteException();
            } else if (!type.isDefaultInstantiable()) {
                // type must have default constructor
                logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
                        + "' does not provide a default constructor.", null);
                throw new UnableToCompleteException();
            } else if (!type.isAssignableTo(componentProvider)) {
                // type must implement ComponentProvider
                logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
                        + "' does not implement ComponentProvider.", null);
                throw new UnableToCompleteException();
            }
            componentExtensionClasses.add(type);
        }
    }

    String packageName = componentExtensionManager.getPackage().getName();
    String className = componentExtensionManager.getSimpleSourceName() + "Impl";

    generateClass(logger, context, packageName, className, componentExtensionClasses);

    return packageName + "." + className;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:52,代码来源:ComponentExtensionManagerGenerator.java


注:本文中的com.google.gwt.core.ext.typeinfo.TypeOracle.getTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。