/** * Heuristic method to check whether symbol was created by DeclaredGlobalExternsOnWindow.java * pass. */ private boolean isSymbolDuplicatedExternOnWindow(Symbol symbol) { Node node = symbol.getDeclarationNode(); // Check that node is of type "window.foo"; return !node.isIndexable() && node.isGetProp() && node.getFirstChild().isName() && node.getFirstChild().getString().equals("window"); }
private void toDebugString(StringBuilder builder, Symbol symbol) { SymbolScope scope = symbol.scope; if (scope.isGlobalScope()) { builder.append(SimpleFormat.format("'%s' : in global scope:\n", symbol.getName())); } else if (scope.getRootNode() != null) { builder.append( SimpleFormat.format( "'%s' : in scope %s:%d\n", symbol.getName(), scope.getRootNode().getSourceFileName(), scope.getRootNode().getLineno())); } else if (scope.getSymbolForScope() != null) { builder.append( SimpleFormat.format( "'%s' : in scope %s\n", symbol.getName(), scope.getSymbolForScope().getName())); } else { builder.append(SimpleFormat.format("'%s' : in unknown scope\n", symbol.getName())); } int refCount = 0; for (Reference ref : getReferences(symbol)) { builder.append( SimpleFormat.format( " Ref %d: %s:%d %s\n", refCount, ref.getNode().getSourceFileName(), ref.getNode().getLineno(), ref.getNode().isIndexable() ? "" : "non indexable")); refCount++; } }