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–196 unchanged (196 lines)
197 reservedNames.add(name);
198 return;
199 }
200
201 // Check if we can rename this.
202 if (!okToRenameVar(name, local)) {
203 // Blindly de-uniquify for the Prototype library for issue 103.
204 return;
205 }
206
207 if (isExternsPass_) {
208 // Keep track of extern globals.
209 if (!local) {
210 externNames.add(name);
…lines 211–483 unchanged (273 lines)

After

…lines 1–196 unchanged (196 lines)
197 reservedNames.add(name);
198 return;
199 }
200
201 // Check if we can rename this.
202 if (!okToRenameVar(name, local)) {
203 if (local) {
204 // Blindly de-uniquify for the Prototype library for issue 103.
205 String newName =
206 MakeDeclaredNamesUnique.ContextualRenameInverter.getOrginalName(
207 name);
208 if (!newName.equals(name)) {
209 n.setString(newName);
210 }
211 }
212 return;
213 }
214
215 if (isExternsPass_) {
216 // Keep track of extern globals.
217 if (!local) {
…lines 218–491 unchanged (274 lines)

Before

program
block_comment "/*\n * Copyright 2004 Google Inc.\n *\n * Licensed under the Ap"...
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
identifier "javax"
. "."
identifier "annotation"
. "."
identifier "Nullable"
; ";"
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 "Sets"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "NodeTraversal"
. "."
identifier "AbstractPostOrderCallback"
; ";"
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 * RenameVars renames all the variables names into short"...
class_declaration
modifiers
final "final"
class "class"
identifier "RenameVars"
super_interfaces
implements "implements"
type_list
type_identifier "CompilerPass"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
block_comment "/** List of global NAME nodes */"
field_declaration (+25 nodes collapsed)
block_comment "/** List of local NAME nodes */"
field_declaration (+25 nodes collapsed)
block_comment "/** List of local names that corresponds to the localNameNod"...
field_declaration (+25 nodes collapsed)
block_comment "/** Set of extern variable names */"
field_declaration (+25 nodes collapsed)
block_comment "/** Set of reserved variable names */"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "reservedNames"
; ";"
block_comment "/** The renaming map */"
field_declaration (+29 nodes collapsed)
block_comment "/** The previously used rename map. */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "VariableMap"
variable_declarator
identifier "prevUsedRenameMap"
; ";"
block_comment "/** The global name prefix */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "String"
variable_declarator
identifier "prefix"
; ";"
block_comment "/** Counter for each assignment */"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "assignmentCount"
= "="
decimal_integer_literal "0"
; ";"
block_comment "/** Logs all name assignments */"
field_declaration
modifiers
private "private"
type_identifier "StringBuilder"
variable_declarator
identifier "assignmentLog"
; ";"
class_declaration (+141 nodes collapsed)
block_comment "/** Maps an old name to a new name assignment */"
field_declaration (+29 nodes collapsed)
block_comment "/** Whether renaming should apply to local variables only. *"...
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "localRenamingOnly"
; ";"
block_comment "/**\n * Whether anonymous function names should be preserve"...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveAnonymousFunctionNames"
; ";"
block_comment "/** Generate pseudo names for variables for debugging purpos"...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "generatePseudoNames"
; ";"
block_comment "/** Characters that shouldn't be used in variable names. */"
field_declaration
modifiers
private "private"
final "final"
array_type
integral_type
char "char"
dimensions
[ "["
] "]"
variable_declarator
identifier "reservedCharacters"
; ";"
block_comment "/** A prefix to distinguish temporary local names from globa"...
field_declaration
modifiers
private "private"
static "static"
final "final"
type_identifier "String"
variable_declarator
identifier "LOCAL_VAR_PREFIX"
= "="
string_literal
" "\""
string_fragment "L "
" "\""
; ";"
constructor_declaration (+177 nodes collapsed)
block_comment "/**\n * Iterate through the nodes, collect all the NAME nod"...
class_declaration
class "class"
identifier "ProcessVars"
superclass
extends "extends"
type_identifier "AbstractPostOrderCallback"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "isExternsPass_"
; ";"
constructor_declaration
identifier "ProcessVars"
formal_parameters
( "("
formal_parameter
boolean_type "boolean"
identifier "isExterns"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
identifier "isExternsPass_"
= "="
identifier "isExterns"
; ";"
} "}"
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "visit"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
, ","
formal_parameter
type_identifier "Node"
identifier "n"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement (+24 nodes collapsed)
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "n"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
line_comment "// Ignore anonymous functions"
if_statement (+21 nodes collapsed)
line_comment "// Is this local or Global?"
local_variable_declaration (+23 nodes collapsed)
local_variable_declaration (+22 nodes collapsed)
line_comment "// Are we renaming global variables?"
if_statement (+27 nodes collapsed)
line_comment "// Are we renaming anonymous function names?"
if_statement (+44 nodes collapsed)
line_comment "// Check if we can rename this."
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "okToRenameVar"
argument_list
( "("
identifier "name"
, ","
identifier "local"
) ")"
) ")"
block
{ "{"
line_comment "// Blindly de-uniquify for the Prototype library for issue 1"...
return_statement
return "return"
; ";"
} "}"
if_statement (+34 nodes collapsed)
if_statement (+94 nodes collapsed)
} "}"
line_comment "// Increment count of an assignment"
method_declaration (+76 nodes collapsed)
} "}"
block_comment "/**\n * Sorts Assignment objects by their count, breaking t"...
field_declaration (+94 nodes collapsed)
block_comment "/**\n * Sorts Assignment objects by the order the variable "...
field_declaration (+61 nodes collapsed)
block_comment "/**\n * {@inheritDoc}\n */"
method_declaration (+319 nodes collapsed)
method_declaration (+104 nodes collapsed)
method_declaration (+103 nodes collapsed)
method_declaration (+39 nodes collapsed)
block_comment "/**\n * Runs through the assignments and reuses as many nam"...
method_declaration (+137 nodes collapsed)
block_comment "/**\n * Determines which new names to substitute for the or"...
method_declaration (+444 nodes collapsed)
block_comment "/**\n * Makes a final name assignment.\n */"
method_declaration (+82 nodes collapsed)
block_comment "/**\n * Gets the variable map.\n */"
method_declaration
type_identifier "VariableMap"
identifier "getVariableMap"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
object_creation_expression
new "new"
type_identifier "VariableMap"
argument_list
( "("
identifier "renameMap"
) ")"
; ";"
} "}"
block_comment "/**\n * Determines whether a variable name is okay to renam"...
method_declaration (+39 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Copyright 2004 Google Inc.\n *\n * Licensed under the Ap"...
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
identifier "javax"
. "."
identifier "annotation"
. "."
identifier "Nullable"
; ";"
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 "Sets"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "NodeTraversal"
. "."
identifier "AbstractPostOrderCallback"
; ";"
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 * RenameVars renames all the variables names into short"...
class_declaration
modifiers
final "final"
class "class"
identifier "RenameVars"
super_interfaces
implements "implements"
type_list
type_identifier "CompilerPass"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
block_comment "/** List of global NAME nodes */"
field_declaration (+25 nodes collapsed)
block_comment "/** List of local NAME nodes */"
field_declaration (+25 nodes collapsed)
block_comment "/** List of local names that corresponds to the localNameNod"...
field_declaration (+25 nodes collapsed)
block_comment "/** Set of extern variable names */"
field_declaration (+25 nodes collapsed)
block_comment "/** Set of reserved variable names */"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "reservedNames"
; ";"
block_comment "/** The renaming map */"
field_declaration (+29 nodes collapsed)
block_comment "/** The previously used rename map. */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "VariableMap"
variable_declarator
identifier "prevUsedRenameMap"
; ";"
block_comment "/** The global name prefix */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "String"
variable_declarator
identifier "prefix"
; ";"
block_comment "/** Counter for each assignment */"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "assignmentCount"
= "="
decimal_integer_literal "0"
; ";"
block_comment "/** Logs all name assignments */"
field_declaration
modifiers
private "private"
type_identifier "StringBuilder"
variable_declarator
identifier "assignmentLog"
; ";"
class_declaration (+141 nodes collapsed)
block_comment "/** Maps an old name to a new name assignment */"
field_declaration (+29 nodes collapsed)
block_comment "/** Whether renaming should apply to local variables only. *"...
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "localRenamingOnly"
; ";"
block_comment "/**\n * Whether anonymous function names should be preserve"...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveAnonymousFunctionNames"
; ";"
block_comment "/** Generate pseudo names for variables for debugging purpos"...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "generatePseudoNames"
; ";"
block_comment "/** Characters that shouldn't be used in variable names. */"
field_declaration
modifiers
private "private"
final "final"
array_type
integral_type
char "char"
dimensions
[ "["
] "]"
variable_declarator
identifier "reservedCharacters"
; ";"
block_comment "/** A prefix to distinguish temporary local names from globa"...
field_declaration
modifiers
private "private"
static "static"
final "final"
type_identifier "String"
variable_declarator
identifier "LOCAL_VAR_PREFIX"
= "="
string_literal
" "\""
string_fragment "L "
" "\""
; ";"
constructor_declaration (+177 nodes collapsed)
block_comment "/**\n * Iterate through the nodes, collect all the NAME nod"...
class_declaration
class "class"
identifier "ProcessVars"
superclass
extends "extends"
type_identifier "AbstractPostOrderCallback"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "isExternsPass_"
; ";"
constructor_declaration
identifier "ProcessVars"
formal_parameters
( "("
formal_parameter
boolean_type "boolean"
identifier "isExterns"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
identifier "isExternsPass_"
= "="
identifier "isExterns"
; ";"
} "}"
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "visit"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
, ","
formal_parameter
type_identifier "Node"
identifier "n"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement (+24 nodes collapsed)
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "n"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
line_comment "// Ignore anonymous functions"
if_statement (+21 nodes collapsed)
line_comment "// Is this local or Global?"
local_variable_declaration (+23 nodes collapsed)
local_variable_declaration (+22 nodes collapsed)
line_comment "// Are we renaming global variables?"
if_statement (+27 nodes collapsed)
line_comment "// Are we renaming anonymous function names?"
if_statement (+44 nodes collapsed)
line_comment "// Check if we can rename this."
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "okToRenameVar"
argument_list
( "("
identifier "name"
, ","
identifier "local"
) ")"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
identifier "local"
) ")"
block
{ "{"
line_comment "// Blindly de-uniquify for the Prototype library for issue 1"...
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "newName"
= "="
method_invocation
field_access
identifier "MakeDeclaredNamesUnique"
. "."
identifier "ContextualRenameInverter"
. "."
identifier "getOrginalName"
argument_list
( "("
identifier "name"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "newName"
. "."
identifier "equals"
argument_list
( "("
identifier "name"
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "n"
. "."
identifier "setString"
argument_list
( "("
identifier "newName"
) ")"
; ";"
} "}"
} "}"
return_statement
return "return"
; ";"
} "}"
if_statement (+34 nodes collapsed)
if_statement (+94 nodes collapsed)
} "}"
line_comment "// Increment count of an assignment"
method_declaration (+76 nodes collapsed)
} "}"
block_comment "/**\n * Sorts Assignment objects by their count, breaking t"...
field_declaration (+94 nodes collapsed)
block_comment "/**\n * Sorts Assignment objects by the order the variable "...
field_declaration (+61 nodes collapsed)
block_comment "/**\n * {@inheritDoc}\n */"
method_declaration (+319 nodes collapsed)
method_declaration (+104 nodes collapsed)
method_declaration (+103 nodes collapsed)
method_declaration (+39 nodes collapsed)
block_comment "/**\n * Runs through the assignments and reuses as many nam"...
method_declaration (+137 nodes collapsed)
block_comment "/**\n * Determines which new names to substitute for the or"...
method_declaration (+444 nodes collapsed)
block_comment "/**\n * Makes a final name assignment.\n */"
method_declaration (+82 nodes collapsed)
block_comment "/**\n * Gets the variable map.\n */"
method_declaration
type_identifier "VariableMap"
identifier "getVariableMap"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
object_creation_expression
new "new"
type_identifier "VariableMap"
argument_list
( "("
identifier "renameMap"
) ")"
; ";"
} "}"
block_comment "/**\n * Determines whether a variable name is okay to renam"...
method_declaration (+39 nodes collapsed)
} "}"