<commit_before># A fix atom is used to store and represent a single "atomic" change made by a candidate fix which
# may be represented as a collection of such atomic fixes.
class RubyToRobust::Global::Fix::Atom

  attr_reader :line_no

  # Constructs a new fix atom.
  #
  # *Parameters:*
  # * line_no, the line in the source code which the atom should operate on.
  def initialize(line_no)
    @line_no = line_no
  end

  # Destructively applies the change described by this atomic fix to the given source code.
  #
  # Rather than destructively operating on the source code we could return a modified copy,
  # but since we never need to operate on a new copy we save computational resources by
  # operating on the input source code directly. If you really wanted to create a new copy
  # then you could add a new method "apply" which simply passed a clone of its input to
  # the "apply!" method.
  #
  # *Parameters:*
  # * source, the source code of the affected method (represented as a sequence of lines).
  #
  # *Returns:*
  # The modified source code.
  def apply!(source)
    raise NotImplementedError, 'No "apply!" method was implemented by this Atom.'
  end

end<commit_msg>Implemented idea of atomic fix history and adjusted line number calculation.<commit_after># A fix atom is used to store and represent a single "atomic" change made by a candidate fix which
# may be represented as a collection of such atomic fixes.
class RubyToRobust::Global::Fix::Atom

  # The line which this atomic fix changes.
  attr_reader :line_no

  # Constructs a new fix atom.
  #
  # *Parameters:*
  # * line_no, the line in the source code which the atom should operate on.
  def initialize(line_no)
    @line_no = line_no
  end

  # Calculates the number of lines that will be added by this fix.
  def lines_added
    raise NotImplementedError, 'No "lines_added" method was implemented by this Atom.'
  end

  # Calculate the line number in the adjusted source code that corresponds to the specified
  # line in the original source code.
  #
  # *Parameters:*
  # * changes, an array of the atomic changes already applied to this source.
  def adjusted_line_no(changes)
    adj_n = @line_no
    changes.each do |c|
      if c.line_no < @line_no and lines_added < 0
        adj_n += c.lines_added
      elsif c.line_no >= line_no and lines_added > 0
        adj_n += c.lines_added
      end
    end
    return adj_n
  end

  # Destructively applies the change described by this atomic fix to the given source code.
  #
  # *Parameters:*
  # * source, the source code of the affected method (represented as a sequence of lines).
  # * changes, an array of the atomic changes already applied to this source (in order of application).
  def apply!(source, changes)
    raise NotImplementedError, 'No "apply!" method was implemented by this Atom.'
  end

end
{'fraction_non_alphanumeric': 0.06236860546601261, 'fraction_numerical': 0.000700770847932726, 'mean_word_length': 3.4401244167962677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2312129', 'n_tokens_mistral': 806, 'n_tokens_neox': 787, 'n_words': 392}