From 228ab8643bdfa564356e01656c55c5bc5ab682bd Mon Sep 17 00:00:00 2001 From: Alexey Belkov Date: Tue, 22 Nov 2022 14:37:40 +0400 Subject: [PATCH] [kotlin] Add test for obsolete issue ^KTIJ-10245 Obsolete GitOrigin-RevId: 76acc582d82ae65903ffefa11acb14e551e2e9a2 --- .../kotlin/idea/intentions/AbstractIntentionTestBase.kt | 5 +++++ .../kotlin/idea/intentions/K1IntentionTestGenerated.java | 5 +++++ .../testData/intentions/moveMemberToTopLevel/script.kts | 5 +++++ .../intentions/moveMemberToTopLevel/script.kts.after | 6 ++++++ 4 files changed, 21 insertions(+) create mode 100644 plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts create mode 100644 plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts.after diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTestBase.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTestBase.kt index f1c464e46be0..3fcfd31d7143 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTestBase.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTestBase.kt @@ -25,6 +25,7 @@ import junit.framework.TestCase import org.jetbrains.kotlin.formatter.FormatSettingsUtil import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.idea.codeInsight.hints.KotlinAbstractHintsProvider +import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager import org.jetbrains.kotlin.idea.test.* import org.jetbrains.kotlin.idea.util.application.executeCommand import org.jetbrains.kotlin.idea.util.application.executeWriteCommand @@ -124,6 +125,10 @@ abstract class AbstractIntentionTestBase : KotlinLightCodeInsightFixtureTestCase val pathToFiles = mapOf(*(sourceFilePaths zip psiFiles).toTypedArray()) ConfigLibraryUtil.configureLibrariesByDirective(module, fileText) + if ((myFixture.file as? KtFile)?.isScript() == true) { + ScriptConfigurationManager.updateScriptDependenciesSynchronously(myFixture.file) + } + configureCodeStyleAndRun(project, { FormatSettingsUtil.createConfigurator(fileText, it).configureSettings() }) { configureRegistryAndRun(fileText) { try { diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java index 89646df0e198..5c3fa8d264e1 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java @@ -14107,6 +14107,11 @@ public abstract class K1IntentionTestGenerated extends AbstractK1IntentionTest { public void testRedeclarationPropertyConflict() throws Exception { runTest("testData/intentions/moveMemberToTopLevel/redeclarationPropertyConflict.kt"); } + + @TestMetadata("script.kts") + public void testScript() throws Exception { + runTest("testData/intentions/moveMemberToTopLevel/script.kts"); + } } @RunWith(JUnit3RunnerWithInners.class) diff --git a/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts b/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts new file mode 100644 index 000000000000..35fba43f0d23 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts @@ -0,0 +1,5 @@ +// RUNTIME_WITH_SCRIPT_RUNTIME +object Foo { + fun foo() = 1 + val a = 1 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts.after b/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts.after new file mode 100644 index 000000000000..f20263622cd2 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/script.kts.after @@ -0,0 +1,6 @@ +// RUNTIME_WITH_SCRIPT_RUNTIME +object Foo { + val a = 1 +} + +fun foo() = 1