diff --git a/plugins/kotlin/base/facet/tests/test/KotlinFacetBridgeTest.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetBridgeTest.kt similarity index 91% rename from plugins/kotlin/base/facet/tests/test/KotlinFacetBridgeTest.kt rename to plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetBridgeTest.kt index 1951eacea854..39e2732e1111 100644 --- a/plugins/kotlin/base/facet/tests/test/KotlinFacetBridgeTest.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetBridgeTest.kt @@ -1,4 +1,7 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// 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 + import com.intellij.facet.FacetManager import com.intellij.facet.impl.ui.FacetEditorImpl import com.intellij.facet.mock.MockFacetEditorContext @@ -19,10 +22,16 @@ class KotlinFacetBridgeTest : KotlinFacetTestCase() { fun testEditorTabConfigurationOnFacetCreation() { val facet = getKotlinFacet() val editorContext: FacetEditorContext = MockFacetEditorContext(getKotlinFacet()) - FacetEditorImpl(editorContext, facet.configuration).let { - it.getComponent() - it.reset() - assertNotNull(it.component) + var facetEditorTab: FacetEditorImpl? = null + try { + facetEditorTab = FacetEditorImpl(editorContext, facet.configuration) + facetEditorTab.let { + it.getComponent() + it.reset() + assertNotNull(it.component) + } + } finally { + facetEditorTab?.disposeUIResources() } } diff --git a/plugins/kotlin/base/facet/tests/test/KotlinFacetDeserializationTest.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetDeserializationTest.kt similarity index 98% rename from plugins/kotlin/base/facet/tests/test/KotlinFacetDeserializationTest.kt rename to plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetDeserializationTest.kt index fc1adf5cde98..d5a45a9c6f5a 100644 --- a/plugins/kotlin/base/facet/tests/test/KotlinFacetDeserializationTest.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetDeserializationTest.kt @@ -1,4 +1,7 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// 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 + import com.intellij.facet.Facet import com.intellij.facet.FacetManager import com.intellij.openapi.application.appSystemDir @@ -7,7 +10,6 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.project.doNotEnableExternalStorageByDefaultInTests import com.intellij.openapi.project.getProjectCacheFileName import com.intellij.openapi.util.io.FileUtil -import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile import com.intellij.platform.backend.workspace.WorkspaceModel @@ -82,7 +84,6 @@ class KotlinFacetDeserializationTest { assertEmpty(additionalVisibleModuleNames) assertEmpty(externalProjectId) assertEquals(KotlinModuleKind.DEFAULT, kind) - assertNotNull(compilerArguments) } } } diff --git a/plugins/kotlin/base/facet/tests/test/KotlinFacetEventListenerTest.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetEventListenerTest.kt similarity index 99% rename from plugins/kotlin/base/facet/tests/test/KotlinFacetEventListenerTest.kt rename to plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetEventListenerTest.kt index e70b4f2f61d1..1cd3d07769f6 100644 --- a/plugins/kotlin/base/facet/tests/test/KotlinFacetEventListenerTest.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetEventListenerTest.kt @@ -1,4 +1,7 @@ // 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 + import com.intellij.facet.Facet import com.intellij.facet.FacetManager import com.intellij.facet.FacetManagerListener diff --git a/plugins/kotlin/base/facet/tests/test/KotlinFacetSerializationTest.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetSerializationTest.kt similarity index 97% rename from plugins/kotlin/base/facet/tests/test/KotlinFacetSerializationTest.kt rename to plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetSerializationTest.kt index 3e05638870a1..cba0f0abef8e 100644 --- a/plugins/kotlin/base/facet/tests/test/KotlinFacetSerializationTest.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetSerializationTest.kt @@ -1,4 +1,7 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// 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 + import com.intellij.facet.FacetManager import com.intellij.facet.impl.FacetUtil import com.intellij.openapi.application.EDT @@ -42,12 +45,8 @@ class KotlinFacetSerializationTest { @Rule val tempDirManager = TemporaryDirectory() - lateinit var module: Module - @Before fun verifyImlDoesntExist() { - //TODO: remove after enabling by default - Registry.get("workspace.model.kotlin.facet.bridge").setValue(true) Assume.assumeTrue("Execute only if kotlin facet bridge enabled", KotlinFacetBridgeFactory.kotlinFacetBridgeEnabled) TestCase.assertFalse(Files.exists(projectRule.module.moduleNioFile)) } diff --git a/plugins/kotlin/base/facet/tests/test/KotlinFacetTestCase.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetTestCase.kt similarity index 69% rename from plugins/kotlin/base/facet/tests/test/KotlinFacetTestCase.kt rename to plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetTestCase.kt index baa7fb69840b..89cc2aee4a9b 100644 --- a/plugins/kotlin/base/facet/tests/test/KotlinFacetTestCase.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetTestCase.kt @@ -1,16 +1,20 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// 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 + import com.intellij.openapi.application.ex.PathManagerEx import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project -import com.intellij.openapi.util.registry.Registry -import com.intellij.testFramework.UsefulTestCase +import com.intellij.testFramework.* import com.intellij.testFramework.fixtures.* +import org.jetbrains.kotlin.idea.workspaceModel.KotlinFacetBridgeFactory +import org.junit.Assume import java.io.File abstract class KotlinFacetTestCase : UsefulTestCase() { - protected lateinit var myTestFixture: JavaCodeInsightTestFixture + private lateinit var myTestFixture: JavaCodeInsightTestFixture lateinit var myProject: Project - lateinit var myKotlinFixtureBuilder: KotlinModuleFixtureBuilder + private lateinit var myKotlinFixtureBuilder: KotlinModuleFixtureBuilder val myModule: Module get() = myTestFixture.module @@ -19,41 +23,36 @@ abstract class KotlinFacetTestCase : UsefulTestCase() { return PathManagerEx.getTestDataPath().replace(File.separatorChar, '/') /*+ getBasePath()*/ } + override fun setUp() { super.setUp() - //TODO: remove after enabling by default - Registry.get("workspace.model.kotlin.facet.bridge").setValue(true) - val projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder( - name - ) + val projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(name) val testDataPath: String = getTestDataPath() myTestFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.fixture) - myTestFixture!!.testDataPath = testDataPath + ?: error("Failed to create test fixture") + myTestFixture.testDataPath = testDataPath configureProjectBuilder(projectBuilder) - //myFixture.setUp() - myTestFixture!!.setUp() + myTestFixture.setUp() myProject = myTestFixture.project + Assume.assumeTrue("Execute only if kotlin facet bridge enabled", KotlinFacetBridgeFactory.kotlinFacetBridgeEnabled) } protected open fun configureProjectBuilder(projectBuilder: TestFixtureBuilder) { val tempDirPath: String = myTestFixture.tempDirPath IdeaTestFixtureFactory.getFixtureFactory().registerFixtureBuilder( KotlinModuleFixtureBuilder::class.java, - "KotlinModuleFixtureBuilderImpl" + KotlinModuleFixtureBuilderImpl::class.java.name ) myKotlinFixtureBuilder = projectBuilder.addModule(KotlinModuleFixtureBuilder::class.java) myKotlinFixtureBuilder.addContentRoot(tempDirPath) - //configure(myKotlinFixtureBuilder) - //TODO: add root here } override fun tearDown() { val fixture: JavaCodeInsightTestFixture = myTestFixture - //myTestFixture = null try { fixture.tearDown() } catch (e: Throwable) { diff --git a/plugins/kotlin/base/facet/tests/test/KotlinModuleFixtureBuilder.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinModuleFixtureBuilder.kt similarity index 72% rename from plugins/kotlin/base/facet/tests/test/KotlinModuleFixtureBuilder.kt rename to plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinModuleFixtureBuilder.kt index a1691e8ac9a2..95e3f6d686ce 100644 --- a/plugins/kotlin/base/facet/tests/test/KotlinModuleFixtureBuilder.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinModuleFixtureBuilder.kt @@ -1,4 +1,7 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// 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 + import com.intellij.facet.FacetTypeRegistry import com.intellij.facet.impl.FacetUtil import com.intellij.openapi.module.Module @@ -13,16 +16,9 @@ import com.intellij.testFramework.fixtures.impl.ModuleFixtureImpl import org.jetbrains.kotlin.idea.facet.KotlinFacet import org.jetbrains.kotlin.idea.facet.KotlinFacetType -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -interface KotlinModuleFixtureBuilder : JavaModuleFixtureBuilder { +interface KotlinModuleFixtureBuilder : JavaModuleFixtureBuilder - - - //fun addWebRoot(rootPath: @NonNls String, relativePath: @NonNls String): com.intellij.testFramework.builders.WebModuleFixtureBuilder - //fun setWebXml(path: @NonNls String): com.intellij.testFramework.builders.WebModuleFixtureBuilder -} - -class KotlinModuleFixtureBuilderImpl(val fixtureBuilder: TestFixtureBuilder) : +class KotlinModuleFixtureBuilderImpl(fixtureBuilder: TestFixtureBuilder) : JavaModuleFixtureBuilderImpl(StdModuleTypes.JAVA, fixtureBuilder), KotlinModuleFixtureBuilder { override fun instantiateFixture() = KotlinModuleTestFixtureImpl(this) @@ -33,16 +29,13 @@ class KotlinModuleFixtureBuilderImpl(val fixtureBuilder: TestFixtureBuilder?) : ModuleFixtureImpl(builder!!), KotlinModuleTestFixture { override val kotlinFacet: KotlinFacet? get() = KotlinFacet.get(module)!! - }