third_party/closure-compiler/src/src/com/google/javascript/rhino/jstype/NamedType.java
/**
   * Resolve a type using a given StaticTypedSlot and list of properties on that type.
   *
   * @param slotType the JSType of teh slot, possibly null
   * @param definitionNode If known, the Node representing the type definition.
   * @param componentIndex the index into {@code componentNames} at which to start resolving
   */
Resolve a type using a given StaticTypedSlot and list of properties on that type.
@param slotType the JSType of teh slot, possibly null
@param definitionNode If known, the Node representing the type definition.
@param componentIndex the index into  componentNames at which to start resolving
Resolve a type using a given StaticTypedSlot and list of properties on that type . @param slotType the JSType of teh slot possibly null @param definitionNode If known the Node representing the type definition . @param componentIndex the index into componentNames at which to start resolving
private void resolveViaPropertyGivenSlot(
      JSType slotType,
      Node definitionNode,
      List<String> componentNames,
      ErrorReporter reporter,
      int componentIndex) {
    if (resolveTypeFromNodeIfTypedef(definitionNode, reporter)) {
      return;
    }
    if (slotType == null || slotType.isAllType() || slotType.isNoType()) {
      handleUnresolvedType(reporter, /* ignoreForwardReferencedTypes= */ true);
      return;
    }
    for (int i = componentIndex; i < componentNames.size(); i++) {
      String component = componentNames.get(i);
      ObjectType parentObj = ObjectType.cast(slotType);
      if (parentObj == null || component.length() == 0) {
        handleUnresolvedType(reporter, /* ignoreForwardReferencedTypes= */ true);
        return;
      }
      if (i == componentNames.size() - 1) {
        Node def = parentObj.getPropertyDefSite(component);
        if (resolveTypeFromNodeIfTypedef(def, reporter)) {
          return;
        }
      }
      slotType = parentObj.getPropertyType(component);
    }
    if (slotType == null) {
      handleUnresolvedType(reporter, /* ignoreForwardReferencedTypes= */ true);
    } else if (slotType.isFunctionType() && (slotType.isConstructor() || slotType.isInterface())) {
      setReferencedAndResolvedType(slotType.toMaybeFunctionType().getInstanceType(), reporter);
    } else if (slotType.isNoObjectType()) {
      setReferencedAndResolvedType(
          registry.getNativeObjectType(JSTypeNative.NO_OBJECT_TYPE), reporter);
    } else if (slotType instanceof EnumType) {
      setReferencedAndResolvedType(((EnumType) slotType).getElementsType(), reporter);
    } else {
       So if the type does resolve to an actual value, but it's not named,
       then don't respect the forward declaration.
      handleUnresolvedType(reporter, slotType.isUnknownType());
    }
  }
private void resolveViaPropertyGivenSlot ( JSType slotType , Node definitionNode , List < String > componentNames , ErrorReporter reporter , int componentIndex ) { if ( resolveTypeFromNodeIfTypedef ( definitionNode , reporter ) ) { return ; } if ( slotType == null || slotType . isAllType ( ) || slotType . isNoType ( ) ) { handleUnresolvedType ( reporter , /* ignoreForwardReferencedTypes= */ true ) ; return ; } for ( int i = componentIndex ; i < componentNames . size ( ) ; i ++ ) { String component = componentNames . get ( i ) ; ObjectType parentObj = ObjectType . cast ( slotType ) ; if ( parentObj == null || component . length ( ) == 0 ) { handleUnresolvedType ( reporter , /* ignoreForwardReferencedTypes= */ true ) ; return ; } if ( i == componentNames . size ( ) - 1 ) { Node def = parentObj . getPropertyDefSite ( component ) ; if ( resolveTypeFromNodeIfTypedef ( def , reporter ) ) { return ; } } slotType = parentObj . getPropertyType ( component ) ; } if ( slotType == null ) { handleUnresolvedType ( reporter , /* ignoreForwardReferencedTypes= */ true ) ; } else if ( slotType . isFunctionType ( ) && ( slotType . isConstructor ( ) || slotType . isInterface ( ) ) ) { setReferencedAndResolvedType ( slotType . toMaybeFunctionType ( ) . getInstanceType ( ) , reporter ) ; } else if ( slotType . isNoObjectType ( ) ) { setReferencedAndResolvedType ( registry . getNativeObjectType ( JSTypeNative . NO_OBJECT_TYPE ) , reporter ) ; } else if ( slotType instanceof EnumType ) { setReferencedAndResolvedType ( ( ( EnumType ) slotType ) . getElementsType ( ) , reporter ) ; } else { handleUnresolvedType ( reporter , slotType . isUnknownType ( ) ) ; } }
Resolve a type using a given StaticTypedSlot and list of properties on that type.
Resolve a type using a given StaticTypedSlot and list of properties on that type .
// If the first component has a type of 'Unknown', then any type // names using it should be regarded as silently 'Unknown' rather than be // noisy about it. // resolving component by component // Look for a typedefTypeProp on the definition node of the last component. // Translate "constructor" types to "instance" types. // We've been running into issues where people forward-declare // non-named types. (This is legitimate...our dependency management // code doubles as our forward-declaration code.) // // So if the type does resolve to an actual value, but it's not named, // then don't respect the forward declaration.