diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinDeclarationRangeHandler.kt b/plugins/kotlin/base/code-insight/minimal/src/org/jetbrains/kotlin/idea/codeInsight/KotlinDeclarationRangeHandler.kt similarity index 100% rename from plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinDeclarationRangeHandler.kt rename to plugins/kotlin/base/code-insight/minimal/src/org/jetbrains/kotlin/idea/codeInsight/KotlinDeclarationRangeHandler.kt diff --git a/plugins/kotlin/code-insight/kotlin.code-insight.k2/test/org/jetbrains/kotlin/idea/k2/AbstractKotlinFirPairMatcherTest.kt b/plugins/kotlin/code-insight/kotlin.code-insight.k2/test/org/jetbrains/kotlin/idea/k2/AbstractKotlinFirPairMatcherTest.kt new file mode 100644 index 000000000000..66c8ee23dc0f --- /dev/null +++ b/plugins/kotlin/code-insight/kotlin.code-insight.k2/test/org/jetbrains/kotlin/idea/k2/AbstractKotlinFirPairMatcherTest.kt @@ -0,0 +1,10 @@ +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.k2 + +import org.jetbrains.kotlin.idea.codeInsight.AbstractPairMatcherTest + +abstract class AbstractKotlinFirPairMatcherTest: AbstractPairMatcherTest() { + override fun isFirPlugin(): Boolean { + return true + } +} \ No newline at end of file diff --git a/plugins/kotlin/code-insight/kotlin.code-insight.k2/test/org/jetbrains/kotlin/idea/k2/KotlinFirPairMatcherTestGenerated.java b/plugins/kotlin/code-insight/kotlin.code-insight.k2/test/org/jetbrains/kotlin/idea/k2/KotlinFirPairMatcherTestGenerated.java new file mode 100644 index 000000000000..d48836bba5db --- /dev/null +++ b/plugins/kotlin/code-insight/kotlin.code-insight.k2/test/org/jetbrains/kotlin/idea/k2/KotlinFirPairMatcherTestGenerated.java @@ -0,0 +1,40 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +package org.jetbrains.kotlin.idea.k2; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.idea.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.jetbrains.kotlin.idea.base.test.TestRoot; +import org.junit.runner.RunWith; + +/** + * This class is generated by {@link org.jetbrains.kotlin.testGenerator.generator.TestGenerator}. + * DO NOT MODIFY MANUALLY. + */ +@SuppressWarnings("all") +@TestRoot("code-insight/kotlin.code-insight.k2") +@TestDataPath("$CONTENT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +@TestMetadata("../../idea/tests/testData/codeInsight/pairMatcher") +public class KotlinFirPairMatcherTestGenerated extends AbstractKotlinFirPairMatcherTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("For.kt") + public void testFor() throws Exception { + runTest("../../idea/tests/testData/codeInsight/pairMatcher/For.kt"); + } + + @TestMetadata("Fun.kt") + public void testFun() throws Exception { + runTest("../../idea/tests/testData/codeInsight/pairMatcher/Fun.kt"); + } + + @TestMetadata("Klass.kt") + public void testKlass() throws Exception { + runTest("../../idea/tests/testData/codeInsight/pairMatcher/Klass.kt"); + } +} diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/KotlinPairMatcherTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractPairMatcherTest.kt similarity index 66% rename from plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/KotlinPairMatcherTest.kt rename to plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractPairMatcherTest.kt index 1a9b8d5387ae..8d4b69c809cc 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/KotlinPairMatcherTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractPairMatcherTest.kt @@ -2,19 +2,18 @@ package org.jetbrains.kotlin.idea.codeInsight +import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.KotlinPairMatcher import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor -import org.junit.internal.runners.JUnit38ClassRunner -import org.junit.runner.RunWith +import java.io.File -@RunWith(JUnit38ClassRunner::class) -class KotlinPairMatcherTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractPairMatcherTest : KotlinLightCodeInsightFixtureTestCase() { override fun getProjectDescriptor(): KotlinLightProjectDescriptor = KotlinLightProjectDescriptor.INSTANCE - private fun doTest(testData: String) { - var docText = testData + protected fun doTest(path: String) { + var docText = FileUtil.loadFile(File(path)) val startPos = docText.indexOf("") if (startPos == -1) { throw IllegalArgumentException(" marker not found in testdata") @@ -29,16 +28,4 @@ class KotlinPairMatcherTest : KotlinLightCodeInsightFixtureTestCase() { val pos = KotlinPairMatcher().getCodeConstructStart(myFixture.file, bracePos) assertEquals(startPos, pos) } - - fun testClass() { - doTest("/* Doc comment */ class Foo : Bar, Baz { fun xyzzy() { } }") - } - - fun testFun() { - doTest("/* Doc comment */ fun xyzzy(x: Int, y: String): Any { }") - } - - fun testFor() { - doTest("fun xyzzy() { for (x in 0..1){ } }") - } } diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/PairMatcherTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/PairMatcherTestGenerated.java new file mode 100644 index 000000000000..be571db1fe60 --- /dev/null +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/PairMatcherTestGenerated.java @@ -0,0 +1,40 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +package org.jetbrains.kotlin.idea.codeInsight; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.idea.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.jetbrains.kotlin.idea.base.test.TestRoot; +import org.junit.runner.RunWith; + +/** + * This class is generated by {@link org.jetbrains.kotlin.testGenerator.generator.TestGenerator}. + * DO NOT MODIFY MANUALLY. + */ +@SuppressWarnings("all") +@TestRoot("idea/tests") +@TestDataPath("$CONTENT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +@TestMetadata("testData/codeInsight/pairMatcher") +public class PairMatcherTestGenerated extends AbstractPairMatcherTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("For.kt") + public void testFor() throws Exception { + runTest("testData/codeInsight/pairMatcher/For.kt"); + } + + @TestMetadata("Fun.kt") + public void testFun() throws Exception { + runTest("testData/codeInsight/pairMatcher/Fun.kt"); + } + + @TestMetadata("Klass.kt") + public void testKlass() throws Exception { + runTest("testData/codeInsight/pairMatcher/Klass.kt"); + } +} diff --git a/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/For.kt b/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/For.kt new file mode 100644 index 000000000000..e8df7a2f6fda --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/For.kt @@ -0,0 +1 @@ +fun xyzzy() { for (x in 0..1){ } } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/Fun.kt b/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/Fun.kt new file mode 100644 index 000000000000..3951cb79b89f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/Fun.kt @@ -0,0 +1 @@ +/* Doc comment */ fun xyzzy(x: Int, y: String): Any { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/Klass.kt b/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/Klass.kt new file mode 100644 index 000000000000..bcd5bc7c8505 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/codeInsight/pairMatcher/Klass.kt @@ -0,0 +1,3 @@ +/* Doc comment */ class Foo : Bar, Baz { + fun xyzzy() { } +} \ No newline at end of file diff --git a/plugins/kotlin/util/test-generator-fe10/test/org/jetbrains/kotlin/fe10/testGenerator/Fe10GenerateTests.kt b/plugins/kotlin/util/test-generator-fe10/test/org/jetbrains/kotlin/fe10/testGenerator/Fe10GenerateTests.kt index 03e4de34c3fd..1c82d02043cb 100644 --- a/plugins/kotlin/util/test-generator-fe10/test/org/jetbrains/kotlin/fe10/testGenerator/Fe10GenerateTests.kt +++ b/plugins/kotlin/util/test-generator-fe10/test/org/jetbrains/kotlin/fe10/testGenerator/Fe10GenerateTests.kt @@ -507,6 +507,10 @@ private fun assembleWorkspace(): TWorkspace = workspace { model("codeInsight/breadcrumbs", pattern = KT_OR_KTS) } + testClass { + model("codeInsight/pairMatcher", pattern = KT_OR_KTS) + } + testClass { model("intentions", pattern = Patterns.forRegex("^([\\w\\-_]+)\\.(kt|kts)$")) } diff --git a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2CodeInsightTests.kt b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2CodeInsightTests.kt index 32153ea8842b..dbd3e21e1eff 100644 --- a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2CodeInsightTests.kt +++ b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2CodeInsightTests.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlin.fir.testGenerator.codeinsight import org.jetbrains.kotlin.idea.k2.AbstractKotlinFirBreadcrumbsTest +import org.jetbrains.kotlin.idea.k2.AbstractKotlinFirPairMatcherTest import org.jetbrains.kotlin.idea.k2.moveUpDown.AbstractFirMoveLeftRightTest import org.jetbrains.kotlin.idea.k2.moveUpDown.AbstractKotlinFirMoveStatementTest import org.jetbrains.kotlin.idea.k2.quickDoc.AbstractFirRenderingKDocTest @@ -43,6 +44,9 @@ internal fun MutableTWorkspace.generateK2CodeInsightTests() { testClass { model("../../../idea/tests/testData/codeInsight/breadcrumbs", pattern = KT_OR_KTS) } + testClass { + model("../../../idea/tests/testData/codeInsight/pairMatcher") + } testClass { model("../../../idea/tests/testData/codeInsight/unwrapAndRemove/removeExpression", testMethodName = "doTestExpressionRemover") model("../../../idea/tests/testData/codeInsight/unwrapAndRemove/unwrapThen", testMethodName = "doTestThenUnwrapper")