本文整理汇总了Java中com.google.javascript.rhino.jstype.JSTypeRegistry类的典型用法代码示例。如果您正苦于以下问题:Java JSTypeRegistry类的具体用法?Java JSTypeRegistry怎么用?Java JSTypeRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSTypeRegistry类属于com.google.javascript.rhino.jstype包,在下文中一共展示了JSTypeRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: TypeCheck
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
public TypeCheck(AbstractCompiler compiler,
ReverseAbstractInterpreter reverseInterpreter,
JSTypeRegistry typeRegistry,
Scope topScope,
ScopeCreator scopeCreator,
CheckLevel reportMissingOverride,
CheckLevel reportUnknownTypes) {
this.compiler = compiler;
this.validator = compiler.getTypeValidator();
this.reverseInterpreter = reverseInterpreter;
this.typeRegistry = typeRegistry;
this.topScope = topScope;
this.scopeCreator = scopeCreator;
this.reportMissingOverride = reportMissingOverride;
this.reportUnknownTypes = reportUnknownTypes;
this.inferJSDocInfo = new InferJSDocInfo(compiler);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:TypeCheck.java
示例2: fixFunctionType
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
/**
* Creates a new JSType based on the original function type by
* adding the original this pointer type to the beginning of the
* argument type list and replacing the this pointer type with
* NO_TYPE.
*/
private void fixFunctionType(Node functionNode) {
FunctionType type = (FunctionType) functionNode.getJSType();
if (type != null) {
JSTypeRegistry typeRegistry = compiler.getTypeRegistry();
List<JSType> parameterTypes = Lists.newArrayList();
parameterTypes.add(type.getTypeOfThis());
for (Node param : type.getParameters()) {
parameterTypes.add(param.getJSType());
}
ObjectType thisType =
typeRegistry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE);
JSType returnType = type.getReturnType();
JSType newType = typeRegistry.createFunctionType(
thisType, returnType, parameterTypes);
functionNode.setJSType(newType);
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:28,代码来源:DevirtualizePrototypeMethods.java
示例3: AmbiguateProperties
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
AmbiguateProperties(AbstractCompiler compiler,
char[] reservedCharacters) {
this.compiler = compiler;
this.reservedCharacters = reservedCharacters;
JSTypeRegistry r = compiler.getTypeRegistry();
invalidatingTypes = Sets.newHashSet(
r.getNativeType(JSTypeNative.ALL_TYPE),
r.getNativeType(JSTypeNative.NO_OBJECT_TYPE),
r.getNativeType(JSTypeNative.NO_TYPE),
r.getNativeType(JSTypeNative.NULL_TYPE),
r.getNativeType(JSTypeNative.VOID_TYPE),
r.getNativeType(JSTypeNative.FUNCTION_FUNCTION_TYPE),
r.getNativeType(JSTypeNative.FUNCTION_PROTOTYPE),
r.getNativeType(JSTypeNative.GLOBAL_THIS),
r.getNativeType(JSTypeNative.OBJECT_TYPE),
r.getNativeType(JSTypeNative.OBJECT_PROTOTYPE),
r.getNativeType(JSTypeNative.OBJECT_FUNCTION_TYPE),
r.getNativeType(JSTypeNative.TOP_LEVEL_PROTOTYPE),
r.getNativeType(JSTypeNative.UNKNOWN_TYPE));
for (TypeMismatch mis : compiler.getTypeValidator().getMismatches()) {
addInvalidatingType(mis.typeA);
addInvalidatingType(mis.typeB);
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:27,代码来源:AmbiguateProperties.java
示例4: 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
示例5: 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
示例6: buildInvalidatingTypeSet
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
private void buildInvalidatingTypeSet() {
JSTypeRegistry registry = compiler.getTypeRegistry();
invalidatingTypes = Sets.newHashSet(
registry.getNativeType(JSTypeNative.ALL_TYPE),
registry.getNativeType(JSTypeNative.NO_OBJECT_TYPE),
registry.getNativeType(JSTypeNative.NO_TYPE),
registry.getNativeType(JSTypeNative.NULL_TYPE),
registry.getNativeType(JSTypeNative.VOID_TYPE),
registry.getNativeType(JSTypeNative.FUNCTION_FUNCTION_TYPE),
registry.getNativeType(JSTypeNative.FUNCTION_INSTANCE_TYPE),
registry.getNativeType(JSTypeNative.FUNCTION_PROTOTYPE),
registry.getNativeType(JSTypeNative.GLOBAL_THIS),
registry.getNativeType(JSTypeNative.OBJECT_TYPE),
registry.getNativeType(JSTypeNative.OBJECT_PROTOTYPE),
registry.getNativeType(JSTypeNative.OBJECT_FUNCTION_TYPE),
registry.getNativeType(JSTypeNative.TOP_LEVEL_PROTOTYPE),
registry.getNativeType(JSTypeNative.UNKNOWN_TYPE));
for (TypeMismatch mis : compiler.getTypeValidator().getMismatches()) {
addInvalidatingType(mis.typeA);
addInvalidatingType(mis.typeB);
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:InlineProperties.java
示例7: TypeCheck
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
public TypeCheck(AbstractCompiler compiler,
ReverseAbstractInterpreter reverseInterpreter,
JSTypeRegistry typeRegistry,
Scope topScope,
MemoizedScopeCreator scopeCreator,
CheckLevel reportMissingOverride,
CheckLevel reportUnknownTypes) {
this.compiler = compiler;
this.validator = compiler.getTypeValidator();
this.reverseInterpreter = reverseInterpreter;
this.typeRegistry = typeRegistry;
this.topScope = topScope;
this.scopeCreator = scopeCreator;
this.reportMissingOverride = reportMissingOverride;
this.reportUnknownTypes = reportUnknownTypes;
this.inferJSDocInfo = new InferJSDocInfo(compiler);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:TypeCheck.java
示例8: fixFunctionType
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
/**
* Creates a new JSType based on the original function type by
* adding the original this pointer type to the beginning of the
* argument type list and replacing the this pointer type with
* NO_TYPE.
*/
private void fixFunctionType(Node functionNode) {
FunctionType type = JSType.toMaybeFunctionType(functionNode.getJSType());
if (type != null) {
JSTypeRegistry typeRegistry = compiler.getTypeRegistry();
List<JSType> parameterTypes = Lists.newArrayList();
parameterTypes.add(type.getTypeOfThis());
for (Node param : type.getParameters()) {
parameterTypes.add(param.getJSType());
}
ObjectType thisType =
typeRegistry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE);
JSType returnType = type.getReturnType();
JSType newType = typeRegistry.createFunctionType(
thisType, returnType, parameterTypes);
functionNode.setJSType(newType);
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:28,代码来源:DevirtualizePrototypeMethods.java
示例9: 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 super.getAssertedType(call, registry);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:ClosureCodingConvention.java
示例10: testApplySubclassRelationship
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
public void testApplySubclassRelationship() {
JSTypeRegistry registry = new JSTypeRegistry(null);
Node nodeA = new Node(Token.FUNCTION);
FunctionType ctorA = registry.createConstructorType("A", nodeA,
new Node(Token.PARAM_LIST), null, null);
Node nodeB = new Node(Token.FUNCTION);
FunctionType ctorB = registry.createConstructorType("B", nodeB,
new Node(Token.PARAM_LIST), null, null);
conv.applySubclassRelationship(ctorA, ctorB, SubclassType.INHERITS);
assertTrue(ctorB.getPrototype().hasOwnProperty("constructor"));
assertEquals(nodeB, ctorB.getPrototype().getPropertyNode("constructor"));
assertTrue(ctorB.hasOwnProperty("superClass_"));
assertEquals(nodeB, ctorB.getPropertyNode("superClass_"));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:ClosureCodingConventionTest.java
示例11: 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
示例12: 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
示例13: TypeCheck
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
public TypeCheck(
AbstractCompiler compiler,
ReverseAbstractInterpreter reverseInterpreter,
JSTypeRegistry typeRegistry,
TypedScope topScope,
MemoizedTypedScopeCreator scopeCreator) {
this.compiler = compiler;
this.validator = compiler.getTypeValidator();
this.reverseInterpreter = reverseInterpreter;
this.typeRegistry = typeRegistry;
this.topScope = topScope;
this.scopeCreator = scopeCreator;
this.reportUnknownTypes = ((Compiler) compiler).getOptions().enables(
DiagnosticGroups.REPORT_UNKNOWN_TYPES);
this.inferJSDocInfo = new InferJSDocInfo(compiler);
}
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:TypeCheck.java
示例14: 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
示例15: testApplySubclassRelationship
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
public void testApplySubclassRelationship() {
JSTypeRegistry registry = new JSTypeRegistry(null);
Node nodeA = new Node(Token.FUNCTION);
FunctionType ctorA =
registry.createConstructorType("A", nodeA, new Node(Token.PARAM_LIST), null, null, false);
Node nodeB = new Node(Token.FUNCTION);
FunctionType ctorB =
registry.createConstructorType("B", nodeB, new Node(Token.PARAM_LIST), null, null, false);
conv.applySubclassRelationship(
new NominalTypeBuilderOti(ctorA, ctorA.getInstanceType()),
new NominalTypeBuilderOti(ctorB, ctorB.getInstanceType()),
SubclassType.INHERITS);
assertTrue(ctorB.getPrototype().hasOwnProperty("constructor"));
assertEquals(nodeB, ctorB.getPrototype().getPropertyNode("constructor"));
assertTrue(ctorB.hasOwnProperty("superClass_"));
assertEquals(nodeB, ctorB.getPropertyNode("superClass_"));
}
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:ClosureCodingConventionTest.java
示例16: 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
示例17: 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
示例18: 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
示例19: NominalTypeProcessor
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
NominalTypeProcessor(
@Provided LinkFactoryBuilder linkFactoryBuilder,
@Provided DossierFileSystem dfs,
@Provided CommentParser parser,
@Provided TypeRegistry typeRegistry,
@Provided JSTypeRegistry jsTypeRegistry,
@Provided StaticTypedScope<JSType> globalScope,
@Provided TypeExpressionParserFactory expressionParserFactory,
@Provided TypeInspectorFactory typeInspectorFactory,
@Provided IndexBuilder typeIndex,
NominalType type) {
this.dfs = dfs;
this.parser = parser;
this.typeRegistry = typeRegistry;
this.jsRegistry = jsTypeRegistry;
this.globalScope = globalScope;
this.expressionParserFactory = expressionParserFactory;
this.linkFactory = linkFactoryBuilder.create(type).withTypeContext(type);
this.typeInspector = typeInspectorFactory.create(type);
this.type = type;
this.indexReference = updateTypeIndex(typeIndex);
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:23,代码来源:RenderDocumentationTaskSupplier.java
示例20: LinkFactory
import com.google.javascript.rhino.jstype.JSTypeRegistry; //导入依赖的package包/类
/**
* Creates a new link factory.
*
* @param dfs used to generate paths to documentation in the output file system.
* @param typeRegistry used to lookup nominal types.
* @param jsTypeRegistry used to lookup JavaScript types.
* @param typeContext defines the context in which to resolve type names.
* @param urlTemplate if provided, defines a template for links to source files.
* @param pathContext the object, if any, to generate paths relative to in the output file system.
* If {@code null}, paths will be relative to the output root.
*/
LinkFactory(
@Provided DossierFileSystem dfs,
@Provided TypeRegistry typeRegistry,
@Provided JSTypeRegistry jsTypeRegistry,
@Provided NodeLibrary nodeLibrary,
@Provided ModuleNamingConvention namingConvention,
@Provided TypeContext typeContext,
@Provided @SourceUrlTemplate Optional<String> urlTemplate,
@Provided @TypeFilter Predicate<String> typeNameFilter,
@Nullable NominalType pathContext) {
this(
dfs,
typeRegistry,
jsTypeRegistry,
nodeLibrary,
namingConvention,
typeContext,
urlTemplate,
typeNameFilter,
pathContext,
false);
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:34,代码来源:LinkFactory.java
注:本文中的com.google.javascript.rhino.jstype.JSTypeRegistry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论