mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[kotlin] Implement tests for actual declaration completion
* #FL-26673 GitOrigin-RevId: 7042baa2367ae8890aeee39e7a5e6128a9b6c7dd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a500d8ecf4
commit
183f7aace0
@@ -0,0 +1,3 @@
|
||||
expect fun foo()
|
||||
expect fun bar(): Int
|
||||
expect fun baz(): String
|
||||
@@ -0,0 +1,8 @@
|
||||
actual fun baz(): String = "baz"
|
||||
|
||||
actual<caret>
|
||||
|
||||
// IGNORE_K2
|
||||
// EXIST: {"lookupString": "actual", "module": "testModule_Common", "icon": "Function", "allLookupStrings": "actual, foo", "itemText": "actual fun foo() {...}"}
|
||||
// EXIST: {"lookupString": "actual", "module": "testModule_Common", "icon": "Function", "allLookupStrings": "actual, bar", "itemText": "actual fun bar(): Int {...}"}
|
||||
// ABSENT: {"lookupString": "actual", "module": "testModule_Common", "icon": "Function", "allLookupStrings": "actual, baz", "itemText": "actual fun baz(): String {...}"}
|
||||
@@ -0,0 +1,3 @@
|
||||
expect val foo: Int
|
||||
expect val bar: Float
|
||||
expect val baz: String
|
||||
@@ -0,0 +1,8 @@
|
||||
actual val baz: String = "baz"
|
||||
|
||||
actual<caret>
|
||||
|
||||
// IGNORE_K2
|
||||
// EXIST: {"lookupString": "actual", "module": "testModule_Common", "icon": "org/jetbrains/kotlin/idea/icons/field_value.svg", "allLookupStrings": "actual, foo", "itemText": "actual val foo: Int"}
|
||||
// EXIST: {"lookupString": "actual", "module": "testModule_Common", "icon": "org/jetbrains/kotlin/idea/icons/field_value.svg", "allLookupStrings": "actual, bar", "itemText": "actual val bar: Float"}
|
||||
// ABSENT: {"lookupString": "actual", "module": "testModule_Common", "icon": "org/jetbrains/kotlin/idea/icons/field_value.svg", "allLookupStrings": "actual, baz", "itemText": "actual val baz: String"}
|
||||
@@ -19,6 +19,30 @@ import org.junit.runner.RunWith;
|
||||
@TestDataPath("$CONTENT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public abstract class MultiPlatformCompletionTestGenerated extends AbstractMultiPlatformCompletionTest {
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../testData/multiPlatform/actualDeclaration")
|
||||
public static class ActualDeclaration extends AbstractMultiPlatformCompletionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K1;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("actualFun")
|
||||
public void testActualFun() throws Exception {
|
||||
runTest("../testData/multiPlatform/actualDeclaration/actualFun/");
|
||||
}
|
||||
|
||||
@TestMetadata("actualVal")
|
||||
public void testActualVal() throws Exception {
|
||||
runTest("../testData/multiPlatform/actualDeclaration/actualVal/");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../testData/multiPlatform/classDeclaration")
|
||||
public static class ClassDeclaration extends AbstractMultiPlatformCompletionTest {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.EditorFactory
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil
|
||||
import org.jetbrains.kotlin.idea.base.test.IgnoreTests
|
||||
import org.jetbrains.kotlin.idea.multiplatform.setupMppProjectFromDirStructure
|
||||
import org.jetbrains.kotlin.idea.test.AbstractMultiModuleTest
|
||||
import org.jetbrains.kotlin.idea.test.extractMarkerOffset
|
||||
@@ -17,18 +18,22 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractMultiPlatformCompletionTest : AbstractMultiModuleTest() {
|
||||
|
||||
protected fun doTest(testPath: String) {
|
||||
setupMppProjectFromDirStructure(File(testPath))
|
||||
val testFile = File(testPath)
|
||||
setupMppProjectFromDirStructure(testFile)
|
||||
val file = project.findFileWithCaret() as KtFile
|
||||
val doc = PsiDocumentManager.getInstance(myProject).getDocument(file)!!
|
||||
val offset = doc.extractMarkerOffset(project)
|
||||
val editor = EditorFactory.getInstance().createEditor(doc, myProject)!!
|
||||
editor.caretModel.moveToOffset(offset)
|
||||
try {
|
||||
testCompletion(file, editor)
|
||||
} finally {
|
||||
EditorFactory.getInstance().releaseEditor(editor)
|
||||
val virtualFilePath = file.virtualFile!!.toNioPath()
|
||||
|
||||
IgnoreTests.runTestIfNotDisabledByFileDirective(virtualFilePath, IgnoreTests.DIRECTIVES.of(pluginMode)) {
|
||||
val doc = PsiDocumentManager.getInstance(myProject).getDocument(file)!!
|
||||
val offset = doc.extractMarkerOffset(project)
|
||||
val editor = EditorFactory.getInstance().createEditor(doc, myProject)!!
|
||||
editor.caretModel.moveToOffset(offset)
|
||||
try {
|
||||
testCompletion(file, editor)
|
||||
} finally {
|
||||
EditorFactory.getInstance().releaseEditor(editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,30 @@ import org.junit.runner.RunWith;
|
||||
@TestDataPath("$CONTENT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public abstract class K2MultiPlatformCompletionTestGenerated extends AbstractK2MultiPlatformCompletionTest {
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../../completion/testData/multiPlatform/actualDeclaration")
|
||||
public static class ActualDeclaration extends AbstractK2MultiPlatformCompletionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("actualFun")
|
||||
public void testActualFun() throws Exception {
|
||||
runTest("../../completion/testData/multiPlatform/actualDeclaration/actualFun/");
|
||||
}
|
||||
|
||||
@TestMetadata("actualVal")
|
||||
public void testActualVal() throws Exception {
|
||||
runTest("../../completion/testData/multiPlatform/actualDeclaration/actualVal/");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../../completion/testData/multiPlatform/classDeclaration")
|
||||
public static class ClassDeclaration extends AbstractK2MultiPlatformCompletionTest {
|
||||
|
||||
@@ -1377,6 +1377,7 @@ private fun assembleWorkspace(): TWorkspace = workspace(KotlinPluginMode.K1) {
|
||||
}
|
||||
|
||||
testClass<AbstractMultiPlatformCompletionTest> {
|
||||
model("multiPlatform/actualDeclaration", isRecursive = false, pattern = DIRECTORY)
|
||||
model("multiPlatform/classDeclaration", isRecursive = false, pattern = DIRECTORY)
|
||||
model("multiPlatform/functionDeclaration", isRecursive = false, pattern = DIRECTORY)
|
||||
}
|
||||
|
||||
@@ -304,6 +304,7 @@ private fun assembleWorkspace(): TWorkspace = workspace(KotlinPluginMode.K2) {
|
||||
}
|
||||
|
||||
testClass<AbstractK2MultiPlatformCompletionTest> {
|
||||
model("multiPlatform/actualDeclaration", isRecursive = false, pattern = DIRECTORY)
|
||||
model("multiPlatform/classDeclaration", isRecursive = false, pattern = DIRECTORY)
|
||||
model("multiPlatform/functionDeclaration", isRecursive = false, pattern = DIRECTORY)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user