com.google.javascript.jscomp
Class CheckEventfulObjectDisposal

java.lang.Object
  extended by 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.


Nested Class Summary
static class CheckEventfulObjectDisposal.DisposalCheckingPolicy
          Policies to determine the disposal checking level.
 
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.
 
Constructor Summary
CheckEventfulObjectDisposal(AbstractCompiler compiler, CheckEventfulObjectDisposal.DisposalCheckingPolicy checkingPolicy)
           
 
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
 

Field Detail

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
Constructor Detail

CheckEventfulObjectDisposal

public CheckEventfulObjectDisposal(AbstractCompiler compiler,
                                   CheckEventfulObjectDisposal.DisposalCheckingPolicy checkingPolicy)
Method Detail

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 tree
root - Top of JS tree