Skip to content

Commit c078696

Browse files
committed
Print locations using line / col instead of offsets
This commit changes printing of locations to use the format (start_line,start_column)-(end_line,end_column) instead of using offsets.
1 parent a3f5185 commit c078696

File tree

912 files changed

+30188
-30188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

912 files changed

+30188
-30188
lines changed

lib/yarp.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def copy(**options)
7171

7272
# Returns a string representation of this location.
7373
def inspect
74-
"#<YARP::Location @start_offset=#{@start_offset} @length=#{@length}>"
74+
"#<YARP::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>"
7575
end
7676

7777
# The source code that this location represents.
@@ -117,7 +117,7 @@ def deconstruct_keys(keys)
117117
end
118118

119119
def pretty_print(q)
120-
q.text("(#{start_offset}...#{end_offset})")
120+
q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column}))")
121121
end
122122

123123
def ==(other)
@@ -330,7 +330,7 @@ def <<(line)
330330
# for any given node.
331331
def header(node)
332332
output = +"@ #{node.class.name.split("::").last} ("
333-
output << "location: (#{node.location.start_offset}...#{node.location.end_offset})"
333+
output << "location: (#{node.location.start_line},#{node.location.start_column})-(#{node.location.end_line},#{node.location.end_column})"
334334
output << ", newline: true" if node.newline?
335335
output << ")\n"
336336
output
@@ -354,7 +354,7 @@ def list(prefix, nodes)
354354
# Generates a string that represents a location field on a node.
355355
def location(value)
356356
if value
357-
"(#{value.start_offset}...#{value.end_offset}) = #{value.slice.inspect}"
357+
"(#{value.start_line},#{value.start_column})-(#{value.end_line},#{value.end_column}) = #{value.slice.inspect}"
358358
else
359359
"∅"
360360
end

test/yarp/snapshots/alias.txt

Lines changed: 94 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)