This mapping has 1 multi-map group: several pairings are equally correct there. The code view shows one arbitrary valid pairing, not the only one.

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–252 unchanged (252 lines)
253 private final List<AliasUsage> aliasUsages = Lists.newArrayList();
254
255 // This map is temporary and cleared for each scope.
256 private final Map<String, Var> aliases = Maps.newHashMap();
257
258 // Also temporary and cleared for each scope.
259
260 // Suppose you create an alias.
261 // var x = goog.x;
262 // As a side-effect, this means you can shadow the namespace 'goog'
263 // in inner scopes. When we inline the namespaces, we have to rename
264 // these shadows.
265 //
…lines 266–309 unchanged (44 lines)
310 if (t.getScopeDepth() > 2) {
311 findNamespaceShadows(t);
312 }
313
314 if (t.getScopeDepth() == 2) {
315 renameNamespaceShadows(t);
316 aliases.clear();
317 forbiddenLocals.clear();
318 transformation = null;
319 hasNamespaceShadows = false;
320 }
321 }
322
…lines 323–425 unchanged (103 lines)
426
427 if (isHoisted) {
428 grandparent.addChildToFront(newDecl);
429 } else {
430 grandparent.addChildBefore(newDecl, varNode);
431 }
432 }
433
434 // Rewrite "var name = EXPR;" to "var name = $jscomp.scope.name;"
435 v.getNameNode().addChildToFront(
436 NodeUtil.newQualifiedNameNode(
437 compiler.getCodingConvention(), globalName, n, name));
438
…lines 439–574 unchanged (136 lines)
575 aliasUsages.add(new AliasedNode(aliasVar, n));
576 }
577
578 // When we inject declarations, we duplicate jsdoc. Make sure
579 // we only process that jsdoc once.
580 JSDocInfo info = n.getJSDocInfo();
581 if (info != null) {
582 for (Node node : info.getTypeNodes()) {
583 fixTypeNode(node);
584 }
585 }
586
587 // TODO(robbyw): Error for goog.scope not at root.
588 }
589 }
590
591 private void fixTypeNode(Node typeNode) {
…lines 592–612 unchanged (21 lines)

After

…lines 1–252 unchanged (252 lines)
253 private final List<AliasUsage> aliasUsages = Lists.newArrayList();
254
255 // This map is temporary and cleared for each scope.
256 private final Map<String, Var> aliases = Maps.newHashMap();
257
258 // Also temporary and cleared for each scope.
259 private final Set<Node> injectedDecls = Sets.newHashSet();
260
261 // Suppose you create an alias.
262 // var x = goog.x;
263 // As a side-effect, this means you can shadow the namespace 'goog'
264 // in inner scopes. When we inline the namespaces, we have to rename
265 // these shadows.
…lines 266–310 unchanged (45 lines)
311 if (t.getScopeDepth() > 2) {
312 findNamespaceShadows(t);
313 }
314
315 if (t.getScopeDepth() == 2) {
316 renameNamespaceShadows(t);
317 injectedDecls.clear();
318 aliases.clear();
319 forbiddenLocals.clear();
320 transformation = null;
321 hasNamespaceShadows = false;
322 }
323 }
…lines 324–427 unchanged (104 lines)
428
429 if (isHoisted) {
430 grandparent.addChildToFront(newDecl);
431 } else {
432 grandparent.addChildBefore(newDecl, varNode);
433 }
434 injectedDecls.add(newDecl.getFirstChild());
435 }
436
437 // Rewrite "var name = EXPR;" to "var name = $jscomp.scope.name;"
438 v.getNameNode().addChildToFront(
439 NodeUtil.newQualifiedNameNode(
440 compiler.getCodingConvention(), globalName, n, name));
…lines 441–577 unchanged (137 lines)
578 aliasUsages.add(new AliasedNode(aliasVar, n));
579 }
580
581 // When we inject declarations, we duplicate jsdoc. Make sure
582 // we only process that jsdoc once.
583 JSDocInfo info = n.getJSDocInfo();
584 if (info != null && !injectedDecls.contains(n)) {
585 for (Node node : info.getTypeNodes()) {
586 fixTypeNode(node);
587 }
588 }
589
590 // TODO(robbyw): Error for goog.scope not at root.
591 }
592 }
593
594 private void fixTypeNode(Node typeNode) {
…lines 595–615 unchanged (21 lines)

Before

program
block_comment "/*\n * Copyright 2010 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 "HashMultiset"
; ";"
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 "Multiset"
; ";"
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 "CompilerOptions"
. "."
identifier "AliasTransformation"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "CompilerOptions"
. "."
identifier "AliasTransformationHandler"
; ";"
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 "JSDocInfo"
; ";"
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 "SourcePosition"
; ";"
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 "Collection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "javax"
. "."
identifier "annotation"
. "."
identifier "Nullable"
; ";"
block_comment "/**\n * Process aliases in goog.scope blocks.\n *\n * goog.scop"...
class_declaration
class "class"
identifier "ScopedAliases"
super_interfaces
implements "implements"
type_list
type_identifier "HotSwapCompilerPass"
class_body
{ "{"
block_comment "/** Name used to denote an scoped function block used for al"...
field_declaration
modifiers
static "static"
final "final"
type_identifier "String"
variable_declarator
identifier "SCOPING_METHOD_NAME"
= "="
string_literal
" "\""
string_fragment "goog.scope"
" "\""
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "PreprocessorSymbolTable"
variable_declarator
identifier "preprocessorSymbolTable"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AliasTransformationHandler"
variable_declarator
identifier "transformationHandler"
; ";"
line_comment "// Errors"
field_declaration (+25 nodes collapsed)
field_declaration (+31 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration
modifiers
private "private"
generic_type
type_identifier "Multiset"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "scopedAliasNames"
= "="
method_invocation
identifier "HashMultiset"
. "."
identifier "create"
argument_list
( "("
) ")"
; ";"
constructor_declaration (+50 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+500 nodes collapsed)
class_declaration (+138 nodes collapsed)
class_declaration (+86 nodes collapsed)
class_declaration (+158 nodes collapsed)
class_declaration
modifiers
private "private"
class "class"
identifier "Traversal"
super_interfaces
implements "implements"
type_list
scoped_type_identifier
type_identifier "NodeTraversal"
. "."
type_identifier "ScopedCallback"
class_body
{ "{"
line_comment "// The job of this class is to collect these three data sets"...
line_comment "// The order of this list determines the order that aliases "...
field_declaration (+21 nodes collapsed)
field_declaration (+21 nodes collapsed)
field_declaration (+21 nodes collapsed)
line_comment "// This map is temporary and cleared for each scope."
field_declaration (+23 nodes collapsed)
line_comment "// Also temporary and cleared for each scope."
line_comment "// Suppose you create an alias."
line_comment "// var x = goog.x;"
line_comment "// As a side-effect, this means you can shadow the namespace"...
line_comment "// in inner scopes. When we inline the namespaces, we have t"...
line_comment "// these shadows."
line_comment "//"
line_comment "// Fortunately, we already have a name uniquifier that runs "...
line_comment "// normalization (before optimizations). We run it here on a"...
line_comment "// set of variables, but only as a last resort (because this"...
line_comment "// up warning messages downstream)."
field_declaration (+25 nodes collapsed)
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "hasNamespaceShadows"
= "="
false "false"
; ";"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "hasErrors"
= "="
false "false"
; ";"
field_declaration
modifiers
private "private"
type_identifier "AliasTransformation"
variable_declarator
identifier "transformation"
= "="
null_literal "null"
; ";"
method_declaration
generic_type
type_identifier "Collection"
type_arguments
< "<"
type_identifier "Node"
> ">"
identifier "getAliasDefinitionsInOrder"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "aliasDefinitionsInOrder"
; ";"
} "}"
method_declaration
modifiers
private "private"
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "AliasUsage"
> ">"
identifier "getAliasUsages"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "aliasUsages"
; ";"
} "}"
method_declaration
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "Node"
> ">"
identifier "getScopeCalls"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "scopeCalls"
; ";"
} "}"
method_declaration
boolean_type "boolean"
identifier "hasErrors"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "hasErrors"
; ";"
} "}"
method_declaration (+46 nodes collapsed)
method_declaration (+90 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "exitScope"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
) ")"
block
{ "{"
if_statement (+26 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "t"
. "."
identifier "getScopeDepth"
argument_list
( "("
) ")"
== "=="
decimal_integer_literal "2"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "renameNamespaceShadows"
argument_list
( "("
identifier "t"
) ")"
; ";"
expression_statement
method_invocation
identifier "aliases"
. "."
identifier "clear"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "forbiddenLocals"
. "."
identifier "clear"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "transformation"
= "="
null_literal "null"
; ";"
expression_statement
assignment_expression
identifier "hasNamespaceShadows"
= "="
false "false"
; ";"
} "}"
} "}"
method_declaration (+81 nodes collapsed)
method_declaration (+186 nodes collapsed)
method_declaration (+55 nodes collapsed)
method_declaration
modifiers
private "private"
void_type "void"
identifier "findAliases"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Scope"
variable_declarator
identifier "scope"
= "="
method_invocation
identifier "t"
. "."
identifier "getScope"
argument_list
( "("
) ")"
; ";"
enhanced_for_statement
for "for"
( "("
type_identifier "Var"
identifier "v"
: ":"
method_invocation
identifier "scope"
. "."
identifier "getVarIterable"
argument_list
( "("
) ")"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "n"
= "="
method_invocation
identifier "v"
. "."
identifier "getNode"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "parent"
= "="
method_invocation
identifier "n"
. "."
identifier "getParent"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isVar"
= "="
method_invocation
identifier "parent"
. "."
identifier "isVar"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isFunctionDecl"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "isFunctionDeclaration"
argument_list
( "("
identifier "parent"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression (+31 nodes collapsed)
block
{ "{"
expression_statement
method_invocation
identifier "recordAlias"
argument_list
( "("
identifier "v"
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "v"
. "."
identifier "isBleedingFunction"
argument_list
( "("
) ")"
) ")"
block
{ "{"
line_comment "// Bleeding functions already get a BAD_PARAMETERS error, so"...
line_comment "// do nothing."
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "parent"
. "."
identifier "getType"
argument_list
( "("
) ")"
== "=="
field_access
identifier "Token"
. "."
identifier "LP"
) ")"
block
{ "{"
line_comment "// Parameters of the scope function also get a BAD_PARAMETER"...
line_comment "// error."
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "isVar"
|| "||"
identifier "isFunctionDecl"
) ")"
block
{ "{"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isHoisted"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "isHoistedFunctionDeclaration"
argument_list
( "("
identifier "parent"
) ")"
; ";"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "grandparent"
= "="
method_invocation
identifier "parent"
. "."
identifier "getParent"
argument_list
( "("
) ")"
; ";"
local_variable_declaration (+27 nodes collapsed)
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "varNode"
= "="
null_literal "null"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "n"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "nameCount"
= "="
method_invocation
identifier "scopedAliasNames"
. "."
identifier "count"
argument_list
( "("
identifier "name"
) ")"
; ";"
expression_statement
method_invocation
identifier "scopedAliasNames"
. "."
identifier "add"
argument_list
( "("
identifier "name"
) ")"
; ";"
local_variable_declaration (+38 nodes collapsed)
expression_statement
method_invocation
identifier "compiler"
. "."
identifier "ensureLibraryInjected"
argument_list
( "("
string_literal
" "\""
string_fragment "base"
" "\""
) ")"
; ";"
line_comment "// First, we need to free up the function expression (EXPR)"
line_comment "// to be used in another expression."
if_statement (+130 nodes collapsed)
line_comment "// Add $jscomp.scope.name = EXPR;"
line_comment "// Make sure we copy over all the jsdoc and debug info."
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "value"
!= "!="
null_literal "null"
|| "||"
binary_expression
method_invocation
identifier "v"
. "."
identifier "getJSDocInfo"
argument_list
( "("
) ")"
!= "!="
null_literal "null"
) ")"
block
{ "{"
local_variable_declaration (+39 nodes collapsed)
expression_statement (+26 nodes collapsed)
if_statement (+35 nodes collapsed)
} "}"
line_comment "// Rewrite \"var name = EXPR;\" to \"var name = $jscomp.scope.n"...
expression_statement (+35 nodes collapsed)
expression_statement
method_invocation
identifier "recordAlias"
argument_list
( "("
identifier "v"
) ")"
; ";"
} "}"
else "else"
block (+24 nodes collapsed)
} "}"
} "}"
method_declaration (+146 nodes collapsed)
block_comment "/** Find out if there are any local shadows of namespaces. *"...
method_declaration (+87 nodes collapsed)
block_comment "/**\n * Rename any local shadows of namespaces.\n * Th"...
method_declaration (+106 nodes collapsed)
method_declaration (+201 nodes collapsed)
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 (+32 nodes collapsed)
if_statement (+21 nodes collapsed)
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "type"
= "="
method_invocation
identifier "n"
. "."
identifier "getType"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "Var"
variable_declarator
identifier "aliasVar"
= "="
null_literal "null"
; ";"
if_statement (+85 nodes collapsed)
line_comment "// Validate the top-level of the goog.scope block."
if_statement (+180 nodes collapsed)
line_comment "// Validate all descendent scopes of the goog.scope block."
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "t"
. "."
identifier "getScopeDepth"
argument_list
( "("
) ")"
>= ">="
decimal_integer_literal "2"
) ")"
block
{ "{"
line_comment "// Check if this name points to an alias."
if_statement (+36 nodes collapsed)
line_comment "// When we inject declarations, we duplicate jsdoc. Make sur"...
line_comment "// we only process that jsdoc once."
local_variable_declaration
type_identifier "JSDocInfo"
variable_declarator
identifier "info"
= "="
method_invocation
identifier "n"
. "."
identifier "getJSDocInfo"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 1:2
identifier "info"
!= "!="
null_literal "null"
) ")"
block (+28 nodes collapsed)
line_comment "// TODO(robbyw): Error for goog.scope not at root."
} "}"
} "}"
method_declaration (+186 nodes collapsed)
} "}"
} "}"

