File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ def compute_offsets(code)
37
37
class Location
38
38
# A Source object that is used to determine more information from the given
39
39
# offset and length.
40
- private attr_reader :source
40
+ protected attr_reader :source
41
41
42
42
# The byte offset from the beginning of the source where this location
43
43
# starts.
@@ -112,8 +112,13 @@ def ==(other)
112
112
other . end_offset == end_offset
113
113
end
114
114
115
- # Returns a new location that is the union of this location and the other.
116
- def to ( other )
115
+ # Returns a new location that stretches from this location to the given
116
+ # other location. Raises an error if this location is not before the other
117
+ # location or if they don't share the same source.
118
+ def join ( other )
119
+ raise "Incompatible sources" if source != other . source
120
+ raise "Incompatible locations" if start_offset > other . start_offset
121
+
117
122
Location . new ( source , start_offset , other . end_offset - start_offset )
118
123
end
119
124
You can’t perform that action at this time.
0 commit comments