private void flattenNameRefAtDepth ( String alias , Node n , int depth , String originalName ) { // This method has to work for both GETPROP chains and, in rare cases, // OBJLIT keys, possibly nested. That's why we check for children before // proceeding. In the OBJLIT case, we don't need to do anything. Token nType = n . getToken ( ) ; boolean isQName = nType == Token . NAME || nType == Token . GETPROP ; boolean isObjKey = NodeUtil . mayBeObjectLitKey ( n ) ; checkState ( isObjKey || isQName ) ; if ( isQName ) { for ( int i = 1 ; i < depth && n . hasChildren ( ) ; i ++ ) { n = n . getFirstChild ( ) ; } if ( n . isGetProp ( ) && n . getFirstChild ( ) . isGetProp ( ) ) { flattenNameRef ( alias , n . getFirstChild ( ) , n , originalName ) ; } } }
Flattens a particular prefix of a single name reference .