public final class TypeCheck extends java.lang.Object implements NodeTraversal.Callback, CompilerPass
Checks the types of JS expressions against any declared type information.
| Modifier and Type | Field and Description |
|---|---|
static DiagnosticType |
INEXISTENT_PROPERTY |
protected static DiagnosticType |
NOT_A_CONSTRUCTOR |
static DiagnosticType |
STRICT_INEXISTENT_PROPERTY |
static DiagnosticType |
STRICT_INEXISTENT_UNION_PROPERTY |
| Constructor and Description |
|---|
TypeCheck(AbstractCompiler compiler,
ReverseAbstractInterpreter reverseInterpreter,
JSTypeRegistry typeRegistry) |
TypeCheck(AbstractCompiler compiler,
ReverseAbstractInterpreter reverseInterpreter,
JSTypeRegistry typeRegistry,
TypedScope topScope,
com.google.javascript.jscomp.TypedScopeCreator scopeCreator) |
| Modifier and Type | Method and Description |
|---|---|
void |
process(Node externsRoot,
Node jsRoot)
Main entry point for this phase of processing.
|
TypedScope |
processForTesting(Node externsRoot,
Node jsRoot)
Main entry point of this phase for testing code.
|
boolean |
shouldTraverse(NodeTraversal t,
Node n,
Node parent)
Visits a node in preorder (before its children) and decides whether its children should be
traversed.
|
void |
visit(NodeTraversal t,
Node n,
Node parent)
This is the meat of the type checking.
|
public static final DiagnosticType INEXISTENT_PROPERTY
public static final DiagnosticType STRICT_INEXISTENT_PROPERTY
public static final DiagnosticType STRICT_INEXISTENT_UNION_PROPERTY
protected static final DiagnosticType NOT_A_CONSTRUCTOR
public TypeCheck(AbstractCompiler compiler, ReverseAbstractInterpreter reverseInterpreter, JSTypeRegistry typeRegistry, TypedScope topScope, com.google.javascript.jscomp.TypedScopeCreator scopeCreator)
public TypeCheck(AbstractCompiler compiler, ReverseAbstractInterpreter reverseInterpreter, JSTypeRegistry typeRegistry)
public void process(Node externsRoot, Node jsRoot)
process in interface CompilerPassexternsRoot - The root of the externs parse tree.jsRoot - The root of the input parse tree to be checked.public TypedScope processForTesting(Node externsRoot, Node jsRoot)
externsRoot - may be null or a ROOT node. If null the externs are not typechecked. Note:
the externs node must always exist in the AST, even if not typechecked.jsRoot - must be a ROOT node and the second child of the global ROOT.public boolean shouldTraverse(NodeTraversal t, Node n, Node parent)
NodeTraversal.CallbackNodeTraversal.Callback.shouldTraverse(NodeTraversal, Node, Node) in preorder and by NodeTraversal.Callback.visit(NodeTraversal,
Node, Node) in postorder.
Siblings are always visited left-to-right.
Implementations can have side-effects (e.g. modify the parse tree). Removing the current node is legal, but removing or reordering nodes above the current node may cause nodes to be visited twice or not at all.
shouldTraverse in interface NodeTraversal.Callbackt - The current traversal.n - The current node.parent - The parent of the current node.public void visit(NodeTraversal t, Node n, Node parent)
visit in interface NodeTraversal.Callbackt - The node traversal object that supplies context, such as the
scope chain to use in name lookups as well as error reporting.n - The node being visited.parent - The parent of the node n.Copyright © 2009-2020 Google. All Rights Reserved.