Java Code Examples for com.google.javascript.rhino.jstype.ObjectType#isNoResolvedType()

The following examples show how to use com.google.javascript.rhino.jstype.ObjectType#isNoResolvedType() . 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: TypeRegistry.java    From js-dossier with Apache License 2.0 6 votes vote down vote up
private void scanExtendedInterfaces(Set<FunctionType> seenCtors, FunctionType type) {
  checkArgument(type.isInterface());

  for (ObjectType iface : type.getExtendedInterfaces()) {
    if (iface.isUnknownType() || iface.isNoResolvedType()) {
      continue;
    }

    checkState(iface.getConstructor() != null, "no constructor for %s", iface);
    checkState(
        iface.getConstructor().isInterface(), "unexpected type: %s", iface.getConstructor());

    if (seenCtors.add(iface.getConstructor())) {
      scanExtendedInterfaces(seenCtors, iface.getConstructor());

      implementedInterfaces.put(type, iface);
      subInterfaces.put(iface.getConstructor(), type.getInstanceType());
      for (ObjectType superInterface : implementedInterfaces.get(iface.getConstructor())) {
        implementedInterfaces.put(type, superInterface);
        subInterfaces.put(superInterface.getConstructor(), type.getInstanceType());
      }
    }
  }
}
 
Example 2
Source File: DeclarationGenerator.java    From clutz with MIT License 5 votes vote down vote up
/**
 * If a constructor statement is not emitted TS will assume a constructor with no arguments and
 * no body (default ctor) for base classes, or the constructor of the superclass.
 *
 * <p>Omitting the constructor is correct only if the closure class and *all* its superclasses
 * have zero argument constructors. If the supertype is NoResolvedType we cannot know whether
 * that's the case so we must return true.
 */
private boolean mustEmitConstructor(FunctionType type) {
  while (type != null) {
    if (type.getParameters().iterator().hasNext()) return true;
    ObjectType oType = getSuperType(type);
    if (oType == null) return false;
    if (oType.isNoResolvedType()) return true;
    type = oType.getConstructor();
  }
  return false;
}