Examples of restrictByNotNullOrUndefined()


Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

        JSType jsType = node.getJSType();
        if (jsType == null) {
          return false;
        }
        jsType = jsType.restrictByNotNullOrUndefined();
        return areTypesEquivalentIgnoringGenerics(jsType, providedJsType);
      }
    };
  }
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

      @Override public boolean matches(Node node, NodeMetadata metadata) {
        JSType providedJsType = getJsType(metadata, type);
        if (providedJsType == null) {
          return false;
        }
        providedJsType = providedJsType.restrictByNotNullOrUndefined();

        JSType jsType = node.getJSType();
        return jsType != null && jsType.isEnumType() && providedJsType.isEquivalentTo(
            jsType.toMaybeEnumType().getElementsType().getPrimitiveType());
      }
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

      @Override public boolean matches(Node node, NodeMetadata metadata) {
        JSType providedJsType = getJsType(metadata, type);
        if (providedJsType == null) {
          return false;
        }
        providedJsType = providedJsType.restrictByNotNullOrUndefined();
        // The JSDoc for a var declaration is on the VAR node, but the type only
        // exists on the NAME node.
        // TODO(mknichel): Make NodeUtil.getBestJSDoc public and use that.
        JSDocInfo jsDoc = node.getParent().isVar()
            ? node.getParent().getJSDocInfo() : node.getJSDocInfo();
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

        // TODO(mknichel): Make NodeUtil.getBestJSDoc public and use that.
        JSDocInfo jsDoc = node.getParent().isVar()
            ? node.getParent().getJSDocInfo() : node.getJSDocInfo();
        JSType jsType = node.getJSType();
        return jsDoc != null && jsType != null
            && providedJsType.isEquivalentTo(jsType.restrictByNotNullOrUndefined());
      }
    };
  }

  private static JSType getJsType(NodeMetadata metadata, String type) {
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

      jsType = node.getFirstChild().getJSType();
    }
    if (jsType == null) {
      return false;
    }
    jsType = jsType.restrictByNotNullOrUndefined();
    if (!jsType.isUnknownType()
        && !jsType.isAllType()
        && jsType.isSubtype(providedJsType)) {
      if (node.isName() && propertyName.equals(node.getString())) {
        return true;
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

  private void ensurePropertyDefined(Node getprop, JSType rightType) {
    String propName = getprop.getLastChild().getString();
    Node obj = getprop.getFirstChild();
    JSType nodeType = getJSType(obj);
    ObjectType objectType = ObjectType.cast(
        nodeType.restrictByNotNullOrUndefined());
    boolean propCreationInConstructor = obj.isThis() &&
        getJSType(syntacticScope.getRootNode()).isConstructor();

    if (objectType == null) {
      registry.registerPropertyOnType(propName, nodeType);
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

        "", null);

    JSType e = globalScope.getVar("myExtern").getType();
    assertEquals("(Extern|null)", e.toString());

    ObjectType externType = (ObjectType) e.restrictByNotNullOrUndefined();
    assertTrue(globalScope.getRootNode().toStringTree(),
        externType.hasOwnProperty("foo"));
    assertTrue(externType.isPropertyTypeDeclared("foo"));
    assertEquals("number", externType.getPropertyType("foo").toString());
    assertTrue(externType.isPropertyInExterns("foo"));
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

        "", null);

    JSType e = globalScope.getVar("myExtern").getType();
    assertEquals("(Extern|null)", e.toString());

    ObjectType externType = (ObjectType) e.restrictByNotNullOrUndefined();
    assertTrue(globalScope.getRootNode().toStringTree(),
        externType.hasOwnProperty("foo"));
    assertTrue(externType.isPropertyTypeDeclared("foo"));
    assertEquals("number", externType.getPropertyType("foo").toString());
    assertTrue(externType.isPropertyInExterns("foo"));
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

    // TODO(johnlenz): consider introducing a CAST node to the AST (or
    // perhaps a parentheses node).

    JSType objlitType = getJSType(objlit);
    ObjectType type = ObjectType.cast(
        objlitType.restrictByNotNullOrUndefined());
    if (type != null) {
      String property = NodeUtil.getObjectLitKeyName(key);
      if (type.hasProperty(property) &&
          !type.isPropertyTypeInferred(property) &&
          !propertyIsImplicitCast(type, property)) {
View Full Code Here

Examples of com.google.javascript.rhino.jstype.JSType.restrictByNotNullOrUndefined()

              JSType lhsType = lhs.getJSType();
              if (lhsType == null) {
                break;
              }
              FunctionType funType =
                  lhsType.restrictByNotNullOrUndefined().toMaybeFunctionType();
              if (funType == null) {
                break;
              }
              ConcreteType retType = createType(funType.getReturnType());
              retType = createUnionWithSubTypes(retType);
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.