Skip to content

Commit dc2c818

Browse files
committed
Rename SourcePosition -> Position
1 parent 890fba1 commit dc2c818

39 files changed

+184
-184
lines changed

compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import SymDenotations._
1212
import Contexts._
1313
import Types._
1414
import Symbols._
15-
import dotty.tools.dotc.util.SourcePosition
15+
import dotty.tools.dotc.util.Position
1616
import Decorators._
1717
import StdNames.nme
1818

@@ -47,7 +47,7 @@ object CollectEntryPoints{
4747
def hasJavaMainMethod(sym: Symbol): Boolean =
4848
(toDenot(sym).info member nme.main).alternatives exists(x => isJavaMainMethod(x.symbol))
4949

50-
def fail(msg: String, pos: SourcePosition = sym.sourcePos) = {
50+
def fail(msg: String, pos: Position = sym.sourcePos) = {
5151
ctx.warning(
5252
i"""${sym.name} has a main method with parameter type Array[String], but ${sym.fullName} will not be a runnable program.
5353
|Reason: $msg""", sym.sourcePos

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
390390
ctx.error(msg)
391391
throw new RuntimeException(msg)
392392
}
393-
def sourcePos(pos: Position)(implicit ctx: Context): util.SourcePosition =
393+
def sourcePos(pos: Position)(implicit ctx: Context): util.Position =
394394
ctx.source.atSpan(pos)
395395

396396
def emitAsmp: Option[String] = None

compiler/src/dotty/tools/dotc/ast/Positioned.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package ast
44

55
import util.Spans._
6-
import util.{SourceFile, NoSource, SourcePosition}
6+
import util.{SourceFile, NoSource, Position}
77
import core.Contexts.Context
88
import core.Decorators._
99
import core.Flags.{JavaDefined, Extension}
@@ -28,7 +28,7 @@ abstract class Positioned(implicit @transientParam src: SourceFile) extends Prod
2828
def uniqueId: Int = myUniqueId
2929

3030
def source: SourceFile = SourceFile.fromId(uniqueId)
31-
def sourcePos(implicit ctx: Context): SourcePosition = source.atSpan(span)
31+
def sourcePos(implicit ctx: Context): Position = source.atSpan(span)
3232

3333
//setId(initialSource(src).nextId)
3434
setPos(initialSpan(src), source)
@@ -68,7 +68,7 @@ abstract class Positioned(implicit @transientParam src: SourceFile) extends Prod
6868
newpd
6969
}
7070

71-
def withSourcePos(sourcePos: SourcePosition): this.type = {
71+
def withSourcePos(sourcePos: Position): this.type = {
7272
val ownSpan = this.span
7373
val newpd: this.type =
7474
if ((sourcePos.source `eq` source) && sourcePos.span == ownSpan || ownSpan.isSynthetic) this

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import language.higherKinds
99
import collection.mutable.ListBuffer
1010
import printing.Printer
1111
import printing.Texts.Text
12-
import util.{Stats, Attachment, Property, SourceFile, NoSource, SourcePosition}
12+
import util.{Stats, Attachment, Property, SourceFile, NoSource, Position}
1313
import config.Config
1414
import annotation.internal.sharable
1515
import annotation.unchecked.uncheckedVariance
@@ -809,7 +809,7 @@ object Trees {
809809
mapElems(_.withSpan(span)).asInstanceOf[this.type]
810810
override def withPosOf(posd: Positioned): this.type =
811811
mapElems(_.withPosOf(posd)).asInstanceOf[this.type]
812-
override def withSourcePos(sourcePos: SourcePosition): this.type =
812+
override def withSourcePos(sourcePos: Position): this.type =
813813
mapElems(_.withSourcePos(sourcePos)).asInstanceOf[this.type]
814814
}
815815

compiler/src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package core
44
import annotation.tailrec
55
import Symbols._
66
import Contexts._, Names._, Phases._, printing.Texts._, printing.Printer
7-
import util.Spans.Span, util.SourcePosition
7+
import util.Spans.Span, util.Position
88
import collection.mutable.ListBuffer
99
import dotty.tools.dotc.transform.MegaPhase
1010
import ast.tpd._

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import reporting.diagnostic.Message
2626
import collection.mutable
2727
import io.AbstractFile
2828
import language.implicitConversions
29-
import util.{SourceFile, NoSource, Property, SourcePosition}
29+
import util.{SourceFile, NoSource, Property, Position}
3030
import scala.collection.JavaConverters._
3131
import scala.annotation.internal.sharable
3232
import config.Printers.typr
@@ -661,7 +661,7 @@ object Symbols {
661661
*/
662662
final def span: Span = if (coord.isSpan) coord.toSpan else NoSpan
663663

664-
final def sourcePos(implicit ctx: Context): SourcePosition = {
664+
final def sourcePos(implicit ctx: Context): Position = {
665665
val src = source
666666
(if (src.exists) src else ctx.source).atSpan(span)
667667
}

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package core
55
import Contexts._, Types._, Symbols._, Names._, Flags._
66
import SymDenotations._
77
import util.Spans._
8-
import util.SourcePosition
8+
import util.Position
99
import NameKinds.DepParamName
1010
import Decorators._
1111
import StdNames._
@@ -321,7 +321,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
321321
def dynamicsEnabled: Boolean =
322322
featureEnabled(defn.LanguageModuleClass, nme.dynamics)
323323

324-
def testScala2Mode(msg: => Message, pos: SourcePosition, replace: => Unit = ()): Boolean = {
324+
def testScala2Mode(msg: => Message, pos: Position, replace: => Unit = ()): Boolean = {
325325
if (scala2Mode) {
326326
migrationWarning(msg, pos)
327327
replace

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import dotty.tools.dotc.core.StdNames.{nme, tpnme}
1616
import dotty.tools.dotc.core.TypeError
1717
import dotty.tools.dotc.core.Types.{NameFilter, NamedType, Type, NoType}
1818
import dotty.tools.dotc.printing.Texts._
19-
import dotty.tools.dotc.util.{NoSourcePosition, SourcePosition}
19+
import dotty.tools.dotc.util.{NoPosition, Position}
2020

2121
import scala.collection.mutable
2222

@@ -39,7 +39,7 @@ object Completion {
3939
*
4040
* @return offset and list of symbols for possible completions
4141
*/
42-
def completions(pos: SourcePosition)(implicit ctx: Context): (Int, List[Completion]) = {
42+
def completions(pos: Position)(implicit ctx: Context): (Int, List[Completion]) = {
4343
val path = Interactive.pathTo(ctx.compilationUnit.tpdTree, pos.span)
4444
computeCompletions(pos, path)(Interactive.contextOfPath(path))
4545
}
@@ -54,7 +54,7 @@ object Completion {
5454
*
5555
* Otherwise, provide no completion suggestion.
5656
*/
57-
private def completionMode(path: List[Tree], pos: SourcePosition): Mode = {
57+
private def completionMode(path: List[Tree], pos: Position): Mode = {
5858
path match {
5959
case (ref: RefTree) :: _ =>
6060
if (ref.name.isTermName) Mode.Term
@@ -77,7 +77,7 @@ object Completion {
7777
* Inspect `path` to determine the completion prefix. Only symbols whose name start with the
7878
* returned prefix should be considered.
7979
*/
80-
private def completionPrefix(path: List[Tree], pos: SourcePosition): String = {
80+
private def completionPrefix(path: List[Tree], pos: Position): String = {
8181
path match {
8282
case Thicket(name :: _ :: Nil) :: (_: Import) :: _ =>
8383
completionPrefix(name :: Nil, pos)
@@ -105,13 +105,13 @@ object Completion {
105105
}
106106

107107
/** Create a new `CompletionBuffer` for completing at `pos`. */
108-
private def completionBuffer(path: List[Tree], pos: SourcePosition): CompletionBuffer = {
108+
private def completionBuffer(path: List[Tree], pos: Position): CompletionBuffer = {
109109
val mode = completionMode(path, pos)
110110
val prefix = completionPrefix(path, pos)
111111
new CompletionBuffer(mode, prefix, pos)
112112
}
113113

114-
private def computeCompletions(pos: SourcePosition, path: List[Tree])(implicit ctx: Context): (Int, List[Completion]) = {
114+
private def computeCompletions(pos: Position, path: List[Tree])(implicit ctx: Context): (Int, List[Completion]) = {
115115

116116
val offset = completionOffset(path)
117117
val buffer = completionBuffer(path, pos)
@@ -135,7 +135,7 @@ object Completion {
135135
(offset, completionList)
136136
}
137137

138-
private class CompletionBuffer(val mode: Mode, val prefix: String, pos: SourcePosition) {
138+
private class CompletionBuffer(val mode: Mode, val prefix: String, pos: Position) {
139139

140140
private[this] val completions = new RenameAwareScope
141141

compiler/src/dotty/tools/dotc/interactive/Interactive.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ast.{NavigateAST, Trees, tpd, untpd}
99
import core._, core.Decorators._
1010
import Contexts._, Flags._, Names._, NameOps._, Symbols._, Trees._, Types._
1111
import transform.SymUtils.decorateSymbol
12-
import util.Spans._, util.SourceFile, util.SourcePosition
12+
import util.Spans._, util.SourceFile, util.Position
1313
import core.Denotations.SingleDenotation
1414
import NameKinds.SimpleNameKind
1515
import config.Printers.interactiv
@@ -70,15 +70,15 @@ object Interactive {
7070
tree.isInstanceOf[DefTree with NameTree]
7171

7272
/** The type of the closest enclosing tree with a type containing position `pos`. */
73-
def enclosingType(trees: List[SourceTree], pos: SourcePosition)(implicit ctx: Context): Type = {
73+
def enclosingType(trees: List[SourceTree], pos: Position)(implicit ctx: Context): Type = {
7474
val path = pathTo(trees, pos)
7575
if (path.isEmpty) NoType
7676
else path.head.tpe
7777
}
7878

7979
/** The closest enclosing tree with a symbol containing position `pos`, or the `EmptyTree`.
8080
*/
81-
def enclosingTree(trees: List[SourceTree], pos: SourcePosition)(implicit ctx: Context): Tree =
81+
def enclosingTree(trees: List[SourceTree], pos: Position)(implicit ctx: Context): Tree =
8282
enclosingTree(pathTo(trees, pos))
8383

8484
/** The closes enclosing tree with a symbol, or the `EmptyTree`.
@@ -97,7 +97,7 @@ object Interactive {
9797
*
9898
* @see sourceSymbol
9999
*/
100-
def enclosingSourceSymbols(path: List[Tree], pos: SourcePosition)(implicit ctx: Context): List[Symbol] = {
100+
def enclosingSourceSymbols(path: List[Tree], pos: Position)(implicit ctx: Context): List[Symbol] = {
101101
val syms = path match {
102102
// For a named arg, find the target `DefDef` and jump to the param
103103
case NamedArg(name, _) :: Apply(fn, _) :: _ =>
@@ -250,7 +250,7 @@ object Interactive {
250250
* or `Nil` if no such path exists. If a non-empty path is returned it starts with
251251
* the tree closest enclosing `pos` and ends with an element of `trees`.
252252
*/
253-
def pathTo(trees: List[SourceTree], pos: SourcePosition)(implicit ctx: Context): List[Tree] =
253+
def pathTo(trees: List[SourceTree], pos: Position)(implicit ctx: Context): List[Tree] =
254254
trees.find(_.pos.contains(pos)) match {
255255
case Some(tree) => pathTo(tree.tree, pos.span)
256256
case None => Nil
@@ -332,7 +332,7 @@ object Interactive {
332332
* @param driver The driver responsible for `path`.
333333
* @return The definitions for the symbol at the end of `path`.
334334
*/
335-
def findDefinitions(path: List[Tree], pos: SourcePosition, driver: InteractiveDriver): List[SourceTree] = {
335+
def findDefinitions(path: List[Tree], pos: Position, driver: InteractiveDriver): List[SourceTree] = {
336336
implicit val ctx = driver.currentCtx
337337
val enclTree = enclosingTree(path)
338338
val includeOverridden = enclTree.isInstanceOf[MemberDef]

compiler/src/dotty/tools/dotc/interactive/SourceTree.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import util._, util.Spans._
1717
case class SourceTree(tree: tpd.Tree /** really: tpd.Import | tpd.NameTree */, source: SourceFile) {
1818

1919
/** The position of `tree` */
20-
final def pos(implicit ctx: Context): SourcePosition = source.atSpan(tree.span)
20+
final def pos(implicit ctx: Context): Position = source.atSpan(tree.span)
2121

2222
/** The position of the name in `tree` */
23-
def namePos(implicit ctx: Context): SourcePosition = tree match {
23+
def namePos(implicit ctx: Context): Position = tree match {
2424
case tree: tpd.NameTree =>
2525
// FIXME: Merge with NameTree#namePos ?
2626
val treeSpan = tree.span
2727
if (treeSpan.isZeroExtent || tree.name.toTermName == nme.ERROR)
28-
NoSourcePosition
28+
NoPosition
2929
else {
3030
// Constructors are named `<init>` in the trees, but `this` in the source.
3131
val nameLength = tree.name match {
@@ -46,7 +46,7 @@ case class SourceTree(tree: tpd.Tree /** really: tpd.Import | tpd.NameTree */, s
4646
source.atSpan(position)
4747
}
4848
case _ =>
49-
NoSourcePosition
49+
NoPosition
5050
}
5151
}
5252

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package parsing
55
import scala.annotation.internal.sharable
66
import scala.collection.mutable.ListBuffer
77
import scala.collection.immutable.BitSet
8-
import util.{ SourceFile, SourcePosition }
8+
import util.{ SourceFile, Position }
99
import Tokens._
1010
import Scanners._
1111
import xml.MarkupParsers.MarkupParser
@@ -102,7 +102,7 @@ object Parsers {
102102
def nameStart: Offset =
103103
if (in.token == BACKQUOTED_IDENT) in.offset + 1 else in.offset
104104

105-
def sourcePos(off: Int = in.offset): SourcePosition =
105+
def sourcePos(off: Int = in.offset): Position =
106106
source.atSpan(Span(off))
107107

108108
/* ------------- ERROR HANDLING ------------------------------------------- */
@@ -259,7 +259,7 @@ object Parsers {
259259
}
260260
}
261261

262-
def warning(msg: => Message, sourcePos: SourcePosition): Unit =
262+
def warning(msg: => Message, sourcePos: Position): Unit =
263263
ctx.warning(msg, sourcePos)
264264

265265
def warning(msg: => Message, offset: Int = in.offset): Unit =

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import StdNames.nme
88
import ast.Trees._
99
import typer.Implicits._
1010
import typer.ImportInfo
11-
import util.SourcePosition
11+
import util.Position
1212
import java.lang.Integer.toOctalString
1313
import config.Config.summarizeDepth
1414
import scala.util.control.NonFatal
@@ -506,7 +506,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
506506
nodeName ~ "(" ~ elems ~ tpSuffix ~ ")" ~ (Str(tree.sourcePos.toString) provided ctx.settings.YprintPos.value)
507507
}.close // todo: override in refined printer
508508

509-
def toText(pos: SourcePosition): Text = {
509+
def toText(pos: Position): Text = {
510510
if (!pos.exists) "<no position>"
511511
else if (pos.source.exists) s"${pos.source.file.name}:${pos.line + 1}"
512512
else s"(no source file, offset = ${pos.span.point})"

compiler/src/dotty/tools/dotc/printing/Printer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Texts._, ast.Trees._
77
import Types.Type, Symbols.Symbol, Scopes.Scope, Constants.Constant,
88
Names.Name, Denotations._, Annotations.Annotation
99
import typer.Implicits.SearchResult
10-
import util.SourcePosition
10+
import util.Position
1111
import typer.ImportInfo
1212

1313
import scala.annotation.internal.sharable
@@ -136,7 +136,7 @@ abstract class Printer {
136136
def toText[T >: Untyped](tree: Tree[T]): Text
137137

138138
/** Textual representation of source position */
139-
def toText(pos: SourcePosition): Text
139+
def toText(pos: Position): Text
140140

141141
/** Textual representation of implicit search result */
142142
def toText(result: SearchResult): Text

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import scala.tasty.util.Chars.isOperatorPart
2424
import transform.TypeUtils._
2525

2626
import language.implicitConversions
27-
import dotty.tools.dotc.util.SourcePosition
27+
import dotty.tools.dotc.util.Position
2828
import dotty.tools.dotc.ast.untpd.{MemberDef, Modifiers, PackageDef, RefTree, Template, TypeDef, ValOrDefDef}
2929

3030
class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
@@ -841,7 +841,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
841841

842842
override def plain: PlainPrinter = new PlainPrinter(_ctx)
843843

844-
private def withPos(txt: Text, pos: SourcePosition): Text = {
844+
private def withPos(txt: Text, pos: Position): Text = {
845845
if (!printLines || !pos.exists) txt
846846
else txt match {
847847
case Str(s, _) => Str(s, LineRange(pos.line, pos.endLine))

0 commit comments

Comments
 (0)