[JS] Support the 'names' field in sourcemaps
This commit is contained in:
committed by
Space Team
parent
227864c6ec
commit
1d0025c3cf
+4
-4
@@ -522,17 +522,17 @@ object JsAstUtils {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T : JsNode> T.withSource(node: IrElement, context: JsGenerationContext): T {
|
||||
addSourceInfoIfNeed(node, context)
|
||||
internal fun <T : JsNode> T.withSource(node: IrElement, context: JsGenerationContext, originalName: String? = null): T {
|
||||
addSourceInfoIfNeed(node, context, originalName)
|
||||
return this
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun <T : JsNode> T.addSourceInfoIfNeed(node: IrElement, context: JsGenerationContext) {
|
||||
private inline fun <T : JsNode> T.addSourceInfoIfNeed(node: IrElement, context: JsGenerationContext, originalName: String?) {
|
||||
|
||||
val sourceMapsInfo = context.staticContext.backendContext.sourceMapsInfo ?: return
|
||||
|
||||
val location = context.getLocationForIrElement(node) ?: return
|
||||
val location = context.getLocationForIrElement(node, originalName) ?: return
|
||||
|
||||
val isNodeFromCurrentModule = context.currentFile.module.descriptor == context.staticContext.backendContext.module
|
||||
|
||||
|
||||
+2
-2
@@ -87,9 +87,9 @@ class JsGenerationContext(
|
||||
|
||||
fun checkIfHasAssociatedJsCode(symbol: IrFunctionSymbol): Boolean = staticContext.backendContext.getJsCodeForFunction(symbol) != null
|
||||
|
||||
fun getLocationForIrElement(irElement: IrElement): JsLocation? {
|
||||
fun getLocationForIrElement(irElement: IrElement, originalName: String? = null): JsLocation? {
|
||||
return locationCache.getOrPut(irElement.startOffset) {
|
||||
irElement.getSourceInfo(currentFile.fileEntry) ?: return null
|
||||
}
|
||||
}.copy(name = originalName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user