I can't imagine a diff like this being accepted by a human. This is a defects4j research artifact, far beyond what humans would actually write.

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–19 unchanged (19 lines)
20import com.google.common.collect.HashMultiset;
21import com.google.common.collect.ImmutableSet;
22import com.google.common.collect.Lists;
23import com.google.common.collect.Maps;
24import com.google.common.collect.Multiset;
25import com.google.common.collect.Sets;
26import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
27import com.google.javascript.jscomp.Scope.Var;
28import com.google.javascript.rhino.Node;
29import com.google.javascript.rhino.Token;
30import com.google.javascript.rhino.TokenStream;
31
32import java.util.ArrayDeque;
…lines 33–40 unchanged (8 lines)
41 * unique. Specifically, it will not modify object properties.
42 * @author johnlenz@google.com (John Lenz)
43 * TODO(johnlenz): Try to merge this with the ScopeCreator.
44 */
45class MakeDeclaredNamesUnique
46 implements NodeTraversal.ScopedCallback {
47
48 private Deque<Renamer> nameStack = new ArrayDeque<Renamer>();
49 private final Renamer rootRenamer;
50
51 MakeDeclaredNamesUnique() {
52 this.rootRenamer = new ContextualRenamer();
53 }
…lines 54–228 unchanged (175 lines)
229 Renamer forChildScope();
230 }
231
232 /**
233 * Inverts the transformation by {@link ContextualRenamer}, when possible.
234 */
235 static class ContextualRenameInverter extends AbstractPostOrderCallback
236 implements CompilerPass {
237 private final AbstractCompiler compiler;
238
239 // The set of names referenced in the current scope.
240
241 // Stack reference sets.
242
243 // Name are globally unique initially, so we don't need a per-scope map.
244 private Map<Var, String> nameMap = Maps.newHashMap();
245
246 private ContextualRenameInverter(AbstractCompiler compiler) {
247 this.compiler = compiler;
248 }
249
250 public void process(Node externs, Node js) {
…lines 251–259 unchanged (9 lines)
260 return name.lastIndexOf(ContextualRenamer.UNIQUE_ID_SEPARATOR);
261 }
262
263 private boolean containsSeparator(String name) {
264 return name.indexOf(ContextualRenamer.UNIQUE_ID_SEPARATOR) != -1;
265 }
266 private static String getOrginalNameInternal(String name, int index) {
267 return name.substring(0, index);
268 }
269
270 /**
271 * Prepare a set for the new scope.
272 */
273
274 private static String getNameSuffix(String name, int index) {
275 return name.substring(
276 index + ContextualRenamer.UNIQUE_ID_SEPARATOR.length(),
277 name.length());
278 }
279
280 /**
281 * Rename vars for the current scope, and merge any referenced
282 * names into the parent scope reference set.
283 */
284 @Override
285 public void visit(NodeTraversal t, Node node, Node parent) {
286 if (node.getType() == Token.NAME) {
287 String oldName = node.getString();
288 if (containsSeparator(oldName)) {
289 Scope scope = t.getScope();
290 Var var = t.getScope().getVar(oldName);
291 if (var == null || var.isGlobal()) {
292 return;
293 }
294
295 if (nameMap.containsKey(var)) {
296 node.setString(nameMap.get(var));
297 } else {
298 int index = indexOfSeparator(oldName);
299 String newName = getOrginalNameInternal(oldName, index);
300 String suffix = getNameSuffix(oldName, index);
301
302 // Merge any names that were referenced but not declared in the current
303 // scope.
304 // If there isn't anything left in the stack we will be going into the
305 // global scope: don't try to build a set of referenced names for the
306 // global scope.
307 boolean recurseScopes = false;
308 if (!suffix.matches("\\d+")) {
309 recurseScopes = true;
310 }
311
312 /**
313 * For the Var declared in the current scope determine if it is possible
314 * to revert the name to its orginal form without conflicting with other
315 * values.
316 */
317 // Check if the new name is valid and if it would cause conflicts.
318 if (var.scope.isDeclared(newName, recurseScopes) ||
319 !TokenStream.isJSIdentifier(newName)) {
320 newName = oldName;
321 } else {
322 var.scope.declare(newName, var.nameNode, null, null);
323 // Adding a reference to the new name to prevent either the parent
324 // scopes or the current scope renaming another var to this new name.
325 Node parentNode = var.getParentNode();
326 if (parentNode.getType() == Token.FUNCTION &&
327 parentNode == var.scope.getRootNode()) {
328 var.getNameNode().setString(newName);
329 }
330
331 node.setString(newName);
332 compiler.reportCodeChange();
333 }
334
335 nameMap.put(var, newName);
336
337 }
338
339 // Add all referenced names to the set so it is possible to check for
340 // conflicts.
341 // Store only references to candidate names in the node map.
342 }
343 }
344 }
345
346 }
347
348 /**
349 * Rename every locally name to be unique, the first encountered declaration
350 * (specifically global names) are left in their original form. Those that are
351 * renamed are made unique by giving them a unique suffix based on
…lines 352–384 unchanged (33 lines)
385 }
386
387 /**
388 * Adds a name to the map of names declared in this scope.
389 */
390 @Override
391 public void addDeclaredName(String name) {
392 if (global) {
393 reserveName(name);
394 } else {
395 // It hasn't been declared locally yet, so increment the count.
396 if (!declarations.containsKey(name)) {
397 int id = incrementNameCount(name);
398 String newName = null;
399 if (id != 0) {
400 newName = getUniqueName(name, id);
401 }
402 declarations.put(name, newName);
403 }
404 }
405 }
406
407 @Override
408 public String getReplacementName(String oldName) {
409 return declarations.get(oldName);
410 }
411
…lines 412–455 unchanged (44 lines)
456 this.idPrefix = idPrefix;
457 this.removeConstness = removeConstness;
458 }
459
460 @Override
461 public void addDeclaredName(String name) {
462 if (!declarations.containsKey(name)) {
463 declarations.put(name, getUniqueName(name));
464 }
465 }
466
467 private String getUniqueName(String name) {
468 if (name.isEmpty()) {
…lines 469–500 unchanged (32 lines)

After

…lines 1–19 unchanged (19 lines)
20import com.google.common.collect.HashMultiset;
21import com.google.common.collect.ImmutableSet;
22import com.google.common.collect.Lists;
23import com.google.common.collect.Maps;
24import com.google.common.collect.Multiset;
25import com.google.common.collect.Sets;
26import com.google.javascript.jscomp.NodeTraversal.ScopedCallback;
27import com.google.javascript.jscomp.Scope.Var;
28import com.google.javascript.rhino.Node;
29import com.google.javascript.rhino.Token;
30import com.google.javascript.rhino.TokenStream;
31
32import java.util.ArrayDeque;
…lines 33–41 unchanged (9 lines)
42 * @author johnlenz@google.com (John Lenz)
43 * TODO(johnlenz): Try to merge this with the ScopeCreator.
44 */
45class MakeDeclaredNamesUnique
46 implements NodeTraversal.ScopedCallback {
47
48 public static final String ARGUMENTS = "arguments";
49 private Deque<Renamer> nameStack = new ArrayDeque<Renamer>();
50 private final Renamer rootRenamer;
51
52 MakeDeclaredNamesUnique() {
53 this.rootRenamer = new ContextualRenamer();
54 }
…lines 55–230 unchanged (176 lines)
231 }
232
233 /**
234 * Inverts the transformation by {@link ContextualRenamer}, when possible.
235 */
236 static class ContextualRenameInverter
237 implements ScopedCallback, CompilerPass {
238 private final AbstractCompiler compiler;
239
240 // The set of names referenced in the current scope.
241 private Set<String> referencedNames = ImmutableSet.of();
242
243 // Stack reference sets.
244 private Deque<Set<String>> referenceStack = new ArrayDeque<Set<String>>();
245
246 // Name are globally unique initially, so we don't need a per-scope map.
247 private Map<String, List<Node>> nameMap = Maps.newHashMap();
248
249 private ContextualRenameInverter(AbstractCompiler compiler) {
250 this.compiler = compiler;
251 }
252
253 public void process(Node externs, Node js) {
…lines 254–262 unchanged (9 lines)
263 return name.lastIndexOf(ContextualRenamer.UNIQUE_ID_SEPARATOR);
264 }
265
266 private boolean containsSeparator(String name) {
267 return name.indexOf(ContextualRenamer.UNIQUE_ID_SEPARATOR) != -1;
268 }
269
270 /**
271 * Prepare a set for the new scope.
272 */
273 public void enterScope(NodeTraversal t) {
274 if (t.inGlobalScope()) {
275 return;
276 }
277
278 referenceStack.push(referencedNames);
279 referencedNames = Sets.newHashSet();
280 }
281
282 /**
283 * Rename vars for the current scope, and merge any referenced
284 * names into the parent scope reference set.
285 */
286 public void exitScope(NodeTraversal t) {
287 if (t.inGlobalScope()) {
288 return;
289 }
290
291 for (Iterator<Var> it = t.getScope().getVars(); it.hasNext();) {
292 Var v = it.next();
293 handleScopeVar(v);
294 }
295
296 // Merge any names that were referenced but not declared in the current
297 // scope.
298 Set<String> current = referencedNames;
299 referencedNames = referenceStack.pop();
300 // If there isn't anything left in the stack we will be going into the
301 // global scope: don't try to build a set of referenced names for the
302 // global scope.
303 if (!referenceStack.isEmpty()) {
304 referencedNames.addAll(current);
305 }
306 }
307
308 /**
309 * For the Var declared in the current scope determine if it is possible
310 * to revert the name to its orginal form without conflicting with other
311 * values.
312 */
313 void handleScopeVar(Var v) {
314 String name = v.getName();
315 if (containsSeparator(name)) {
316 String newName = getOrginalName(name);
317 // Check if the new name is valid and if it would cause conflicts.
318 if (TokenStream.isJSIdentifier(newName) &&
319 !referencedNames.contains(newName) &&
320 !newName.equals(ARGUMENTS)) {
321 referencedNames.remove(name);
322 // Adding a reference to the new name to prevent either the parent
323 // scopes or the current scope renaming another var to this new name.
324 referencedNames.add(newName);
325 List<Node> references = nameMap.get(name);
326 Preconditions.checkState(references != null);
327 for (Node n : references) {
328 Preconditions.checkState(n.getType() == Token.NAME);
329 n.setString(newName);
330 }
331 compiler.reportCodeChange();
332 }
333 nameMap.remove(name);
334 }
335 }
336
337 @Override
338 public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
339 return true;
340 }
341
342 @Override
343 public void visit(NodeTraversal t, Node node, Node parent) {
344 if (t.inGlobalScope()) {
345 return;
346 }
347
348 if (NodeUtil.isReferenceName(node)) {
349 String name = node.getString();
350 // Add all referenced names to the set so it is possible to check for
351 // conflicts.
352 referencedNames.add(name);
353 // Store only references to candidate names in the node map.
354 if (containsSeparator(name)) {
355 addCandidateNameReference(name, node);
356 }
357 }
358 }
359
360 private void addCandidateNameReference(String name, Node n) {
361 List<Node> nodes = nameMap.get(name);
362 if (null == nodes) {
363 nodes = Lists.newLinkedList();
364 nameMap.put(name, nodes);
365 }
366 nodes.add(n);
367 }
368 }
369
370 /**
371 * Rename every locally name to be unique, the first encountered declaration
372 * (specifically global names) are left in their original form. Those that are
373 * renamed are made unique by giving them a unique suffix based on
…lines 374–406 unchanged (33 lines)
407 }
408
409 /**
410 * Adds a name to the map of names declared in this scope.
411 */
412 @Override
413 public void addDeclaredName(String name) {
414 if (!name.equals(ARGUMENTS)) {
415 if (global) {
416 reserveName(name);
417 } else {
418 // It hasn't been declared locally yet, so increment the count.
419 if (!declarations.containsKey(name)) {
420 int id = incrementNameCount(name);
421 String newName = null;
422 if (id != 0) {
423 newName = getUniqueName(name, id);
424 }
425 declarations.put(name, newName);
426 }
427 }
428 }
429 }
430
431 @Override
432 public String getReplacementName(String oldName) {
433 return declarations.get(oldName);
434 }
435
…lines 436–479 unchanged (44 lines)
480 this.idPrefix = idPrefix;
481 this.removeConstness = removeConstness;
482 }
483
484 @Override
485 public void addDeclaredName(String name) {
486 Preconditions.checkState(!name.equals(ARGUMENTS));
487 if (!declarations.containsKey(name)) {
488 declarations.put(name, getUniqueName(name));
489 }
490 }
491
492 private String getUniqueName(String name) {
…lines 493–525 unchanged (33 lines)

Before

program
block_comment "/*\n * Copyright 2009 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
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 "HashMultiset"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "ImmutableSet"
; ";"
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 "NodeTraversal"
. "."
identifier "AbstractPostOrderCallback"
; ";"
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 "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
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "TokenStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayDeque"
; ";"
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 "Iterator"
; ";"
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"
; ";"
block_comment "/**\n * Find all Functions, VARs, and Exception names and ma"...
class_declaration
class "class"
identifier "MakeDeclaredNamesUnique"
super_interfaces
implements "implements"
type_list
scoped_type_identifier
type_identifier "NodeTraversal"
. "."
type_identifier "ScopedCallback"
class_body
{ "{"
field_declaration (+24 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
type_identifier "Renamer"
variable_declarator
identifier "rootRenamer"
; ";"
constructor_declaration (+22 nodes collapsed)
constructor_declaration
identifier "MakeDeclaredNamesUnique"
formal_parameters
( "("
formal_parameter
type_identifier "Renamer"
identifier "renamer"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "rootRenamer"
= "="
identifier "renamer"
; ";"
} "}"
method_declaration (+24 nodes collapsed)
method_declaration (+281 nodes collapsed)
method_declaration (+43 nodes collapsed)
method_declaration (+232 nodes collapsed)
method_declaration (+190 nodes collapsed)
block_comment "/**\n * Walks the stack of name maps and finds the replacem"...
method_declaration (+59 nodes collapsed)
block_comment "/**\n * Traverses the current scope and collects declared n"...
method_declaration (+188 nodes collapsed)
block_comment "/**\n * Declared names renaming policy interface.\n */"
interface_declaration (+44 nodes collapsed)
block_comment "/**\n * Inverts the transformation by {@link ContextualRena"...
class_declaration
modifiers
static "static"
class "class"
identifier "ContextualRenameInverter"
superclass
extends "extends"
type_identifier "AbstractPostOrderCallback"
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"
; ";"
line_comment "// The set of names referenced in the current scope."
line_comment "// Stack reference sets."
line_comment "// Name are globally unique initially, so we don't need a pe"...
field_declaration
modifiers
private "private"
generic_type
type_identifier "Map"
type_arguments
< "<"
type_identifier "Var"
, ","
type_identifier "String"
> ">"
variable_declarator
identifier "nameMap"
= "="
method_invocation
identifier "Maps"
. "."
identifier "newHashMap"
argument_list
( "("
) ")"
; ";"
constructor_declaration (+22 nodes collapsed)
method_declaration (+32 nodes collapsed)
method_declaration (+54 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+33 nodes collapsed)
method_declaration
modifiers
private "private"
static "static"
type_identifier "String"
identifier "getOrginalNameInternal"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
, ","
formal_parameter
integral_type
int "int"
identifier "index"
) ")"
block
{ "{"
return_statement
return "return"
method_invocation
identifier "name"
. "."
identifier "substring"
argument_list
( "("
decimal_integer_literal "0"
, ","
identifier "index"
) ")"
; ";"
} "}"
block_comment "/**\n * Prepare a set for the new scope.\n */"
method_declaration
modifiers
private "private"
static "static"
type_identifier "String"
identifier "getNameSuffix"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
, ","
formal_parameter
integral_type
int "int"
identifier "index"
) ")"
block
{ "{"
return_statement
return "return"
method_invocation
identifier "name"
. "."
identifier "substring"
argument_list
( "("
binary_expression
identifier "index"
+ "+"
method_invocation
field_access
identifier "ContextualRenamer"
. "."
identifier "UNIQUE_ID_SEPARATOR"
. "."
identifier "length"
argument_list
( "("
) ")"
, ","
method_invocation
identifier "name"
. "."
identifier "length"
argument_list
( "("
) ")"
) ")"
; ";"
} "}"
block_comment "/**\n * Rename vars for the current scope, and merge any "...
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 "node"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "node"
. "."
identifier "getType"
argument_list
( "("
) ")"
== "=="
field_access
identifier "Token"
. "."
identifier "NAME"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "oldName"
= "="
method_invocation
identifier "node"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "containsSeparator"
argument_list
( "("
identifier "oldName"
) ")"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Scope"
variable_declarator
identifier "scope"
= "="
method_invocation
identifier "t"
. "."
identifier "getScope"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "Var"
variable_declarator
identifier "var"
= "="
method_invocation
method_invocation
identifier "t"
. "."
identifier "getScope"
argument_list
( "("
) ")"
. "."
identifier "getVar"
argument_list
( "("
identifier "oldName"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "var"
== "=="
null_literal "null"
|| "||"
method_invocation
identifier "var"
. "."
identifier "isGlobal"
argument_list
( "("
) ")"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "nameMap"
. "."
identifier "containsKey"
argument_list
( "("
identifier "var"
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "node"
. "."
identifier "setString"
argument_list
( "("
method_invocation
identifier "nameMap"
. "."
identifier "get"
argument_list
( "("
identifier "var"
) ")"
) ")"
; ";"
} "}"
else "else"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "index"
= "="
method_invocation
identifier "indexOfSeparator"
argument_list
( "("
identifier "oldName"
) ")"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "newName"
= "="
method_invocation
identifier "getOrginalNameInternal"
argument_list
( "("
identifier "oldName"
, ","
identifier "index"
) ")"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "suffix"
= "="
method_invocation
identifier "getNameSuffix"
argument_list
( "("
identifier "oldName"
, ","
identifier "index"
) ")"
; ";"
line_comment "// Merge any names that were referenced but not declared in "...
line_comment "// scope."
line_comment "// If there isn't anything left in the stack we will be goin"...
line_comment "// global scope: don't try to build a set of referenced name"...
line_comment "// global scope."
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "recurseScopes"
= "="
false "false"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "suffix"
. "."
identifier "matches"
argument_list
( "("
string_literal
" "\""
escape_sequence "\\\\"
string_fragment "d+"
" "\""
) ")"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "recurseScopes"
= "="
true "true"
; ";"
} "}"
block_comment "/**\n * For the Var declared in the current scope determi"...
line_comment "// Check if the new name is valid and if it would cause conf"...
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
field_access
identifier "var"
. "."
identifier "scope"
. "."
identifier "isDeclared"
argument_list
( "("
identifier "newName"
, ","
identifier "recurseScopes"
) ")"
|| "||"
unary_expression
! "!"
method_invocation
identifier "TokenStream"
. "."
identifier "isJSIdentifier"
argument_list
( "("
identifier "newName"
) ")"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "newName"
= "="
identifier "oldName"
; ";"
} "}"
else "else"
block
{ "{"
expression_statement
method_invocation
field_access
identifier "var"
. "."
identifier "scope"
. "."
identifier "declare"
argument_list
( "("
identifier "newName"
, ","
field_access
identifier "var"
. "."
identifier "nameNode"
, ","
null_literal "null"
, ","
null_literal "null"
) ")"
; ";"
line_comment "// Adding a reference to the new name to prevent either the "...
line_comment "// scopes or the current scope renaming another var to this "...
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "parentNode"
= "="
method_invocation
identifier "var"
. "."
identifier "getParentNode"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
method_invocation
identifier "parentNode"
. "."
identifier "getType"
argument_list
( "("
) ")"
== "=="
field_access
identifier "Token"
. "."
identifier "FUNCTION"
&& "&&"
binary_expression
identifier "parentNode"
== "=="
method_invocation
field_access
identifier "var"
. "."
identifier "scope"
. "."
identifier "getRootNode"
argument_list
( "("
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
method_invocation
identifier "var"
. "."
identifier "getNameNode"
argument_list
( "("
) ")"
. "."
identifier "setString"
argument_list
( "("
identifier "newName"
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "node"
. "."
identifier "setString"
argument_list
( "("
identifier "newName"
) ")"
; ";"
expression_statement
method_invocation
identifier "compiler"
. "."
identifier "reportCodeChange"
argument_list
( "("
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "nameMap"
. "."
identifier "put"
argument_list
( "("
identifier "var"
, ","
identifier "newName"
) ")"
; ";"
} "}"
line_comment "// Add all referenced names to the set so it is possible to "...
line_comment "// conflicts."
line_comment "// Store only references to candidate names in the node map."
} "}"
} "}"
} "}"
} "}"
block_comment "/**\n * Rename every locally name to be unique, the first e"...
class_declaration
modifiers
static "static"
class "class"
identifier "ContextualRenamer"
super_interfaces
implements "implements"
type_list
type_identifier "Renamer"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Multiset"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "nameUsage"
; ";"
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "global"
; ";"
field_declaration
modifiers
final "final"
static "static"
type_identifier "String"
variable_declarator
identifier "UNIQUE_ID_SEPARATOR"
= "="
string_literal
" "\""
string_fragment "$$"
" "\""
; ";"
constructor_declaration (+29 nodes collapsed)
block_comment "/**\n * Constructor for child scopes.\n */"
constructor_declaration (+36 nodes collapsed)
block_comment "/**\n * Create a ContextualRenamer\n */"
method_declaration (+24 nodes collapsed)
block_comment "/**\n * Adds a name to the map of names declared in this "...
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "addDeclaredName"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block (+100 nodes collapsed)
method_declaration (+28 nodes collapsed)
block_comment "/**\n * Given a name and the associated id, create a new "...
method_declaration (+29 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
boolean_type "boolean"
identifier "stripConstIfReplaced"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
false "false"
; ";"
} "}"
} "}"
block_comment "/**\n * Rename every declared name to be unique. Typically "...
class_declaration
modifiers
static "static"
class "class"
identifier "InlineRenamer"
super_interfaces
implements "implements"
type_list
type_identifier "Renamer"
class_body
{ "{"
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "uniqueIdSupplier"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "String"
variable_declarator
identifier "idPrefix"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "removeConstness"
; ";"
constructor_declaration (+71 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "addDeclaredName"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
if_statement (+35 nodes collapsed)
} "}"
method_declaration (+106 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
boolean_type "boolean"
identifier "stripConstIfReplaced"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "removeConstness"
; ";"
} "}"
} "}"
} "}"

