com.google.javascript.jscomp
Class ReplaceStrings

java.lang.Object
  extended by com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback
      extended by com.google.javascript.jscomp.ReplaceStrings
All Implemented Interfaces:
CompilerPass, NodeTraversal.Callback

public class ReplaceStrings
extends NodeTraversal.AbstractPostOrderCallback
implements CompilerPass

Replaces JavaScript strings in the list of supplied methods with shortened forms. Useful for replacing debug message such as: throw new Error("Something bad happened"); with generated codes like: throw new Error("a"); This makes the compiled JavaScript smaller and prevents us from leaking details about the source code. Based in concept on the work by Jared Jacobs.


Method Summary
 void process(Node externs, Node root)
          Process the JS with root node root.
 void visit(NodeTraversal t, Node n, Node parent)
          Visits a node in post order (after its children have been visited).
 
Methods inherited from class com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback
shouldTraverse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

visit

public void visit(NodeTraversal t,
                  Node n,
                  Node parent)
Description copied from interface: NodeTraversal.Callback

Visits a node in post order (after its children have been visited). A node is visited only if all its parents should be traversed (NodeTraversal.Callback.shouldTraverse(NodeTraversal, Node, Node)).

Implementations can have side effects (e.g. modifying the parse tree).

Specified by:
visit in interface NodeTraversal.Callback