本文整理汇总了Java中com.google.javascript.rhino.jstype.JSType.visit方法的典型用法代码示例。如果您正苦于以下问题:Java JSType.visit方法的具体用法?Java JSType.visit怎么用?Java JSType.visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.jstype.JSType
的用法示例。
在下文中一共展示了JSType.visit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private TypeReference visit(JSType type) {
if (type.isVoidType() || type.isNullType()) {
return type.visit(this);
}
// Nullable type and optional type are represented in closure by an union type with
// respectively Null and Undefined. We don't use this information (yet), so we remove Null
// or Undefined before to visit the type.
return type.restrictByNotNullOrUndefined().visit(this);
}
示例2: caseUnionType
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
public JSType caseUnionType(UnionType type) {
JSType restricted = null;
for (JSType alternate : type.getAlternates()) {
JSType restrictedAlternate = alternate.visit(this);
if (restrictedAlternate != null) {
if (restricted == null) {
restricted = restrictedAlternate;
} else {
restricted = restrictedAlternate.getLeastSupertype(restricted);
}
}
}
return restricted;
}
示例3: getRestrictedWithoutUndefined
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* Returns a version of type where undefined is not present.
*/
final JSType getRestrictedWithoutUndefined(JSType type) {
return type == null ? null : type.visit(restrictUndefinedVisitor);
}
示例4: getRestrictedWithoutNull
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* Returns a version of type where null is not present.
*/
final JSType getRestrictedWithoutNull(JSType type) {
return type == null ? null : type.visit(restrictNullVisitor);
}
示例5: getRestrictedByTypeOfResult
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* Returns a version of {@code type} that is restricted by some knowledge
* about the result of the {@code typeof} operation.
* <p>
* The behavior of the {@code typeof} operator can be summarized by the
* following table:
* <table>
* <tr><th>type</th><th>result</th></tr>
* <tr><td>{@code undefined}</td><td>"undefined"</td></tr>
* <tr><td>{@code null}</td><td>"object"</td></tr>
* <tr><td>{@code boolean}</td><td>"boolean"</td></tr>
* <tr><td>{@code number}</td><td>"number"</td></tr>
* <tr><td>{@code string}</td><td>"string"</td></tr>
* <tr><td>{@code Object} (which doesn't implement [[Call]])</td>
* <td>"object"</td></tr>
* <tr><td>{@code Object} (which implements [[Call]])</td>
* <td>"function"</td></tr>
* </table>
* @param type the type to restrict
* @param value A value known to be equal or not equal to the result of the
* {@code typeof} operation
* @param resultEqualsValue {@code true} if the {@code typeOf} result is known
* to equal {@code value}; {@code false} if it is known <em>not</em> to
* equal {@code value}
* @return the restricted type or null if no version of the type matches the
* restriction
*/
JSType getRestrictedByTypeOfResult(JSType type, String value,
boolean resultEqualsValue) {
if (type == null) {
if (resultEqualsValue) {
JSType result = getNativeTypeForTypeOf(value);
return result == null ? getNativeType(UNKNOWN_TYPE) : result;
} else {
return null;
}
}
return type.visit(
new RestrictByOneTypeOfResultVisitor(value, resultEqualsValue));
}