}
private void validateName(Name name, boolean isDefined) {
// If the name is not defined, emit warnings for each reference. While
// we're looking through each reference, check all the module dependencies.
Ref declaration = name.getDeclaration();
Name parent = name.parent;
boolean singleGlobalParentDecl =
parent != null &&
parent.getDeclaration() != null &&
parent.localSets == 0;
JSModuleGraph moduleGraph = compiler.getModuleGraph();
for (Ref ref : name.getRefs()) {
if (!isDefined && !isTypedef(ref)) {
reportRefToUndefinedName(name, ref);
} else if (declaration != null &&
ref.getModule() != declaration.getModule() &&
!moduleGraph.dependsOn(
ref.getModule(), declaration.getModule())) {
reportBadModuleReference(name, ref);
} else if (ref.scope.isGlobal() &&
singleGlobalParentDecl &&
parent.getDeclaration().preOrderIndex > ref.preOrderIndex) {
compiler.report(