def _RetainVerticalSpacingBetweenTokens(cur_tok, prev_tok):
  """Retain vertical spacing between two tokens."""
  if prev_tok is None:
    return

  if prev_tok.is_string:
    prev_lineno = prev_tok.lineno + prev_tok.value.count('\n')
  elif prev_tok.is_pseudo_paren:
    prev_lineno = prev_tok.previous_token.lineno
  else:
    prev_lineno = prev_tok.lineno

  if cur_tok.is_comment:
    cur_lineno = cur_tok.lineno - cur_tok.value.count('\n')
  else:
    cur_lineno = cur_tok.lineno

  cur_tok.AdjustNewlinesBefore(cur_lineno - prev_lineno)
dataset/ETHPy150Open google/yapf/yapf/yapflib/reformatter.py/_RetainVerticalSpacingBetweenTokens/original