Java Code Examples for com.google.javascript.rhino.jstype.JSType#isArrayType()

The following examples show how to use com.google.javascript.rhino.jstype.JSType#isArrayType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClosureTypeRegistry.java    From jsinterop-generator with Apache License 2.0 6 votes vote down vote up
private TypeReference createMethodDefiningTypeReferenceFrom(TemplateType templateType) {
  JSType jsType = jsTypeByThisTemplateType.get(templateType);
  checkNotNull(jsType, "%s is not used a method receiver.", templateType);

  TypeReference typeReference = resolveTypeReference(jsType);
  List<TemplateType> templateKeys =
      (jsType instanceof ObjectType ? ((ObjectType) jsType).getConstructor() : jsType)
          .getTemplateTypeMap()
          .getTemplateKeys();
  // Create a ParametrizedTypeReference if the replacing type has template type. The JSType
  // stored in the map is never a TemplatizedType because it's the type definition not a type
  // reference.
  if (templateKeys.isEmpty()) {
    return typeReference;
  } else if (jsType.isArrayType()) {
    checkState(templateKeys.size() == 1, templateKeys);
    return new ArrayTypeReference(resolveTypeReference(templateKeys.get(0)));
  } else {
    return createParametrizedTypeReference(jsType, templateKeys);
  }
}
 
Example 2
Source File: TypeCollectionPass.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
private static boolean isPrimitive(JSType type) {
  return !type.isEnumElementType()
      && (type.isBooleanValueType()
          || type.isBooleanObjectType()
          || type.isNumber()
          || type.isNumberValueType()
          || type.isNumberObjectType()
          || type.isString()
          || type.isStringObjectType()
          || type.isStringValueType()
          || type.isVoidType()
          || type.isArrayType());
}