@Override public JSType caseProxyObjectType(ProxyObjectType type) { return type.visitReferenceType(this); } };
ProxyObjectType(JSTypeRegistry registry, JSType referencedType, TemplateTypeMap templateTypeMap) { super(registry, templateTypeMap); setReferencedType(checkNotNull(referencedType)); }
@Override public JSType caseProxyObjectType(ProxyObjectType type) { // Be careful not to unwrap a type unless it has changed. JSType beforeType = type.getReferencedTypeInternal(); JSType replacement = beforeType.visit(this); if (replacement != beforeType) { return replacement; } return type; } }
@Override public boolean setValidator(Predicate<JSType> validator) { // If the type is already resolved, we can validate it now. If // the type has not been resolved yet, we need to wait till its // resolved before we can validate it. if (this.isResolved()) { return super.setValidator(validator); } else { this.validator = validator; return true; } }
@Override public JSType getPropertyType(String propertyName) { JSType result = super.getPropertyType(propertyName); return result == null ? null : result.visit(replacer); }
@Nullable private String deepestResolvedTypeNameOf(ObjectType objType) { if (!objType.isResolved() || !(objType instanceof ProxyObjectType)) { return objType.getReferenceName(); } ObjectType internal = ((ProxyObjectType) objType).getReferencedObjTypeInternal(); return (internal != null && internal.isNominalType()) ? deepestResolvedTypeNameOf(internal) : null; }
@Override boolean defineProperty(String propertyName, JSType type, boolean inferred, Node propertyNode) { if (!isResolved()) { // If this is an unresolved object type, we need to save all its // properties and define them when it is resolved. if (propertyContinuations == null) { propertyContinuations = new ArrayList<>(); } propertyContinuations.add( new PropertyContinuation( propertyName, type, inferred, propertyNode)); return true; } else { return super.defineProperty( propertyName, type, inferred, propertyNode); } }
return super.resolveInternal(reporter); handleTypeCycle(reporter); super.resolveInternal(reporter); finishPropertyContinuations();
@Override StringBuilder appendTo(StringBuilder sb, boolean forAnnotations) { super.appendTo(sb, forAnnotations); if (!this.templateTypes.isEmpty()) { sb.append("<"); int lastIndex = this.templateTypes.size() - 1; for (int i = 0; i < lastIndex; i++) { this.templateTypes.get(i).appendTo(sb, forAnnotations); sb.append(","); } this.templateTypes.get(lastIndex).appendTo(sb, forAnnotations); sb.append(">"); } return sb; }
@Override public JSType caseProxyObjectType(ProxyObjectType type) { // Be careful not to unwrap a type unless it has changed. JSType beforeType = type.getReferencedTypeInternal(); JSType replacement = beforeType.visit(this); if (replacement != beforeType) { return replacement; } return type; } }
@Override public boolean setValidator(Predicate<JSType> validator) { // If the type is already resolved, we can validate it now. If // the type has not been resolved yet, we need to wait till its // resolved before we can validate it. if (this.isResolved()) { return super.setValidator(validator); } else { this.validator = validator; return true; } }
@Override public JSType getPropertyType(String propertyName) { JSType result = super.getPropertyType(propertyName); return result == null ? null : result.visit(replacer); }
private String getConcreteNominalTypeName(ObjectType objType) { if (objType instanceof ProxyObjectType) { ObjectType internal = ((ProxyObjectType) objType) .getReferencedObjTypeInternal(); if (internal != null && internal.isNominalType()) { return getConcreteNominalTypeName(internal); } } return objType.getReferenceName(); }
@Override boolean defineProperty(String propertyName, JSType type, boolean inferred, Node propertyNode) { if (!isResolved()) { // If this is an unresolved object type, we need to save all its // properties and define them when it is resolved. if (propertyContinuations == null) { propertyContinuations = new ArrayList<PropertyContinuation>(); } propertyContinuations.add( new PropertyContinuation( propertyName, type, inferred, propertyNode)); return true; } else { return super.defineProperty( propertyName, type, inferred, propertyNode); } }
/** * Resolve the referenced type within the enclosing scope. */ @Override JSType resolveInternal(ErrorReporter t, StaticTypedScope<JSType> enclosing) { // TODO(user): Investigate whether it is really necessary to keep two // different mechanisms for resolving named types, and if so, which order // makes more sense. Now, resolution via registry is first in order to // avoid triggering the warnings built into the resolution via properties. boolean resolved = resolveViaRegistry(t); if (detectInheritanceCycle()) { handleTypeCycle(t); } if (resolved) { super.resolveInternal(t, enclosing); finishPropertyContinuations(); return registry.isLastGeneration() ? getReferencedType() : this; } resolveViaProperties(t, enclosing); if (detectInheritanceCycle()) { handleTypeCycle(t); } super.resolveInternal(t, enclosing); if (isResolved()) { finishPropertyContinuations(); } return registry.isLastGeneration() ? getReferencedType() : this; }
@Override public JSType caseProxyObjectType(ProxyObjectType type) { return type.visitReferenceType(this); } };
.getReferencedTypeInternal().checkEquivalenceHelper( that, eqMethod, eqCache); ((ProxyObjectType) that).getReferencedTypeInternal(), eqMethod, eqCache);
ProxyObjectType(JSTypeRegistry registry, JSType referencedType, TemplateTypeMap templateTypeMap) { super(registry, templateTypeMap); setReferencedType(Preconditions.checkNotNull(referencedType)); }
@Override public JSType caseProxyObjectType(ProxyObjectType type) { return type.visitReferenceType(this); } }
.getReferencedTypeInternal().checkEquivalenceHelper( that, eqMethod, eqCache); ((ProxyObjectType) that).getReferencedTypeInternal(), eqMethod, eqCache);