diff --git a/compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt b/compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt index 0cb7ee0dfd4..6427ee7de86 100644 --- a/compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt +++ b/compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt @@ -10,4 +10,4 @@ fun testSome(): Boolean { return false } -// 2 3 4 2 7 10 \ No newline at end of file +// 2 +3 4 2 7 10 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/callWithReceiver.kt b/compiler/testData/lineNumber/custom/callWithReceiver.kt index cc64eb25e64..69c92dad789 100644 --- a/compiler/testData/lineNumber/custom/callWithReceiver.kt +++ b/compiler/testData/lineNumber/custom/callWithReceiver.kt @@ -12,4 +12,4 @@ fun foo() { .bar() } -// 2 3 1 7 8 9 8 9 11 12 11 12 17 13 +// 2 3 1 7 8 +9 +8 9 11 +12 +11 12 16 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/chainCall.kt b/compiler/testData/lineNumber/custom/chainCall.kt index 102d3473811..0046cec9a9f 100644 --- a/compiler/testData/lineNumber/custom/chainCall.kt +++ b/compiler/testData/lineNumber/custom/chainCall.kt @@ -12,4 +12,4 @@ fun foo() { .bar() } -// 2 3 1 7 8 9 8 9 11 12 11 17 12 18 13 +// 2 3 1 7 8 +9 +8 9 11 +12 +11 16 12 17 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/compileTimeConstant.kt b/compiler/testData/lineNumber/custom/compileTimeConstant.kt index ef023d32f0c..4146efee5fd 100644 --- a/compiler/testData/lineNumber/custom/compileTimeConstant.kt +++ b/compiler/testData/lineNumber/custom/compileTimeConstant.kt @@ -3,4 +3,4 @@ fun foo() { 42 } -// 2 3 2 4 +// 2 +3 2 4 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/functionCallWithDefault.kt b/compiler/testData/lineNumber/custom/functionCallWithDefault.kt index 525d51f47b4..8a3b82e3ff7 100644 --- a/compiler/testData/lineNumber/custom/functionCallWithDefault.kt +++ b/compiler/testData/lineNumber/custom/functionCallWithDefault.kt @@ -9,4 +9,4 @@ fun foo(i: Int = 1) { inline fun bar(i: Int = 1) { } -// 2 3 14 15 4 7 6 10 9 16 +// 2 3 13 14 +4 7 6 10 9 15 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt b/compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt index d644367916d..53b0cf92b11 100644 --- a/compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt +++ b/compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt @@ -13,4 +13,4 @@ inline fun foo(f: () -> Unit) { f() } -// 2 18 19 3 4 20 6 21 22 7 8 23 9 12 13 14 +// 2 17 18 +3 4 19 +6 20 21 +7 8 22 +9 12 13 14 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/ifThenElse.kt b/compiler/testData/lineNumber/custom/ifThenElse.kt index 066417809fd..fff753e0222 100644 --- a/compiler/testData/lineNumber/custom/ifThenElse.kt +++ b/compiler/testData/lineNumber/custom/ifThenElse.kt @@ -12,4 +12,4 @@ fun foo() { } } -// 2 3 5 6 8 9 11 8 13 +// 2 3 5 6 +8 9 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/tryCatchExpression.kt b/compiler/testData/lineNumber/custom/tryCatchExpression.kt index c1929e12c21..c2955009952 100644 --- a/compiler/testData/lineNumber/custom/tryCatchExpression.kt +++ b/compiler/testData/lineNumber/custom/tryCatchExpression.kt @@ -12,4 +12,4 @@ fun foo() { } } -// 2 3 4 5 6 8 9 10 11 8 13 \ No newline at end of file +// 2 3 4 5 6 +8 9 10 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/tryCatchFinally.kt b/compiler/testData/lineNumber/custom/tryCatchFinally.kt index e418cae339f..75e8a0ac02d 100644 --- a/compiler/testData/lineNumber/custom/tryCatchFinally.kt +++ b/compiler/testData/lineNumber/custom/tryCatchFinally.kt @@ -16,4 +16,4 @@ fun foo() { } } -// 2 3 7 4 5 7 8 10 11 15 12 13 15 10 17 \ No newline at end of file +// 2 3 7 4 5 7 8 +10 11 15 12 13 15 10 17 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/tryFinally.kt b/compiler/testData/lineNumber/custom/tryFinally.kt index ccf48210009..5d635e59a93 100644 --- a/compiler/testData/lineNumber/custom/tryFinally.kt +++ b/compiler/testData/lineNumber/custom/tryFinally.kt @@ -12,4 +12,4 @@ fun foo() { } } -// 2 3 5 6 8 9 11 8 13 +// 2 3 5 6 +8 9 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/when.kt b/compiler/testData/lineNumber/custom/when.kt index b8ead48506d..b18edc1199e 100644 --- a/compiler/testData/lineNumber/custom/when.kt +++ b/compiler/testData/lineNumber/custom/when.kt @@ -12,4 +12,4 @@ fun foo(x: Int) { } } -// 2 3 4 5 6 8 9 10 11 8 13 +// 2 +3 4 5 6 +8 +9 10 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/whenSubject.kt b/compiler/testData/lineNumber/custom/whenSubject.kt index 728a6301724..5fc3bf18896 100644 --- a/compiler/testData/lineNumber/custom/whenSubject.kt +++ b/compiler/testData/lineNumber/custom/whenSubject.kt @@ -12,4 +12,4 @@ fun foo(x: Int) { } } -// 2 3 4 5 6 8 9 10 11 8 13 +// 2 3 4 5 6 +8 9 10 11 8 13 \ No newline at end of file diff --git a/compiler/tests-common/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.java b/compiler/tests-common/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.java index 6c387dd72a1..82e96fd7d7b 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.java +++ b/compiler/tests-common/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.java @@ -37,14 +37,10 @@ import org.jetbrains.org.objectweb.asm.*; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.jetbrains.kotlin.codegen.CodegenTestUtil.generateFiles; - public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir { private static final String LINE_NUMBER_FUN = "lineNumber"; private static final Pattern TEST_LINE_NUMBER_PATTERN = Pattern.compile("^.*test." + LINE_NUMBER_FUN + "\\(\\).*$"); @@ -101,14 +97,14 @@ public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir { try { if (custom) { - List actualLineNumbers = extractActualLineNumbersFromBytecode(classFileFactory, false); + List actualLineNumbers = extractActualLineNumbersFromBytecode(classFileFactory, false); String text = psiFile.getText(); String newFileText = text.substring(0, text.indexOf("// ")) + getActualLineNumbersAsString(actualLineNumbers); KotlinTestUtils.assertEqualsToFile(new File(filename), newFileText); } else { - List expectedLineNumbers = extractSelectedLineNumbersFromSource(psiFile); - List actualLineNumbers = extractActualLineNumbersFromBytecode(classFileFactory, true); + List expectedLineNumbers = extractSelectedLineNumbersFromSource(psiFile); + List actualLineNumbers = extractActualLineNumbersFromBytecode(classFileFactory, true); assertSameElements(actualLineNumbers, expectedLineNumbers); } } catch (Throwable e) { @@ -118,22 +114,22 @@ public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir { } - private static String getActualLineNumbersAsString(List list) { - return CollectionsKt.joinToString(list, " ", "// ", "", -1, "...", new Function1() { + private static String getActualLineNumbersAsString(List lines) { + return CollectionsKt.joinToString(lines, " ", "// ", "", -1, "...", new Function1() { @Override - public CharSequence invoke(Integer integer) { - return integer.toString(); + public CharSequence invoke(String lineNumber) { + return lineNumber; } }); } @NotNull - private static List extractActualLineNumbersFromBytecode(@NotNull ClassFileFactory factory, boolean testFunInvoke) { - List actualLineNumbers = Lists.newArrayList(); + private static List extractActualLineNumbersFromBytecode(@NotNull ClassFileFactory factory, boolean testFunInvoke) { + List actualLineNumbers = Lists.newArrayList(); for (OutputFile outputFile : ClassFileUtilsKt.getClassFiles(factory)) { ClassReader cr = new ClassReader(outputFile.asByteArray()); try { - List lineNumbers = testFunInvoke ? readTestFunLineNumbers(cr) : readAllLineNumbers(cr); + List lineNumbers = testFunInvoke ? readTestFunLineNumbers(cr) : readAllLineNumbers(cr); actualLineNumbers.addAll(lineNumbers); } catch (Throwable e) { @@ -154,15 +150,15 @@ public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir { } @NotNull - private static List extractSelectedLineNumbersFromSource(@NotNull KtFile file) { + private static List extractSelectedLineNumbersFromSource(@NotNull KtFile file) { String fileContent = file.getText(); - List lineNumbers = Lists.newArrayList(); + List lineNumbers = Lists.newArrayList(); String[] lines = StringUtil.convertLineSeparators(fileContent).split("\n"); for (int i = 0; i < lines.length; i++) { Matcher matcher = TEST_LINE_NUMBER_PATTERN.matcher(lines[i]); if (matcher.matches()) { - lineNumbers.add(i + 1); + lineNumbers.add(Integer.toString(i + 1)); } } @@ -170,9 +166,9 @@ public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir { } @NotNull - private static List readTestFunLineNumbers(@NotNull ClassReader cr) { + private static List readTestFunLineNumbers(@NotNull ClassReader cr) { final List