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


Java StaticSlot.getDeclaration方法代码示例

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


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

示例1: expectInterfaceProperty

import com.google.javascript.rhino.jstype.StaticSlot; //导入方法依赖的package包/类
/**
 * Expect that the property in an interface that this type implements is
 * implemented and correctly typed.
 */
private void expectInterfaceProperty(NodeTraversal t, Node n,
    ObjectType instance, ObjectType implementedInterface, String prop) {
  StaticSlot<JSType> propSlot = instance.getSlot(prop);
  if (propSlot == null) {
    // Not implemented
    String sourceName = n.getSourceFileName();
    sourceName = sourceName == null ? "" : sourceName;
    registerMismatch(instance, implementedInterface,
        report(JSError.make(sourceName, n,
        INTERFACE_METHOD_NOT_IMPLEMENTED,
        prop, implementedInterface.toString(), instance.toString())));
  } else {
    Node propNode = propSlot.getDeclaration() == null ?
        null : propSlot.getDeclaration().getNode();

    // Fall back on the constructor node if we can't find a node for the
    // property.
    propNode = propNode == null ? n : propNode;

    JSType found = propSlot.getType();
    JSType required
        = implementedInterface.getImplicitPrototype().getPropertyType(prop);
    found = found.restrictByNotNullOrUndefined();
    required = required.restrictByNotNullOrUndefined();
    if (!found.isSubtype(required)) {
      // Implemented, but not correctly typed
      FunctionType constructor =
          implementedInterface.toObjectType().getConstructor();
      registerMismatch(found, required, report(t.makeError(propNode,
          HIDDEN_INTERFACE_PROPERTY_MISMATCH, prop,
          constructor.getTopMostDefiningType(prop).toString(),
          required.toString(), found.toString())));
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:40,代码来源:TypeValidator.java

示例2: expectInterfaceProperty

import com.google.javascript.rhino.jstype.StaticSlot; //导入方法依赖的package包/类
/**
 * Expect that the property in an interface that this type implements is
 * implemented and correctly typed.
 */
private void expectInterfaceProperty(NodeTraversal t, Node n,
    ObjectType instance, ObjectType implementedInterface, String prop) {
  StaticSlot<JSType> propSlot = instance.getSlot(prop);
  if (propSlot == null) {
    // Not implemented
    String sourceName = n.getSourceFileName();
    sourceName = sourceName == null ? "" : sourceName;
    registerMismatch(instance, implementedInterface,
        report(JSError.make(sourceName, n,
        INTERFACE_METHOD_NOT_IMPLEMENTED,
        prop, implementedInterface.toString(), instance.toString())));
  } else {
    Node propNode = propSlot.getDeclaration() == null ?
        null : propSlot.getDeclaration().getNode();

    // Fall back on the constructor node if we can't find a node for the
    // property.
    propNode = propNode == null ? n : propNode;

    JSType found = propSlot.getType();
    found = found.restrictByNotNullOrUndefined();

    JSType required
        = implementedInterface.getImplicitPrototype().getPropertyType(prop);
    TemplateTypeMap typeMap = implementedInterface.getTemplateTypeMap();
    if (!typeMap.isEmpty()) {
      TemplateTypeMapReplacer replacer = new TemplateTypeMapReplacer(
          typeRegistry, typeMap);
      required = required.visit(replacer);
    }
    required = required.restrictByNotNullOrUndefined();

    if (!found.isSubtype(required)) {
      // Implemented, but not correctly typed
      FunctionType constructor =
          implementedInterface.toObjectType().getConstructor();
      registerMismatch(found, required, report(t.makeError(propNode,
          HIDDEN_INTERFACE_PROPERTY_MISMATCH, prop,
          constructor.getTopMostDefiningType(prop).toString(),
          required.toString(), found.toString())));
    }
  }
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:48,代码来源:TypeValidator.java


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