[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 sourceMapFile = File(outputFile.parentFile, outputFile.name + ".map")
|
||||||
val textOutput = TextOutputImpl()
|
val textOutput = TextOutputImpl()
|
||||||
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput, "")
|
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput::getColumn, "")
|
||||||
val consumer = SourceMapBuilderConsumer(
|
val consumer = SourceMapBuilderConsumer(
|
||||||
File("."),
|
File("."),
|
||||||
sourceMapBuilder,
|
sourceMapBuilder,
|
||||||
|
|||||||
+1
-1
@@ -461,7 +461,7 @@ fun generateSingleWrappedModuleBody(
|
|||||||
val sourceMapBuilderConsumer: SourceLocationConsumer
|
val sourceMapBuilderConsumer: SourceLocationConsumer
|
||||||
if (sourceMapsInfo != null) {
|
if (sourceMapsInfo != null) {
|
||||||
val sourceMapPrefix = sourceMapsInfo.sourceMapPrefix
|
val sourceMapPrefix = sourceMapsInfo.sourceMapPrefix
|
||||||
sourceMapBuilder = SourceMap3Builder(null, jsCode, sourceMapPrefix)
|
sourceMapBuilder = SourceMap3Builder(null, jsCode::getColumn, sourceMapPrefix)
|
||||||
|
|
||||||
val pathResolver = SourceFilePathResolver.create(sourceMapsInfo.sourceRoots, sourceMapPrefix, sourceMapsInfo.outputDir)
|
val pathResolver = SourceFilePathResolver.create(sourceMapsInfo.sourceRoots, sourceMapPrefix, sourceMapsInfo.outputDir)
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class DeadCodeElimination(
|
|||||||
val sourceMapFile = File(file.outputPath + ".map")
|
val sourceMapFile = File(file.outputPath + ".map")
|
||||||
val textOutput = TextOutputImpl()
|
val textOutput = TextOutputImpl()
|
||||||
val outputFile = File(file.outputPath)
|
val outputFile = File(file.outputPath)
|
||||||
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput, "")
|
val sourceMapBuilder = SourceMap3Builder(outputFile, textOutput::getColumn, "")
|
||||||
|
|
||||||
val inputFile = File(file.resource.name)
|
val inputFile = File(file.resource.name)
|
||||||
val sourceBaseDir = if (inputFile.exists()) inputFile.parentFile else File(".")
|
val sourceBaseDir = if (inputFile.exists()) inputFile.parentFile else File(".")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.function.Supplier
|
|||||||
|
|
||||||
class SourceMap3Builder(
|
class SourceMap3Builder(
|
||||||
private val generatedFile: File?,
|
private val generatedFile: File?,
|
||||||
private val textOutput: TextOutput,
|
private val getCurrentOutputColumn: () -> Int,
|
||||||
private val pathPrefix: String
|
private val pathPrefix: String
|
||||||
) : SourceMapBuilder {
|
) : SourceMapBuilder {
|
||||||
|
|
||||||
@@ -169,13 +169,16 @@ class SourceMap3Builder(
|
|||||||
if (newGroupStarted) {
|
if (newGroupStarted) {
|
||||||
previousGeneratedColumn = 0
|
previousGeneratedColumn = 0
|
||||||
}
|
}
|
||||||
val columnDiff = textOutput.column - previousGeneratedColumn
|
|
||||||
|
val column = getCurrentOutputColumn()
|
||||||
|
|
||||||
|
val columnDiff = column - previousGeneratedColumn
|
||||||
if (!newGroupStarted) {
|
if (!newGroupStarted) {
|
||||||
out.append(',')
|
out.append(',')
|
||||||
}
|
}
|
||||||
if (columnDiff > 0 || newGroupStarted) {
|
if (columnDiff > 0 || newGroupStarted) {
|
||||||
Base64VLQ.encode(out, columnDiff)
|
Base64VLQ.encode(out, columnDiff)
|
||||||
previousGeneratedColumn = textOutput.column
|
previousGeneratedColumn = column
|
||||||
|
|
||||||
previousMappingOffset = out.length
|
previousMappingOffset = out.length
|
||||||
previousPreviousSourceIndex = previousSourceIndex
|
previousPreviousSourceIndex = previousSourceIndex
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class JsSourceMapHandler(testServices: TestServices) : JsBinaryArtifactHandler(t
|
|||||||
|
|
||||||
val output = TextOutputImpl()
|
val output = TextOutputImpl()
|
||||||
val pathResolver = SourceFilePathResolver(mutableListOf(File(".")), null)
|
val pathResolver = SourceFilePathResolver(mutableListOf(File(".")), null)
|
||||||
val sourceMapBuilder = SourceMap3Builder(outputFile, output, "")
|
val sourceMapBuilder = SourceMap3Builder(outputFile, output::getColumn, "")
|
||||||
generatedProgram.accept(
|
generatedProgram.accept(
|
||||||
JsToStringGenerationVisitor(
|
JsToStringGenerationVisitor(
|
||||||
output, SourceMapBuilderConsumer(File("."), sourceMapBuilder, pathResolver, false, false)
|
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 {
|
override fun getOutputFiles(outputFile: File, outputPrefixFile: File?, outputPostfixFile: File?): OutputFileCollection {
|
||||||
val output = TextOutputImpl()
|
val output = TextOutputImpl()
|
||||||
|
|
||||||
val sourceMapBuilder = SourceMap3Builder(outputFile, output, config.sourceMapPrefix)
|
val sourceMapBuilder = SourceMap3Builder(outputFile, output::getColumn, config.sourceMapPrefix)
|
||||||
val sourceMapBuilderConsumer =
|
val sourceMapBuilderConsumer =
|
||||||
if (config.configuration.getBoolean(JSConfigurationKeys.SOURCE_MAP)) {
|
if (config.configuration.getBoolean(JSConfigurationKeys.SOURCE_MAP)) {
|
||||||
val sourceMapContentEmbedding = config.sourceMapContentEmbedding
|
val sourceMapContentEmbedding = config.sourceMapContentEmbedding
|
||||||
|
|||||||
Reference in New Issue
Block a user