Examples of defineDeclaredProperty()


Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

          if ((!ownerType.hasOwnProperty(propName) ||
               ownerType.isPropertyTypeInferred(propName)) &&
              ((isExtern && !ownerType.isNativeObjectType()) ||
               !ownerType.isInstanceType())) {
            // If the property is undeclared or inferred, declare it now.
            ownerType.defineDeclaredProperty(propName, valueType, n);
          }
        }

        // If the property is already declared, the error will be
        // caught when we try to declare it in the current scope.
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

              type == null ?
              getNativeType(JSTypeNative.NO_TYPE) :
              type,
              n);
        } else {
          globalThis.defineDeclaredProperty(variableName, type, n);
        }
      }

      if (isGlobalVar && "Window".equals(variableName)
          && type != null
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

    verify("y", createUnionType(OBJECT_TYPE, NUMBER_TYPE));
  }

  public void testPropertyInference1() {
    ObjectType thisType = registry.createAnonymousObjectType(null);
    thisType.defineDeclaredProperty("foo",
        createUndefinableType(STRING_TYPE), null);
    assumingThisType(thisType);
    inFunction("var y = 1; if (this.foo) { y = this.foo; }");
    verify("y", createUnionType(NUMBER_TYPE, STRING_TYPE));
  }
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

    verify("y", createUnionType(NUMBER_TYPE, STRING_TYPE));
  }

  public void testPropertyInference2() {
    ObjectType thisType = registry.createAnonymousObjectType(null);
    thisType.defineDeclaredProperty("foo",
        createUndefinableType(STRING_TYPE), null);
    assumingThisType(thisType);
    inFunction("var y = 1; this.foo = 'x'; y = this.foo;");
    verify("y", STRING_TYPE);
  }
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

    verify("y", STRING_TYPE);
  }

  public void testPropertyInference3() {
    ObjectType thisType = registry.createAnonymousObjectType(null);
    thisType.defineDeclaredProperty("foo",
        createUndefinableType(STRING_TYPE), null);
    assumingThisType(thisType);
    inFunction("var y = 1; this.foo = x; y = this.foo;");
    verify("y", CHECKED_UNKNOWN_TYPE);
  }
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

        // 4) If this is a stub, define it.
        // 5) Otherwise, do not define the type, but declare it in the registry
        //    so that we can use it for missing property checks.
        if (objectType.hasProperty(propName) || !objectType.isInstanceType()) {
          if ("prototype".equals(propName)) {
            objectType.defineDeclaredProperty(propName, rightType, getprop);
          } else {
            objectType.defineInferredProperty(propName, rightType, getprop);
          }
        } else if (propCreationInConstructor) {
          objectType.defineInferredProperty(propName, rightType, getprop);
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

  private ConcreteInstanceType createInstance(
      String name, String... propNames) {
    ObjectType objType = typeRegistry.createObjectType(name, null,
        typeRegistry.createObjectType(name + ".prototype", null, null));
    for (int i = 0; i < propNames.length; ++i) {
      objType.defineDeclaredProperty(propNames[i], unknownType, null);
    }
    return new ConcreteInstanceType(factory, objType);
  }

  private class FakeFactory implements Factory {
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

              type == null ?
              getNativeType(JSTypeNative.NO_TYPE) :
              type,
              n);
        } else {
          globalThis.defineDeclaredProperty(variableName, type, n);
        }
      }

      if (isGlobalVar && "Window".equals(variableName)
          && type != null
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

          if ((!ownerType.hasOwnProperty(propName) ||
               ownerType.isPropertyTypeInferred(propName)) &&
              ((isExtern && !ownerType.isNativeObjectType()) ||
               !ownerType.isInstanceType())) {
            // If the property is undeclared or inferred, declare it now.
            ownerType.defineDeclaredProperty(propName, valueType, n);
          }
        }

        // If the property is already declared, the error will be
        // caught when we try to declare it in the current scope.
View Full Code Here

Examples of com.google.javascript.rhino.jstype.ObjectType.defineDeclaredProperty()

        // 5) Otherwise, do not define the type, but declare it in the registry
        //    so that we can use it for missing property checks.
        if (objectType.hasProperty(propName) ||
            !objectType.isInstanceType()) {
          if ("prototype".equals(propName)) {
            objectType.defineDeclaredProperty(
                propName, rightType, getprop);
          } else {
            objectType.defineInferredProperty(
                propName, rightType, getprop);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.