     []
   end
 
-  defp gather_followup_comments(line, _, [{line, {previous_eol, next_eol}, text} | comments], doc)
+  defp gather_followup_comments(
+         line,
+         _,
+         [%{line: line, previous_eol: previous_eol, next_eol: next_eol, text: text} | comments],
+         doc
+       )
        when previous_eol != nil do
     gather_followup_comments(line + 1, next_eol, comments, line(doc, text))
   end


  defp preserve_comments(line, _column, tokens, comment, rest) do
    comments = Process.get(:code_formatter_comments)
    comment = {line, {previous_eol(tokens), next_eol(rest, 0)}, format_comment(comment, [])}
    Process.put(:code_formatter_comments, [comment | comments])
  end



  # If the document is immediately followed by comment which is followed by newlines,
  # its newlines wouldn't have considered the comment, so we need to adjust it.
  defp adjust_trailing_newlines({doc, next_line, newlines}, doc_end, [%{line: line} | _])
       when newlines > 1 and line == doc_end + 1 do
    {doc, next_line, 1}
  end
