@@ -19,7 +19,7 @@ import util.Spans._
19
19
class PositionPickler (
20
20
pickler : TastyPickler ,
21
21
addrOfTree : PositionPickler .TreeToAddr ,
22
- treeAnnots : untpd.MemberDef => List [tpd.Tree ]) {
22
+ treeAnnots : untpd.MemberDef => List [tpd.Tree ])( using Context ) {
23
23
24
24
import ast .tpd ._
25
25
val buf : TastyBuffer = new TastyBuffer (5000 )
@@ -67,21 +67,10 @@ class PositionPickler(
67
67
// specialization.
68
68
}
69
69
70
- def pickleSource (source : SourceFile ): Unit = {
70
+ def pickleSource (source : SourceFile )( using Context ) : Unit = {
71
71
buf.writeInt(SOURCE )
72
- val pathName = source.path
73
- val pickledPath =
74
- val originalPath = java.nio.file.Paths .get(pathName.toString).normalize()
75
- if originalPath.isAbsolute then
76
- val path = originalPath.toAbsolutePath().normalize()
77
- val cwd = java.nio.file.Paths .get(" " ).toAbsolutePath().normalize()
78
- try cwd.relativize(path)
79
- catch case _ : IllegalArgumentException =>
80
- warnings += " Could not relativize path for pickling: " + originalPath
81
- originalPath
82
- else
83
- originalPath
84
- buf.writeInt(pickler.nameBuffer.nameIndex(pickledPath.toString.toTermName).index)
72
+ val relativePath = SourceFile .relativePath(source)
73
+ buf.writeInt(pickler.nameBuffer.nameIndex(relativePath.toTermName).index)
85
74
}
86
75
87
76
/** True if x's position shouldn't be reconstructed automatically from its initial span
@@ -105,7 +94,7 @@ class PositionPickler(
105
94
case _ => false
106
95
}
107
96
108
- def traverse (x : Any , current : SourceFile ): Unit = x match {
97
+ def traverse (x : Any , current : SourceFile )( using Context ) : Unit = x match {
109
98
case x : untpd.Tree =>
110
99
if (x.span.exists) {
111
100
val addr = addrOfTree(x)
0 commit comments