translate_location(spot, backtrace_location, source)
public
Translate an error location returned by ErrorHighlight to the correct
source location inside the template.
# File actionview/lib/action_view/template/handlers/erb.rb, line 43
def translate_location(spot, backtrace_location, source)
# Tokenize the source line
tokens = ::ERB::Util.tokenize(source.lines[backtrace_location.lineno - 1])
new_first_column = find_offset(spot[:snippet], tokens, spot[:first_column])
lineno_delta = spot[:first_lineno] - backtrace_location.lineno
spot[:first_lineno] -= lineno_delta
spot[:last_lineno] -= lineno_delta
column_delta = spot[:first_column] - new_first_column
spot[:first_column] -= column_delta
spot[:last_column] -= column_delta
spot[:script_lines] = source.lines
spot
rescue NotImplementedError, LocationParsingError
nil
end