steep 0.29.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,86 +0,0 @@
1
- module Steep
2
- module AST
3
- class Location
4
- attr_reader :buffer
5
- attr_reader :start_pos
6
- attr_reader :end_pos
7
-
8
- def initialize(buffer:, start_pos:, end_pos:)
9
- @buffer = buffer
10
- @start_pos = start_pos
11
- @end_pos = end_pos
12
- end
13
-
14
- def inspect
15
- "#<#{self.class}:#{self.__id__} @buffer=#{buffer.name}, @start_pos=#{start_pos}, @end_pos=#{end_pos}, source='#{source.lines.first}', start_line=#{start_line}, start_column=#{start_column}>"
16
- end
17
-
18
- def name
19
- buffer.name
20
- end
21
-
22
- def start_line
23
- start_loc[0]
24
- end
25
-
26
- def start_column
27
- start_loc[1]
28
- end
29
-
30
- def end_line
31
- end_loc[0]
32
- end
33
-
34
- def end_column
35
- end_loc[1]
36
- end
37
-
38
- def start_loc
39
- @start_loc ||= buffer.pos_to_loc(start_pos)
40
- end
41
-
42
- def end_loc
43
- @end_loc ||= buffer.pos_to_loc(end_pos)
44
- end
45
-
46
- def source
47
- @source ||= buffer.source(start_pos...end_pos)
48
- end
49
-
50
- def to_s
51
- "#{start_line}:#{start_column}...#{end_line}:#{end_column}"
52
- end
53
-
54
- def ==(other)
55
- other.is_a?(Location) &&
56
- other.buffer == buffer &&
57
- other.start_pos == start_pos &&
58
- other.end_pos == end_pos
59
- end
60
-
61
- def +(other)
62
- if other
63
- raise "Invalid concat: buffer=#{buffer.name}, other.buffer=#{other.buffer.name}" unless other.buffer == buffer
64
-
65
- self.class.new(buffer: buffer,
66
- start_pos: start_pos,
67
- end_pos: other.end_pos)
68
- else
69
- self
70
- end
71
- end
72
-
73
- def self.concat(*locations)
74
- locations.inject {|l1, l2|
75
- l1 + l2
76
- }
77
- end
78
-
79
- def pred?(loc)
80
- loc.is_a?(Location) &&
81
- loc.name == name &&
82
- loc.start_pos == end_pos
83
- end
84
- end
85
- end
86
- end