本文整理汇总了Java中com.google.javascript.rhino.jstype.StaticScope类的典型用法代码示例。如果您正苦于以下问题:Java StaticScope类的具体用法?Java StaticScope怎么用?Java StaticScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StaticScope类属于com.google.javascript.rhino.jstype包,在下文中一共展示了StaticScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDescriptionForThrownType
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/**
* Returns the description for the given thrown type, if it
* exists.
*/
public String getDescriptionForThrownType(JSType type,
StaticScope<JSType> scope) {
if (documentation == null || documentation.throwsDescriptions == null) {
return null;
}
for (JSTypeExpression typeExpr :
documentation.throwsDescriptions.keySet()) {
if (type.canAssignTo(typeExpr.evaluate(scope))) {
return documentation.throwsDescriptions.get(typeExpr);
}
}
return null;
}
示例2: createFunctionScope
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
@Override
public StaticScope<ConcreteType> createFunctionScope(
Node decl, StaticScope<ConcreteType> parent) {
ConcreteScope scope = new ConcreteScope((ConcreteScope) parent);
scope.declareSlot(ConcreteFunctionType.CALL_SLOT_NAME, decl);
scope.declareSlot(ConcreteFunctionType.THIS_SLOT_NAME, decl);
scope.declareSlot(ConcreteFunctionType.RETURN_SLOT_NAME, decl);
for (Node n = decl.getFirstChild().getNext().getFirstChild();
n != null;
n = n.getNext()) {
scope.declareSlot(n.getString(), n);
}
// TODO(user): Create an 'arguments' variable that returns the union
// of the concrete types of all parameters.
scope.initForScopeRoot(decl.getLastChild());
return scope;
}
示例3: createInstanceScope
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/** @inheritDoc */
public StaticScope<ConcreteType> createInstanceScope(
ObjectType instanceType) {
FakeScope parentScope = null;
if (instanceType.getImplicitPrototype() != null) {
ConcreteInstanceType prototype =
createConcreteInstance(instanceType.getImplicitPrototype());
parentScope = (FakeScope) prototype.getScope();
}
FakeScope scope = new FakeScope(parentScope);
for (String propName : instanceType.getOwnPropertyNames()) {
scope.addSlot(propName);
}
return scope;
}
示例4: createInstanceScope
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/** {@inheritDoc} */
public StaticScope<ConcreteType> createInstanceScope(
ObjectType instanceType) {
FakeScope parentScope = null;
if (instanceType.getImplicitPrototype() != null) {
ConcreteInstanceType prototype =
createConcreteInstance(instanceType.getImplicitPrototype());
parentScope = (FakeScope) prototype.getScope();
}
FakeScope scope = new FakeScope(parentScope);
for (String propName : instanceType.getOwnPropertyNames()) {
scope.addSlot(propName);
}
return scope;
}
示例5: createInstanceScope
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public StaticScope<ConcreteType> createInstanceScope(
ObjectType instanceType) {
FakeScope parentScope = null;
if (instanceType.getImplicitPrototype() != null) {
ConcreteInstanceType prototype =
createConcreteInstance(instanceType.getImplicitPrototype());
parentScope = (FakeScope) prototype.getScope();
}
FakeScope scope = new FakeScope(parentScope);
for (String propName : instanceType.getOwnPropertyNames()) {
scope.addSlot(propName);
}
return scope;
}
示例6: evaluate
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/**
* Evaluates the type expression into a {@code JSType} object.
*/
public JSType evaluate(StaticScope<JSType> scope) {
JSType type = registry.createFromTypeNodes(root, sourceName, scope);
if (root.getBooleanProp(Node.BRACELESS_TYPE)) {
type.forgiveUnknownNames();
}
return type;
}
示例7: assertValidResolve
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/** @return The resolved type */
public static JSType assertValidResolve(
JSType type, StaticScope<JSType> scope) {
ErrorReporter t = TestErrorReporter.forNoExpectedReports();
JSType resolvedType = type.resolve(t, scope);
Assert.assertEquals("JSType#resolve should not affect object equality",
type, resolvedType);
Assert.assertEquals("JSType#resolve should not affect hash codes",
type.hashCode(), resolvedType.hashCode());
return resolvedType;
}
示例8: ConcreteFunctionType
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
ConcreteFunctionType(Factory factory,
Node declaration,
StaticScope<ConcreteType> parentScope) {
this.factory = factory;
this.declaration = declaration;
this.parentScope = parentScope;
Preconditions.checkArgument(declaration.getType() == Token.FUNCTION);
Preconditions.checkArgument(declaration.getJSType() != null);
Preconditions.checkArgument(declaration.getJSType().isFunctionType());
}
示例9: getScope
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/** Returns the scope for the body of this function. */
@Override StaticScope<ConcreteType> getScope() {
if (bodyScope == null) {
bodyScope = factory.createFunctionScope(declaration, parentScope);
}
return bodyScope;
}
示例10: createConcreteFunction
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
@Override
public ConcreteFunctionType createConcreteFunction(
Node decl, StaticScope<ConcreteType> parent) {
ConcreteFunctionType funType = functionFromDeclaration.get(decl);
if (funType == null) {
functionFromDeclaration.put(decl,
funType = new ConcreteFunctionType(this, decl, parent));
if (decl.getJSType() != null) {
functionFromJSType.put((FunctionType) decl.getJSType(), funType);
}
}
return funType;
}
示例11: createInstanceScope
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
@Override
public StaticScope<ConcreteType> createInstanceScope(
ObjectType instanceType) {
ConcreteScope parentScope = null;
if (instanceType.getImplicitPrototype() != null) {
ConcreteInstanceType prototype =
createConcreteInstance(instanceType.getImplicitPrototype());
parentScope = (ConcreteScope) prototype.getScope();
}
ConcreteScope scope = new ConcreteScope(parentScope);
for (String propName : instanceType.getOwnPropertyNames()) {
scope.declareSlot(propName, null);
}
return scope;
}
示例12: process
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
public void process(Node externs, Node root) {
for (TypeMismatch mis : compiler.getTypeValidator().getMismatches()) {
addInvalidatingType(mis.typeA);
addInvalidatingType(mis.typeB);
}
StaticScope<T> scope = typeSystem.getRootScope();
NodeTraversal.traverse(compiler, externs, new FindExternProperties());
NodeTraversal.traverse(compiler, root, new FindRenameableProperties());
renameProperties();
}
示例13: getType
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
@Override public JSType getType(
StaticScope<JSType> scope, Node node, String prop) {
if (node.getJSType() == null) {
return registry.getNativeType(JSTypeNative.UNKNOWN_TYPE);
}
return node.getJSType();
}
示例14: createConcreteFunction
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/** @inheritDoc */
public ConcreteFunctionType createConcreteFunction(
Node decl, StaticScope<ConcreteType> parent) {
ConcreteFunctionType funcType = functionByDeclaration.get(decl);
if (funcType == null) {
functionByDeclaration.put(decl, funcType =
new ConcreteFunctionType(this, decl, parent));
if (decl.getJSType() != null) {
functionByJSType.put((FunctionType) decl.getJSType(), funcType);
}
}
return funcType;
}
示例15: createFunctionScope
import com.google.javascript.rhino.jstype.StaticScope; //导入依赖的package包/类
/** @inheritDoc */
public StaticScope<ConcreteType> createFunctionScope(
Node decl, StaticScope<ConcreteType> parent) {
FakeScope scope = new FakeScope((FakeScope) parent);
scope.addSlot(ConcreteFunctionType.CALL_SLOT_NAME);
scope.addSlot(ConcreteFunctionType.THIS_SLOT_NAME);
scope.addSlot(ConcreteFunctionType.RETURN_SLOT_NAME);
for (Node n = decl.getFirstChild().getNext().getFirstChild();
n != null;
n = n.getNext()) {
scope.addSlot(n.getString());
}
return scope;
}