[JS IR] Don't set fileIdentity when embedding sources into sourcemaps
(see the comment)
This commit is contained in:
+16
-7
@@ -515,14 +515,23 @@ private inline fun <T : JsNode> T.addSourceInfoIfNeed(node: IrElement, context:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun JsLocation.withEmbeddedSource(
|
private fun JsLocation.withEmbeddedSource(
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
context: JsGenerationContext
|
context: JsGenerationContext
|
||||||
) = JsLocationWithEmbeddedSource(this, fileIdentity = context.currentFile) {
|
): JsLocationWithEmbeddedSource {
|
||||||
try {
|
// FIXME: fileIdentity is used to distinguish between different files with the same paths.
|
||||||
InputStreamReader(FileInputStream(file), StandardCharsets.UTF_8)
|
// For now we use the file's path to read its content, which makes fileIdentity useless.
|
||||||
} catch (e: IOException) {
|
// However, when we have a mechanism to reliably get the source code from an IrFile or IrFileEntry no matter what's stored
|
||||||
// TODO: If the source file is not available at path (e. g. it's an stdlib file), use heuristics to find it.
|
// in fileEntry.name (including the source code for external libraries or klibs with relative paths in them).
|
||||||
// If all heuristics fail, use dumpKotlinLike() on freshly deserialized IrFile.
|
// Another issue is that JS AST serializer/deserializer ignores fileIdentity, which means that this will not work with incremental
|
||||||
null
|
// compilation.
|
||||||
|
return JsLocationWithEmbeddedSource(this, fileIdentity = null /*context.currentFile.fileEntry*/) {
|
||||||
|
try {
|
||||||
|
InputStreamReader(FileInputStream(file), StandardCharsets.UTF_8)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
// TODO: If the source file is not available at path (e. g. it's an stdlib file), use heuristics to find it.
|
||||||
|
// If all heuristics fail, use dumpKotlinLike() on freshly deserialized IrFile.
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user