当前位置: 首页>>代码示例>>Java>>正文


Java JSType.equals方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.jstype.JSType.equals方法的典型用法代码示例。如果您正苦于以下问题:Java JSType.equals方法的具体用法?Java JSType.equals怎么用?Java JSType.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.jstype.JSType的用法示例。


在下文中一共展示了JSType.equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkPropertyAccess

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
 * Make sure that the access of this property is ok.
 */
private void checkPropertyAccess(JSType childType, String propName,
    NodeTraversal t, Node n) {
  ObjectType objectType = childType.dereference();
  if (objectType != null) {
    JSType propType = getJSType(n);
    if ((!objectType.hasProperty(propName) ||
         objectType.equals(typeRegistry.getNativeType(UNKNOWN_TYPE))) &&
        propType.equals(typeRegistry.getNativeType(UNKNOWN_TYPE))) {
      if (objectType instanceof EnumType) {
        t.report(n, INEXISTENT_ENUM_ELEMENT, propName);
      } else if (!objectType.isEmptyType() &&
          reportMissingProperties && !isPropertyTest(n)) {
        if (!typeRegistry.canPropertyBeDefined(objectType, propName)) {
          t.report(n, INEXISTENT_PROPERTY, propName,
              validator.getReadableJSTypeName(n.getFirstChild(), true));
        }
      }
    }
  } else {
    // TODO(nicksantos): might want to flag the access on a non object when
    // it's impossible to get a property from this type.
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:27,代码来源:TypeCheck.java

示例2: traverseCall

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private FlowScope traverseCall(Node n, FlowScope scope) {
  scope = traverseChildren(n, scope);

  Node left = n.getFirstChild();
  JSType functionType = getJSType(left).restrictByNotNullOrUndefined();
  if (functionType != null) {
    if (functionType instanceof FunctionType) {
      FunctionType fnType = (FunctionType) functionType;
      n.setJSType(fnType.getReturnType());
      updateTypeOfParametersOnClosure(n, fnType);
      updateTypeOfThisOnClosure(n, fnType);
    } else if (functionType.equals(getNativeType(CHECKED_UNKNOWN_TYPE))) {
      n.setJSType(getNativeType(CHECKED_UNKNOWN_TYPE));
    }
  }
  return scope;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:TypeInference.java

示例3: equalsJSType

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private boolean equalsJSType(JSType jsType) {
  if (jsType == null || jstype == null) {
    return jstype == jsType;
  } else {
    return jsType.equals(this.jstype);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:TightenTypes.java

示例4: getPropertyType

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private JSType getPropertyType(JSType objType, String propName,
    Node n, FlowScope scope) {
  // Scopes sometimes contain inferred type info about qualified names.
  String qualifiedName = n.getQualifiedName();
  StaticSlot<JSType> var = scope.getSlot(qualifiedName);
  if (var != null) {
    JSType varType = var.getType();
    if (varType != null) {
      if (varType.equals(getNativeType(UNKNOWN_TYPE)) &&
          var != syntacticScope.getSlot(qualifiedName)) {
        // If the type of this qualified name has been checked in this scope,
        // then use CHECKED_UNKNOWN_TYPE instead to indicate that.
        return getNativeType(CHECKED_UNKNOWN_TYPE);
      } else {
        return varType;
      }
    }
  }

  JSType propertyType = null;
  if (objType != null) {
    propertyType = objType.findPropertyType(propName);
  }

  if ((propertyType == null || propertyType.isUnknownType()) &&
      qualifiedName != null) {
    // If we find this node in the registry, then we can infer its type.
    ObjectType regType = ObjectType.cast(registry.getType(qualifiedName));
    if (regType != null) {
      propertyType = regType.getConstructor();
    }
  }

  return propertyType;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:36,代码来源:TypeInference.java

示例5: expectUndeclaredVariable

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
 * Expect that the given variable has not been declared with a type.
 *
 * @param sourceName The name of the source file we're in.
 * @param n The node where warnings should point to.
 * @param parent The parent of {@code n}.
 * @param var The variable that we're checking.
 * @param variableName The name of the variable.
 * @param newType The type being applied to the variable. Mostly just here
 *     for the benefit of the warning.
 */
void expectUndeclaredVariable(String sourceName, Node n, Node parent, Var var,
    String variableName, JSType newType) {
  boolean allowDupe = false;
  if (n.getType() == Token.GETPROP) {
    JSDocInfo info = n.getJSDocInfo();
    if (info == null) {
      info = parent.getJSDocInfo();
    }
    allowDupe =
        info != null && info.getSuppressions().contains("duplicate");
  }

  JSType varType = var.getType();

  // Only report duplicate declarations that have types. Other duplicates
  // will be reported by the syntactic scope creator later in the
  // compilation process.
  if (varType != null &&
      varType != typeRegistry.getNativeType(UNKNOWN_TYPE) &&
      newType != null &&
      newType != typeRegistry.getNativeType(UNKNOWN_TYPE)) {
    // If there are two typed declarations of the same variable, that
    // is an error and the second declaration is ignored, except in the
    // case of native types. A null input type means that the declaration
    // was made in TypedScopeCreator#createInitialScope and is a
    // native type.
    if (var.input == null) {
      n.setJSType(varType);
      if (parent.getType() == Token.VAR) {
        if (n.getFirstChild() != null) {
          n.getFirstChild().setJSType(varType);
        }
      } else {
        Preconditions.checkState(parent.getType() == Token.FUNCTION);
        parent.setJSType(varType);
      }
    } else {
      // Always warn about duplicates if the overridden type does not
      // match the original type.
      //
      // If the types match, suppress the warning iff there was a @suppress
      // tag, or if the original declaration was a stub.
      if (!(allowDupe ||
            var.getParentNode().getType() == Token.EXPR_RESULT) ||
          !newType.equals(varType)) {
        compiler.report(
            JSError.make(sourceName, n, DUP_VAR_DECLARATION,
                variableName, newType.toString(), var.getInputName(),
                String.valueOf(var.nameNode.getLineno()),
                varType.toString()));
      }
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:66,代码来源:TypeValidator.java


注:本文中的com.google.javascript.rhino.jstype.JSType.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。