// name to shadow a global variable.
if (t.inGlobalScope()) {
return;
}
Var var = t.getScope().getVar(n.getString());
if (var == null) {
// extern name or undefined name.
return;
}
if (var.getScope().isGlobal()) {
// We will not shadow a global variable name.
return;
}
// Using the definition of upward referencing, fill in the map.
if (var.getScope() != t.getScope()) {
for (Scope s = t.getScope();
s != var.getScope() && s.isLocal(); s = s.getParent()) {
scopeUpRefMap.put(s.getRootNode(), var.name);
}
}
if (var.getScope() == t.getScope()) {
scopeUpRefMap.put(t.getScopeRoot(), var.name);
}
// Find in the usage map that tracks a var and all of its usage.
varToNameUsage.put(var, n);