Java Code Examples for com.google.javascript.rhino.jstype.ObjectType#getOwnerFunction()
The following examples show how to use
com.google.javascript.rhino.jstype.ObjectType#getOwnerFunction() .
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: TypeInspector.java From js-dossier with Apache License 2.0 | 6 votes |
private Map<String, InstanceProperty> getOwnProperties(ObjectType object) { ObjectType definingType = object; if (definingType.isFunctionPrototypeType()) { definingType = definingType.getOwnerFunction(); } else if (definingType.isInstanceType()) { definingType = definingType.getConstructor(); } Map<String, InstanceProperty> properties = new HashMap<>(); for (String name : object.getOwnPropertyNames()) { if (!"constructor".equals(name)) { Property property = object.getOwnSlot(name); properties.put( property.getName(), InstanceProperty.builder() .setOwnerType(getFirst(registry.getTypes(definingType), null)) .setDefinedByType(definingType) .setName(property.getName()) .setType(getType(object, property)) .setNode(property.getNode()) .setJsDoc(JsDoc.from(property.getJSDocInfo())) .build()); } } return properties; }
Example 2
Source File: Closure_118_DisambiguateProperties_t.java From coming with MIT License | 5 votes |
@Override public 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; }
Example 3
Source File: Closure_118_DisambiguateProperties_t.java From coming with MIT License | 5 votes |
@Override public void recordInterfaces(JSType type, JSType relatedType, DisambiguateProperties<JSType>.Property p) { ObjectType objType = ObjectType.cast(type); if (objType != null) { FunctionType constructor; if (objType.isFunctionType()) { constructor = objType.toMaybeFunctionType(); } else if (objType.isFunctionPrototypeType()) { constructor = objType.getOwnerFunction(); } else { constructor = objType.getConstructor(); } while (constructor != null) { for (ObjectType itype : constructor.getImplementedInterfaces()) { JSType top = getTypeWithProperty(p.name, itype); if (top != null) { p.addType(itype, top, relatedType); } else { recordInterfaces(itype, relatedType, p); } // If this interface invalidated this property, return now. if (p.skipRenaming) { return; } } if (constructor.isInterface() || constructor.isConstructor()) { constructor = constructor.getSuperClassConstructor(); } else { constructor = null; } } } }
Example 4
Source File: Closure_118_DisambiguateProperties_s.java From coming with MIT License | 5 votes |
@Override public 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; }
Example 5
Source File: Closure_118_DisambiguateProperties_s.java From coming with MIT License | 5 votes |
@Override public void recordInterfaces(JSType type, JSType relatedType, DisambiguateProperties<JSType>.Property p) { ObjectType objType = ObjectType.cast(type); if (objType != null) { FunctionType constructor; if (objType.isFunctionType()) { constructor = objType.toMaybeFunctionType(); } else if (objType.isFunctionPrototypeType()) { constructor = objType.getOwnerFunction(); } else { constructor = objType.getConstructor(); } while (constructor != null) { for (ObjectType itype : constructor.getImplementedInterfaces()) { JSType top = getTypeWithProperty(p.name, itype); if (top != null) { p.addType(itype, top, relatedType); } else { recordInterfaces(itype, relatedType, p); } // If this interface invalidated this property, return now. if (p.skipRenaming) { return; } } if (constructor.isInterface() || constructor.isConstructor()) { constructor = constructor.getSuperClassConstructor(); } else { constructor = null; } } } }
Example 6
Source File: DisambiguateProperties.java From astor with GNU General Public License v2.0 | 5 votes |
@Override public 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; }
Example 7
Source File: DisambiguateProperties.java From astor with GNU General Public License v2.0 | 5 votes |
@Override public void recordInterfaces(JSType type, JSType relatedType, DisambiguateProperties<JSType>.Property p) { ObjectType objType = ObjectType.cast(type); if (objType != null) { FunctionType constructor; if (objType.isFunctionType()) { constructor = objType.toMaybeFunctionType(); } else if (objType.isFunctionPrototypeType()) { constructor = objType.getOwnerFunction(); } else { constructor = objType.getConstructor(); } while (constructor != null) { for (ObjectType itype : constructor.getImplementedInterfaces()) { JSType top = getTypeWithProperty(p.name, itype); if (top != null) { p.addType(itype, top, relatedType); } else { recordInterfaces(itype, relatedType, p); } // If this interface invalidated this property, return now. if (p.skipRenaming) return; } if (constructor.isInterface() || constructor.isConstructor()) { constructor = constructor.getSuperClassConstructor(); } else { constructor = null; } } } }