Skip to content

Improve Source Positions #5644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
3227793
Rename nextId -> nextSymId in Context
odersky Dec 18, 2018
2e3dab3
Make nextTreeId counter a context field
odersky Dec 19, 2018
1cdae05
Adapt refelect.TreeOps to new scheme
odersky Dec 19, 2018
1b6a471
@transientParam annotation
odersky Dec 19, 2018
2cad642
Apply @transientParam to compiler
odersky Dec 19, 2018
d4779f1
Produce tree ids in chunks
odersky Dec 19, 2018
f0451af
Set source field of context directly
odersky Dec 19, 2018
712adcc
Make TreeCopiers preserve source
odersky Dec 19, 2018
edaafd5
Refactor getSource and withSource
odersky Dec 19, 2018
1949b53
Serialize source file changes
odersky Dec 20, 2018
454df0c
Better caching of sources
odersky Dec 20, 2018
368a68d
Allocate tree ids globally
odersky Dec 20, 2018
03b3ac8
Follow source changes when unpickling
odersky Dec 21, 2018
559defd
Remove unpickleTypeTree
odersky Dec 23, 2018
7f63293
Keep sourcefile info when pickling
odersky Dec 23, 2018
19f3bde
Eliminate Decorators.sourcePos
odersky Dec 23, 2018
8d9f3ca
Fix position of inline bodies in unpickler.
odersky Dec 25, 2018
1ce8b59
Lazy load contents of source position
odersky Dec 31, 2018
3c56fa6
Print full source positions in trees
odersky Dec 31, 2018
4a5d09a
Fix dropInlined
odersky Dec 31, 2018
9f54f73
Check sources correspond under -Ytest-pickler
odersky Dec 31, 2018
30008ae
Fix PositionPickler
odersky Dec 31, 2018
ed27a4e
Make Inliner source-position aware
odersky Dec 31, 2018
a1e367b
Fix Symbol#sourceFile
odersky Jan 1, 2019
56b313a
Make PositionPickler work for shared trees
odersky Jan 1, 2019
b8e23f4
Make Modifiers not extend from Positioned
odersky Jan 2, 2019
9f86d2f
Temporary hack to circumvent missing sourcefile info
odersky Jan 2, 2019
e22d702
Add source component to Positioned
odersky Jan 2, 2019
27a7a77
Inliner tweaks
odersky Jan 2, 2019
91af81a
withPos(Positioned) -> withPosOf
odersky Jan 3, 2019
2907634
Unpickler always takes source from context
odersky Jan 3, 2019
14d2c5a
withPos -> withSpan
odersky Jan 3, 2019
6f6d1ab
Fix position pickler
odersky Jan 3, 2019
3f09d91
Harden IDE: Survive duplicate package and object
odersky Jan 3, 2019
6c07a94
Position -> Span
odersky Jan 3, 2019
cf94fc4
Add missing check files
odersky Jan 3, 2019
012c5e9
Fix rebase breakage
odersky Jan 3, 2019
ca4e463
atPos -> atSpan
odersky Jan 3, 2019
dbc5251
Rename SourcePos#pos -> SourcePos#span
odersky Jan 4, 2019
6c88c93
Rename Span#pos -> Span#span
odersky Jan 4, 2019
a958ece
Rename Symbol#pos -> span, Comment#pos -> span
odersky Jan 4, 2019
1d16fab
Apply renamings to language server
odersky Jan 4, 2019
70768fa
Rename other uses of `pos` to `span`
odersky Jan 4, 2019
39c4ca5
Polishings
odersky Jan 4, 2019
7dc693e
Convert some checking methods to take Positioned arguments
odersky Jan 4, 2019
0a00ed2
Simplify Parser
odersky Jan 4, 2019
078a491
Fix rebase breakage
odersky Jan 6, 2019
fc3020b
Add missing source to context
nicolasstucki Jan 5, 2019
2150fdd
Add missing contents to vitual files
nicolasstucki Jan 5, 2019
fa08b7e
Avoid memoization of virtual source files with same path
nicolasstucki Jan 5, 2019
57e893f
Use non-virtual files in dottydoc tests
nicolasstucki Jan 6, 2019
6188f37
Update test to use Spans
nicolasstucki Jan 6, 2019
ba52c01
Update missing `pos` to `span`
nicolasstucki Jan 6, 2019
ff7a87e
Update implicit modifier test
nicolasstucki Jan 7, 2019
d0d6393
Add missing spans in closures
nicolasstucki Jan 7, 2019
5413f87
Comment debug assertion
nicolasstucki Jan 7, 2019
1f7ab41
Remove unnecessary workaround for repl
nicolasstucki Jan 7, 2019
19cf827
Fix rebase breakage
odersky Jan 9, 2019
6491872
Avoid creating source positions in backend interface
odersky Jan 7, 2019
512d7c3
Optimize computation of Sourcefile#content
odersky Jan 7, 2019
a2f437a
Make SourceFile equals depend on file
odersky Jan 9, 2019
cb3515b
Optimize equals + hashCode on PlainFile
odersky Jan 9, 2019
d1008fc
Reduce concurrent hashmap lookups
odersky Jan 9, 2019
4421092
Refactor SourceFile operations
odersky Jan 9, 2019
c03e31b
Optimize PlainFile.equals
odersky Jan 10, 2019
036546f
Implement -Ydebug-pos
odersky Jan 10, 2019
7947349
Revise PositionPickler
odersky Jan 10, 2019
29c8f45
Fix rebase breakage
odersky Jan 10, 2019
a7a8203
Optimize initialPos in Positioned
odersky Jan 10, 2019
a3ee7c0
Optimize SourceFile.fromId
odersky Jan 11, 2019
66ebabd
Optimize Symbol#source
odersky Jan 11, 2019
8ed8723
Use SourceFile implicits instead of SourceInfo
odersky Jan 11, 2019
5a6b1ee
Make virtual source files explicit
nicolasstucki Jan 14, 2019
84321eb
Sourcefile refactoring
odersky Jan 14, 2019
f5e226d
Don't read contents when creating a source file
odersky Jan 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SymDenotations._
import Contexts._
import Types._
import Symbols._
import dotty.tools.dotc.util.Positions.Position
import dotty.tools.dotc.util.SourcePosition
import Decorators._
import StdNames.nme

