Examples of JClassType


Examples of com.google.gwt.core.ext.typeinfo.JClassType

    assert jsoType != null;
    assert stringType != null;

    for (JClassType t : typeOracle.getTypes()) {
      if (t.isAssignableTo(exportOverlayType) && !t.equals(exportOverlayType)) {
        JClassType targetType = getExportOverlayType(t);
        overlayTypes.put(targetType.getQualifiedSourceName(),
            new JExportOverlayClassType(this, t));
      }
    }
  }
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

      }
    }
  }

  public JExportableClassType findExportableClassType(String requestedClass) {
    JClassType requestedType = typeOracle.findType(requestedClass);
    if (requestedType != null) {
      if (requestedType.isAssignableTo(exportOverlayType)) {
        return new JExportOverlayClassType(this, requestedType);
      } else if (requestedType.isAssignableTo(exportableType)) {
        return new JExportableClassType(this, requestedType);
      }
      JExportOverlayClassType exportOverlay = overlayTypes.get(requestedClass);
      return exportOverlay;
    }
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

  }

  public JExportableType findExportableType(String paramTypeName) {
    try {
      JType type = typeOracle.parse(paramTypeName);
      JClassType cType = type != null ? type.isClassOrInterface() : null;
      if (type.isPrimitive() != null) {
        return new JExportablePrimitiveType(this, type.isPrimitive());
      } else if (type.isArray() != null) {
        return new JExportableArrayType(this, type.isArray());
      } else if (overlayTypes.containsKey(paramTypeName)) {
        return overlayTypes.get(paramTypeName);
      } else if (cType.isAssignableTo(exportOverlayType)) {
        return new JExportOverlayClassType(this, type.isClassOrInterface());
      } else if (cType != null && (cType.isAssignableTo(exportableType)
          || cType.isAssignableTo(stringType)
          || cType.isAssignableTo(dateType)
          || cType.isAssignableTo(jsoType))) {
        return new JExportableClassType(this, type.isClassOrInterface());
      } else {
        return null;
      }
    } catch (TypeOracleException e) {
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

    String cType = jExportableClassType.getType().getQualifiedSourceName();
    if (closuresCache.containsKey(cType)) {
      return true;
    }

    JClassType rType = jExportableClassType.getRequestedType();
    if (rType != null && rType.isAssignableTo(exportableType)) {
      ExportClosure ann = rType.getAnnotation(ExportClosure.class);
      if (ann != null && rType.isInterface() != null) {
        if (rType.getMethods().length > 0) {
          closuresCache.put(rType.getQualifiedSourceName(), jExportableClassType);
          closuresCache.put(cType, jExportableClassType);
          return true;
        }
      }
    }
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

    return pkg + getJSExportName();
  }
 
  public String getJSExportName () {
    Export ann = type.getAnnotation(Export.class);
    JClassType type = getTypeToExport();
    return ann != null && !ann.value().isEmpty() ? ann.value() : type.getName();
  }
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

  }

  public String getJSExportPackage() {
    String requestedPackageName = getPrefix();
    ExportPackage ann = type.getAnnotation(ExportPackage.class);
    JClassType type = getTypeToExport();
    if (ann != null) {
      requestedPackageName = ann.value();
    } else if (type.getEnclosingType() != null) {
      JExportableClassType encType = exportableTypeOracle
          .findExportableClassType(
              type.getEnclosingType().getQualifiedSourceName());
      if (encType != null) {
        return encType.getJSExportPackage();
      }
    }
    return requestedPackageName;
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

    // The TypeOracle knows about all types in the type system
    final TypeOracle typeOracle = context.getTypeOracle();

    // Get a reference to the type that the generator should implement
    final JClassType sourceType = typeOracle.findType(typeName);

    // Ensure that the requested type exists
    if (sourceType == null) {
      logger.log(TreeLogger.ERROR, "Could not find requested typeName", null);
      throw new UnableToCompleteException();
    }

    String locale;
    try {
      locale = context.getPropertyOracle().getPropertyValue(logger, "locale");
    } catch (BadPropertyValueException e) {
      // Don't care, likely the user isn't using localization.
      locale = "";
    }

    // Pick a name for the generated class to not conflict. Enclosing class
    // names must be preserved.
    final String generatedSimpleSourceName = generateSimpleSourceName(sourceType.getName())
        + locale;

    // Begin writing the generated source.
    final ClassSourceFileComposerFactory f = new ClassSourceFileComposerFactory(
        sourceType.getPackage().getName(), generatedSimpleSourceName);

    // The generated class needs to be able to determine the module base URL
    f.addImport(GWT.class.getName());
    f.addImport(ResourcePrototype.class.getName());

    // Determine the interface to implement
    if (sourceType.isInterface() != null) {
      f.addImplementedInterface(sourceType.getQualifiedSourceName());

    } else {
      // The incoming type wasn't a plain interface, we don't support
      // abstract base classes
      logger.log(TreeLogger.ERROR, sourceType.getQualifiedSourceName()
          + " is not an interface.", null);
      throw new UnableToCompleteException();
    }

    // All source gets written through this Writer
    final PrintWriter out = context.tryCreate(logger,
        sourceType.getPackage().getName(), generatedSimpleSourceName);

    // Aggregates the field names of the resources for use with
    // ResourceBundle.getResources()
    List<String> fieldNames = new ArrayList<String>();

    // If an implementation already exists, we don't need to do any work
    if (out != null) {

      // We really use a SourceWriter since it's convenient
      final SourceWriter sw = f.createSourceWriter(context, out);

      JMethod[] methods = sourceType.getMethods();

      Map<Class<? extends ResourceGenerator>, List<JMethod>> resourceGenerators = new HashMap<Class<? extends ResourceGenerator>, List<JMethod>>();

      ResourceContext resourceContext = createResourceContext(logger, context,
          sourceType, sw);

      // First assemble all of the ResourceGenerators that we may need for the
      // type
      for (JMethod m : methods) {
        JClassType returnType = m.getReturnType().isClassOrInterface();
        if (returnType == null) {
          logger.log(TreeLogger.ERROR, "Cannot implement " + m.getName()
              + ": not a class or interface.", null);
          throw new UnableToCompleteException();
        }
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

   */
  private Class<? extends ResourceGenerator> findResourceGenerator(
      TreeLogger logger, TypeOracle typeOracle, JMethod method)
      throws UnableToCompleteException {

    JClassType resourceType = method.getReturnType().isClassOrInterface();
    ResourceGeneratorType generatorType = resourceType.getAnnotation(ResourceGeneratorType.class);

    if (generatorType == null) {
      logger.log(TreeLogger.ERROR, "No @"
          + ResourceGeneratorType.class.getName()
          + " was specifed for resource type "
          + resourceType.getQualifiedSourceName());
      throw new UnableToCompleteException();
    }
    String className = generatorType.value();

    try {
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

   */
  public boolean validate(JSWrapperGenerator generator,
      FragmentGeneratorContext context) {
    TreeLogger logger = context.parentLogger.branch(TreeLogger.DEBUG,
        "Validating task " + getJavaMethodName() + "().", null);
    JClassType jsoType = context.typeOracle.findType(JavaScriptObject.class.getName());

    if ((imported != null) && ((getter != null) || (setter != null))) {
      logger.log(TreeLogger.ERROR, "Imported functions may not be combined "
          + "with bean-style accessors", null);
      return true;
    }

    // If there are no methods attached to a task, we've encountered an
    // internal error.
    if (!hasMethods()) {
      logger.log(TreeLogger.ERROR, "No methods for task.", null);
      return true;
    }

    if (constructor != null) {
      JClassType returnType = constructor.getReturnType().isClassOrInterface();
      JClassType wrapperType = context.typeOracle.findType(JSWrapper.class.getName());

      if (!(jsoType.isAssignableFrom(returnType) || constructor.getEnclosingType().isAssignableFrom(
          returnType))) {
        logger.log(TreeLogger.ERROR,
            "Methods annotated with @gwt.constructor or @gwt.global must "
                + "return a JavaScriptObject or their enclosing class.", null);
        return true;
      }

      try {
        if (wrapperType.isAssignableFrom(returnType)
            && JSWrapperGenerator.hasTag(logger, constructor, Global.class) != null) {
          logger.log(TreeLogger.ERROR,
              "Cannot place @gwt.global annotation on JSWrapper methods."
                  + " Apply to the class or interface instead.", null);
          return true;
View Full Code Here

Examples of com.google.gwt.core.ext.typeinfo.JClassType

        return m.getName();
      }

      // If no gwt.fieldName is specified, see if there's a naming policy
      // defined on the enclosing class.
      JClassType enclosing = m.getEnclosingType();
      com.google.gwt.jsio.client.NamePolicy namePolicyAnnotation = JSWrapperGenerator.hasTag(
          logger, enclosing, com.google.gwt.jsio.client.NamePolicy.class);
      NamePolicy policy;

      // If there is no namePolicy or it's not of the desired form, default
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.