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–208 unchanged (208 lines)
209 private void visitLabel(Node node, Node parent) {
210 Node nameNode = node.getFirstChild();
211 Preconditions.checkState(nameNode != null);
212 String name = nameNode.getString();
213 LabelInfo li = getLabelInfo(name);
214 // This is a label...
215 if (li.referenced) {
216 String newName = getNameForId(li.id);
217 if (!name.equals(newName)) {
218 // ... and it is used, give it the short name.
219 nameNode.setString(newName);
220 compiler.reportCodeChange();
221 }
…lines 222–277 unchanged (56 lines)

After

…lines 1–208 unchanged (208 lines)
209 private void visitLabel(Node node, Node parent) {
210 Node nameNode = node.getFirstChild();
211 Preconditions.checkState(nameNode != null);
212 String name = nameNode.getString();
213 LabelInfo li = getLabelInfo(name);
214 // This is a label...
215 if (li.referenced || !removeUnused) {
216 String newName = getNameForId(li.id);
217 if (!name.equals(newName)) {
218 // ... and it is used, give it the short name.
219 nameNode.setString(newName);
220 compiler.reportCodeChange();
221 }
…lines 222–277 unchanged (56 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 "base"
. "."
identifier "Supplier"
; ";"
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
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "NodeTraversal"
. "."
identifier "ScopedCallback"
; ";"
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
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Deque"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashSet"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
block_comment "/**\n * RenameLabels renames all the labels so that they have"...
class_declaration
modifiers
final "final"
class "class"
identifier "RenameLabels"
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"
; ";"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "nameSupplier"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "removeUnused"
; ";"
constructor_declaration (+27 nodes collapsed)
constructor_declaration (+51 nodes collapsed)
class_declaration (+73 nodes collapsed)
block_comment "/**\n * Iterate through the nodes, renaming all the labels."...
class_declaration
class "class"
identifier "ProcessLabels"
super_interfaces
implements "implements"
type_list
type_identifier "ScopedCallback"
class_body
{ "{"
constructor_declaration (+24 nodes collapsed)
line_comment "// A stack of labels namespaces. Labels in an outer scope ar"...
line_comment "// inner scope, so a new namespace is created each time a sc"...
field_declaration
modifiers
final "final"
generic_type
type_identifier "Deque"
type_arguments
< "<"
type_identifier "LabelNamespace"
> ">"
variable_declarator
identifier "namespaceStack"
= "="
method_invocation
identifier "Lists"
. "."
identifier "newLinkedList"
argument_list
( "("
) ")"
; ";"
line_comment "// The list of generated names. Typically, the first name wi"...
line_comment "// the second \"b\", etc."
field_declaration (+24 nodes collapsed)
method_declaration (+33 nodes collapsed)
method_declaration (+26 nodes collapsed)
block_comment "/**\n * shouldTraverse is call when descending into the N"...
method_declaration (+223 nodes collapsed)
block_comment "/**\n * Delegate the actual processing of the node to vis"...
method_declaration (+85 nodes collapsed)
block_comment "/**\n * Rename label references in breaks and continues.\n"...
method_declaration (+159 nodes collapsed)
block_comment "/**\n * Rename or remove labels.\n * @param node The "...
method_declaration
modifiers
private "private"
void_type "void"
identifier "visitLabel"
formal_parameters
( "("
formal_parameter
type_identifier "Node"
identifier "node"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "nameNode"
= "="
method_invocation
identifier "node"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "Preconditions"
. "."
identifier "checkState"
argument_list
( "("
binary_expression
identifier "nameNode"
!= "!="
null_literal "null"
) ")"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "nameNode"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "LabelInfo"
variable_declarator
identifier "li"
= "="
method_invocation
identifier "getLabelInfo"
argument_list
( "("
identifier "name"
) ")"
; ";"
line_comment "// This is a label..."
if_statement
if "if"
parenthesized_expression
( "("
field_access
identifier "li"
. "."
identifier "referenced"
) ")"
block (+56 nodes collapsed)
else "else"
block (+79 nodes collapsed)
line_comment "// Remove the label from the current stack of labels."
expression_statement
method_invocation
field_access
method_invocation
identifier "namespaceStack"
. "."
identifier "peek"
argument_list
( "("
) ")"
. "."
identifier "renameMap"
. "."
identifier "remove"
argument_list
( "("
identifier "name"
) ")"
; ";"
} "}"
block_comment "/**\n * @param id The id, which is the depth of the label"...
method_declaration (+27 nodes collapsed)
block_comment "/**\n * @param name The name to retrieve information abou"...
method_declaration (+32 nodes collapsed)
} "}"
method_declaration (+41 nodes collapsed)
class_declaration (+45 nodes collapsed)
class_declaration (+37 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 "base"
. "."
identifier "Supplier"
; ";"
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
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "NodeTraversal"
. "."
identifier "ScopedCallback"
; ";"
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
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Deque"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashSet"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
block_comment "/**\n * RenameLabels renames all the labels so that they have"...
class_declaration
modifiers
final "final"
class "class"
identifier "RenameLabels"
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"
; ";"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "nameSupplier"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "removeUnused"
; ";"
constructor_declaration (+27 nodes collapsed)
constructor_declaration (+51 nodes collapsed)
class_declaration (+73 nodes collapsed)
block_comment "/**\n * Iterate through the nodes, renaming all the labels."...
class_declaration
class "class"
identifier "ProcessLabels"
super_interfaces
implements "implements"
type_list
type_identifier "ScopedCallback"
class_body
{ "{"
constructor_declaration (+24 nodes collapsed)
line_comment "// A stack of labels namespaces. Labels in an outer scope ar"...
line_comment "// inner scope, so a new namespace is created each time a sc"...
field_declaration
modifiers
final "final"
generic_type
type_identifier "Deque"
type_arguments
< "<"
type_identifier "LabelNamespace"
> ">"
variable_declarator
identifier "namespaceStack"
= "="
method_invocation
identifier "Lists"
. "."
identifier "newLinkedList"
argument_list
( "("
) ")"
; ";"
line_comment "// The list of generated names. Typically, the first name wi"...
line_comment "// the second \"b\", etc."
field_declaration (+24 nodes collapsed)
method_declaration (+33 nodes collapsed)
method_declaration (+26 nodes collapsed)
block_comment "/**\n * shouldTraverse is call when descending into the N"...
method_declaration (+223 nodes collapsed)
block_comment "/**\n * Delegate the actual processing of the node to vis"...
method_declaration (+85 nodes collapsed)
block_comment "/**\n * Rename label references in breaks and continues.\n"...
method_declaration (+159 nodes collapsed)
block_comment "/**\n * Rename or remove labels.\n * @param node The "...
method_declaration
modifiers
private "private"
void_type "void"
identifier "visitLabel"
formal_parameters
( "("
formal_parameter
type_identifier "Node"
identifier "node"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "nameNode"
= "="
method_invocation
identifier "node"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "Preconditions"
. "."
identifier "checkState"
argument_list
( "("
binary_expression
identifier "nameNode"
!= "!="
null_literal "null"
) ")"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "nameNode"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "LabelInfo"
variable_declarator
identifier "li"
= "="
method_invocation
identifier "getLabelInfo"
argument_list
( "("
identifier "name"
) ")"
; ";"
line_comment "// This is a label..."
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
field_access
identifier "li"
. "."
identifier "referenced"
|| "||"
unary_expression
! "!"
identifier "removeUnused"
) ")"
block (+56 nodes collapsed)
else "else"
block (+79 nodes collapsed)
line_comment "// Remove the label from the current stack of labels."
expression_statement
method_invocation
field_access
method_invocation
identifier "namespaceStack"
. "."
identifier "peek"
argument_list
( "("
) ")"
. "."
identifier "renameMap"
. "."
identifier "remove"
argument_list
( "("
identifier "name"
) ")"
; ";"
} "}"
block_comment "/**\n * @param id The id, which is the depth of the label"...
method_declaration (+27 nodes collapsed)
block_comment "/**\n * @param name The name to retrieve information abou"...
method_declaration (+32 nodes collapsed)
} "}"
method_declaration (+41 nodes collapsed)
class_declaration (+45 nodes collapsed)
class_declaration (+37 nodes collapsed)
} "}"