aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-04-07 21:47:22 +0200
committerMartin Odersky <odersky@gmail.com>2016-04-07 21:47:22 +0200
commit8ddfa83177c5962e06a0a2ee2365e2e62ea6dfa0 (patch)
tree51f35264005ae4daa5f3b5c38f9aec76bf94ad23 /src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala
parentcb1f38669abb118697e1351822fa6705f52dcce7 (diff)
downloaddotty-8ddfa83177c5962e06a0a2ee2365e2e62ea6dfa0.tar.gz
dotty-8ddfa83177c5962e06a0a2ee2365e2e62ea6dfa0.tar.bz2
dotty-8ddfa83177c5962e06a0a2ee2365e2e62ea6dfa0.zip
Add unpickled source file path as annotation to root symbols
Diffstat (limited to 'src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala b/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala
index 6d0e73efb..edaeacd9a 100644
--- a/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala
+++ b/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala
@@ -3,13 +3,14 @@ package dotc
package core
package tasty
-import Contexts._, SymDenotations._
+import Contexts._, SymDenotations._, Symbols._
import dotty.tools.dotc.ast.tpd
import TastyUnpickler._, TastyBuffer._
import dotty.tools.dotc.core.tasty.DottyUnpickler.{SourceFileUnpickler, TreeSectionUnpickler, PositionsSectionUnpickler}
import util.Positions._
import util.{SourceFile, NoSource}
import PositionUnpickler._
+import Annotations.Annotation
import classfile.ClassfileParser
object DottyUnpickler {
@@ -43,21 +44,24 @@ class DottyUnpickler(bytes: Array[Byte]) extends ClassfileParser.Embedded {
val unpickler = new TastyUnpickler(bytes)
private val treeUnpickler = unpickler.unpickle(new TreeSectionUnpickler).get
+ private val source = unpickler.unpickle(new SourceFileUnpickler).getOrElse(NoSource)
/** Enter all toplevel classes and objects into their scopes
* @param roots a set of SymDenotations that should be overwritten by unpickling
*/
- def enter(roots: Set[SymDenotation])(implicit ctx: Context): Unit =
+ def enter(roots: Set[SymDenotation])(implicit ctx: Context): Unit = {
treeUnpickler.enterTopLevel(roots)
+ if (source.exists)
+ for (root <- roots) root.addAnnotation(Annotation.makeSourceFile(source.path))
+ }
/** The unpickled trees, and the source file they come from
* @param readPositions if true, trees get decorated with position information.
*/
def body(readPositions: Boolean = false)(implicit ctx: Context): (List[Tree], SourceFile) = {
- val source = unpickler.unpickle(new SourceFileUnpickler).getOrElse(NoSource)
if (readPositions)
for ((totalRange, positions) <- unpickler.unpickle(new PositionsSectionUnpickler))
treeUnpickler.usePositions(totalRange, positions)
- (treeUnpickler.unpickle(), source)
+ (treeUnpickler.unpickle(source), source)
}
}