private boolean mayBeGlobalAlias(Ref alias) {
    // Note: alias.scope is the closest scope in which the aliasing assignment occurred.
    // So for "if (true) { var alias = aliasedVar; }", the alias.scope would be the IF block scope.
    if (alias.scope.isGlobal()) {
      return true;
    }
    // If the scope in which the alias is assigned is not global, look up the LHS of the assignment.
    Node aliasParent = alias.getNode().getParent();
    if (!aliasParent.isAssign() && !aliasParent.isName()) {
      // Only handle variable assignments and initializing declarations.
      return true;
    }
    Node aliasLhsNode = aliasParent.isName() ? aliasParent : aliasParent.getFirstChild();
    if (!aliasLhsNode.isName()) {
      // Only handle assignments to simple names, not qualified names or GETPROPs.
      return true;
    }
    String aliasVarName = aliasLhsNode.getString();
    Var aliasVar = alias.scope.getVar(aliasVarName);
    if (aliasVar != null) {
      return aliasVar.isGlobal();
    }
    return true;
  }
private boolean mayBeGlobalAlias ( Ref alias ) { if ( alias . scope . isGlobal ( ) ) { return true ; } Node aliasParent = alias . getNode ( ) . getParent ( ) ; if ( ! aliasParent . isAssign ( ) && ! aliasParent . isName ( ) ) { return true ; } Node aliasLhsNode = aliasParent . isName ( ) ? aliasParent : aliasParent . getFirstChild ( ) ; if ( ! aliasLhsNode . isName ( ) ) { return true ; } String aliasVarName = aliasLhsNode . getString ( ) ; Var aliasVar = alias . scope . getVar ( aliasVarName ) ; if ( aliasVar != null ) { return aliasVar . isGlobal ( ) ; } return true ; }
Returns true if the alias is possibly defined in the global scope, which we handle with more
caution than with locally scoped variables. May return false positives.

@param alias An aliasing get.
@return If the alias is possibly defined in the global scope.