本文整理汇总了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方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)));
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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);
}
示例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)));
}
示例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)));
}
示例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);
}
示例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());
}
示例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));
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}