original_string: protected function get_previewed_rows() {
          $previewlimit = 10;
          if (count($this->processeddata) <= 1) {
              $rows = array();
          } else if (count($this->processeddata) < $previewlimit + 1) {
              // Return all rows.
              $rows = range(1, count($this->processeddata) - 1);
          } else {
              // First find rows with errors and warnings (no more than 10 of each).
              $errorrows = $warningrows = array();
              foreach ($this->processeddata as $rownum => $line) {
                  if ($rownum && $line['errors']) {
                      $errorrows[] = $rownum;
                      if (count($errorrows) >= $previewlimit) {
                          return $errorrows;
                      }
                  } else if ($rownum && $line['warnings']) {
                      if (count($warningrows) + count($errorrows) < $previewlimit) {
                          $warningrows[] = $rownum;
                      }
                  }
              }
              // Include as many error rows as possible and top them up with warning rows.
              $rows = array_merge($errorrows, array_slice($warningrows, 0, $previewlimit - count($errorrows)));
              // Keep adding good rows until we reach limit.
              for ($rownum = 1; count($rows) < $previewlimit; $rownum++) {
                  if (!in_array($rownum, $rows)) {
                      $rows[] = $rownum;
                  }
              }
              asort($rows);
          }
          return $rows;
      }
code: protected function get_previewed_rows() {
          $previewlimit = 10;
          if (count($this->processeddata) <= 1) {
              $rows = array();
          } else if (count($this->processeddata) < $previewlimit + 1) {
              // Return all rows.
              $rows = range(1, count($this->processeddata) - 1);
          } else {
              // First find rows with errors and warnings (no more than 10 of each).
              $errorrows = $warningrows = array();
              foreach ($this->processeddata as $rownum => $line) {
                  if ($rownum && $line['errors']) {
                      $errorrows[] = $rownum;
                      if (count($errorrows) >= $previewlimit) {
                          return $errorrows;
                      }
                  } else if ($rownum && $line['warnings']) {
                      if (count($warningrows) + count($errorrows) < $previewlimit) {
                          $warningrows[] = $rownum;
                      }
                  }
              }
              // Include as many error rows as possible and top them up with warning rows.
              $rows = array_merge($errorrows, array_slice($warningrows, 0, $previewlimit - count($errorrows)));
              // Keep adding good rows until we reach limit.
              for ($rownum = 1; count($rows) < $previewlimit; $rownum++) {
                  if (!in_array($rownum, $rows)) {
                      $rows[] = $rownum;
                  }
              }
              asort($rows);
          }
          return $rows;
      }
code_tokens: protected function get_previewed_rows ( ) { $ previewlimit = 10 ; if ( count ( $ this -> processeddata ) <= 1 ) { $ rows = array ( ) ; } else if ( count ( $ this -> processeddata ) < $ previewlimit + 1 ) { // Return all rows. $ rows = range ( 1 , count ( $ this -> processeddata ) - 1 ) ; } else { // First find rows with errors and warnings (no more than 10 of each). $ errorrows = $ warningrows = array ( ) ; foreach ( $ this -> processeddata as $ rownum => $ line ) { if ( $ rownum && $ line [ 'errors' ] ) { $ errorrows [ ] = $ rownum ; if ( count ( $ errorrows ) >= $ previewlimit ) { return $ errorrows ; } } else if ( $ rownum && $ line [ 'warnings' ] ) { if ( count ( $ warningrows ) + count ( $ errorrows ) < $ previewlimit ) { $ warningrows [ ] = $ rownum ; } } } // Include as many error rows as possible and top them up with warning rows. $ rows = array_merge ( $ errorrows , array_slice ( $ warningrows , 0 , $ previewlimit - count ( $ errorrows ) ) ) ; // Keep adding good rows until we reach limit. for ( $ rownum = 1 ; count ( $ rows ) < $ previewlimit ; $ rownum ++ ) { if ( ! in_array ( $ rownum , $ rows ) ) { $ rows [ ] = $ rownum ; } } asort ( $ rows ) ; } return $ rows ; }
docstring: Find up rows to show in preview
  
  Number of previewed rows is limited but rows with errors and warnings have priority.
  
  @return array
docstring_tokens: Find up rows to show in preview