@@ -110,7 +110,7 @@ object InlinedSourceMaps:
110
110
if cunit.source.file.isVirtual then InlinedSourceMap (cunit, Nil , Map .empty[SourceFile , String ])
111
111
else
112
112
var lastLine = cunit.tpdTree.sourcePos.endLine
113
- // returns the first fake line (starting from 0)
113
+ // returns the first fake line (starting from 0)
114
114
def allocate (origPos : SourcePosition ): Int =
115
115
val line = lastLine + 1
116
116
lastLine += origPos.lines.length
@@ -128,7 +128,35 @@ object InlinedSourceMaps:
128
128
requests : List [Request ],
129
129
internalNames : Map [SourceFile , String ])(using Context ):
130
130
131
- def debugExtension : Option [String ] = Some (" TODO" )
131
+ def debugExtension : Option [String ] = Option .when(requests.nonEmpty) {
132
+ val scalaStratum =
133
+ val files = cunit.source :: requests.map(_.inline.expansion.source).distinct.filter(_ != cunit.source)
134
+ val mappings = requests.map { case Request (inline, firstFakeLine) =>
135
+ Mapping (inline.expansion.sourcePos.startLine,
136
+ files.indexOf(inline.expansion.source) + 1 ,
137
+ inline.expansion.sourcePos.lines.length,
138
+ firstFakeLine, 1 )
139
+ }
140
+ Stratum (" Scala" ,
141
+ files.zipWithIndex.map { case (f, n) => File (n + 1 , f.name, internalNames.get(f)) },
142
+ Mapping (0 , 1 , cunit.tpdTree.sourcePos.lines.length, 0 , 1 ) +: mappings
143
+ )
144
+
145
+ val debugStratum =
146
+ val mappings = requests.map { case Request (inline, firstFakeLine) =>
147
+ Mapping (inline.sourcePos.startLine, 1 , 1 , firstFakeLine, inline.expansion.sourcePos.lines.length)
148
+ }
149
+ Stratum (" ScalaDebug" , File (1 , cunit.source.name, None ) :: Nil , mappings)
150
+
151
+ val b = new StringBuilder
152
+ b ++= " SMAP\n "
153
+ b ++= cunit.source.name
154
+ b += '\n '
155
+ b ++= " Scala\n "
156
+ scalaStratum.write(b)
157
+ debugStratum.write(b)
158
+ b.toString
159
+ }
132
160
133
161
def lineFor (tree : Tree ): Option [Int ] =
134
162
0 commit comments