class Solargraph::Source::Updater


the update via the Source#synchronize method.
Updaters contain changes to be applied to a source. The source applies

def initialize filename, version, changes

Parameters:
  • changes (Array) -- The changes.
  • version (Integer) -- A version number associated with this update.
  • filename (String) -- The file to update.
def initialize filename, version, changes
  @filename = filename
  @version = version
  @changes = changes
  @input = nil
  @did_nullify = nil
  @output = nil
end

def repair text

Returns:
  • (String) -

Parameters:
  • text (String) --
def repair text
  changes.each do |ch|
    text = ch.repair(text)
  end
  text
end

def write text, nullable = false

Returns:
  • (String) -

Parameters:
  • nullable (Boolean) --
  • text (String) --
def write text, nullable = false
  can_nullify = (nullable and changes.length == 1)
  return @output if @input == text and can_nullify == @did_nullify
  @input = text
  @output = text
  @did_nullify = can_nullify
  changes.each do |ch|
    @output = ch.write(@output, can_nullify)
  end
  @output
end