Skip to content

Commit 570b26f

Browse files
committed
Talk consistently about spans in Parser
1 parent 652b570 commit 570b26f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ object Parsers {
6969
/* ------------- POSITIONS ------------------------------------------- */
7070

7171
/** Positions tree.
72-
* If `t` does not have a position yet, set its position to the given one.
72+
* If `t` does not have a span yet, set its span to the given one.
7373
*/
7474
def atSpan[T <: Positioned](span: Span)(t: T): T =
7575
if (t.span.isSourceDerived) t else t.withSpan(span)
7676

7777
def atSpan[T <: Positioned](start: Offset, point: Offset, end: Offset)(t: T): T =
7878
atSpan(Span(start, end, point))(t)
7979

80-
/** If the last read offset is strictly greater than `start`, position tree
81-
* to position spanning from `start` to last read offset, with given point.
80+
/** If the last read offset is strictly greater than `start`, assign tree
81+
* the span from `start` to last read offset, with given point.
8282
* If the last offset is less than or equal to start, the tree `t` did not
83-
* consume any source for its construction. In this case, don't position it yet,
84-
* but wait for its position to be determined by `setChildSpans` when the
83+
* consume any source for its construction. In this case, don't assign a span yet,
84+
* but wait for its span to be determined by `setChildSpans` when the
8585
* parent node is positioned.
8686
*/
8787
def atSpan[T <: Positioned](start: Offset, point: Offset)(t: T): T =
@@ -128,9 +128,9 @@ object Parsers {
128128
lastErrorOffset = in.offset
129129
}
130130

131-
/** Unconditionally issue an error at given position, without
132-
* updating lastErrorOffset.
133-
*/
131+
/** Unconditionally issue an error at given span, without
132+
* updating lastErrorOffset.
133+
*/
134134
def syntaxError(msg: => Message, span: Span): Unit =
135135
ctx.error(msg, source.atSpan(span))
136136
}
@@ -1559,7 +1559,7 @@ object Parsers {
15591559
}
15601560

15611561
/** Block ::= BlockStatSeq
1562-
* @note Return tree does not carry source position.
1562+
* @note Return tree does not have a defined span.
15631563
*/
15641564
def block(): Tree = {
15651565
val stats = blockStatSeq()
@@ -1892,7 +1892,7 @@ object Parsers {
18921892
/** Wrap annotation or constructor in New(...).<init> */
18931893
def wrapNew(tpt: Tree): Select = Select(New(tpt), nme.CONSTRUCTOR)
18941894

1895-
/** Adjust start of annotation or constructor to position of preceding @ or new */
1895+
/** Adjust start of annotation or constructor to offset of preceding @ or new */
18961896
def adjustStart(start: Offset)(tree: Tree): Tree = {
18971897
val tree1 = tree match {
18981898
case Apply(fn, args) => cpy.Apply(tree)(adjustStart(start)(fn), args)
@@ -2101,7 +2101,7 @@ object Parsers {
21012101
val offset = accept(IMPORT)
21022102
commaSeparated(importExpr) match {
21032103
case t :: rest =>
2104-
// The first import should start at the position of the keyword.
2104+
// The first import should start at the start offset of the keyword.
21052105
val firstPos =
21062106
if (t.span.exists) t.span.withStart(offset)
21072107
else Span(offset, in.lastOffset)
@@ -2155,8 +2155,8 @@ object Parsers {
21552155
val to = termIdentOrWildcard()
21562156
val toWithPos =
21572157
if (to.name == nme.ERROR)
2158-
// error identifiers don't consume any characters, so atSpan(start)(id) wouldn't set a position.
2159-
// Some testcases would then fail in Positioned.checkPos. Set a position anyway!
2158+
// error identifiers don't consume any characters, so atSpan(start)(id) wouldn't set a span.
2159+
// Some testcases would then fail in Positioned.checkPos. Set a span anyway!
21602160
atSpan(start, start, in.lastOffset)(to)
21612161
else
21622162
to

0 commit comments

Comments
 (0)