module RuboCop::Cop::Util

def source_range(source_buffer, line_number, column, length = 1)

def source_range(source_buffer, line_number, column, length = 1)
  if column.is_a?(Range)
    column_index = column.begin
    length = numeric_range_size(column)
  else
    column_index = column
  end
  preceding_line_numbers = (1...line_number)
  line_begin_pos = preceding_line_numbers.reduce(0) do |pos, line|
    pos + source_buffer.source_line(line).length + 1
  end
  begin_pos = line_begin_pos + column_index
  end_pos = begin_pos + length
  Parser::Source::Range.new(source_buffer, begin_pos, end_pos)
end