com.google.javascript.jscomp
Class CheckEventfulObjectDisposal
java.lang.Object
com.google.javascript.jscomp.CheckEventfulObjectDisposal
- All Implemented Interfaces:
- CompilerPass
public class CheckEventfulObjectDisposal
- extends Object
- implements CompilerPass
Check to ensure there exists a path to dispose of each eventful object
created.
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.
Field Summary |
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. |
Method Summary |
void |
process(Node externs,
Node root)
Process the JS with root node root. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DISPOSE_ALL
public static final int DISPOSE_ALL
- Constant used to signify all arguments of method/function
should be marked as disposed.
- See Also:
- Constant Field Values
DISPOSE_SELF
public static final int DISPOSE_SELF
- Constant used to signify that object on which this method is called,
will itself get disposed of.
- See Also:
- Constant Field Values
CheckEventfulObjectDisposal
public CheckEventfulObjectDisposal(AbstractCompiler compiler,
CheckEventfulObjectDisposal.DisposalCheckingPolicy checkingPolicy)
process
public void process(Node externs,
Node root)
- Description copied from interface:
CompilerPass
- Process the JS with root node root.
Can modify the contents of each Node tree
- Specified by:
process
in interface CompilerPass
- Parameters:
externs
- Top of external JS treeroot
- Top of JS tree