static List < Nc4Cursor > getCursorPath ( Nc4Cursor cursor ) { List < Nc4Cursor > path = new ArrayList <> ( ) ; for ( ; ; ) { if ( ! cursor . getScheme ( ) . isCompoundArray ( ) ) // suppress path . add ( 0 , cursor ) ; if ( cursor . getScheme ( ) == Scheme . SEQUENCE ) { // Stop here because the sequence has the vlen mem as its mem break ; } Nc4Cursor next = ( Nc4Cursor ) cursor . getContainer ( ) ; if ( next == null ) { assert cursor . getTemplate ( ) . isTopLevel ( ) ; break ; } assert next . getTemplate ( ) . getSort ( ) == DapSort . VARIABLE ; cursor = next ; } return path ; }
Given a cursor get a list of containing cursors with the following constraints . 1 . the first element in the path is a top - level variable . 2 . the remaining elements are the enclosing compound variables 3 . the last element is the incoming cursor .