本文整理汇总了Java中com.google.javascript.rhino.jstype.ObjectType.getPropertyType方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectType.getPropertyType方法的具体用法?Java ObjectType.getPropertyType怎么用?Java ObjectType.getPropertyType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.jstype.ObjectType
的用法示例。
在下文中一共展示了ObjectType.getPropertyType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findOverriddenFunction
import com.google.javascript.rhino.jstype.ObjectType; //导入方法依赖的package包/类
/**
* Find the function that's being overridden on this type, if any.
*/
private FunctionType findOverriddenFunction(
ObjectType ownerType, String propName) {
// First, check to see if the property is implemented
// on a superclass.
JSType propType = ownerType.getPropertyType(propName);
if (propType instanceof FunctionType) {
return (FunctionType) propType;
} else {
// If it's not, then check to see if it's implemented
// on an implemented interface.
for (ObjectType iface :
ownerType.getCtorImplementedInterfaces()) {
propType = iface.getPropertyType(propName);
if (propType instanceof FunctionType) {
return (FunctionType) propType;
}
}
}
return null;
}
示例2: testAbstractMethod
import com.google.javascript.rhino.jstype.ObjectType; //导入方法依赖的package包/类
public void testAbstractMethod() {
testSame(
"/** Abstract method. \n * @type {!Function} */ var abstractMethod;" +
"/** @constructor */ function Foo() {}" +
"/** Block description. \n * @param {number} x */" +
"Foo.prototype.bar = abstractMethod;");
FunctionType abstractMethod =
(FunctionType) findGlobalNameType("abstractMethod");
assertNull(abstractMethod.getJSDocInfo());
FunctionType ctor = (FunctionType) findGlobalNameType("Foo");
ObjectType proto = ctor.getInstanceType().getImplicitPrototype();
FunctionType method = (FunctionType) proto.getPropertyType("bar");
assertEquals(
"Block description.",
method.getJSDocInfo().getBlockDescription());
assertEquals(
"Block description.",
proto.getOwnPropertyJSDocInfo("bar").getBlockDescription());
}
示例3: testConstructorProperty
import com.google.javascript.rhino.jstype.ObjectType; //导入方法依赖的package包/类
public void testConstructorProperty() {
testSame("var foo = {}; /** @constructor */ foo.Bar = function() {};");
ObjectType foo = (ObjectType) findNameType("foo", globalScope);
assertTrue(foo.hasProperty("Bar"));
assertFalse(foo.isPropertyTypeInferred("Bar"));
JSType fooBar = foo.getPropertyType("Bar");
assertEquals("function (this:foo.Bar): ?", fooBar.toString());
assertEquals(Sets.newHashSet(foo), registry.getTypesWithProperty("Bar"));
}
示例4: testEnumProperty
import com.google.javascript.rhino.jstype.ObjectType; //导入方法依赖的package包/类
public void testEnumProperty() {
testSame("var foo = {}; /** @enum */ foo.Bar = {XXX: 'xxx'};");
ObjectType foo = (ObjectType) findNameType("foo", globalScope);
assertTrue(foo.hasProperty("Bar"));
assertFalse(foo.isPropertyTypeInferred("Bar"));
assertTrue(foo.isPropertyTypeDeclared("Bar"));
JSType fooBar = foo.getPropertyType("Bar");
assertEquals("enum{foo.Bar}", fooBar.toString());
assertEquals(Sets.newHashSet(foo), registry.getTypesWithProperty("Bar"));
}
示例5: testAddingMethodsUsingPrototypeIdiomComplexNamespace
import com.google.javascript.rhino.jstype.ObjectType; //导入方法依赖的package包/类
private void testAddingMethodsUsingPrototypeIdiomComplexNamespace(
TypeCheckResult p) {
ObjectType goog = (ObjectType) p.scope.getVar("goog").getType();
assertEquals(NATIVE_PROPERTIES_COUNT + 1, goog.getPropertiesCount());
JSType googA = goog.getPropertyType("A");
assertNotNull(googA);
assertTrue(googA instanceof FunctionType);
FunctionType googAFunction = (FunctionType) googA;
ObjectType classA = googAFunction.getInstanceType();
assertEquals(NATIVE_PROPERTIES_COUNT + 1, classA.getPropertiesCount());
checkObjectType(classA, "m1", NUMBER_TYPE);
}