本文整理汇总了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())));
}
}
}
示例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())));
}
}
}