本文整理汇总了Java中com.google.javascript.rhino.jstype.JSType.isEmptyType方法的典型用法代码示例。如果您正苦于以下问题:Java JSType.isEmptyType方法的具体用法?Java JSType.isEmptyType怎么用?Java JSType.isEmptyType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.jstype.JSType
的用法示例。
在下文中一共展示了JSType.isEmptyType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 "";
}
}
示例2: createType
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/** Returns a concrete type from the given JSType. */
private ConcreteType createType(JSType jsType) {
if (jsType.isUnknownType() || jsType.isEmptyType()) {
return ConcreteType.ALL;
}
if (jsType.isUnionType()) {
ConcreteType type = ConcreteType.NONE;
for (JSType alt : ((UnionType) jsType).getAlternates()) {
type = type.unionWith(createType(alt));
}
return type;
}
if (jsType.isFunctionType()) {
if (getConcreteFunction((FunctionType) jsType) != null) {
return getConcreteFunction((FunctionType) jsType);
}
// Since we don't have a declaration, it's not concrete.
return ConcreteType.ALL;
}
if (jsType.isObject()) {
return createConcreteInstance(jsType.toObjectType());
}
return ConcreteType.NONE; // Not a reference type.
}
示例3: getFunctionAnnotation
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* @param node A node for a function for which to generate a type annotation
*/
private String getFunctionAnnotation(Node node) {
StringBuilder sb = new StringBuilder("/**\n");
if (node.getJSType().isUnknownType()) {
return "";
}
FunctionType funType = (FunctionType) node.getJSType();
// We need to use the child nodes of the function as the nodes for the
// parameters of the function type do not have the real parameter names.
// FUNCTION
// NAME
// LP
// NAME param1
// NAME param2
Node fnNode = funType.getSource();
if (fnNode != null) {
Node paramNode = NodeUtil.getFnParameters(fnNode).getFirstChild();
// Param types
for (Node n : funType.getParameters()) {
// Bail out if the paramNode is not there.
if (paramNode == null) {
break;
}
sb.append(" * @param {" + n.getJSType() + "} ");
sb.append(paramNode.getString());
sb.append("\n");
paramNode = paramNode.getNext();
}
}
// Return type
JSType retType = funType.getReturnType();
if (retType != null && !retType.isUnknownType() && !retType.isEmptyType()) {
sb.append(" * @return {" + retType + "}\n");
}
// Constructor/interface
if (funType.isConstructor() || funType.isInterface()) {
ObjectType superInstance =
funType.getSuperClassConstructor().getInstanceType();
if (!superInstance.toString().equals("Object")) {
sb.append(" * @extends {" + superInstance + "}\n");
}
for (ObjectType interfaze : funType.getImplementedInterfaces()) {
sb.append(" * @implements {" + interfaze + "}\n");
}
if (funType.isConstructor()) {
sb.append(" * @constructor\n");
} else if (funType.isInterface()) {
sb.append(" * @interface\n");
}
}
if (fnNode != null && fnNode.getBooleanProp(Node.IS_DISPATCHER)) {
sb.append(" * @javadispatch\n");
}
sb.append(" */\n");
return sb.toString();
}