mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] move declaration range handler to module kotlin.code-insight.minimal
Because it's required for pair matcher logic which should be available on JB Client Also convert tests to "generated" and enable K2 counterpart part of KTIJ-28142 GitOrigin-RevId: e01ffd4f45a04fc18d7c3b2d21b49c85da129914
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1a807eeb26
commit
eb6938506c
+10
@@ -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
|
||||
}
|
||||
}
|
||||
+40
@@ -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");
|
||||
}
|
||||
}
|
||||
+5
-18
@@ -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("<start>")
|
||||
if (startPos == -1) {
|
||||
throw IllegalArgumentException("<start> 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 */ <start>class Foo : Bar, Baz <brace>{ fun xyzzy() { } }")
|
||||
}
|
||||
|
||||
fun testFun() {
|
||||
doTest("/* Doc comment */ <start>fun xyzzy(x: Int, y: String): Any <brace>{ }")
|
||||
}
|
||||
|
||||
fun testFor() {
|
||||
doTest("fun xyzzy() { for (x in 0..1)<start><brace>{ } }")
|
||||
}
|
||||
}
|
||||
+40
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
fun xyzzy() { for (x in 0..1)<start><brace>{ } }
|
||||
@@ -0,0 +1 @@
|
||||
/* Doc comment */ <start>fun xyzzy(x: Int, y: String): Any <brace>{ }
|
||||
@@ -0,0 +1,3 @@
|
||||
/* Doc comment */ <start>class Foo : Bar, Baz <brace>{
|
||||
fun xyzzy() { }
|
||||
}
|
||||
+4
@@ -507,6 +507,10 @@ private fun assembleWorkspace(): TWorkspace = workspace {
|
||||
model("codeInsight/breadcrumbs", pattern = KT_OR_KTS)
|
||||
}
|
||||
|
||||
testClass<AbstractPairMatcherTest> {
|
||||
model("codeInsight/pairMatcher", pattern = KT_OR_KTS)
|
||||
}
|
||||
|
||||
testClass<AbstractK1IntentionTest> {
|
||||
model("intentions", pattern = Patterns.forRegex("^([\\w\\-_]+)\\.(kt|kts)$"))
|
||||
}
|
||||
|
||||
+4
@@ -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<AbstractKotlinFirBreadcrumbsTest> {
|
||||
model("../../../idea/tests/testData/codeInsight/breadcrumbs", pattern = KT_OR_KTS)
|
||||
}
|
||||
testClass<AbstractKotlinFirPairMatcherTest> {
|
||||
model("../../../idea/tests/testData/codeInsight/pairMatcher")
|
||||
}
|
||||
testClass<AbstractKotlinFirUnwrapRemoveTest> {
|
||||
model("../../../idea/tests/testData/codeInsight/unwrapAndRemove/removeExpression", testMethodName = "doTestExpressionRemover")
|
||||
model("../../../idea/tests/testData/codeInsight/unwrapAndRemove/unwrapThen", testMethodName = "doTestThenUnwrapper")
|
||||
|
||||
Reference in New Issue
Block a user