本文整理汇总了Java中com.google.javascript.rhino.jstype.JSType.isConstructor方法的典型用法代码示例。如果您正苦于以下问题:Java JSType.isConstructor方法的具体用法?Java JSType.isConstructor怎么用?Java JSType.isConstructor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.jstype.JSType
的用法示例。
在下文中一共展示了JSType.isConstructor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private void accept(StaticTypedSlot<JSType> var, boolean isStatic) {
JSType type = var.getType();
if ((type.isInterface() || type.isConstructor())
&& !type.isInstanceType()
&& toFunctionType(type).getSource() != null
&& !isTypeAlias(var)) {
acceptClassOrInterface(toFunctionType(type));
} else if (isModule(type)) {
acceptModule(var);
} else if (isTypedef(var)) {
acceptTypedef(var);
} else if (type.isEnumType()) {
acceptEnumType(toEnumType(type));
} else if (isTypeAlias(var)) {
// We don't process type alias.
// /** @constructor */ function Foo() {};
// /** @const */ var Bar = Foo;
} else {
acceptMember(var, isStatic);
}
}
示例2: recordStaticNameDefinition
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private Name recordStaticNameDefinition(NodeTraversal t, String name,
JSType type, Node n, Node parent, Node gParent, Node rValue) {
if (getNamedContainingFunction() != graph.MAIN) {
// TODO(user): if A.B() defines A.C(), there is a dependence from
// A.C() -> A.B(). However, this is not important in module code motion
// and will be ignored (for now).
}
if (type.isFunctionType() && type.isConstructor()) {
return recordClassConstructorOrInterface(
name, (FunctionType) type, n, parent, parent.getParent(), rValue);
} else {
Name symbol = graph.defineNameIfNotExists(name, isExtern);
symbol.setType(type);
if (NodeUtil.isAssign(n)) {
symbol.addAssignmentDeclaration(n);
} else {
symbol.addFunctionDeclaration(n);
}
return symbol;
}
}
示例3: getClassOfMethod
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* Gets the type of the class that "owns" a method, or null if
* we know that its un-owned.
*/
private JSType getClassOfMethod(Node n, Node parent) {
if (parent.getType() == Token.ASSIGN) {
Node lValue = parent.getFirstChild();
if (lValue.isQualifiedName()) {
if (lValue.getType() == Token.GETPROP) {
// We have an assignment of the form "a.b = ...".
JSType lValueType = lValue.getJSType();
if (lValueType != null && lValueType.isConstructor()) {
// If a.b is a constructor, then everything in this function
// belongs to the "a.b" type.
return ((FunctionType) lValueType).getInstanceType();
} else {
// If a.b is not a constructor, then treat this as a method
// of whatever type is on "a".
return normalizeClassType(lValue.getFirstChild().getJSType());
}
} else {
// We have an assignment of the form "a = ...", so pull the
// type off the "a".
return normalizeClassType(lValue.getJSType());
}
}
} else if (NodeUtil.isFunctionDeclaration(n) ||
parent.getType() == Token.NAME) {
return normalizeClassType(n.getJSType());
}
return null;
}
示例4: normalizeClassType
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
* Normalize the type of a constructor, its instance, and its prototype
* all down to the same type (the instance type).
*/
private JSType normalizeClassType(JSType type) {
if (type == null || type.isUnknownType()) {
return type;
} else if (type.isConstructor()) {
return ((FunctionType) type).getInstanceType();
} else if (type.isFunctionPrototypeType()) {
FunctionType owner = ((FunctionPrototypeType) type).getOwnerFunction();
if (owner.isConstructor()) {
return owner.getInstanceType();
}
}
return type;
}
示例5: bothIntrinsics
import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private boolean bothIntrinsics(JSType rightType, JSType leftType) {
return (leftType.isConstructor() || leftType.isEnumType()) &&
(rightType.isConstructor() || rightType.isEnumType());
}