Properly parse smap information
#KT-23369 Fixed
This commit is contained in:
@@ -42,25 +42,24 @@ object SMAPParser {
|
|||||||
fun parse(mappingInfo: String): SMAP {
|
fun parse(mappingInfo: String): SMAP {
|
||||||
val fileMappings = linkedMapOf<Int, FileMapping>()
|
val fileMappings = linkedMapOf<Int, FileMapping>()
|
||||||
|
|
||||||
val fileSectionStart = mappingInfo.indexOf(SMAP.FILE_SECTION) + SMAP.FILE_SECTION.length
|
val iterator = mappingInfo.lineSequence().dropWhile { it.trim() != SMAP.FILE_SECTION }.drop(1).iterator()
|
||||||
val lineSectionAnchor = mappingInfo.indexOf(SMAP.LINE_SECTION)
|
while (iterator.hasNext()) {
|
||||||
val files = mappingInfo.substring(fileSectionStart, lineSectionAnchor)
|
val fileDeclaration = iterator.next().trim()
|
||||||
|
if (fileDeclaration == SMAP.LINE_SECTION) break
|
||||||
|
|
||||||
val fileEntries = files.trim().split('+')
|
if (!fileDeclaration.startsWith('+')) {
|
||||||
|
throw AssertionError("File declaration should be in extended form, but: $fileDeclaration in $mappingInfo")
|
||||||
|
}
|
||||||
|
|
||||||
for (fileDeclaration in fileEntries) {
|
val indexAndFileInternalName = fileDeclaration.substringAfter("+ ").trim()
|
||||||
if (fileDeclaration == "") continue
|
val fileIndex = indexAndFileInternalName.substringBefore(' ').toInt()
|
||||||
val fileInternalName = fileDeclaration.trim()
|
val fileName = indexAndFileInternalName.substringAfter(' ')
|
||||||
|
val path = iterator.next().trim()
|
||||||
val indexEnd = fileInternalName.indexOf(' ')
|
fileMappings[fileIndex] = FileMapping(fileName, path)
|
||||||
val fileIndex = fileInternalName.substring(0, indexEnd).toInt()
|
|
||||||
val newLine = fileInternalName.indexOf('\n')
|
|
||||||
val fileName = fileInternalName.substring(indexEnd + 1, newLine)
|
|
||||||
fileMappings[fileIndex] = FileMapping(fileName, fileInternalName.substring(newLine + 1).trim())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val lines = mappingInfo.substring(lineSectionAnchor + SMAP.LINE_SECTION.length, mappingInfo.indexOf(SMAP.END)).trim().split('\n')
|
for (lineMapping in iterator) {
|
||||||
for (lineMapping in lines) {
|
if (lineMapping.trim() == SMAP.END) break
|
||||||
/*only simple mapping now*/
|
/*only simple mapping now*/
|
||||||
val targetSplit = lineMapping.indexOf(':')
|
val targetSplit = lineMapping.indexOf(':')
|
||||||
val originalPart = lineMapping.substring(0, targetSplit)
|
val originalPart = lineMapping.substring(0, targetSplit)
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// FILE: 1+a.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline fun inlineFun(lambda: () -> String): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun { "OK" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1+a.smap
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 1+a.kt
|
||||||
|
test/_1_aKt
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
6#2:9
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
5#1:9
|
||||||
|
*E
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// FILE: 1+ a.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline fun inlineFun(lambda: () -> String): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun { "OK" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1+ a.smap
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 1+ a.kt
|
||||||
|
test/_1__aKt
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
6#2:9
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
5#1:9
|
||||||
|
*E
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// FILE: + a.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline fun inlineFun(lambda: () -> String): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun { "OK" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: + a.smap
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 + a.kt
|
||||||
|
test/__aKt
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
6#2:9
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
5#1:9
|
||||||
|
*E
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// FILE: 1*E.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline fun inlineFun(lambda: () -> String): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun { "OK" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1+a.smap
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 1*E.kt
|
||||||
|
test/_1_EKt
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
6#2:9
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
5#1:9
|
||||||
|
*E
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// FILE: 1*F.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline fun inlineFun(lambda: () -> String): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun { "OK" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1+a.smap
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 1*F.kt
|
||||||
|
test/_1_FKt
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
6#2:9
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
5#1:9
|
||||||
|
*E
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// FILE: 1*L.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline fun inlineFun(lambda: () -> String): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun { "OK" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1+a.smap
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 1*L.kt
|
||||||
|
test/_1_LKt
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
6#2:9
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
5#1:9
|
||||||
|
*E
|
||||||
+30
@@ -2841,6 +2841,36 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369.kt")
|
||||||
|
public void testKt23369() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_2.kt")
|
||||||
|
public void testKt23369_2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_3.kt")
|
||||||
|
public void testKt23369_3() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_E.kt")
|
||||||
|
public void testKt23369_E() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_E.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_F.kt")
|
||||||
|
public void testKt23369_F() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_F.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_L.kt")
|
||||||
|
public void testKt23369_L() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_L.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("oneFile.kt")
|
@TestMetadata("oneFile.kt")
|
||||||
public void testOneFile() throws Exception {
|
public void testOneFile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
runTest("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
||||||
|
|||||||
Generated
+30
@@ -2841,6 +2841,36 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369.kt")
|
||||||
|
public void testKt23369() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_2.kt")
|
||||||
|
public void testKt23369_2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_3.kt")
|
||||||
|
public void testKt23369_3() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_E.kt")
|
||||||
|
public void testKt23369_E() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_E.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_F.kt")
|
||||||
|
public void testKt23369_F() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_F.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_L.kt")
|
||||||
|
public void testKt23369_L() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_L.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("oneFile.kt")
|
@TestMetadata("oneFile.kt")
|
||||||
public void testOneFile() throws Exception {
|
public void testOneFile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
runTest("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
||||||
|
|||||||
+30
@@ -2841,6 +2841,36 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
|||||||
runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
runTest("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369.kt")
|
||||||
|
public void testKt23369() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_2.kt")
|
||||||
|
public void testKt23369_2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_3.kt")
|
||||||
|
public void testKt23369_3() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_E.kt")
|
||||||
|
public void testKt23369_E() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_E.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_F.kt")
|
||||||
|
public void testKt23369_F() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_F.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt23369_L.kt")
|
||||||
|
public void testKt23369_L() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/smap/kt23369_L.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("oneFile.kt")
|
@TestMetadata("oneFile.kt")
|
||||||
public void testOneFile() throws Exception {
|
public void testOneFile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
runTest("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user