class NameReferenceGraphConstruction {
public void process(Node externs, Node root) {
// Use the MemoizedScopeCreator instance from TypeCheck if available
// as FunctionTypeBuilder warns about existing types if TypedScopeCreator is
// ran a second time.
ScopeCreator scopeCreator = compiler.getScopeCreator();
if (scopeCreator == null) {
// The TypedScopeCreator gives us correct handling of namespaces,
// while the default NodeTraversal only gives us a
// SyntacticScopeCreator.
scopeCreator = new TypedScopeCreator(compiler);
}
NodeTraversal externsTraversal = new NodeTraversal(compiler,
new Traversal(true), scopeCreator);
NodeTraversal codeTraversal = new NodeTraversal(compiler,
new Traversal(false), scopeCreator);
Scope topScope = compiler.getTopScope();
if (topScope != null) {
externsTraversal.traverseWithScope(externs, topScope);
codeTraversal.traverseWithScope(root, topScope);
} else {
externsTraversal.traverse(externs);
codeTraversal.traverse(root);
}
connectUnknowns();
}
}