当前位置: 首页>>代码示例>>Java>>正文


Java ObjectType.getPropertyType方法代码示例

本文整理汇总了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;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:TypedScopeCreator.java

示例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());
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:21,代码来源:InferJSDocInfoTest.java

示例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"));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:11,代码来源:TypedScopeCreatorTest.java

示例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"));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:12,代码来源:TypedScopeCreatorTest.java

示例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);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:13,代码来源:TypeCheckTest.java


注:本文中的com.google.javascript.rhino.jstype.ObjectType.getPropertyType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。