/** Returns whether this function type has an instance type. */ public final boolean hasInstanceType() { return isConstructor() || isInterface(); }
/** * Returns whether this function type has an instance type. */ public boolean hasInstanceType() { return isConstructor() || isInterface(); }
public final Collection<ObjectType> getAncestorInterfaces() { Set<ObjectType> result = new HashSet<>(); if (isConstructor()) { result.addAll((Collection<? extends ObjectType>) getImplementedInterfaces()); } else { result.addAll((Collection<? extends ObjectType>) getExtendedInterfaces()); } return result; }
public final boolean hasImplementedInterfaces() { if (!implementedInterfaces.isEmpty()) { return true; } FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor != null) { return superCtor.hasImplementedInterfaces(); } return false; }
/** * Utility function for getting an instance type from a var pointing * to the constructor. */ static ObjectType getInstanceOfCtor(@Nullable TypedVar v) { FunctionType ctor = getFunctionType(v); if (ctor != null && ctor.isConstructor()) { return ctor.getInstanceType(); } return null; }
/** * Utility function for getting an instance type from a var pointing * to the constructor. */ static ObjectType getInstanceOfCtor(@Nullable TypedVar v) { FunctionType ctor = getFunctionType(v); if (ctor != null && ctor.isConstructor()) { return ctor.getInstanceType(); } return null; }
public boolean hasImplementedInterfaces() { if (!implementedInterfaces.isEmpty()){ return true; } FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor != null) { return superCtor.hasImplementedInterfaces(); } return false; }
public final void setImplementedInterfaces(List<ObjectType> implementedInterfaces) { if (isConstructor()) { // Records this type for each implemented interface. for (ObjectType type : implementedInterfaces) { registry.registerTypeImplementingInterface(this, type); typeOfThis.extendTemplateTypeMap(type.getTemplateTypeMap()); } this.implementedInterfaces = ImmutableList.copyOf(implementedInterfaces); } else { throw new UnsupportedOperationException("An interface cannot implement other inferfaces"); } }
public void setImplementedInterfaces(List<ObjectType> implementedInterfaces) { if (isConstructor()) { // Records this type for each implemented interface. for (ObjectType type : implementedInterfaces) { registry.registerTypeImplementingInterface(this, type); typeOfThis.extendTemplateTypeMap(type.getTemplateTypeMap()); } this.implementedInterfaces = ImmutableList.copyOf(implementedInterfaces); } else { throw new UnsupportedOperationException( "An interface cannot implement other inferfaces"); } }
private void checkAbstractMethodInConcreteClass( NodeTraversal t, Node n, FunctionType ctorType, JSDocInfo info) { if (info == null || !info.isAbstract()) { return; } if (ctorType.isConstructor() && !ctorType.isAbstract()) { report(t, n, ABSTRACT_METHOD_IN_CONCRETE_CLASS); } }
/** * Given a constructor or an interface type, get its superclass constructor * or {@code null} if none exists. */ public FunctionType getSuperClassConstructor() { Preconditions.checkArgument(isConstructor() || isInterface()); ObjectType maybeSuperInstanceType = getPrototype().getImplicitPrototype(); if (maybeSuperInstanceType == null) { return null; } return maybeSuperInstanceType.getConstructor(); }
/** * Given a constructor or an interface type, get its superclass constructor or {@code null} if * none exists. */ @Override public final FunctionType getSuperClassConstructor() { checkArgument(isConstructor() || isInterface()); ObjectType maybeSuperInstanceType = getPrototype().getImplicitPrototype(); if (maybeSuperInstanceType == null) { return null; } return maybeSuperInstanceType.getConstructor(); }
/** Gets the symbol for the given constructor or interface. */ public Symbol getSymbolDeclaredBy(FunctionType fn) { checkState(fn.isConstructor() || fn.isInterface()); ObjectType instanceType = fn.getInstanceType(); return getSymbolForName(fn.getSource(), instanceType.getReferenceName()); }
/** Gets the symbol for the prototype of the given constructor or interface. */ public Symbol getSymbolForInstancesOf(FunctionType fn) { checkState(fn.isConstructor() || fn.isInterface()); ObjectType pType = fn.getPrototype(); return getSymbolForName(fn.getSource(), pType.getReferenceName()); }
private void visitFunction(Node n) { FunctionType funType = n.getJSType().toMaybeFunctionType(); if (funType != null && !funType.isConstructor()) { return; } Node nodeToInsertAfter = findNodeToInsertAfter(n); nodeToInsertAfter = addMarker(funType, nodeToInsertAfter, null); TreeSet<ObjectType> stuff = new TreeSet<ObjectType>(ALPHA); Iterables.addAll(stuff, funType.getAllImplementedInterfaces()); for (ObjectType interfaceType : stuff) { nodeToInsertAfter = addMarker(funType, nodeToInsertAfter, interfaceType); } }
/** * Gets the symbol for the given constructor or interface. */ public Symbol getSymbolDeclaredBy(FunctionType fn) { Preconditions.checkState(fn.isConstructor() || fn.isInterface()); ObjectType instanceType = fn.getInstanceType(); return getSymbolForName(fn.getSource(), instanceType.getReferenceName()); }
/** * Gets the symbol for the prototype of the given constructor or interface. */ public Symbol getSymbolForInstancesOf(FunctionType fn) { Preconditions.checkState(fn.isConstructor() || fn.isInterface()); ObjectType pType = fn.getPrototype(); return getSymbolForName(fn.getSource(), pType.getReferenceName()); }
private void checkPropertyInheritance( NodeTraversal t, Node key, String propertyName, FunctionType ctorType, ObjectType type) { if (ctorType != null && (ctorType.isConstructor() || ctorType.isInterface())) { checkDeclaredPropertyInheritance( t, key.getFirstChild(), ctorType, propertyName, key.getJSDocInfo(), type.getPropertyType(propertyName)); } }
private JSType getInstanceFromPrototype(JSType type) { if (type.isFunctionPrototypeType()) { ObjectType prototype = (ObjectType) type; FunctionType owner = prototype.getOwnerFunction(); if (owner.isConstructor() || owner.isInterface()) { return prototype.getOwnerFunction().getInstanceType(); } } return null; }
/** Copies all the information from another function type. */ public FunctionBuilder copyFromOtherFunction(FunctionType otherType) { this.name = otherType.getReferenceName(); this.sourceNode = otherType.getSource(); this.parametersNode = otherType.getParametersNode(); this.returnType = otherType.getReturnType(); this.typeOfThis = otherType.getTypeOfThis(); this.templateTypeMap = otherType.getTemplateTypeMap(); this.isConstructor = otherType.isConstructor(); this.isNativeType = otherType.isNativeObjectType(); return this; }