After

program
block_comment "/*\n * Copyright 2010 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 "HashMultiset"
; ";"
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 "Multiset"
; ";"
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 "CompilerOptions"
. "."
identifier "AliasTransformation"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "CompilerOptions"
. "."
identifier "AliasTransformationHandler"
; ";"
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 "JSDocInfo"
; ";"
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 "SourcePosition"
; ";"
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 "Collection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "javax"
. "."
identifier "annotation"
. "."
identifier "Nullable"
; ";"
block_comment "/**\n * Process aliases in goog.scope blocks.\n *\n * goog.scop"...
class_declaration
class "class"
identifier "ScopedAliases"
super_interfaces
implements "implements"
type_list
type_identifier "HotSwapCompilerPass"
class_body
{ "{"
block_comment "/** Name used to denote an scoped function block used for al"...
field_declaration
modifiers
static "static"
final "final"
type_identifier "String"
variable_declarator
identifier "SCOPING_METHOD_NAME"
= "="
string_literal
" "\""
string_fragment "goog.scope"
" "\""
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "PreprocessorSymbolTable"
variable_declarator
identifier "preprocessorSymbolTable"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AliasTransformationHandler"
variable_declarator
identifier "transformationHandler"
; ";"
line_comment "// Errors"
field_declaration (+25 nodes collapsed)
field_declaration (+31 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration
modifiers
private "private"
generic_type
type_identifier "Multiset"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "scopedAliasNames"
= "="
method_invocation
identifier "HashMultiset"
. "."
identifier "create"
argument_list
( "("
) ")"
; ";"
constructor_declaration (+50 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+500 nodes collapsed)
class_declaration (+138 nodes collapsed)
class_declaration (+86 nodes collapsed)
class_declaration (+158 nodes collapsed)
class_declaration
modifiers
private "private"
class "class"
identifier "Traversal"
super_interfaces
implements "implements"
type_list
scoped_type_identifier
type_identifier "NodeTraversal"
. "."
type_identifier "ScopedCallback"
class_body
{ "{"
line_comment "// The job of this class is to collect these three data sets"...
line_comment "// The order of this list determines the order that aliases "...
field_declaration (+21 nodes collapsed)
field_declaration (+21 nodes collapsed)
field_declaration (+21 nodes collapsed)
line_comment "// This map is temporary and cleared for each scope."
field_declaration (+23 nodes collapsed)
line_comment "// Also temporary and cleared for each scope."
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "Node"
> ">"
variable_declarator
identifier "injectedDecls"
= "="
method_invocation
identifier "Sets"
. "."
identifier "newHashSet"
argument_list
( "("
) ")"
; ";"
line_comment "// Suppose you create an alias."
line_comment "// var x = goog.x;"
line_comment "// As a side-effect, this means you can shadow the namespace"...
line_comment "// in inner scopes. When we inline the namespaces, we have t"...
line_comment "// these shadows."
line_comment "//"
line_comment "// Fortunately, we already have a name uniquifier that runs "...
line_comment "// normalization (before optimizations). We run it here on a"...
line_comment "// set of variables, but only as a last resort (because this"...
line_comment "// up warning messages downstream)."
field_declaration (+25 nodes collapsed)
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "hasNamespaceShadows"
= "="
false "false"
; ";"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "hasErrors"
= "="
false "false"
; ";"
field_declaration
modifiers
private "private"
type_identifier "AliasTransformation"
variable_declarator
identifier "transformation"
= "="
null_literal "null"
; ";"
method_declaration
generic_type
type_identifier "Collection"
type_arguments
< "<"
type_identifier "Node"
> ">"
identifier "getAliasDefinitionsInOrder"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "aliasDefinitionsInOrder"
; ";"
} "}"
method_declaration
modifiers
private "private"
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "AliasUsage"
> ">"
identifier "getAliasUsages"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "aliasUsages"
; ";"
} "}"
method_declaration
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "Node"
> ">"
identifier "getScopeCalls"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "scopeCalls"
; ";"
} "}"
method_declaration
boolean_type "boolean"
identifier "hasErrors"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "hasErrors"
; ";"
} "}"
method_declaration (+46 nodes collapsed)
method_declaration (+90 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "exitScope"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
) ")"
block
{ "{"
if_statement (+26 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "t"
. "."
identifier "getScopeDepth"
argument_list
( "("
) ")"
== "=="
decimal_integer_literal "2"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "renameNamespaceShadows"
argument_list
( "("
identifier "t"
) ")"
; ";"
expression_statement
method_invocation
identifier "injectedDecls"
. "."
identifier "clear"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "aliases"
. "."
identifier "clear"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "forbiddenLocals"
. "."
identifier "clear"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "transformation"
= "="
null_literal "null"
; ";"
expression_statement
assignment_expression
identifier "hasNamespaceShadows"
= "="
false "false"
; ";"
} "}"
} "}"
method_declaration (+81 nodes collapsed)
method_declaration (+186 nodes collapsed)
method_declaration (+55 nodes collapsed)
method_declaration
modifiers
private "private"
void_type "void"
identifier "findAliases"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Scope"
variable_declarator
identifier "scope"
= "="
method_invocation
identifier "t"
. "."
identifier "getScope"
argument_list
( "("
) ")"
; ";"
enhanced_for_statement
for "for"
( "("
type_identifier "Var"
identifier "v"
: ":"
method_invocation
identifier "scope"
. "."
identifier "getVarIterable"
argument_list
( "("
) ")"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "n"
= "="
method_invocation
identifier "v"
. "."
identifier "getNode"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "parent"
= "="
method_invocation
identifier "n"
. "."
identifier "getParent"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isVar"
= "="
method_invocation
identifier "parent"
. "."
identifier "isVar"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isFunctionDecl"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "isFunctionDeclaration"
argument_list
( "("
identifier "parent"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression (+31 nodes collapsed)
block
{ "{"
expression_statement
method_invocation
identifier "recordAlias"
argument_list
( "("
identifier "v"
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "v"
. "."
identifier "isBleedingFunction"
argument_list
( "("
) ")"
) ")"
block
{ "{"
line_comment "// Bleeding functions already get a BAD_PARAMETERS error, so"...
line_comment "// do nothing."
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "parent"
. "."
identifier "getType"
argument_list
( "("
) ")"
== "=="
field_access
identifier "Token"
. "."
identifier "LP"
) ")"
block
{ "{"
line_comment "// Parameters of the scope function also get a BAD_PARAMETER"...
line_comment "// error."
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "isVar"
|| "||"
identifier "isFunctionDecl"
) ")"
block
{ "{"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isHoisted"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "isHoistedFunctionDeclaration"
argument_list
( "("
identifier "parent"
) ")"
; ";"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "grandparent"
= "="
method_invocation
identifier "parent"
. "."
identifier "getParent"
argument_list
( "("
) ")"
; ";"
local_variable_declaration (+27 nodes collapsed)
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "varNode"
= "="
null_literal "null"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "n"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "nameCount"
= "="
method_invocation
identifier "scopedAliasNames"
. "."
identifier "count"
argument_list
( "("
identifier "name"
) ")"
; ";"
expression_statement
method_invocation
identifier "scopedAliasNames"
. "."
identifier "add"
argument_list
( "("
identifier "name"
) ")"
; ";"
local_variable_declaration (+38 nodes collapsed)
expression_statement
method_invocation
identifier "compiler"
. "."
identifier "ensureLibraryInjected"
argument_list
( "("
string_literal
" "\""
string_fragment "base"
" "\""
) ")"
; ";"
line_comment "// First, we need to free up the function expression (EXPR)"
line_comment "// to be used in another expression."
if_statement (+130 nodes collapsed)
line_comment "// Add $jscomp.scope.name = EXPR;"
line_comment "// Make sure we copy over all the jsdoc and debug info."
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "value"
!= "!="
null_literal "null"
|| "||"
binary_expression
method_invocation
identifier "v"
. "."
identifier "getJSDocInfo"
argument_list
( "("
) ")"
!= "!="
null_literal "null"
) ")"
block
{ "{"
local_variable_declaration (+39 nodes collapsed)
expression_statement (+26 nodes collapsed)
if_statement (+35 nodes collapsed)
expression_statement
method_invocation
identifier "injectedDecls"
. "."
identifier "add"
argument_list
( "("
method_invocation
identifier "newDecl"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
) ")"
; ";"
} "}"
line_comment "// Rewrite \"var name = EXPR;\" to \"var name = $jscomp.scope.n"...
expression_statement (+35 nodes collapsed)
expression_statement
method_invocation
identifier "recordAlias"
argument_list
( "("
identifier "v"
) ")"
; ";"
} "}"
else "else"
block (+24 nodes collapsed)
} "}"
} "}"
method_declaration (+146 nodes collapsed)
block_comment "/** Find out if there are any local shadows of namespaces. *"...
method_declaration (+87 nodes collapsed)
block_comment "/**\n * Rename any local shadows of namespaces.\n * Th"...
method_declaration (+106 nodes collapsed)
method_declaration (+201 nodes collapsed)
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 (+32 nodes collapsed)
if_statement (+21 nodes collapsed)
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "type"
= "="
method_invocation
identifier "n"
. "."
identifier "getType"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "Var"
variable_declarator
identifier "aliasVar"
= "="
null_literal "null"
; ";"
if_statement (+85 nodes collapsed)
line_comment "// Validate the top-level of the goog.scope block."
if_statement (+180 nodes collapsed)
line_comment "// Validate all descendent scopes of the goog.scope block."
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "t"
. "."
identifier "getScopeDepth"
argument_list
( "("
) ")"
>= ">="
decimal_integer_literal "2"
) ")"
block
{ "{"
line_comment "// Check if this name points to an alias."
if_statement (+36 nodes collapsed)
line_comment "// When we inject declarations, we duplicate jsdoc. Make sur"...
line_comment "// we only process that jsdoc once."
local_variable_declaration
type_identifier "JSDocInfo"
variable_declarator
identifier "info"
= "="
method_invocation
identifier "n"
. "."
identifier "getJSDocInfo"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 1:2
binary_expression any 1:2
identifier "info"
!= "!="
null_literal "null"
&& "&&"
unary_expression
! "!"
method_invocation
identifier "injectedDecls"
. "."
identifier "contains"
argument_list
( "("
identifier "n"
) ")"
) ")"
block (+28 nodes collapsed)
line_comment "// TODO(robbyw): Error for goog.scope not at root."
} "}"
} "}"
method_declaration (+186 nodes collapsed)
} "}"
} "}"