@Override public void visit(NodeTraversal t, Node n, Node parent) { if (!n.isName()) { return; } String name = n.getString(); // Ignore anonymous functions if (name.length() == 0) { return; } // Is this local or Global? // Bleeding functions should be treated as part of their outer // scope, because IE has bugs in how it handles bleeding // functions. Scope.Var var = t.getScope().getVar(name); boolean local = (var != null) && var.isLocal() && (!var.scope.getParent().isGlobal() || !var.isBleedingFunction()); // Are we renaming global variables? if (!local && localRenamingOnly) { reservedNames.add(name); return; } // Are we renaming function expression names? if (preserveFunctionExpressionNames && var != null && NodeUtil.isFunctionExpression(var.getParentNode())) { reservedNames.add(name); return; } // Check if we can rename this. if (!okToRenameVar(name, local)) { if (local) { // Blindly de-uniquify for the Prototype library for issue 103. String newName = MakeDeclaredNamesUnique.ContextualRenameInverter.getOrginalName(name); if (!newName.equals(name)) { n.setString(newName); } } return; } if (isExternsPass_) { // Keep track of extern globals. if (!local) { externNames.add(name); } return; } if (pseudoNameMap != null) { recordPseudoName(n); } if (local) { // Local var: assign a new name String tempName = LOCAL_VAR_PREFIX + getLocalVarIndex(var); incCount(tempName); localNameNodes.add(n); n.setString(tempName); } else if (var != null) { // Not an extern // If it's global, increment global count incCount(name); globalNameNodes.add(n); } }