[Sourcemap] Introduce getCurrentColumn and stop using TextOutput directly
The general goal is remove dependency on TextOutput and make it simpler to use for wasm backend.
This commit is contained in:
committed by
Space Team
parent
e34d3d09bc
commit
fb4dcc6a6a
@@ -75,7 +75,7 @@ private fun mergeStdlibParts(outputFile: File, wrapperFile: File, baseDir: File,
|
||||
|
||||
val sourceMapFile = File(outputFile.parentFile, outputFile.name + ".map")
|
||||
val textOutput = TextOutputImpl()
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput, "")
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput::getColumn, "")
|
||||
val consumer = SourceMapBuilderConsumer(
|
||||
File("."),
|
||||
sourceMapBuilder,
|
||||
|
||||
+1
-1
@@ -461,7 +461,7 @@ fun generateSingleWrappedModuleBody(
|
||||
val sourceMapBuilderConsumer: SourceLocationConsumer
|
||||
if (sourceMapsInfo != null) {
|
||||
val sourceMapPrefix = sourceMapsInfo.sourceMapPrefix
|
||||
sourceMapBuilder = SourceMap3Builder(null, jsCode, sourceMapPrefix)
|
||||
sourceMapBuilder = SourceMap3Builder(null, jsCode::getColumn, sourceMapPrefix)
|
||||
|
||||
val pathResolver = SourceFilePathResolver.create(sourceMapsInfo.sourceRoots, sourceMapPrefix, sourceMapsInfo.outputDir)
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ class DeadCodeElimination(
|
||||
val sourceMapFile = File(file.outputPath + ".map")
|
||||
val textOutput = TextOutputImpl()
|
||||
val outputFile = File(file.outputPath)
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput, "")
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput::getColumn, "")
|
||||
|
||||
val inputFile = File(file.resource.name)
|
||||
val sourceBaseDir = if (inputFile.exists()) inputFile.parentFile else File(".")
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.function.Supplier
|
||||
|
||||
class SourceMap3Builder(
|
||||
private val generatedFile: File?,
|
||||
private val textOutput: TextOutput,
|
||||
private val getCurrentOutputColumn: () -> Int,
|
||||
private val pathPrefix: String
|
||||
) : SourceMapBuilder {
|
||||
|
||||
@@ -169,13 +169,16 @@ class SourceMap3Builder(
|
||||
if (newGroupStarted) {
|
||||
previousGeneratedColumn = 0
|
||||
}
|
||||
val columnDiff = textOutput.column - previousGeneratedColumn
|
||||
|
||||
val column = getCurrentOutputColumn()
|
||||
|
||||
val columnDiff = column - previousGeneratedColumn
|
||||
if (!newGroupStarted) {
|
||||
out.append(',')
|
||||
}
|
||||
if (columnDiff > 0 || newGroupStarted) {
|
||||
Base64VLQ.encode(out, columnDiff)
|
||||
previousGeneratedColumn = textOutput.column
|
||||
previousGeneratedColumn = column
|
||||
|
||||
previousMappingOffset = out.length
|
||||
previousPreviousSourceIndex = previousSourceIndex
|
||||
|
||||
@@ -59,7 +59,7 @@ class JsSourceMapHandler(testServices: TestServices) : JsBinaryArtifactHandler(t
|
||||
|
||||
val output = TextOutputImpl()
|
||||
val pathResolver = SourceFilePathResolver(mutableListOf(File(".")), null)
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, output, "")
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, output::getColumn, "")
|
||||
generatedProgram.accept(
|
||||
JsToStringGenerationVisitor(
|
||||
output, SourceMapBuilderConsumer(File("."), sourceMapBuilder, pathResolver, false, false)
|
||||
|
||||
@@ -117,7 +117,7 @@ abstract class TranslationResult protected constructor(val diagnostics: Diagnost
|
||||
override fun getOutputFiles(outputFile: File, outputPrefixFile: File?, outputPostfixFile: File?): OutputFileCollection {
|
||||
val output = TextOutputImpl()
|
||||
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, output, config.sourceMapPrefix)
|
||||
val sourceMapBuilder = SourceMap3Builder(outputFile, output::getColumn, config.sourceMapPrefix)
|
||||
val sourceMapBuilderConsumer =
|
||||
if (config.configuration.getBoolean(JSConfigurationKeys.SOURCE_MAP)) {
|
||||
val sourceMapContentEmbedding = config.sourceMapContentEmbedding
|
||||
|
||||
Reference in New Issue
Block a user