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


Java TypeOracle类代码示例

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


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

示例1: findLocalComponentsForComponent

import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入依赖的package包/类
/**
 * Register all locally declared components.
 * @param localComponents The {@link LocalComponents} where we register our local components
 * @param componentType The JClass type of the local component
 * @param typeOracle Used to retrieve a {@link JClassType} in GWT Context
 */
private void findLocalComponentsForComponent(LocalComponents localComponents,
    JClassType componentType, TypeOracle typeOracle)
{
    Component componentAnnotation = componentType.getAnnotation(Component.class);
    if (componentAnnotation == null)
        return;

    Arrays
        .stream(componentAnnotation.components())
        .map(Class::getCanonicalName)
        .map(typeOracle::findType)
        .forEach(childType -> processLocalComponentClass(localComponents, childType));

    findLocalComponentsForComponent(localComponents, componentType.getSuperclass(), typeOracle);
}
 
开发者ID:Axellience,项目名称:vue-gwt,代码行数:22,代码来源:TemplateGwtGenerator.java

示例2: findReflectedClasses

import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入依赖的package包/类
protected Set<JType> findReflectedClasses(final GeneratorContext context, final TypeOracle typeOracle,
        final TreeLogger logger) throws UnableToCompleteException {
    final Set<JType> types = new HashSet<JType>();
    final Set<String> uediInterfaceNames = getUediInterfaceNames();
    final Set<JClassType> uediInterfaces = new HashSet<JClassType>();
    final String rootPackage = getRootPackage(context, logger);

    for (final JPackage jPackage : typeOracle.getPackages()) {
        for (final JClassType jType : jPackage.getTypes()) {
            if (uediInterfaceNames.contains(jType.getQualifiedSourceName())) {
                uediInterfaces.add(jType);
            } else if (jType.isClass() != null && jType.isInterface() == null && !jType.isClass().isAbstract()
                    && jType.getQualifiedSourceName().startsWith(rootPackage)) {
                types.add(jType);
            }
        }
    }
    if (uediInterfaces.size() < uediInterfaceNames.size()) {
        logger.log(Type.ERROR, "UEDIT: Unable to find UEDI interfaces in classpath. Aborting.");
        throw new UnableToCompleteException();
    }
    return filter(types, uediInterfaces);
}
 
开发者ID:czyzby,项目名称:uedi,代码行数:24,代码来源:ReflectionPoolGenerator.java

示例3: 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;
}
 
开发者ID:google,项目名称:easy-gwt-mock,代码行数:19,代码来源:MocksControlGenerator.java

示例4: 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. ");
  	}
   }
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:17,代码来源:GeneratorHelper.java

示例5: 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

示例6: 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

示例7: buildEventBusElement

import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入依赖的package包/类
/**
 * Build event bus element according to the implemented interface.
 *
 * @param c             annoted class type
 * @param configuration configuration containing loaded elements of the application
 * @return event bus corresponding to the implemented interface (null if none of the interfaces
 * are implemented)
 */
private EventBusElement buildEventBusElement(JClassType c,
                                             Mvp4gConfiguration configuration) {

  TypeOracle oracle = configuration.getOracle();

  EventBusElement eventBus = null;
  if (c.isAssignableTo(oracle.findType(EventBusWithLookup.class.getCanonicalName()))) {
    eventBus = new EventBusElement(c.getQualifiedSourceName(),
                                   BaseEventBusWithLookUp.class.getCanonicalName(),
                                   true);
  } else if (c.isAssignableTo(oracle.findType(EventBus.class.getCanonicalName()))) {
    eventBus = new EventBusElement(c.getQualifiedSourceName(),
                                   BaseEventBus.class.getCanonicalName(),
                                   false);
  }

  return eventBus;
}
 
开发者ID:mvp4g,项目名称:mvp4g,代码行数:27,代码来源:EventsAnnotationsLoader.java

示例8: 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();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:19,代码来源:ReflectionCacheGenerator.java

示例9: 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();
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:26,代码来源:ClazzGenerator.java

示例10: generate

import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入依赖的package包/类
@Override
public String generate( TreeLogger logger, GeneratorContext context, String typeName ) throws UnableToCompleteException
{
	this.logger = logger;
	this.context = context;
	this.askedTypeName = typeName;

	// get the "reflection" machine of GWT compiler
	TypeOracle typeOracle = context.getTypeOracle();
	try
	{
		reflectedType = getReflectedType( typeOracle, typeName );
		ClazzInfoBuilder builder = new ClazzInfoBuilder( logger, context );

		return builder.buildClassInfoFor(reflectedType);
	}
	catch( Exception e )
	{
		// record to logger that Map generation threw an exception
		logger.log( TreeLogger.ERROR, "ERROR when generating " + generatedClassName + " for " + typeName, e );
		return null;
	}
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:24,代码来源:ClazzGenerator.java

示例11: 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 toGenerate = typeOracle.findType(typeName)
                                    .isInterface();
  if (toGenerate == null) {
    logger.log(Type.ERROR,
               typeName + " is not an interface");
    throw new UnableToCompleteException();
  }

  TreeLogger propertyLogger = logger.branch(TreeLogger.DEBUG,
                                            "property generator",
                                            null);

  return create(propertyLogger,
                context,
                toGenerate);
}
 
开发者ID:gwt4e,项目名称:gwt4e,代码行数:26,代码来源:BindingPropertyGenerator.java

示例12: populateVelocityContext

import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入依赖的package包/类
@Override
protected void populateVelocityContext(VelocityContext velocityContext, TypeOracle typeOracle, JClassType modelType)
      throws UnableToCompleteException
{
   try
   {
      super.populateVelocityContext(velocityContext, typeOracle, modelType);
      TableContext tableContext = new TableContext(typeOracle, modelType);
      velocityContext.put("generatorType", getClass());
      velocityContext.put(TABLE_CONTEXT_KEY, tableContext);
   }
   catch (NotFoundException e)
   {
      throw new UnableToCompleteException();
   }
}
 
开发者ID:symulakr,项目名称:gwt-generators,代码行数:17,代码来源:CellTableGenerator.java

示例13: 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() );
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:23,代码来源:JacksonTypeOracle.java

示例14: createTypeOracle

import com.google.gwt.core.ext.typeinfo.TypeOracle; //导入依赖的package包/类
private TypeOracle createTypeOracle() {
  TypeOracle typeOracle = mock(TypeOracle.class);
  when(typeOracle.findType(anyString())).then(new Answer<JClassType>() {
    @Override
    public JClassType answer(InvocationOnMock invocationOnMock) throws Throwable {
      String parameter = (String) invocationOnMock.getArguments()[0];
      Class<? extends GenericEvent> klass;
      try {
        klass = (Class<? extends GenericEvent>) Class.forName(parameter);
      } catch (ClassNotFoundException ex) {
        char[] klassName = parameter.toCharArray();
        klassName[parameter.lastIndexOf('.')] = '$';
        klass = (Class<? extends GenericEvent>) Class.forName(String.valueOf(klassName));
      }
      return getEventType(klass);
    }
  });
  return typeOracle;
}
 
开发者ID:google,项目名称:gwteventbinder,代码行数:20,代码来源:EventBinderWriterTest.java

示例15: 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();
    }
}
 
开发者ID:rfilippone,项目名称:gwt-dom-event-binder,代码行数:21,代码来源:DomEventBinderGenerator.java


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