Expand Down Expand Up @@ -47,10 +47,10 @@ object CollectEntryPoints{
def hasJavaMainMethod(sym: Symbol): Boolean =
(toDenot(sym).info member nme.main).alternatives exists(x => isJavaMainMethod(x.symbol))

def fail(msg: String, pos: Position = sym.pos) = {
ctx.warning( sym.name +
s" has a main method with parameter type Array[String], but ${toDenot(sym).fullName} will not be a runnable program.\n Reason: $msg",
sourcePos(sym.pos)
def fail(msg: String, pos: SourcePosition = sym.sourcePos) = {
ctx.warning(
i"""${sym.name} has a main method with parameter type Array[String], but ${sym.fullName} will not be a runnable program.
|Reason: $msg""", sym.sourcePos
// TODO: make this next claim true, if possible
// by generating valid main methods as static in module classes
// not sure what the jvm allows here
Expand Down Expand Up @@ -92,11 +92,11 @@ object CollectEntryPoints{
fail("main methods cannot be generic.")
case MethodTpe(paramNames, paramTypes, resultType) =>
if (resultType :: paramTypes exists (_.typeSymbol.isAbstractType))
fail("main methods cannot refer to type parameters or abstract types.", m.symbol.pos)
fail("main methods cannot refer to type parameters or abstract types.", m.symbol.sourcePos)
else
isJavaMainMethod(m.symbol) || fail("main method must have exact signature (Array[String])Unit", m.symbol.pos)
isJavaMainMethod(m.symbol) || fail("main method must have exact signature (Array[String])Unit", m.symbol.sourcePos)
case tp =>
fail(s"don't know what this is: $tp", m.symbol.pos)
fail(s"don't know what this is: $tp", m.symbol.sourcePos)
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import Types._
import Symbols._
import Phases._

import dotty.tools.dotc.util.Positions
import dotty.tools.dotc.util
import dotty.tools.dotc.util.Spans
import Decorators._
import tpd._

Expand All @@ -41,7 +42,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
type CompilationUnit = dotc.CompilationUnit
type Constant = Constants.Constant
type Literal = tpd.Literal
type Position = Positions.Position
type Position = Spans.Span
type Name = Names.Name
type ClassDef = tpd.TypeDef
type TypeDef = tpd.TypeDef
Expand Down Expand Up @@ -77,7 +78,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
type Closure = tpd.Closure

val NoSymbol: Symbol = Symbols.NoSymbol
val NoPosition: Position = Positions.NoPosition
val NoPosition: Position = Spans.NoSpan
val EmptyTree: Tree = tpd.EmptyTree


Expand Down Expand Up @@ -380,16 +381,17 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
ctx.requiredModule(className)
}


def debuglog(msg: => String): Unit = ctx.debuglog(msg)
def informProgress(msg: String): Unit = ctx.informProgress(msg)
def log(msg: => String): Unit = ctx.log(msg)
def error(pos: Position, msg: String): Unit = ctx.error(msg, pos)
def warning(pos: Position, msg: String): Unit = ctx.warning(msg, pos)
def error(pos: Position, msg: String): Unit = ctx.error(msg, sourcePos(pos))
def warning(pos: Position, msg: String): Unit = ctx.warning(msg, sourcePos(pos))
def abort(msg: String): Nothing = {
ctx.error(msg)
throw new RuntimeException(msg)
}
def sourcePos(pos: Position)(implicit ctx: Context): util.SourcePosition =
ctx.source.atSpan(pos)

def emitAsmp: Option[String] = None

Expand Down Expand Up @@ -502,7 +504,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName}
|signature: $sig
|if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
""".trim, sym.pos)
""".trim, sym.sourcePos)
}
}

Expand Down Expand Up @@ -587,7 +589,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
implicit def treeHelper(a: Tree): TreeHelper = new TreeHelper {
def symbol: Symbol = a.symbol

def pos: Position = a.pos
def pos: Position = a.span

def isEmpty: Boolean = a.isEmpty

Expand Down Expand Up @@ -809,7 +811,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma

def moduleSuffix: String = "" // todo: validate that names already have $ suffix
def outputDirectory: AbstractFile = DottyBackendInterface.this.outputDirectory
def pos: Position = sym.pos
def pos: Position = sym.span

def throwsAnnotations: List[Symbol] = Nil

Expand Down Expand Up @@ -1105,7 +1107,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def _1: Type = field.tpe match {
case JavaArrayType(elem) => elem
case _ =>
ctx.error(s"JavaSeqArray with type ${field.tpe} reached backend: $field", field.pos)
error(field.span, s"JavaSeqArray with type ${field.tpe} reached backend: $field")
UnspecifiedErrorType
}
def _2: List[Tree] = field.elems
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
else (dupClassSym, classSymbol)
ctx.atPhase(ctx.typerPhase) { implicit ctx =>
ctx.warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.pos)
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.sourcePos)
}
}
}
Expand Down
Loading