diff --git a/plugins/kotlin/highlighting/test/org/jetbrains/kotlin/idea/k2/highlighting/K2HighlightExitPointsTestGenerated.java b/plugins/kotlin/highlighting/test/org/jetbrains/kotlin/idea/k2/highlighting/K2HighlightExitPointsTestGenerated.java index c679b22e1d0b..73039bfee0fd 100644 --- a/plugins/kotlin/highlighting/test/org/jetbrains/kotlin/idea/k2/highlighting/K2HighlightExitPointsTestGenerated.java +++ b/plugins/kotlin/highlighting/test/org/jetbrains/kotlin/idea/k2/highlighting/K2HighlightExitPointsTestGenerated.java @@ -33,24 +33,29 @@ public class K2HighlightExitPointsTestGenerated extends AbstractK2HighlightExitP runTest("../idea/tests/testData/exitPoints/anonymousFunction2.kt"); } - @TestMetadata("functionNameIdentifier.kt") - public void testFunctionNameIdentifier() throws Exception { - runTest("../idea/tests/testData/exitPoints/functionNameIdentifier.kt"); + @TestMetadata("funKeyword.kt") + public void testFunKeyword() throws Exception { + runTest("../idea/tests/testData/exitPoints/funKeyword.kt"); } - @TestMetadata("functionNameIdentifier2.kt") - public void testFunctionNameIdentifier2() throws Exception { - runTest("../idea/tests/testData/exitPoints/functionNameIdentifier2.kt"); + @TestMetadata("funKeyword2.kt") + public void testFunKeyword2() throws Exception { + runTest("../idea/tests/testData/exitPoints/funKeyword2.kt"); } - @TestMetadata("functionNameIdentifier3.kt") - public void testFunctionNameIdentifier3() throws Exception { - runTest("../idea/tests/testData/exitPoints/functionNameIdentifier3.kt"); + @TestMetadata("funKeyword3.kt") + public void testFunKeyword3() throws Exception { + runTest("../idea/tests/testData/exitPoints/funKeyword3.kt"); } - @TestMetadata("functionNameIdentifier31.kt") - public void testFunctionNameIdentifier31() throws Exception { - runTest("../idea/tests/testData/exitPoints/functionNameIdentifier31.kt"); + @TestMetadata("funKeyword31.kt") + public void testFunKeyword31() throws Exception { + runTest("../idea/tests/testData/exitPoints/funKeyword31.kt"); + } + + @TestMetadata("funName.kt") + public void testFunName() throws Exception { + runTest("../idea/tests/testData/exitPoints/funName.kt"); } @TestMetadata("getter.kt") diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt index 5352d56794a1..c18353b805c2 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt @@ -2,24 +2,41 @@ package org.jetbrains.kotlin.idea.highlighter +import com.intellij.codeInsight.daemon.impl.HighlightInfo +import com.intellij.codeInsight.daemon.impl.HighlightInfoType import com.intellij.codeInsight.highlighting.HighlightUsagesHandler import com.intellij.codeInsight.highlighting.highlightUsages import com.intellij.openapi.application.ReadAction import com.intellij.openapi.editor.colors.EditorColors -import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.project.DumbService import com.intellij.psi.PsiElement +import com.intellij.refactoring.suggested.range +import com.intellij.testFramework.ExpectedHighlightingData import com.intellij.util.concurrency.AppExecutorUtil -import org.jetbrains.kotlin.idea.test.InTextDirectivesUtils import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.extractMarkerOffset import java.util.concurrent.Callable abstract class AbstractHighlightExitPointsTest : KotlinLightCodeInsightFixtureTestCase() { + companion object { + // Not standard to leave it in text after configureByFile and remove manually after collecting highlighting information + const val CARET_TAG = "~" + } + open fun doTest(unused: String) { myFixture.configureByFile(fileName()) val editor = myFixture.editor + + val document = myFixture.editor.document + val data = ExpectedHighlightingData(document, false, false, true, false) + data.init() + + val caret = document.extractMarkerOffset(project, CARET_TAG) + assert(caret != -1) { "Caret marker '${CARET_TAG}' expected" } + editor.caretModel.moveToOffset(caret) + val customHandler = HighlightUsagesHandler.createCustomHandler(editor, myFixture.file) @@ -34,13 +51,23 @@ abstract class AbstractHighlightExitPointsTest : KotlinLightCodeInsightFixtureTe }) } - val text = myFixture.file.text - val expectedToBeHighlighted = InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "//HIGHLIGHTED:") - val searchResultsTextAttributes = - EditorColorsManager.getInstance().globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES) - val highlighters = editor.markupModel.allHighlighters - .filter { it.textAttributes == searchResultsTextAttributes } - val actual = highlighters.map { text.substring(it.startOffset, it.endOffset) } - assertEquals(expectedToBeHighlighted, actual) + val ranges = editor.markupModel.allHighlighters + .filter { it.textAttributesKey == EditorColors.SEARCH_RESULT_ATTRIBUTES } + .mapNotNull { it.range } + + val infos = ranges.toHashSet() + .map { + var startOffset = it.startOffset + var endOffset = it.endOffset + + if (startOffset > caret) startOffset += CARET_TAG.length + if (endOffset > caret) endOffset += CARET_TAG.length + + HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION) + .range(startOffset, endOffset) + .create() + } + + data.checkResult(myFixture.file, infos, StringBuilder(document.text).insert(caret, CARET_TAG).toString()) } } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/HighlightExitPointsTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/HighlightExitPointsTestGenerated.java index a7c2adab290a..9e804281ca90 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/HighlightExitPointsTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/highlighter/HighlightExitPointsTestGenerated.java @@ -33,24 +33,29 @@ public class HighlightExitPointsTestGenerated extends AbstractHighlightExitPoint runTest("testData/exitPoints/anonymousFunction2.kt"); } - @TestMetadata("functionNameIdentifier.kt") - public void testFunctionNameIdentifier() throws Exception { - runTest("testData/exitPoints/functionNameIdentifier.kt"); + @TestMetadata("funKeyword.kt") + public void testFunKeyword() throws Exception { + runTest("testData/exitPoints/funKeyword.kt"); } - @TestMetadata("functionNameIdentifier2.kt") - public void testFunctionNameIdentifier2() throws Exception { - runTest("testData/exitPoints/functionNameIdentifier2.kt"); + @TestMetadata("funKeyword2.kt") + public void testFunKeyword2() throws Exception { + runTest("testData/exitPoints/funKeyword2.kt"); } - @TestMetadata("functionNameIdentifier3.kt") - public void testFunctionNameIdentifier3() throws Exception { - runTest("testData/exitPoints/functionNameIdentifier3.kt"); + @TestMetadata("funKeyword3.kt") + public void testFunKeyword3() throws Exception { + runTest("testData/exitPoints/funKeyword3.kt"); } - @TestMetadata("functionNameIdentifier31.kt") - public void testFunctionNameIdentifier31() throws Exception { - runTest("testData/exitPoints/functionNameIdentifier31.kt"); + @TestMetadata("funKeyword31.kt") + public void testFunKeyword31() throws Exception { + runTest("testData/exitPoints/funKeyword31.kt"); + } + + @TestMetadata("funName.kt") + public void testFunName() throws Exception { + runTest("testData/exitPoints/funName.kt"); } @TestMetadata("getter.kt") diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction.kt b/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction.kt index fb63e568ca82..adcfb292c51f 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction.kt @@ -1,10 +1,7 @@ fun foo() { - listOf(1, 2, 3, 4, 5).forEach(fun(value: Int) { - if (value == 3) return + listOf(1, 2, 3, 4, 5).forEach(fun(value: Int) { + if (value == 3) ~return print(value) }) print(" done with anonymous function") -} - -//HIGHLIGHTED: fun -//HIGHLIGHTED: return +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction2.kt index efb538fc325c..9a0fd34b00e2 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/anonymousFunction2.kt @@ -1,10 +1,7 @@ fun foo() { - listOf(1, 2, 3, 4, 5).forEach(fun(value: Int) { - if (value == 3) return@forEach + listOf(1, 2, 3, 4, 5).forEach(fun(value: Int) { + if (value == 3) return@~forEach print(value) }) print(" done with anonymous function") -} - -//HIGHLIGHTED: fun -//HIGHLIGHTED: return@forEach +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword.kt b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword.kt new file mode 100644 index 000000000000..daa57303c0e9 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword.kt @@ -0,0 +1,6 @@ +~fun test(s: String?): Int { + if (s != null) { + return@test 1 + } + return 0 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword2.kt new file mode 100644 index 000000000000..cddc9b567890 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword2.kt @@ -0,0 +1,4 @@ +fun~ test(s: String?): Int = + if (s != null) { + 1 + } else 0 diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier3.kt b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword3.kt similarity index 92% rename from plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier3.kt rename to plugins/kotlin/idea/tests/testData/exitPoints/funKeyword3.kt index 87c4523b43d4..96a61ce3a95b 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier3.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword3.kt @@ -1,6 +1,6 @@ fun test(s: String?): Int = if (s != null) { - 1 + 1~ } else 0 // no exit point highlighting as to KTIJ-26395: we should not highlight exit points on the latest statement as it interferes with variable/call/type highlighting \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier31.kt b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword31.kt similarity index 73% rename from plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier31.kt rename to plugins/kotlin/idea/tests/testData/exitPoints/funKeyword31.kt index fe8de5644e28..0a41887107a9 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier31.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/funKeyword31.kt @@ -1,5 +1,5 @@ fun test(s: String?): Int = if (s != null) { - val q = 0 + val q = 0~ 1 } else 0 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/funName.kt b/plugins/kotlin/idea/tests/testData/exitPoints/funName.kt new file mode 100644 index 000000000000..73597f2486e0 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/exitPoints/funName.kt @@ -0,0 +1,6 @@ +fun ~test(s: String?): Int { + if (s != null) { + return@test 1 + } + return 0 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier.kt b/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier.kt deleted file mode 100644 index 68705837c5e4..000000000000 --- a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier.kt +++ /dev/null @@ -1,10 +0,0 @@ -fun test(s: String?): Int { - if (s != null) { - return@test 1 - } - return 0 -} - -//HIGHLIGHTED: return@test 1 -//HIGHLIGHTED: test -//HIGHLIGHTED: return 0 diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier2.kt deleted file mode 100644 index 9a382d23bb5b..000000000000 --- a/plugins/kotlin/idea/tests/testData/exitPoints/functionNameIdentifier2.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun test(s: String?): Int = - if (s != null) { - 1 - } else 0 - -//HIGHLIGHTED: 1 -//HIGHLIGHTED: test -//HIGHLIGHTED: 0 diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/getter.kt b/plugins/kotlin/idea/tests/testData/exitPoints/getter.kt index 28a6ec32037a..f6f2cd72ff4e 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/getter.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/getter.kt @@ -1,13 +1,9 @@ val Any?.foo: Int - get() { + get() { this?.let { - return 1 + ~return 1 } - return 2 + return 2 } -public inline fun T.let(block: (T) -> Unit) {} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: get -//HIGHLIGHTED: return 2 \ No newline at end of file +public inline fun T.let(block: (T) -> Unit) {} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/getter2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/getter2.kt index 755015a05400..50d214c80fea 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/getter2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/getter2.kt @@ -1,9 +1,6 @@ val Any?.foo: Int - get() { - return 42 + get() { + return~ 42 } -public inline fun T.let(block: (T) -> Unit) {} - -//HIGHLIGHTED: get -//HIGHLIGHTED: return 42 +public inline fun T.let(block: (T) -> Unit) {} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/getter3.kt b/plugins/kotlin/idea/tests/testData/exitPoints/getter3.kt index 9cf1bcd089de..b24aa9e437b7 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/getter3.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/getter3.kt @@ -1,9 +1,6 @@ val Any?.foo: Int - get() { - return 42 + get~() { + return 42 } -public inline fun T.let(block: (T) -> Unit) {} - -//HIGHLIGHTED: get -//HIGHLIGHTED: return 42 +public inline fun T.let(block: (T) -> Unit) {} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambda.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambda.kt index f0ba7cb1470c..1c4ca0cfa797 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambda.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambda.kt @@ -1,13 +1,9 @@ fun foo(f: (String?) -> Int) {} fun test() { - foo { - if (it == null) return@foo 1 + foo { + if (it == null) return@~foo 1 (1+1) - if (it == "a") 2 else 0 + if (it == "a") 2 else 0 } -} -//HIGHLIGHTED: return@foo 1 -//HIGHLIGHTED: foo -//HIGHLIGHTED: 2 -//HIGHLIGHTED: 0 \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambda1.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambda1.kt index 43f2354f1723..846424a5028a 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambda1.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambda1.kt @@ -1,11 +1,8 @@ fun foo(f: (String?) -> Int) {} fun test() { - foo { - if (it == null) return@foo 1 - 0 + foo { + if (it == null) return@~foo 1 + 0 } -} -//HIGHLIGHTED: return@foo 1 -//HIGHLIGHTED: foo -//HIGHLIGHTED: 0 \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambda2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambda2.kt index 7cf248a7bc53..6d34dcc48839 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambda2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambda2.kt @@ -3,7 +3,7 @@ fun foo(f: (String?) -> Int) {} fun test() { foo { if (it != null) return@foo 1 - (1+1) + ~(1+1) 0 } } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement1.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement1.kt index 4ad2b2cf60e8..fcc0d1dbd272 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement1.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement1.kt @@ -3,7 +3,7 @@ fun foo(f: (String?) -> Int) {} fun test() { foo { if (it != null) return@foo 1 - 0 + 0~ } } // no exit point highlighting as to KTIJ-26395: we should not highlight exit points on the latest statement as it interferes with variable/call/type highlighting diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement2.kt index fd65c4b6433b..1853e4da8b61 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement2.kt @@ -3,7 +3,7 @@ fun foo(f: (String?) -> Int) {} fun test() { foo { if (it == null) return@foo 1 - if (it == "a") 2 else 0 + if (it == "a") 2~ else 0 } } // no exit point highlighting as to KTIJ-26395: we should not highlight exit points on the latest statement as it interferes with variable/call/type highlighting \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement3.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement3.kt index 605874d3c175..8926737e96c7 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement3.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement3.kt @@ -3,6 +3,6 @@ fun foo(f: (String?) -> Int) {} fun test() { foo { if (it == null) return@foo 1 - if (it == "a") 2 else 0 + if (it == "a") 2 e~lse 0 } } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement4.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement4.kt index 376e212cefb6..d3b16f0cf11d 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement4.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement4.kt @@ -4,7 +4,7 @@ fun test() { foo { if (it != null) return@foo 1 if (it == "a") { - val q = 1 + val q = 1~ 2 } else { 0 diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement5.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement5.kt index b9aa29ed6154..993b923cecc4 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement5.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inLambdaLastStatement5.kt @@ -1,16 +1,14 @@ fun foo(f: (String?) -> Int) {} -fun y(): Int = 11 +fun y(): Int = 11 fun test() { foo { if (it != null) return@foo 1 if (it == "a") { - if (it == "aa") y() else 2 + if (it == "aa") y~() else 2 } else { 0 } } } -// no exit point highlighting as to KTIJ-26395: we should not highlight exit points on the latest statement as it interferes with variable/call/type highlighting -//HIGHLIGHTED: y -//HIGHLIGHTED: y \ No newline at end of file +// no exit point highlighting as to KTIJ-26395: we should not highlight exit points on the latest statement as it interferes with variable/call/type highlighting \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inline1.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inline1.kt index ecaecfddf003..d0ce228c35d4 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inline1.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inline1.kt @@ -1,16 +1,12 @@ -fun f(a: Int): Int { +fun f(a: Int): Int { if (a < 5) { run { - return 1 + ~return 1 } } else { - return 2 + return 2 } } -inline public fun run(f: () -> T): T { } - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: f -//HIGHLIGHTED: return 2 \ No newline at end of file +inline public fun run(f: () -> T): T { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inline2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inline2.kt index c2be493befe4..b7feb7ae93a9 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inline2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inline2.kt @@ -1,16 +1,12 @@ -fun f(a: Int): Int { +fun f(a: Int): Int { if (a < 5) { run { - return 1 + return 1 } } else { - return 2 + ~return 2 } } -inline public fun run(f: () -> T): T { } - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: f -//HIGHLIGHTED: return 2 \ No newline at end of file +inline public fun run(f: () -> T): T { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inline3.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inline3.kt index cbe26c078307..b11e72714baf 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inline3.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inline3.kt @@ -1,12 +1,8 @@ -fun Any?.foo(): Int { +fun Any?.foo(): Int { this?.let { - return 1 + ~return 1 } - return 2 + return 2 } -public inline fun T.let(block: (T) -> Unit) {} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: foo -//HIGHLIGHTED: return 2 \ No newline at end of file +public inline fun T.let(block: (T) -> Unit) {} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn1.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn1.kt index 6da49d5977ae..a1180b999022 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn1.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn1.kt @@ -1,7 +1,7 @@ fun f(a: Int): Int { if (a < 5) { - run { - return@run 1 + run { + ~return@run 1 } } else { @@ -9,7 +9,4 @@ fun f(a: Int): Int { } } -inline public fun run(f: () -> T): T { } - -//HIGHLIGHTED: run -//HIGHLIGHTED: return@run 1 +inline public fun run(f: () -> T): T { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn2.kt index ff050d238ac9..26fd611b40cf 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn2.kt @@ -1,15 +1,12 @@ -fun f(a: Int): Int { +fun f(a: Int): Int { if (a < 5) { run { return@run 1 } } else { - return 2 + ~return 2 } } -inline public fun run(f: () -> T): T { } - -//HIGHLIGHTED: f -//HIGHLIGHTED: return 2 \ No newline at end of file +inline public fun run(f: () -> T): T { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn3.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn3.kt index dd9d044300e4..de8108af77e0 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn3.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inlineLocalReturn3.kt @@ -1,12 +1,8 @@ fun foo(x: Int): Int { if (x == 1) return 1 - listOf(1, 2, 3).map { - if (it == 2) return@map 2 - return@map 3 + listOf(1, 2, 3).map { + if (it == 2) return@map 2 + return@~map 3 } return 4 -} - -//HIGHLIGHTED: return@map 2 -//HIGHLIGHTED: map -//HIGHLIGHTED: return@map 3 \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/inlineWithNoInlineParam.kt b/plugins/kotlin/idea/tests/testData/exitPoints/inlineWithNoInlineParam.kt index 9576fcdd5285..15a3d21a5d13 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/inlineWithNoInlineParam.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/inlineWithNoInlineParam.kt @@ -1,13 +1,10 @@ fun f(a: Int): Int { if (a < 5) { - run1(fun (): Int { - return 1 + run1(fun (): Int { + ~return 1 }) } return 2 } -inline public fun run1(noinline f: () -> T): T { } - -//HIGHLIGHTED: fun -//HIGHLIGHTED: return 1 +inline public fun run1(noinline f: () -> T): T { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/invalidReturn.kt b/plugins/kotlin/idea/tests/testData/exitPoints/invalidReturn.kt index ea2fc1423380..2e5581761d4c 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/invalidReturn.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/invalidReturn.kt @@ -1,4 +1,4 @@ // KT-8042 ISE at KotlinHighlightExitPointsHandlerFactory.createHighlightUsagesHandler() on typing a function name starting with `throw` // EA-68157 -fun return \ No newline at end of file +fun return~ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/invalidThrow.kt b/plugins/kotlin/idea/tests/testData/exitPoints/invalidThrow.kt index 20527152e1a2..2e4dd44747cd 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/invalidThrow.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/invalidThrow.kt @@ -1,4 +1,4 @@ // KT-8042 ISE at KotlinHighlightExitPointsHandlerFactory.createHighlightUsagesHandler() on typing a function name starting with `throw` // EA-68157 -fun throw \ No newline at end of file +fun throw~ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/localFunction1.kt b/plugins/kotlin/idea/tests/testData/exitPoints/localFunction1.kt index 4b3df694d415..6abe7356cb65 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/localFunction1.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/localFunction1.kt @@ -1,6 +1,6 @@ fun f(a: Int): Int { - fun localFun() { - return + fun localFun() { + ~return } if (a < 5) { @@ -9,7 +9,4 @@ fun f(a: Int): Int { else { return 2 } -} - -//HIGHLIGHTED: localFun -//HIGHLIGHTED: return +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/localFunction2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/localFunction2.kt index 011a5c376722..32c443d1a4c7 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/localFunction2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/localFunction2.kt @@ -1,16 +1,12 @@ -fun f(a: Int): Int { +fun f(a: Int): Int { fun localFun() { return } if (a < 5) { - return 1 + return 1 } else { - return 2 + ~return 2 } -} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: f -//HIGHLIGHTED: return 2 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/localFunctionThrow.kt b/plugins/kotlin/idea/tests/testData/exitPoints/localFunctionThrow.kt index 74b1e8838f2f..cc912626e28d 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/localFunctionThrow.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/localFunctionThrow.kt @@ -1,9 +1,9 @@ fun f(a: Int): Int { - fun localFun() { + fun localFun() { if (a > 5) { - return + return } - throw Error() + ~throw Error() } if (a < 5) { @@ -12,8 +12,4 @@ fun f(a: Int): Int { else { throw Exception() } -} - -//HIGHLIGHTED: return -//HIGHLIGHTED: localFun -//HIGHLIGHTED: throw Error() +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/notInline1.kt b/plugins/kotlin/idea/tests/testData/exitPoints/notInline1.kt index 2b8adc83251b..eca95820e070 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/notInline1.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/notInline1.kt @@ -2,15 +2,12 @@ import javax.swing.SwingUtilities fun f(a: Int): Int { if (a < 5) { - SwingUtilities.invokeLater(fun (): Unit { - return + SwingUtilities.invokeLater(fun (): Unit { + ~return }) return 1 } else { return 2 } -} - -//HIGHLIGHTED: fun -//HIGHLIGHTED: return +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/notInline2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/notInline2.kt index e6e15ee87aed..9a9dd9769bf1 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/notInline2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/notInline2.kt @@ -1,17 +1,13 @@ import javax.swing.SwingUtilities -fun f(a: Int): Int { +fun f(a: Int): Int { if (a < 5) { SwingUtilities.invokeLater(fun (): Unit { return }) - return 1 + ~return 1 } else { - return 2 + return 2 } -} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: f -//HIGHLIGHTED: return 2 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/notInline3.kt b/plugins/kotlin/idea/tests/testData/exitPoints/notInline3.kt index 98ccd002471d..739bd99160f7 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/notInline3.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/notInline3.kt @@ -1,12 +1,8 @@ -fun foo(x: Int): Int { - if (x == 1) return 1 +fun foo(x: Int): Int { + if (x == 1) return 1 listOf(1, 2, 3).map { if (it == 2) return@map 2 return@map 3 } - return 4 -} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: foo -//HIGHLIGHTED: return 4 \ No newline at end of file + ~return 4 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/notReturnedLabeledExpression.kt b/plugins/kotlin/idea/tests/testData/exitPoints/notReturnedLabeledExpression.kt index d597ff137cd1..c2a1e5a3d0ee 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/notReturnedLabeledExpression.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/notReturnedLabeledExpression.kt @@ -4,6 +4,6 @@ fun List<*>.func(function: List<*>.()-> Unit) { fun test() { return listOf(1, 2, 3).func { - this@func + this@func~ } } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/returnIfStatement.kt b/plugins/kotlin/idea/tests/testData/exitPoints/returnIfStatement.kt index db37118452c3..57d6b3d0d028 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/returnIfStatement.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/returnIfStatement.kt @@ -1,14 +1,9 @@ -fun f(a: Int): Int { - return if (a < 5) { +fun f(a: Int): Int { + return~ if (a < 5) { val q = 1 - 1 + 1 } else { - 2 + 2 } -} - -//HIGHLIGHTED: return -//HIGHLIGHTED: f -//HIGHLIGHTED: 1 -//HIGHLIGHTED: 2 \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/returnTryStatement.kt b/plugins/kotlin/idea/tests/testData/exitPoints/returnTryStatement.kt index c76f7eba1c3e..a1abd1160349 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/returnTryStatement.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/returnTryStatement.kt @@ -1,20 +1,14 @@ fun yy(): Int = 5 -fun f(a: Int): Int { - return try { +fun f(a: Int): Int { + return~ try { val q = a * a - q + q } catch (e: Exception) { - 0 + 0 } catch (e: Throwable) { - -1 + -1 } finally { println() } } - -//HIGHLIGHTED: return -//HIGHLIGHTED: f -//HIGHLIGHTED: 0 -//HIGHLIGHTED: q -//HIGHLIGHTED: -1 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/returnWhenStatement.kt b/plugins/kotlin/idea/tests/testData/exitPoints/returnWhenStatement.kt index e4c68ef8be8d..50353d407943 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/returnWhenStatement.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/returnWhenStatement.kt @@ -1,20 +1,14 @@ fun yy(): Int = 5 -fun f(a: Int): Int { - return when { +fun f(a: Int): Int { + return~ when { a < 0 -> { val q = 1 - 2 * 2 + 2 * 2 } a > 0 -> { - 2 * (2 + 2) + 2 * (2 + 2) } - else -> yy() + else -> yy() } -} - -//HIGHLIGHTED: return -//HIGHLIGHTED: f -//HIGHLIGHTED: 2 * (2 + 2) -//HIGHLIGHTED: 2 * 2 -//HIGHLIGHTED: yy() \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/simple.kt b/plugins/kotlin/idea/tests/testData/exitPoints/simple.kt index 8c43f5d81d66..c1762b4dffc1 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/simple.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/simple.kt @@ -1,12 +1,8 @@ -fun f(a: Int): Int { +fun f(a: Int): Int { if (a < 5) { - return 1 + ~return 1 } else { - return 2 + return 2 } -} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: f -//HIGHLIGHTED: return 2 \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/throw1.kt b/plugins/kotlin/idea/tests/testData/exitPoints/throw1.kt index 2765c8552584..315606262424 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/throw1.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/throw1.kt @@ -1,12 +1,8 @@ -fun f(a: Int): Int { +fun f(a: Int): Int { if (a < 5) { - return 1 + return 1 } else { - throw Error() + ~throw Error() } -} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: f -//HIGHLIGHTED: throw Error() \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/exitPoints/throw2.kt b/plugins/kotlin/idea/tests/testData/exitPoints/throw2.kt index e956c36a542c..1e697b8ed973 100644 --- a/plugins/kotlin/idea/tests/testData/exitPoints/throw2.kt +++ b/plugins/kotlin/idea/tests/testData/exitPoints/throw2.kt @@ -1,12 +1,8 @@ -fun f(a: Int): Int { +fun f(a: Int): Int { if (a < 5) { - return 1 + ~return 1 } else { - throw Error() + throw Error() } -} - -//HIGHLIGHTED: return 1 -//HIGHLIGHTED: f -//HIGHLIGHTED: throw Error() \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/usageHighlighter/functionNameIdentifier.kt b/plugins/kotlin/idea/tests/testData/usageHighlighter/functionNameIdentifier.kt index 1002a3c77b31..cb616704a932 100644 --- a/plugins/kotlin/idea/tests/testData/usageHighlighter/functionNameIdentifier.kt +++ b/plugins/kotlin/idea/tests/testData/usageHighlighter/functionNameIdentifier.kt @@ -1,4 +1,4 @@ -fun test~(s: String?): Int { +fun~ test(s: String?): Int { if (s != null) { return@test 1 }