diff --git a/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/base/test/ModuleStructureSplitter.kt b/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/base/test/ModuleStructureSplitter.kt index 23499948632e..edee40fa3f7f 100644 --- a/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/base/test/ModuleStructureSplitter.kt +++ b/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/base/test/ModuleStructureSplitter.kt @@ -23,7 +23,7 @@ object ModuleStructureSplitter { var isMainFile = false fun dumpFile(currentPlatform: String?, currentFileName: String?, currentText: String?) { - if (currentText != null && currentFileName != null && currentPlatform != null) { + if (!currentText.isNullOrEmpty() && currentFileName != null && currentPlatform != null) { result.getOrPut(currentPlatform) { mutableListOf() }.add(TestFile(currentFileName, currentText, isMainFile)) } } @@ -31,10 +31,13 @@ object ModuleStructureSplitter { lines.forEach { line -> if (line == IS_MAIN) { isMainFile = true - } else if (line.startsWith(PLATFORM_PREFIX)) { + } else if (line.startsWith(PLATFORM_PREFIX, true)) { dumpFile(currentPlatform, currentFileName, currentText) - currentPlatform = line.substringAfter(PLATFORM_PREFIX).trim() + currentText = "" + currentFileName = null + currentPlatform = line.substring(PLATFORM_PREFIX.length).trim() } else if (line.startsWith(FILE_PATH_PREFIX)) { + dumpFile(currentPlatform, currentFileName, currentText) isMainFile = false currentFileName = line.substringAfter(FILE_PATH_PREFIX).trim() currentText = "" diff --git a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocMultiplatformTestGenerated.java b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocMultiplatformTestGenerated.java index b356e6b03da1..c5732112613d 100644 --- a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocMultiplatformTestGenerated.java +++ b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocMultiplatformTestGenerated.java @@ -28,6 +28,11 @@ public class FirQuickDocMultiplatformTestGenerated extends AbstractFirQuickDocMu runTest("../../idea/tests/testData/editor/quickDoc/multiplatform/OnActualClassWithConstructorFromExpect.kt"); } + @TestMetadata("OnActualDeclarationWithDocWhenInheritedDocPresent.kt") + public void testOnActualDeclarationWithDocWhenInheritedDocPresent() throws Exception { + runTest("../../idea/tests/testData/editor/quickDoc/multiplatform/OnActualDeclarationWithDocWhenInheritedDocPresent.kt"); + } + @TestMetadata("OnActualDeclarationWithInheritedDoc.kt") public void testOnActualDeclarationWithInheritedDoc() throws Exception { runTest("../../idea/tests/testData/editor/quickDoc/multiplatform/OnActualDeclarationWithInheritedDoc.kt"); diff --git a/plugins/kotlin/idea/tests/testData/editor/quickDoc/multiplatform/OnActualDeclarationWithDocWhenInheritedDocPresent.kt b/plugins/kotlin/idea/tests/testData/editor/quickDoc/multiplatform/OnActualDeclarationWithDocWhenInheritedDocPresent.kt new file mode 100644 index 000000000000..83ca5f3c8829 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/editor/quickDoc/multiplatform/OnActualDeclarationWithDocWhenInheritedDocPresent.kt @@ -0,0 +1,16 @@ +// PLATFORM: Common +// FILE: Foo.kt +/** + * Doc for expected class Foo + */ +expect class Foo + +// PLATFORM: Jvm +// FILE: Foo.kt +// MAIN +/** + * Doc for actual class Foo + */ +actual class Foo + +//INFO:
public actual final class Foo

Doc for actual class Foo

 Foo.kt
diff --git a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightMultiplatformCodeInsightFixtureTestCase.kt b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightMultiplatformCodeInsightFixtureTestCase.kt index 1e87dd390fcd..c05adce93a63 100644 --- a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightMultiplatformCodeInsightFixtureTestCase.kt +++ b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightMultiplatformCodeInsightFixtureTestCase.kt @@ -11,8 +11,6 @@ import java.io.File abstract class KotlinLightMultiplatformCodeInsightFixtureTestCase : KotlinLightCodeInsightFixtureTestCaseBase() { - private val exceptions = ArrayList() - @Deprecated("Migrate to 'testDataDirectory'.", ReplaceWith("testDataDirectory")) final override fun getTestDataPath(): String = testDataDirectory.slashedPath @@ -37,7 +35,7 @@ abstract class KotlinLightMultiplatformCodeInsightFixtureTestCase : KotlinLightC */ fun configureModuleStructure(abstractFilePath: String): VirtualFile? { val map = ModuleStructureSplitter.splitPerModule(File(abstractFilePath)) - var currentFile: VirtualFile? = null + var mainFile: VirtualFile? = null map.forEach { (platform, files) -> val platformDescriptor = when (platform) { "Common" -> KotlinMultiPlatformProjectDescriptor.PlatformDescriptor.COMMON @@ -49,13 +47,13 @@ abstract class KotlinLightMultiplatformCodeInsightFixtureTestCase : KotlinLightC for (testFile in files) { val virtualFile = VfsTestUtil.createFile(platformDescriptor.sourceRoot()!!, testFile.relativePath, testFile.text) if (testFile.isMain) { - currentFile = virtualFile + mainFile = virtualFile } myFixture.configureFromExistingVirtualFile(virtualFile) } } } - return currentFile + return mainFile } override fun tearDown() { @@ -64,11 +62,6 @@ abstract class KotlinLightMultiplatformCodeInsightFixtureTestCase : KotlinLightC { KotlinSdkType.removeKotlinSdkInTests() }, { super.tearDown() }, ) - - if (exceptions.isNotEmpty()) { - exceptions.forEach { it.printStackTrace() } - throw AssertionError("Exceptions in other threads happened") - } } override fun getProjectDescriptor(): LightProjectDescriptor = KotlinMultiPlatformProjectDescriptor diff --git a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinMultiPlatformProjectDescriptor.kt b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinMultiPlatformProjectDescriptor.kt index efb25e7ddded..bc556c5dc0b1 100644 --- a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinMultiPlatformProjectDescriptor.kt +++ b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/KotlinMultiPlatformProjectDescriptor.kt @@ -1,9 +1,11 @@ // 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.test +import com.intellij.openapi.application.runReadAction import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project +import com.intellij.openapi.projectRoots.ProjectJdkTable import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.roots.* import com.intellij.openapi.util.io.FileUtil @@ -13,6 +15,7 @@ import com.intellij.pom.java.LanguageLevel import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.IndexingTestUtil import org.jetbrains.jps.model.java.JavaSourceRootType +import org.jetbrains.kotlin.idea.framework.KotlinSdkType import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.js.JsPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms @@ -65,21 +68,32 @@ object KotlinMultiPlatformProjectDescriptor : KotlinLightProjectDescriptor() { private fun configureModule(module: Module, model: ModifiableRootModel, descriptor: PlatformDescriptor) { model.getModuleExtension(LanguageLevelModuleExtension::class.java).languageLevel = LanguageLevel.HIGHEST - model.sdk = sdk if (descriptor.sourceRootName != null) { val sourceRoot = createSourceRoot(module, descriptor.sourceRootName) model.addContentEntry(sourceRoot).addSourceFolder(sourceRoot, JavaSourceRootType.SOURCE) } + val setupKotlinSdk: () -> Unit = { + KotlinSdkType.setUpIfNeeded(module) + ConfigLibraryUtil.configureSdk( + module, + runReadAction { ProjectJdkTable.getInstance() }.findMostRecentSdkOfType(KotlinSdkType.INSTANCE) + ?: error("Kotlin SDK wasn't created") + ) + } when (descriptor) { PlatformDescriptor.JVM -> { + model.sdk = sdk module.createMultiplatformFacetM3(JvmPlatforms.jvm8, false, listOf("Common"), listOf(descriptor.sourceRoot()!!.path)) } - PlatformDescriptor.JS -> + PlatformDescriptor.JS -> { + setupKotlinSdk() module.createMultiplatformFacetM3(JsPlatforms.defaultJsPlatform, false, listOf("Common"), listOf(descriptor.sourceRoot()!!.path)) + } - PlatformDescriptor.COMMON -> + PlatformDescriptor.COMMON -> { + setupKotlinSdk() module.createMultiplatformFacetM3( TargetPlatform( setOf( @@ -88,6 +102,7 @@ object KotlinMultiPlatformProjectDescriptor : KotlinLightProjectDescriptor() { ) ), false, emptyList(), listOf(descriptor.sourceRoot()!!.path) ) + } } }