Java Code Examples for com.google.javascript.rhino.jstype.FunctionType#setPrototypeBasedOn()

The following examples show how to use com.google.javascript.rhino.jstype.FunctionType#setPrototypeBasedOn() . 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: Closure_6_TypeValidator_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 2
Source File: TypeValidator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 3
Source File: Closure_6_TypeValidator_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 4
Source File: TypedScopeCreator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 5
Source File: Closure_95_TypedScopeCreator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 6
Source File: Closure_95_TypedScopeCreator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 7
Source File: Closure_54_TypedScopeCreator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 8
Source File: Closure_54_TypedScopeCreator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 9
Source File: Closure_117_TypeValidator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null && declaredSuper.isTemplatizedType()) {
    declaredSuper =
        declaredSuper.toMaybeTemplatizedType().getReferencedType();
  }
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 10
Source File: Closure_43_TypedScopeCreator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 11
Source File: Nopol2017_0027_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 12
Source File: Closure_48_TypedScopeCreator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 13
Source File: Closure_48_TypedScopeCreator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 14
Source File: Closure_70_TypedScopeCreator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 15
Source File: Closure_70_TypedScopeCreator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 16
Source File: Closure_17_TypedScopeCreator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 17
Source File: Nopol2017_0027_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Apply special properties that only apply to delegates.
 */
private void applyDelegateRelationship(
    DelegateRelationship delegateRelationship) {
  ObjectType delegatorObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegator));
  ObjectType delegateBaseObject = ObjectType.cast(
      typeRegistry.getType(delegateRelationship.delegateBase));
  ObjectType delegateSuperObject = ObjectType.cast(
      typeRegistry.getType(codingConvention.getDelegateSuperclassName()));
  if (delegatorObject != null &&
      delegateBaseObject != null &&
      delegateSuperObject != null) {
    FunctionType delegatorCtor = delegatorObject.getConstructor();
    FunctionType delegateBaseCtor = delegateBaseObject.getConstructor();
    FunctionType delegateSuperCtor = delegateSuperObject.getConstructor();

    if (delegatorCtor != null && delegateBaseCtor != null &&
        delegateSuperCtor != null) {
      FunctionParamBuilder functionParamBuilder =
          new FunctionParamBuilder(typeRegistry);
      functionParamBuilder.addRequiredParams(
          getNativeType(U2U_CONSTRUCTOR_TYPE));
      FunctionType findDelegate = typeRegistry.createFunctionType(
          typeRegistry.createDefaultObjectUnion(delegateBaseObject),
          functionParamBuilder.build());

      FunctionType delegateProxy = typeRegistry.createConstructorType(
          delegateBaseObject.getReferenceName() + DELEGATE_PROXY_SUFFIX,
          null, null, null);
      delegateProxy.setPrototypeBasedOn(delegateBaseObject);

      codingConvention.applyDelegateRelationship(
          delegateSuperObject, delegateBaseObject, delegatorObject,
          delegateProxy, findDelegate);
      delegateProxyPrototypes.add(delegateProxy.getPrototype());
    }
  }
}
 
Example 18
Source File: Closure_41_FunctionTypeBuilder_t.java    From coming with MIT License 4 votes vote down vote up
private void maybeSetBaseType(FunctionType fnType) {
  if (!fnType.isInterface() && baseType != null) {
    fnType.setPrototypeBasedOn(baseType);
  }
}
 
Example 19
Source File: FunctionTypeBuilder.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void maybeSetBaseType(FunctionType fnType) {
  if (!fnType.isInterface() && baseType != null) {
    fnType.setPrototypeBasedOn(baseType);
  }
}
 
Example 20
Source File: Closure_90_FunctionTypeBuilder_t.java    From coming with MIT License 4 votes vote down vote up
private void maybeSetBaseType(FunctionType fnType) {
  if (baseType != null) {
    fnType.setPrototypeBasedOn(baseType);
  }
}