Skip to content

Commit 21b3904

Browse files
committed
Rename Parser.atPos -> atSpan
1 parent 4ef3cea commit 21b3904

File tree

3 files changed

+149
-149
lines changed

3 files changed

+149
-149
lines changed

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -245,24 +245,24 @@ object JavaParsers {
245245
// -------------------- specific parsing routines ------------------
246246

247247
def qualId(): RefTree = {
248-
var t: RefTree = atPos(in.offset) { Ident(ident()) }
248+
var t: RefTree = atSpan(in.offset) { Ident(ident()) }
249249
while (in.token == DOT) {
250250
in.nextToken()
251-
t = atPos(t.span.start, in.offset) { Select(t, ident()) }
251+
t = atSpan(t.span.start, in.offset) { Select(t, ident()) }
252252
}
253253
t
254254
}
255255

256256
def optArrayBrackets(tpt: Tree): Tree =
257257
if (in.token == LBRACKET) {
258-
val tpt1 = atPos(tpt.span.start, in.offset) { arrayOf(tpt) }
258+
val tpt1 = atSpan(tpt.span.start, in.offset) { arrayOf(tpt) }
259259
in.nextToken()
260260
accept(RBRACKET)
261261
optArrayBrackets(tpt1)
262262
} else tpt
263263

264264
def basicType(): Tree =
265-
atPos(in.offset) {
265+
atSpan(in.offset) {
266266
in.token match {
267267
case BYTE => in.nextToken(); TypeTree(ByteType)
268268
case SHORT => in.nextToken(); TypeTree(ShortType)
@@ -280,7 +280,7 @@ object JavaParsers {
280280
optArrayBrackets {
281281
if (in.token == FINAL) in.nextToken()
282282
if (in.token == IDENTIFIER) {
283-
var t = typeArgs(atPos(in.offset)(Ident(ident())))
283+
var t = typeArgs(atSpan(in.offset)(Ident(ident())))
284284
// typeSelect generates Select nodes if the lhs is an Ident or Select,
285285
// For other nodes it always assumes that the selected item is a type.
286286
def typeSelect(t: Tree, name: Name) = t match {
@@ -289,7 +289,7 @@ object JavaParsers {
289289
}
290290
while (in.token == DOT) {
291291
in.nextToken()
292-
t = typeArgs(atPos(t.span.start, in.offset)(typeSelect(t, ident())))
292+
t = typeArgs(atSpan(t.span.start, in.offset)(typeSelect(t, ident())))
293293
}
294294
convertToTypeId(t)
295295
} else {
@@ -305,7 +305,7 @@ object JavaParsers {
305305
in.nextToken()
306306
val hi = if (in.token == EXTENDS) { in.nextToken() ; typ() } else EmptyTree
307307
val lo = if (in.token == SUPER) { in.nextToken() ; typ() } else EmptyTree
308-
atPos(offset) {
308+
atSpan(offset) {
309309
/*
310310
TypeDef(
311311
Modifiers(Flags.JavaDefined | Flags.Deferred),
@@ -323,7 +323,7 @@ object JavaParsers {
323323
val t1 = convertToTypeId(t)
324324
val args = repsep(() => typeArg(), COMMA)
325325
acceptClosingAngle()
326-
atPos(t1.span.start) {
326+
atSpan(t1.span.start) {
327327
AppliedTypeTree(t1, args)
328328
}
329329
} else t
@@ -352,7 +352,7 @@ object JavaParsers {
352352
var isPackageAccess = true
353353
var annots: List[Tree] = Nil
354354
def addAnnot(sym: ClassSymbol) =
355-
annots :+= atPos(in.offset) {
355+
annots :+= atSpan(in.offset) {
356356
in.nextToken()
357357
New(TypeTree(sym.typeRef))
358358
}
@@ -413,14 +413,14 @@ object JavaParsers {
413413
} else List()
414414

415415
def typeParam(flags: FlagSet): TypeDef =
416-
atPos(in.offset) {
416+
atSpan(in.offset) {
417417
val name = identForType()
418418
val hi = if (in.token == EXTENDS) { in.nextToken() ; bound() } else EmptyTree
419419
TypeDef(name, TypeBoundsTree(EmptyTree, hi)).withMods(Modifiers(flags))
420420
}
421421

422422
def bound(): Tree =
423-
atPos(in.offset) {
423+
atSpan(in.offset) {
424424
val buf = ListBuffer[Tree](typ())
425425
while (in.token == AMP) {
426426
in.nextToken()
@@ -445,11 +445,11 @@ object JavaParsers {
445445
var t = typ()
446446
if (in.token == DOTDOTDOT) {
447447
in.nextToken()
448-
t = atPos(t.span.start) {
448+
t = atSpan(t.span.start) {
449449
PostfixOp(t, Ident(tpnme.raw.STAR))
450450
}
451451
}
452-
atPos(start, in.offset) {
452+
atSpan(start, in.offset) {
453453
varDecl(Modifiers(Flags.JavaDefined | Flags.Param), t, ident().toTermName)
454454
}
455455
}
@@ -461,7 +461,7 @@ object JavaParsers {
461461
}
462462
}
463463

464-
def methodBody(): Tree = atPos(in.offset) {
464+
def methodBody(): Tree = atSpan(in.offset) {
465465
skipAhead()
466466
accept(RBRACE) // skip block
467467
unimplementedExpr
@@ -475,7 +475,7 @@ object JavaParsers {
475475
val isVoid = in.token == VOID
476476
var rtpt =
477477
if (isVoid)
478-
atPos(in.offset) {
478+
atSpan(in.offset) {
479479
in.nextToken()
480480
TypeTree(UnitType)
481481
}
@@ -490,7 +490,7 @@ object JavaParsers {
490490
val vparams = formalParams()
491491
optThrows()
492492
List {
493-
atPos(start) {
493+
atSpan(start) {
494494
DefDef(nme.CONSTRUCTOR, parentTParams,
495495
List(vparams), TypeTree(), methodBody()).withMods(mods)
496496
}
@@ -512,7 +512,7 @@ object JavaParsers {
512512
} else {
513513
if (parentToken == AT && in.token == DEFAULT) {
514514
val annot =
515-
atPos(nameOffset) {
515+
atSpan(nameOffset) {
516516
New(Select(Select(scalaDot(nme.annotation), nme.internal), tpnme.AnnotationDefaultATTR), Nil)
517517
}
518518
mods1 = mods1 withAddedAnnotation annot
@@ -527,7 +527,7 @@ object JavaParsers {
527527
}
528528
//if (inInterface) mods1 |= Flags.Deferred
529529
List {
530-
atPos(start, nameOffset) {
530+
atSpan(start, nameOffset) {
531531
DefDef(name.toTermName, tparams, List(vparams), rtpt, body).withMods(mods1 | Flags.Method)
532532
}
533533
}
@@ -551,7 +551,7 @@ object JavaParsers {
551551
*/
552552
def fieldDecls(start: Offset, firstNameOffset: Offset, mods: Modifiers, tpt: Tree, name: Name): List[Tree] = {
553553
val buf = ListBuffer[Tree](
554-
atPos(start, firstNameOffset) { varDecl(mods, tpt, name.toTermName) })
554+
atSpan(start, firstNameOffset) { varDecl(mods, tpt, name.toTermName) })
555555
val maybe = new ListBuffer[Tree] // potential variable definitions.
556556
while (in.token == COMMA) {
557557
in.nextToken()
@@ -560,10 +560,10 @@ object JavaParsers {
560560
val name = ident()
561561
if (in.token == EQUALS || in.token == SEMI) { // ... followed by a `=` or `;`, we know it's a real variable definition
562562
buf ++= maybe
563-
buf += atPos(start, nextNameOffset) { varDecl(mods, tpt, name.toTermName) }
563+
buf += atSpan(start, nextNameOffset) { varDecl(mods, tpt, name.toTermName) }
564564
maybe.clear()
565565
} else if (in.token == COMMA) { // ... if there's a comma after the ident, it could be a real vardef or not.
566-
maybe += atPos(start, nextNameOffset) { varDecl(mods, tpt, name.toTermName) }
566+
maybe += atSpan(start, nextNameOffset) { varDecl(mods, tpt, name.toTermName) }
567567
} else { // ... if there's something else we were still in the initializer of the
568568
// previous var def; skip to next comma or semicolon.
569569
skipTo(COMMA, SEMI)
@@ -596,7 +596,7 @@ object JavaParsers {
596596
}
597597

598598
def makeCompanionObject(cdef: TypeDef, statics: List[Tree]): Tree =
599-
atPos(cdef.span) {
599+
atSpan(cdef.span) {
600600
assert(cdef.span.exists)
601601
ModuleDef(cdef.name.toTermName,
602602
makeTemplate(List(), statics, List(), false)).withMods((cdef.mods & Flags.RetainedModuleClassFlags).toTermFlags)
@@ -665,7 +665,7 @@ object JavaParsers {
665665
// case nme.WILDCARD => Pair(ident, Ident(null) withPos Span(-1))
666666
// case _ => Pair(ident, ident)
667667
// }
668-
val imp = atPos(start) { Import(qual, List(ident)) }
668+
val imp = atSpan(start) { Import(qual, List(ident)) }
669669
imp :: Nil
670670
}
671671
}
@@ -692,7 +692,7 @@ object JavaParsers {
692692
}
693693
val interfaces = interfacesOpt()
694694
val (statics, body) = typeBody(CLASS, name, tparams)
695-
val cls = atPos(start, nameOffset) {
695+
val cls = atSpan(start, nameOffset) {
696696
TypeDef(name, makeTemplate(superclass :: interfaces, body, tparams, true)).withMods(mods)
697697
}
698698
addCompanionObject(statics, cls)
@@ -711,7 +711,7 @@ object JavaParsers {
711711
List(javaLangObject())
712712
}
713713
val (statics, body) = typeBody(INTERFACE, name, tparams)
714-
val iface = atPos(start, nameOffset) {
714+
val iface = atSpan(start, nameOffset) {
715715
TypeDef(
716716
name,
717717
makeTemplate(parents, body, tparams, false)).withMods(mods | Flags.Trait | Flags.JavaInterface | Flags.Abstract)
@@ -786,7 +786,7 @@ object JavaParsers {
786786
val constr = DefDef(nme.CONSTRUCTOR,
787787
List(), List(constructorParams), TypeTree(), EmptyTree).withMods(Modifiers(Flags.JavaDefined))
788788
val templ = makeTemplate(annotationParents, constr :: body, List(), true)
789-
val annot = atPos(start, nameOffset) {
789+
val annot = atSpan(start, nameOffset) {
790790
TypeDef(name, templ).withMods(mods | Flags.Abstract)
791791
}
792792
addCompanionObject(statics, annot)
@@ -837,7 +837,7 @@ object JavaParsers {
837837
val superclazz = Apply(TypeApply(
838838
Select(New(javaLangDot(tpnme.Enum)), nme.CONSTRUCTOR), List(enumType)),
839839
List(Literal(Constant(null)),Literal(Constant(0))))
840-
val enumclazz = atPos(start, nameOffset) {
840+
val enumclazz = atSpan(start, nameOffset) {
841841
TypeDef(name,
842842
makeTemplate(superclazz :: interfaces, body, List(), true)).withMods(mods | Flags.JavaEnum)
843843
}
@@ -846,7 +846,7 @@ object JavaParsers {
846846

847847
def enumConst(enumType: Tree): ValDef = {
848848
annotations()
849-
atPos(in.offset) {
849+
atSpan(in.offset) {
850850
val name = ident()
851851
if (in.token == LPAREN) {
852852
// skip arguments
@@ -899,7 +899,7 @@ object JavaParsers {
899899
buf ++= typeDecl(start, mods)
900900
}
901901
}
902-
val unit = atPos(start) { PackageDef(pkg, buf.toList) }
902+
val unit = atSpan(start) { PackageDef(pkg, buf.toList) }
903903
accept(EOF)
904904
unit
905905
}

0 commit comments

Comments
 (0)