public final class CheckEventfulObjectDisposal extends Object implements CompilerPass
An eventful class is any class that derives from goog.events.EventHandler or (in aggressive mode) is disposable and disposes of an eventful class when it is disposed (see http://research.google.com/pubs/pub40738.html).
This pass is heuristic based and should not be used for any check of pass/fail testing. The pass traverses the AST and marks as errors cases where an eventful object is allocated but a dispose call is not found. It only tracks eventful objects that has a easily identifiable static name, i.e., objects assigned to arrays, returned from functions or captured in closures are not considered. It simply tries to see if there exists a call to a dispose method in the AST for every object seen as eventful.
This compiler pass uses the inferred types and hence either type checking or type inference needs to be enabled.
Modifier and Type | Field and Description |
---|---|
static int |
DISPOSE_ALL
Constant used to signify all arguments of method/function
should be marked as disposed.
|
static int |
DISPOSE_SELF
Constant used to signify that object on which this method is called,
will itself get disposed of.
|
Constructor and Description |
---|
CheckEventfulObjectDisposal(AbstractCompiler compiler,
CompilerOptions.DisposalCheckingPolicy checkingPolicy) |
Modifier and Type | Method and Description |
---|---|
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
public static final int DISPOSE_ALL
public static final int DISPOSE_SELF
public CheckEventfulObjectDisposal(AbstractCompiler compiler, CompilerOptions.DisposalCheckingPolicy checkingPolicy)
public void process(Node externs, Node root)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treeCopyright © 2009-2016 Google. All Rights Reserved.