本文整理汇总了Java中com.google.javascript.rhino.jstype.JSType.isVoidType方法的典型用法代码示例。如果您正苦于以下问题:Java JSType.isVoidType方法的具体用法?Java JSType.isVoidType怎么用?Java JSType.isVoidType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.jstype.JSType
的用法示例。
在下文中一共展示了JSType.isVoidType方法的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: getName
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private String getName(JSType type) {
if (type.isInstanceType()) {
return ((ObjectType) type).getReferenceName();
} else if (type.isNullType()
|| type.isBooleanValueType()
|| type.isNumberValueType()
|| type.isStringValueType()
|| type.isVoidType()) {
return type.toString();
} else {
// Type unchecked at runtime, so we don't care about the sorting order.
return "";
}
}
示例3: createCheckerNode
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* Creates a node which evaluates to a checker for the given type (which
* must not be a union). We have checkers for value types, classes and
* interfaces.
*
* @return the checker node or {@code null} if the type is not checked
*/
private Node createCheckerNode(JSType type) {
if (type.isNullType()) {
return jsCode("nullChecker");
} else if (type.isBooleanValueType()
|| type.isNumberValueType()
|| type.isStringValueType()
|| type.isVoidType()) {
return new Node(Token.CALL,
jsCode("valueChecker"),
Node.newString(type.toString()));
} else if (type.isInstanceType()) {
ObjectType objType = (ObjectType) type;
String refName = objType.getReferenceName();
String sourceName =
NodeUtil.getSourceName(objType.getConstructor().getSource());
CompilerInput sourceInput = compiler.getInput(sourceName);
if (sourceInput == null || sourceInput.isExtern()) {
return new Node(Token.CALL,
jsCode("externClassChecker"),
Node.newString(refName));
}
return new Node(Token.CALL,
jsCode(objType.getConstructor().isInterface() ?
"interfaceChecker" : "classChecker"),
Node.newString(refName));
} else {
// We don't check this type (e.g. unknown & all types).
return null;
}
}
示例4: expectNotVoid
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* Expect the type to be anything but the void type. If the expectation is not
* met, issue a warning at the provided node's source code position. Note that
* a union type that includes the void type and at least one other type meets
* the expectation.
* @return Whether the expectation was met.
*/
boolean expectNotVoid(
NodeTraversal t, Node n, JSType type, String msg, JSType expectedType) {
if (type.isVoidType()) {
mismatch(t, n, msg, type, expectedType);
return false;
}
return true;
}
示例5: getTypeAnnotation
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private String getTypeAnnotation(Node node) {
JSType type = node.getJSType();
if (type instanceof FunctionType) {
return getFunctionAnnotation(node);
} else if (type != null && !type.isUnknownType()
&& !type.isEmptyType() && !type.isVoidType()) {
return "/** @type {" + node.getJSType() + "} */\n";
} else {
return "";
}
}