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


Java JSTypeRegistry.getNativeType方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.jstype.JSTypeRegistry.getNativeType方法的典型用法代码示例。如果您正苦于以下问题:Java JSTypeRegistry.getNativeType方法的具体用法?Java JSTypeRegistry.getNativeType怎么用?Java JSTypeRegistry.getNativeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.jstype.JSTypeRegistry的用法示例。

在下文中一共展示了JSTypeRegistry.getNativeType方法的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testFunctionMismatch

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
public void testFunctionMismatch() throws Exception {
  testSame(
      "/** \n" +
      " * @param {function(string): number} x \n" +
      " * @return {function(boolean): string} \n" +
      " */ function f(x) { return x; }",
      TYPE_MISMATCH_WARNING);

  JSTypeRegistry registry = compiler.getTypeRegistry();
  JSType string = registry.getNativeType(STRING_TYPE);
  JSType bool = registry.getNativeType(BOOLEAN_TYPE);
  JSType number = registry.getNativeType(NUMBER_TYPE);
  JSType firstFunction = registry.createFunctionType(number, string);
  JSType secondFunction = registry.createFunctionType(string, bool);

  assertMismatches(
      Lists.newArrayList(
          new TypeMismatch(firstFunction, secondFunction),
          fromNatives(STRING_TYPE, BOOLEAN_TYPE),
          fromNatives(NUMBER_TYPE, STRING_TYPE)));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:22,代码来源:TypeValidatorTest.java


示例2: testFunctionMismatch2

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
public void testFunctionMismatch2() throws Exception {
  testSame(
      "/** \n" +
      " * @param {function(string): number} x \n" +
      " * @return {function(boolean): number} \n" +
      " */ function f(x) { return x; }",
      TYPE_MISMATCH_WARNING);

  JSTypeRegistry registry = compiler.getTypeRegistry();
  JSType string = registry.getNativeType(STRING_TYPE);
  JSType bool = registry.getNativeType(BOOLEAN_TYPE);
  JSType number = registry.getNativeType(NUMBER_TYPE);
  JSType firstFunction = registry.createFunctionType(number, string);
  JSType secondFunction = registry.createFunctionType(number, bool);

  assertMismatches(
      Lists.newArrayList(
          new TypeMismatch(firstFunction, secondFunction),
          fromNatives(STRING_TYPE, BOOLEAN_TYPE)));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:21,代码来源:TypeValidatorTest.java


示例3: testFunctionMismatch

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
public void testFunctionMismatch() throws Exception {
  testSame(
      "/** \n" +
      " * @param {function(string): number} x \n" +
      " * @return {function(boolean): string} \n" +
      " */ function f(x) { return x; }",
      TYPE_MISMATCH_WARNING);

  JSTypeRegistry registry = compiler.getTypeRegistry();
  JSType string = registry.getNativeType(STRING_TYPE);
  JSType bool = registry.getNativeType(BOOLEAN_TYPE);
  JSType number = registry.getNativeType(NUMBER_TYPE);
  JSType firstFunction = registry.createFunctionType(number, string);
  JSType secondFunction = registry.createFunctionType(string, bool);

  assertMismatches(
      Lists.newArrayList(
          new TypeMismatch(firstFunction, secondFunction, null),
          fromNatives(STRING_TYPE, BOOLEAN_TYPE),
          fromNatives(NUMBER_TYPE, STRING_TYPE)));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:TypeValidatorTest.java


示例4: testFunctionMismatch2

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
public void testFunctionMismatch2() throws Exception {
  testSame(
      "/** \n" +
      " * @param {function(string): number} x \n" +
      " * @return {function(boolean): number} \n" +
      " */ function f(x) { return x; }",
      TYPE_MISMATCH_WARNING);

  JSTypeRegistry registry = compiler.getTypeRegistry();
  JSType string = registry.getNativeType(STRING_TYPE);
  JSType bool = registry.getNativeType(BOOLEAN_TYPE);
  JSType number = registry.getNativeType(NUMBER_TYPE);
  JSType firstFunction = registry.createFunctionType(number, string);
  JSType secondFunction = registry.createFunctionType(number, bool);

  assertMismatches(
      Lists.newArrayList(
          new TypeMismatch(firstFunction, secondFunction, null),
          fromNatives(STRING_TYPE, BOOLEAN_TYPE)));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:TypeValidatorTest.java


示例5: getAssertedOldType

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
/**
 * Returns the type for a type assertion, or null if the function asserts
 * that the node must not be null or undefined.
 */
@Override
public com.google.javascript.rhino.jstype.JSType
    getAssertedOldType(Node call, JSTypeRegistry registry) {
  if (call.getChildCount() > 2) {
    Node constructor = call.getSecondChild().getNext();
    if (constructor != null) {
      com.google.javascript.rhino.jstype.JSType ownerType =
          constructor.getJSType();
      if (ownerType != null
          && ownerType.isFunctionType()
          && ownerType.isConstructor()) {
        FunctionType functionType = ((FunctionType) ownerType);
        return functionType.getInstanceType();
      }
    }
  }
  return registry.getNativeType(JSTypeNative.UNKNOWN_TYPE);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:ClosureCodingConvention.java


示例6: testFunctionMismatch

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
public void testFunctionMismatch() throws Exception {
  testWarning(
      "/** \n"
          + " * @param {function(string): number} x \n"
          + " * @return {function(boolean): string} \n"
          + " */ function f(x) { return x; }",
      TYPE_MISMATCH_WARNING);

  JSTypeRegistry registry = getLastCompiler().getTypeRegistry();
  JSType string = registry.getNativeType(STRING_TYPE);
  JSType bool = registry.getNativeType(BOOLEAN_TYPE);
  JSType number = registry.getNativeType(NUMBER_TYPE);
  JSType firstFunction = registry.createFunctionType(number, string);
  JSType secondFunction = registry.createFunctionType(string, bool);

  assertMismatches(
      ImmutableList.of(
          new TypeMismatch(firstFunction, secondFunction, null),
          fromNatives(STRING_TYPE, BOOLEAN_TYPE),
          fromNatives(NUMBER_TYPE, STRING_TYPE)));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:22,代码来源:TypeValidatorTest.java


示例7: testFunctionMismatch2

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
public void testFunctionMismatch2() throws Exception {
  testWarning(
      "/** \n"
          + " * @param {function(string): number} x \n"
          + " * @return {function(boolean): number} \n"
          + " */ function f(x) { return x; }",
      TYPE_MISMATCH_WARNING);

  JSTypeRegistry registry = getLastCompiler().getTypeRegistry();
  JSType string = registry.getNativeType(STRING_TYPE);
  JSType bool = registry.getNativeType(BOOLEAN_TYPE);
  JSType number = registry.getNativeType(NUMBER_TYPE);
  JSType firstFunction = registry.createFunctionType(number, string);
  JSType secondFunction = registry.createFunctionType(number, bool);

  assertMismatches(
      ImmutableList.of(
          new TypeMismatch(firstFunction, secondFunction, null),
          fromNatives(STRING_TYPE, BOOLEAN_TYPE)));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:TypeValidatorTest.java


示例8: getAssertedType

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
/**
 * Returns the type for a type assertion, or null if the function asserts
 * that the node must not be null or undefined.
 */
@Override
public JSType getAssertedType(Node call, JSTypeRegistry registry) {
  if (call.getChildCount() > 2) {
    Node constructor = call.getFirstChild().getNext().getNext();
    if (constructor != null) {
      JSType ownerType = constructor.getJSType();
      if (ownerType != null
          && ownerType.isFunctionType()
          && ownerType.isConstructor()) {
        FunctionType functionType = ((FunctionType) ownerType);
        return functionType.getInstanceType();
      }
    }
  }
  return registry.getNativeType(JSTypeNative.UNKNOWN_TYPE);
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:21,代码来源:ClosureCodingConvention.java


示例9: TypeInspector

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
TypeInspector(
    @Provided DossierFileSystem dfs,
    @Provided CommentParser parser,
    @Provided TypeRegistry registry,
    @Provided StaticTypedScope<JSType> globalScope,
    @Provided JSTypeRegistry jsRegistry,
    @Provided @TypeFilter Predicate<String> typeFilter,
    @Provided TypeExpressionParserFactory expressionParserFactory,
    @Provided LinkFactoryBuilder linkFactoryBuilder,
    NominalType inspectedType) {
  this.dfs = dfs;
  this.parser = parser;
  this.registry = registry;
  this.globalScope = globalScope;
  this.jsRegistry = jsRegistry;
  this.expressionParserFactory = expressionParserFactory;
  this.typeFilter = typeFilter;
  this.linkFactory = linkFactoryBuilder.create(inspectedType);
  this.inspectedType = inspectedType;

  JSType type = inspectedType.getType();
  if (type.isConstructor() || type.isInterface()) {
    type = type.toMaybeFunctionType().getInstanceType();
  } else {
    type = jsRegistry.getNativeType(JSTypeNative.UNKNOWN_TYPE);
  }
  typeMapReplacer = new TemplateTypeMapReplacer(jsRegistry, type.getTemplateTypeMap());
}
 
开发者ID:jleyba,项目名称:js-dossier,代码行数:29,代码来源:TypeInspector.java


示例10: fromNatives

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
private TypeMismatch fromNatives(JSTypeNative a, JSTypeNative b) {
  JSTypeRegistry registry = compiler.getTypeRegistry();
  return new TypeMismatch(
      registry.getNativeType(a), registry.getNativeType(b));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:6,代码来源:TypeValidatorTest.java


示例11: setUp

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
@Override
public void setUp() {
  typeRegistry = new JSTypeRegistry(new TestErrorReporter(null, null));
  unknownType = typeRegistry.getNativeType(JSTypeNative.UNKNOWN_TYPE);
  factory = new FakeFactory();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:7,代码来源:ConcreteTypeTest.java


示例12: fromNatives

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
private TypeMismatch fromNatives(JSTypeNative a, JSTypeNative b) {
  JSTypeRegistry registry = compiler.getTypeRegistry();
  return new TypeMismatch(
      registry.getNativeType(a), registry.getNativeType(b), null);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:6,代码来源:TypeValidatorTest.java


示例13: fromNatives

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
private TypeMismatch fromNatives(JSTypeNative a, JSTypeNative b) {
  JSTypeRegistry registry = getLastCompiler().getTypeRegistry();
  return new TypeMismatch(
      registry.getNativeType(a), registry.getNativeType(b), null);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:6,代码来源:TypeValidatorTest.java


示例14: getAssertedType

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
/**
 * Returns the type for a type assertion, or null if the function asserts
 * that the node must not be null or undefined.
 */
public JSType getAssertedType(Node call, JSTypeRegistry registry) {
  return assertedType != null ? registry.getNativeType(assertedType) : null;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:CodingConvention.java


示例15: getAssertedOldType

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
/**
 * Returns the old type system type for a type assertion, or null if
 * the function asserts that the node must not be null or undefined.
 * @param call The asserting call
 */
public com.google.javascript.rhino.jstype.JSType
    getAssertedOldType(Node call, JSTypeRegistry registry) {
  return assertedType != null ? registry.getNativeType(assertedType) : null;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:10,代码来源:CodingConvention.java


示例16: getAssertedType

import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入方法依赖的package包/类
/**
 * Returns the type for a type assertion, or null if the function asserts
 * that the node must not be null or undefined.
 * @param call The asserting call
 */
public JSType getAssertedType(Node call, JSTypeRegistry registry) {
  return assertedType != null ? registry.getNativeType(assertedType) : null;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:9,代码来源:CodingConvention.java



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