Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–372 unchanged (372 lines)
373 // the function's lexical source.
374 //
375 // Rather than create a new option for this, we assume that if the user
376 // is removing globals, then it's OK to remove unused function args.
377 //
378 // See http://code.google.com/p/closure-compiler/issues/detail?id=253
379
380 Node function = fnScope.getRootNode();
381
382 Preconditions.checkState(function.isFunction());
383 if (NodeUtil.isGetOrSetKey(function.getParent())) {
384 // The parameters object literal setters can not be removed.
385 return;
…lines 386–996 unchanged (611 lines)

After

…lines 1–372 unchanged (372 lines)
373 // the function's lexical source.
374 //
375 // Rather than create a new option for this, we assume that if the user
376 // is removing globals, then it's OK to remove unused function args.
377 //
378 // See http://code.google.com/p/closure-compiler/issues/detail?id=253
379 if (!removeGlobals) {
380 return;
381 }
382
383 Node function = fnScope.getRootNode();
384
385 Preconditions.checkState(function.isFunction());
386 if (NodeUtil.isGetOrSetKey(function.getParent())) {
387 // The parameters object literal setters can not be removed.
…lines 388–999 unchanged (612 lines)

Before

program
block_comment "/*\n * Copyright 2008 The Closure Compiler Authors.\n *\n * Lic"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Preconditions"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "ArrayListMultimap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Lists"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Maps"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Multimap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Sets"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "CodingConvention"
. "."
identifier "SubclassRelationship"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "DefinitionsRemover"
. "."
identifier "Definition"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "Scope"
. "."
identifier "Var"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "IR"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
import_declaration
import "import"
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
asterisk
* "*"
; ";"
block_comment "/**\n * Garbage collection for variable and function definiti"...
class_declaration
class "class"
identifier "RemoveUnusedVars"
super_interfaces
implements "implements"
type_list
type_identifier "CompilerPass"
, ","
scoped_type_identifier
type_identifier "OptimizeCalls"
. "."
type_identifier "CallGraphCompilerPass"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "CodingConvention"
variable_declarator
identifier "codingConvention"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "removeGlobals"
; ";"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveFunctionExpressionNames"
; ";"
block_comment "/**\n * Keep track of variables that we've referenced.\n *"...
field_declaration (+21 nodes collapsed)
block_comment "/**\n * Keep track of variables that might be unreferenced."...
field_declaration (+21 nodes collapsed)
block_comment "/**\n * Keep track of scopes that we've traversed.\n */"
field_declaration (+21 nodes collapsed)
block_comment "/**\n * Keep track of assigns to variables that we haven't "...
field_declaration (+23 nodes collapsed)
block_comment "/**\n * The assigns, indexed by the NAME node that they ass"...
field_declaration (+23 nodes collapsed)
block_comment "/**\n * Subclass name -> class-defining call EXPR node. (li"...
field_declaration (+23 nodes collapsed)
block_comment "/**\n * Keep track of continuations that are finished iff t"...
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "modifyCallSites"
; ";"
field_declaration
modifiers
private "private"
type_identifier "CallSiteOptimizer"
variable_declarator
identifier "callSiteOptimizer"
; ";"
constructor_declaration (+74 nodes collapsed)
block_comment "/**\n * Traverses the root, removing all unused variables. "...
method_declaration (+96 nodes collapsed)
method_declaration (+87 nodes collapsed)
block_comment "/**\n * Traverses a node recursively. Call this once per pa"...
method_declaration (+98 nodes collapsed)
block_comment "/**\n * Traverses everything in the current scope and marks"...
method_declaration (+847 nodes collapsed)
method_declaration (+91 nodes collapsed)
block_comment "/**\n * Traverses a function, which creates a new scope in "...
method_declaration (+148 nodes collapsed)
block_comment "/**\n * For each variable in this scope that we haven't fou"...
method_declaration (+84 nodes collapsed)
block_comment "/**\n * Removes unreferenced arguments from a function decl"...
method_declaration
modifiers
private "private"
void_type "void"
identifier "removeUnreferencedFunctionArgs"
formal_parameters
( "("
formal_parameter
type_identifier "Scope"
identifier "fnScope"
) ")"
block
{ "{"
line_comment "// Notice that removing unreferenced function args breaks"
line_comment "// Function.prototype.length. In advanced mode, we don't rea"...
line_comment "// about this: we consider \"length\" the equivalent of reflec"...
line_comment "// the function's lexical source."
line_comment "//"
line_comment "// Rather than create a new option for this, we assume that "...
line_comment "// is removing globals, then it's OK to remove unused functi"...
line_comment "//"
line_comment "// See http://code.google.com/p/closure-compiler/issues/deta"...
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "function"
= "="
method_invocation
identifier "fnScope"
. "."
identifier "getRootNode"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "Preconditions"
. "."
identifier "checkState"
argument_list
( "("
method_invocation
identifier "function"
. "."
identifier "isFunction"
argument_list
( "("
) ")"
) ")"
; ";"
if_statement (+26 nodes collapsed)
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "argList"
= "="
method_invocation
identifier "getFunctionArgList"
argument_list
( "("
identifier "function"
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "modifyCallers"
= "="
binary_expression
identifier "modifyCallSites"
&& "&&"
method_invocation
identifier "callSiteOptimizer"
. "."
identifier "canModifyCallers"
argument_list
( "("
identifier "function"
) ")"
; ";"
if_statement (+121 nodes collapsed)
} "}"
block_comment "/**\n * @return the LP node containing the function paramet"...
method_declaration (+31 nodes collapsed)
class_declaration (+1650 nodes collapsed)
block_comment "/**\n * Look at all the property assigns to all variables.\n"...
method_declaration (+367 nodes collapsed)
block_comment "/**\n * Remove all assigns to a var.\n */"
method_declaration (+50 nodes collapsed)
block_comment "/**\n * Marks a var as referenced, recursing into any value"...
method_declaration (+65 nodes collapsed)
block_comment "/**\n * Removes any vars in the scope that were not referen"...
method_declaration (+523 nodes collapsed)
block_comment "/**\n * Our progress in a traversal can be expressed comple"...
class_declaration (+143 nodes collapsed)
class_declaration (+580 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Copyright 2008 The Closure Compiler Authors.\n *\n * Lic"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Preconditions"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "ArrayListMultimap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Lists"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Maps"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Multimap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Sets"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "CodingConvention"
. "."
identifier "SubclassRelationship"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "DefinitionsRemover"
. "."
identifier "Definition"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "Scope"
. "."
identifier "Var"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "IR"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
import_declaration
import "import"
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
asterisk
* "*"
; ";"
block_comment "/**\n * Garbage collection for variable and function definiti"...
class_declaration
class "class"
identifier "RemoveUnusedVars"
super_interfaces
implements "implements"
type_list
type_identifier "CompilerPass"
, ","
scoped_type_identifier
type_identifier "OptimizeCalls"
. "."
type_identifier "CallGraphCompilerPass"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "CodingConvention"
variable_declarator
identifier "codingConvention"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "removeGlobals"
; ";"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveFunctionExpressionNames"
; ";"
block_comment "/**\n * Keep track of variables that we've referenced.\n *"...
field_declaration (+21 nodes collapsed)
block_comment "/**\n * Keep track of variables that might be unreferenced."...
field_declaration (+21 nodes collapsed)
block_comment "/**\n * Keep track of scopes that we've traversed.\n */"
field_declaration (+21 nodes collapsed)
block_comment "/**\n * Keep track of assigns to variables that we haven't "...
field_declaration (+23 nodes collapsed)
block_comment "/**\n * The assigns, indexed by the NAME node that they ass"...
field_declaration (+23 nodes collapsed)
block_comment "/**\n * Subclass name -> class-defining call EXPR node. (li"...
field_declaration (+23 nodes collapsed)
block_comment "/**\n * Keep track of continuations that are finished iff t"...
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "modifyCallSites"
; ";"
field_declaration
modifiers
private "private"
type_identifier "CallSiteOptimizer"
variable_declarator
identifier "callSiteOptimizer"
; ";"
constructor_declaration (+74 nodes collapsed)
block_comment "/**\n * Traverses the root, removing all unused variables. "...
method_declaration (+96 nodes collapsed)
method_declaration (+87 nodes collapsed)
block_comment "/**\n * Traverses a node recursively. Call this once per pa"...
method_declaration (+98 nodes collapsed)
block_comment "/**\n * Traverses everything in the current scope and marks"...
method_declaration (+847 nodes collapsed)
method_declaration (+91 nodes collapsed)
block_comment "/**\n * Traverses a function, which creates a new scope in "...
method_declaration (+148 nodes collapsed)
block_comment "/**\n * For each variable in this scope that we haven't fou"...
method_declaration (+84 nodes collapsed)
block_comment "/**\n * Removes unreferenced arguments from a function decl"...
method_declaration
modifiers
private "private"
void_type "void"
identifier "removeUnreferencedFunctionArgs"
formal_parameters
( "("
formal_parameter
type_identifier "Scope"
identifier "fnScope"
) ")"
block
{ "{"
line_comment "// Notice that removing unreferenced function args breaks"
line_comment "// Function.prototype.length. In advanced mode, we don't rea"...
line_comment "// about this: we consider \"length\" the equivalent of reflec"...
line_comment "// the function's lexical source."
line_comment "//"
line_comment "// Rather than create a new option for this, we assume that "...
line_comment "// is removing globals, then it's OK to remove unused functi"...
line_comment "//"
line_comment "// See http://code.google.com/p/closure-compiler/issues/deta"...
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
identifier "removeGlobals"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "function"
= "="
method_invocation
identifier "fnScope"
. "."
identifier "getRootNode"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "Preconditions"
. "."
identifier "checkState"
argument_list
( "("
method_invocation
identifier "function"
. "."
identifier "isFunction"
argument_list
( "("
) ")"
) ")"
; ";"
if_statement (+26 nodes collapsed)
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "argList"
= "="
method_invocation
identifier "getFunctionArgList"
argument_list
( "("
identifier "function"
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "modifyCallers"
= "="
binary_expression
identifier "modifyCallSites"
&& "&&"
method_invocation
identifier "callSiteOptimizer"
. "."
identifier "canModifyCallers"
argument_list
( "("
identifier "function"
) ")"
; ";"
if_statement (+121 nodes collapsed)
} "}"
block_comment "/**\n * @return the LP node containing the function paramet"...
method_declaration (+31 nodes collapsed)
class_declaration (+1650 nodes collapsed)
block_comment "/**\n * Look at all the property assigns to all variables.\n"...
method_declaration (+367 nodes collapsed)
block_comment "/**\n * Remove all assigns to a var.\n */"
method_declaration (+50 nodes collapsed)
block_comment "/**\n * Marks a var as referenced, recursing into any value"...
method_declaration (+65 nodes collapsed)
block_comment "/**\n * Removes any vars in the scope that were not referen"...
method_declaration (+523 nodes collapsed)
block_comment "/**\n * Our progress in a traversal can be expressed comple"...
class_declaration (+143 nodes collapsed)
class_declaration (+580 nodes collapsed)
} "}"