class CC::Analyzer::LocationDescription

Attributes

location[R]
suffix[R]

Public Class Methods

new(source_buffer, location, suffix = "") click to toggle source
# File lib/cc/analyzer/location_description.rb, line 4
def initialize(source_buffer, location, suffix = "")
  @source_buffer = source_buffer
  @location = location
  @suffix = suffix
end

Public Instance Methods

to_s() click to toggle source
# File lib/cc/analyzer/location_description.rb, line 10
def to_s
  if location["lines"]
    begin_line = location["lines"]["begin"]
    end_line = location["lines"]["end"]
  elsif location["positions"]
    begin_line = position_to_line(location["positions"]["begin"])
    end_line = position_to_line(location["positions"]["end"])
  end

  str = render_lines(begin_line, end_line)
  str << suffix unless str.blank?
  str
end

Private Instance Methods

position_to_line(position) click to toggle source
# File lib/cc/analyzer/location_description.rb, line 36
def position_to_line(position)
  position["line"] || @source_buffer.decompose_position(position["offset"]).first
end
render_lines(begin_line, end_line) click to toggle source
# File lib/cc/analyzer/location_description.rb, line 28
def render_lines(begin_line, end_line)
  if end_line == begin_line
    begin_line.to_s
  else
    "#{begin_line}-#{end_line}"
  end
end