@@ -59,18 +59,28 @@ object Parsers {
59
59
60
60
/* ------------- POSITIONS ------------------------------------------- */
61
61
62
+ /** Positions tree.
63
+ * If `t` does not have a position yet, set its position to the given one.
64
+ */
65
+ def atPos [T <: Positioned ](pos : Position )(t : T ): T =
66
+ if (t.pos.isSourceDerived) t else t.withPos(pos)
67
+
62
68
def atPos [T <: Positioned ](start : Offset , point : Offset , end : Offset )(t : T ): T =
63
69
atPos(Position (start, end, point))(t)
64
70
71
+ /** If the last read offset is strictly greater than `start`, position tree
72
+ * to position spanning from `start` to last read offset, with given point.
73
+ * If the last offset is less than or equal to start, the tree `t` did not
74
+ * consume any source for its construction. In this case, don't position it yet,
75
+ * but wait for its position to be determined by `setChildPositions` when the
76
+ * parent node is positioned.
77
+ */
65
78
def atPos [T <: Positioned ](start : Offset , point : Offset )(t : T ): T =
66
79
if (in.lastOffset > start) atPos(start, point, in.lastOffset)(t) else t
67
80
68
81
def atPos [T <: Positioned ](start : Offset )(t : T ): T =
69
82
atPos(start, start)(t)
70
83
71
- def atPos [T <: Positioned ](pos : Position )(t : T ): T =
72
- if (t.pos.isSourceDerived) t else t.withPos(pos)
73
-
74
84
def nameStart : Offset =
75
85
if (in.token == BACKQUOTED_IDENT ) in.offset + 1 else in.offset
76
86
0 commit comments