After

program
block_comment "/*\n * Copyright 2009 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
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 "HashMultiset"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "ImmutableSet"
; ";"
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 "NodeTraversal"
. "."
identifier "ScopedCallback"
; ";"
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 "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
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "TokenStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayDeque"
; ";"
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 "Iterator"
; ";"
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"
; ";"
block_comment "/**\n * Find all Functions, VARs, and Exception names and ma"...
class_declaration
class "class"
identifier "MakeDeclaredNamesUnique"
super_interfaces
implements "implements"
type_list
scoped_type_identifier
type_identifier "NodeTraversal"
. "."
type_identifier "ScopedCallback"
class_body
{ "{"
field_declaration
modifiers
public "public"
static "static"
final "final"
type_identifier "String"
variable_declarator
identifier "ARGUMENTS"
= "="
string_literal
" "\""
string_fragment "arguments"
" "\""
; ";"
field_declaration (+24 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
type_identifier "Renamer"
variable_declarator
identifier "rootRenamer"
; ";"
constructor_declaration (+22 nodes collapsed)
constructor_declaration
identifier "MakeDeclaredNamesUnique"
formal_parameters
( "("
formal_parameter
type_identifier "Renamer"
identifier "renamer"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "rootRenamer"
= "="
identifier "renamer"
; ";"
} "}"
method_declaration (+24 nodes collapsed)
method_declaration (+281 nodes collapsed)
method_declaration (+43 nodes collapsed)
method_declaration (+232 nodes collapsed)
method_declaration (+190 nodes collapsed)
block_comment "/**\n * Walks the stack of name maps and finds the replacem"...
method_declaration (+59 nodes collapsed)
block_comment "/**\n * Traverses the current scope and collects declared n"...
method_declaration (+188 nodes collapsed)
block_comment "/**\n * Declared names renaming policy interface.\n */"
interface_declaration (+44 nodes collapsed)
block_comment "/**\n * Inverts the transformation by {@link ContextualRena"...
class_declaration
modifiers
static "static"
class "class"
identifier "ContextualRenameInverter"
super_interfaces
implements "implements"
type_list
type_identifier "ScopedCallback"
, ","
type_identifier "CompilerPass"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
line_comment "// The set of names referenced in the current scope."
field_declaration
modifiers
private "private"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "referencedNames"
= "="
method_invocation
identifier "ImmutableSet"
. "."
identifier "of"
argument_list
( "("
) ")"
; ";"
line_comment "// Stack reference sets."
field_declaration
modifiers
private "private"
generic_type
type_identifier "Deque"
type_arguments
< "<"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
> ">"
variable_declarator
identifier "referenceStack"
= "="
object_creation_expression
new "new"
generic_type
type_identifier "ArrayDeque"
type_arguments
< "<"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
> ">"
argument_list
( "("
) ")"
; ";"
line_comment "// Name are globally unique initially, so we don't need a pe"...
field_declaration
modifiers
private "private"
generic_type
type_identifier "Map"
type_arguments
< "<"
type_identifier "String"
, ","
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "Node"
> ">"
> ">"
variable_declarator
identifier "nameMap"
= "="
method_invocation
identifier "Maps"
. "."
identifier "newHashMap"
argument_list
( "("
) ")"
; ";"
constructor_declaration (+22 nodes collapsed)
method_declaration (+32 nodes collapsed)
method_declaration (+54 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+33 nodes collapsed)
block_comment "/**\n * Prepare a set for the new scope.\n */"
method_declaration
modifiers
public "public"
void_type "void"
identifier "enterScope"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "t"
. "."
identifier "inGlobalScope"
argument_list
( "("
) ")"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
expression_statement
method_invocation
identifier "referenceStack"
. "."
identifier "push"
argument_list
( "("
identifier "referencedNames"
) ")"
; ";"
expression_statement
assignment_expression
identifier "referencedNames"
= "="
method_invocation
identifier "Sets"
. "."
identifier "newHashSet"
argument_list
( "("
) ")"
; ";"
} "}"
block_comment "/**\n * Rename vars for the current scope, and merge any "...
method_declaration
modifiers
public "public"
void_type "void"
identifier "exitScope"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "t"
. "."
identifier "inGlobalScope"
argument_list
( "("
) ")"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
for_statement
for "for"
( "("
local_variable_declaration
generic_type
type_identifier "Iterator"
type_arguments
< "<"
type_identifier "Var"
> ">"
variable_declarator
identifier "it"
= "="
method_invocation
method_invocation
identifier "t"
. "."
identifier "getScope"
argument_list
( "("
) ")"
. "."
identifier "getVars"
argument_list
( "("
) ")"
; ";"
method_invocation
identifier "it"
. "."
identifier "hasNext"
argument_list
( "("
) ")"
; ";"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "Var"
variable_declarator
identifier "v"
= "="
method_invocation
identifier "it"
. "."
identifier "next"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "handleScopeVar"
argument_list
( "("
identifier "v"
) ")"
; ";"
} "}"
line_comment "// Merge any names that were referenced but not declared in "...
line_comment "// scope."
local_variable_declaration
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "current"
= "="
identifier "referencedNames"
; ";"
expression_statement
assignment_expression
identifier "referencedNames"
= "="
method_invocation
identifier "referenceStack"
. "."
identifier "pop"
argument_list
( "("
) ")"
; ";"
line_comment "// If there isn't anything left in the stack we will be goin"...
line_comment "// global scope: don't try to build a set of referenced name"...
line_comment "// global scope."
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "referenceStack"
. "."
identifier "isEmpty"
argument_list
( "("
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "referencedNames"
. "."
identifier "addAll"
argument_list
( "("
identifier "current"
) ")"
; ";"
} "}"
} "}"
block_comment "/**\n * For the Var declared in the current scope determi"...
method_declaration
void_type "void"
identifier "handleScopeVar"
formal_parameters
( "("
formal_parameter
type_identifier "Var"
identifier "v"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "v"
. "."
identifier "getName"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "containsSeparator"
argument_list
( "("
identifier "name"
) ")"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "newName"
= "="
method_invocation
identifier "getOrginalName"
argument_list
( "("
identifier "name"
) ")"
; ";"
line_comment "// Check if the new name is valid and if it would cause conf"...
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
method_invocation
identifier "TokenStream"
. "."
identifier "isJSIdentifier"
argument_list
( "("
identifier "newName"
) ")"
&& "&&"
unary_expression
! "!"
method_invocation
identifier "referencedNames"
. "."
identifier "contains"
argument_list
( "("
identifier "newName"
) ")"
&& "&&"
unary_expression
! "!"
method_invocation
identifier "newName"
. "."
identifier "equals"
argument_list
( "("
identifier "ARGUMENTS"
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "referencedNames"
. "."
identifier "remove"
argument_list
( "("
identifier "name"
) ")"
; ";"
line_comment "// Adding a reference to the new name to prevent either the "...
line_comment "// scopes or the current scope renaming another var to this "...
expression_statement
method_invocation
identifier "referencedNames"
. "."
identifier "add"
argument_list
( "("
identifier "newName"
) ")"
; ";"
local_variable_declaration
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "Node"
> ">"
variable_declarator
identifier "references"
= "="
method_invocation
identifier "nameMap"
. "."
identifier "get"
argument_list
( "("
identifier "name"
) ")"
; ";"
expression_statement
method_invocation
identifier "Preconditions"
. "."
identifier "checkState"
argument_list
( "("
binary_expression
identifier "references"
!= "!="
null_literal "null"
) ")"
; ";"
enhanced_for_statement
for "for"
( "("
type_identifier "Node"
identifier "n"
: ":"
identifier "references"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "Preconditions"
. "."
identifier "checkState"
argument_list
( "("
binary_expression
method_invocation
identifier "n"
. "."
identifier "getType"
argument_list
( "("
) ")"
== "=="
field_access
identifier "Token"
. "."
identifier "NAME"
) ")"
; ";"
expression_statement
method_invocation
identifier "n"
. "."
identifier "setString"
argument_list
( "("
identifier "newName"
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "compiler"
. "."
identifier "reportCodeChange"
argument_list
( "("
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "nameMap"
. "."
identifier "remove"
argument_list
( "("
identifier "name"
) ")"
; ";"
} "}"
} "}"
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
boolean_type "boolean"
identifier "shouldTraverse"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
, ","
formal_parameter
type_identifier "Node"
identifier "n"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
return_statement
return "return"
true "true"
; ";"
} "}"
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 "node"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "t"
. "."
identifier "inGlobalScope"
argument_list
( "("
) ")"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "NodeUtil"
. "."
identifier "isReferenceName"
argument_list
( "("
identifier "node"
) ")"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "name"
= "="
method_invocation
identifier "node"
. "."
identifier "getString"
argument_list
( "("
) ")"
; ";"
line_comment "// Add all referenced names to the set so it is possible to "...
line_comment "// conflicts."
expression_statement
method_invocation
identifier "referencedNames"
. "."
identifier "add"
argument_list
( "("
identifier "name"
) ")"
; ";"
line_comment "// Store only references to candidate names in the node map."
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "containsSeparator"
argument_list
( "("
identifier "name"
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "addCandidateNameReference"
argument_list
( "("
identifier "name"
, ","
identifier "node"
) ")"
; ";"
} "}"
} "}"
} "}"
method_declaration
modifiers
private "private"
void_type "void"
identifier "addCandidateNameReference"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
, ","
formal_parameter
type_identifier "Node"
identifier "n"
) ")"
block
{ "{"
local_variable_declaration
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "Node"
> ">"
variable_declarator
identifier "nodes"
= "="
method_invocation
identifier "nameMap"
. "."
identifier "get"
argument_list
( "("
identifier "name"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
null_literal "null"
== "=="
identifier "nodes"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "nodes"
= "="
method_invocation
identifier "Lists"
. "."
identifier "newLinkedList"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "nameMap"
. "."
identifier "put"
argument_list
( "("
identifier "name"
, ","
identifier "nodes"
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "nodes"
. "."
identifier "add"
argument_list
( "("
identifier "n"
) ")"
; ";"
} "}"
} "}"
block_comment "/**\n * Rename every locally name to be unique, the first e"...
class_declaration
modifiers
static "static"
class "class"
identifier "ContextualRenamer"
super_interfaces
implements "implements"
type_list
type_identifier "Renamer"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Multiset"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "nameUsage"
; ";"
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "global"
; ";"
field_declaration
modifiers
final "final"
static "static"
type_identifier "String"
variable_declarator
identifier "UNIQUE_ID_SEPARATOR"
= "="
string_literal
" "\""
string_fragment "$$"
" "\""
; ";"
constructor_declaration (+29 nodes collapsed)
block_comment "/**\n * Constructor for child scopes.\n */"
constructor_declaration (+36 nodes collapsed)
block_comment "/**\n * Create a ContextualRenamer\n */"
method_declaration (+24 nodes collapsed)
block_comment "/**\n * Adds a name to the map of names declared in this "...
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "addDeclaredName"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "name"
. "."
identifier "equals"
argument_list
( "("
identifier "ARGUMENTS"
) ")"
) ")"
block (+100 nodes collapsed)
} "}"
method_declaration (+28 nodes collapsed)
block_comment "/**\n * Given a name and the associated id, create a new "...
method_declaration (+29 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
boolean_type "boolean"
identifier "stripConstIfReplaced"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
false "false"
; ";"
} "}"
} "}"
block_comment "/**\n * Rename every declared name to be unique. Typically "...
class_declaration
modifiers
static "static"
class "class"
identifier "InlineRenamer"
super_interfaces
implements "implements"
type_list
type_identifier "Renamer"
class_body
{ "{"
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Supplier"
type_arguments
< "<"
type_identifier "String"
> ">"
variable_declarator
identifier "uniqueIdSupplier"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "String"
variable_declarator
identifier "idPrefix"
; ";"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "removeConstness"
; ";"
constructor_declaration (+71 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
void_type "void"
identifier "addDeclaredName"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "Preconditions"
. "."
identifier "checkState"
argument_list
( "("
unary_expression
! "!"
method_invocation
identifier "name"
. "."
identifier "equals"
argument_list
( "("
identifier "ARGUMENTS"
) ")"
) ")"
; ";"
if_statement (+35 nodes collapsed)
} "}"
method_declaration (+106 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
boolean_type "boolean"
identifier "stripConstIfReplaced"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "removeConstness"
; ";"
} "}"
} "}"
} "}"