From 7874b1fcad1d460d1c20b78483a616e6c299644a Mon Sep 17 00:00:00 2001 From: Sergej Jaskiewicz Date: Fri, 2 Sep 2022 18:37:39 +0200 Subject: [PATCH] [JS] Rename JsLocation.identityObject to fileIdentity --- .../ir/backend/js/transformers/irToJs/jsAstUtils.kt | 2 +- .../org/jetbrains/kotlin/js/backend/ast/JsLocation.kt | 10 +++++++--- .../kotlin/js/sourceMap/SourceMap3Builder.java | 4 ++-- .../kotlin/js/sourceMap/SourceMapBuilderConsumer.kt | 2 +- .../kotlin/js/sourceMap/SourceMapMappingConsumer.java | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt index 422001fcdad..e11189bf179 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt @@ -516,7 +516,7 @@ private inline fun T.addSourceInfoIfNeed(node: IrElement, context: private fun JsLocation.withEmbeddedSource( context: JsGenerationContext -) = JsLocationWithEmbeddedSource(this, identityObject = context.currentFile) { +) = JsLocationWithEmbeddedSource(this, fileIdentity = context.currentFile) { try { InputStreamReader(FileInputStream(file), StandardCharsets.UTF_8) } catch (e: IOException) { diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsLocation.kt b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsLocation.kt index 0ccd76f85ba..89c4f333eb2 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsLocation.kt +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsLocation.kt @@ -23,7 +23,7 @@ data class JsLocation( override val startLine: Int, override val startChar: Int ) : JsLocationWithSource { - override val identityObject: Any? + override val fileIdentity: Any? get() = null override val sourceProvider: () -> Reader? get() = { null } @@ -35,7 +35,11 @@ interface JsLocationWithSource { val file: String val startLine: Int val startChar: Int - val identityObject: Any? + + /** + * An object to distinguish different files with the same paths + */ + val fileIdentity: Any? val sourceProvider: () -> Reader? fun asSimpleLocation(): JsLocation @@ -43,6 +47,6 @@ interface JsLocationWithSource { class JsLocationWithEmbeddedSource( private val location: JsLocation, - override val identityObject: Any?, + override val fileIdentity: Any?, override val sourceProvider: () -> Reader? ) : JsLocationWithSource by location diff --git a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java index 2eebefe1dca..27727280d62 100644 --- a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java +++ b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java @@ -122,11 +122,11 @@ public class SourceMap3Builder implements SourceMapBuilder { @Override public void addMapping( - @NotNull String source, @Nullable Object identityObject, @NotNull Supplier sourceContent, + @NotNull String source, @Nullable Object sourceFileIdentity, @NotNull Supplier sourceContent, int sourceLine, int sourceColumn ) { source = source.replace(File.separatorChar, '/'); - int sourceIndex = getSourceIndex(source, identityObject, sourceContent); + int sourceIndex = getSourceIndex(source, sourceFileIdentity, sourceContent); if (!currentMappingIsEmpty && previousSourceIndex == sourceIndex && previousSourceLine == sourceLine && previousSourceColumn == sourceColumn) { diff --git a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt index aeabdee5f0a..2bb0f566f76 100644 --- a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt +++ b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapBuilderConsumer.kt @@ -81,7 +81,7 @@ class SourceMapBuilderConsumer( } mappingConsumer.addMapping( path, - sourceInfo.identityObject, + sourceInfo.fileIdentity, contentSupplier, sourceInfo.startLine, sourceInfo.startChar diff --git a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapMappingConsumer.java b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapMappingConsumer.java index d2294bcfdff..067151fe9e6 100644 --- a/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapMappingConsumer.java +++ b/js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMapMappingConsumer.java @@ -15,7 +15,7 @@ public interface SourceMapMappingConsumer { void newLine(); void addMapping( - @NotNull String source, @Nullable Object sourceIdentity, @NotNull Supplier sourceSupplier, + @NotNull String source, @Nullable Object fileIdentity, @NotNull Supplier sourceSupplier, int sourceLine, int sourceColumn );