code: private static int[] getViewToHeaderPositionImpl(JTextArea view, int start, int end) {
          int finalStartPos = start;
          try {
              finalStartPos += view.getLineOfOffset(finalStartPos);
          } catch (BadLocationException e) {
              // Shouldn't happen, position was already validated.
              LOGGER.error(e.getMessage(), e);
              return INVALID_POSITION;
          }
  
          int finalEndPos = end;
          try {
              finalEndPos += view.getLineOfOffset(finalEndPos);
          } catch (BadLocationException e) {
              // Shouldn't happen, position was already validated.
              LOGGER.error(e.getMessage(), e);
              return INVALID_POSITION;
          }
          return new int[] { finalStartPos, finalEndPos };
      }
docs: Gets the given {@code start} and {@code end} view positions offset to a header.
  <p>
  The {@code view} is expected to replace the header line endings {@code \r\n} to {@code \n} (e.g. so there's no invisible
  newline ({@code \r}) characters when editing), as such the positions of the {@code view} need to be offset to match the
  ones in the header.
  <p>
  <strong>Note:</strong> The {@code view} and {@code start} and {@code end} positions should be validated before calling
  this method.
  
  @param view the view that contains the contents of a header
  @param start the start position
  @param end the end position
  @return the positions offset for the header
  @see #validateView(JTextArea)
  @see #validateStartEnd(int, int)
  @see #isValidStartEndForLength(int, int, int)