Package com.google.javascript.jscomp
Class TypeCheck
java.lang.Object
com.google.javascript.jscomp.TypeCheck
- All Implemented Interfaces:
CompilerPass
,NodeTraversal.Callback
Checks the types of JS expressions against any declared type information.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final DiagnosticType
protected static final String
-
Constructor Summary
ConstructorDescriptionTypeCheck
(AbstractCompiler compiler, ReverseAbstractInterpreter reverseInterpreter, JSTypeRegistry typeRegistry, CheckLevel reportMissingOverride, CheckLevel reportUnknownTypes) TypeCheck
(AbstractCompiler compiler, ReverseAbstractInterpreter reverseInterpreter, JSTypeRegistry typeRegistry, Scope topScope, com.google.javascript.jscomp.MemoizedScopeCreator scopeCreator, CheckLevel reportMissingOverride, CheckLevel reportUnknownTypes) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Main entry point for this phase of processing.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 pre order (before visiting its children) and decides whether this node's children should be traversed.void
visit
(NodeTraversal t, Node n, Node parent) This is the meat of the type checking.
-
Field Details
-
OVERRIDING_PROTOTYPE_WITH_NON_OBJECT
- See Also:
-
NOT_A_CONSTRUCTOR
-
-
Constructor Details
-
TypeCheck
public TypeCheck(AbstractCompiler compiler, ReverseAbstractInterpreter reverseInterpreter, JSTypeRegistry typeRegistry, Scope topScope, com.google.javascript.jscomp.MemoizedScopeCreator scopeCreator, CheckLevel reportMissingOverride, CheckLevel reportUnknownTypes) -
TypeCheck
public TypeCheck(AbstractCompiler compiler, ReverseAbstractInterpreter reverseInterpreter, JSTypeRegistry typeRegistry, CheckLevel reportMissingOverride, CheckLevel reportUnknownTypes)
-
-
Method Details
-
process
Main entry point for this phase of processing. This follows the pattern for JSCompiler phases.- Specified by:
process
in interfaceCompilerPass
- Parameters:
externsRoot
- The root of the externs parse tree.jsRoot
- The root of the input parse tree to be checked.
-
processForTesting
Main entry point of this phase for testing code. -
check
-
shouldTraverse
Description copied from interface:NodeTraversal.Callback
Visits a node in pre order (before visiting its children) and decides whether this node's children should be traversed. If children are traversed, they will be visited by
NodeTraversal.Callback.visit(NodeTraversal, Node, Node)
in post order.Implementations can have side effects (e.g. modifying the parse tree).
- Specified by:
shouldTraverse
in interfaceNodeTraversal.Callback
- Returns:
- whether the children of this node should be visited
-
visit
This is the meat of the type checking. It is basically one big switch, with each case representing one type of parse tree node. The individual cases are usually pretty straightforward.- Specified by:
visit
in interfaceNodeTraversal.Callback
- Parameters:
t
- 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.
-