[Sourcemap] Add an ability to provide outputColumn to SourceMap3Builder#addMapping instead of using getCurrentOutputColumn

The ability will be used later by wasm backend while generating sourcemap.
This commit is contained in:
Zalim Bashorov
2022-12-06 16:17:50 +01:00
committed by Space Team
parent fb4dcc6a6a
commit 54c00cc588
@@ -125,6 +125,18 @@ class SourceMap3Builder(
sourceLine: Int,
sourceColumn: Int,
name: String?,
) {
addMapping(source, fileIdentity, sourceContent, sourceLine, sourceColumn, name, getCurrentOutputColumn())
}
fun addMapping(
source: String,
fileIdentity: Any?,
sourceContent: Supplier<Reader?>,
sourceLine: Int,
sourceColumn: Int,
name: String?,
outputColumn: Int
) {
val sourceIndex = getSourceIndex(source.replace(File.separatorChar, '/'), fileIdentity, sourceContent)
@@ -138,7 +150,7 @@ class SourceMap3Builder(
return
}
startMapping()
startMapping(outputColumn)
Base64VLQ.encode(out, sourceIndex - previousSourceIndex)
previousSourceIndex = sourceIndex
@@ -159,19 +171,17 @@ class SourceMap3Builder(
override fun addEmptyMapping() {
if (!currentMappingIsEmpty) {
startMapping()
startMapping(getCurrentOutputColumn())
currentMappingIsEmpty = true
}
}
private fun startMapping() {
private fun startMapping(column: Int) {
val newGroupStarted = previousGeneratedColumn == -1
if (newGroupStarted) {
previousGeneratedColumn = 0
}
val column = getCurrentOutputColumn()
val columnDiff = column - previousGeneratedColumn
if (!newGroupStarted) {
out.append(',')