From b9ce9f857615d32db3ad84766a414a80775fbf5b Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 2 Dec 2015 14:42:32 +0300 Subject: [PATCH] Script, IDE: tweak extract based refactorings to behave better in scripts Fix not being able to invoke introduce variable for top level script expression Prohibit introduce parameter and introduce property for scripts on top level Basic test for introduce function (produces red code atm) --- .../kotlin/cfg/pseudocode/pseudocodeUtils.kt | 2 +- .../kotlin/generators/tests/GenerateTests.kt | 12 +- .../idea/codeInsight/CodeInsightUtils.java | 5 + .../extractableAnalysisUtil.kt | 6 +- .../KotlinIntroducePropertyHandler.kt | 2 +- .../KotlinIntroduceVariableHandler.kt | 3 +- .../extractFunction/script/NotExpression.kts | 1 + .../script/NotExpression.kts.conflicts | 1 + .../script/TopLevelExpression.kts | 3 + .../script/TopLevelExpression.kts.after | 7 + .../script/ExpressionPart.kts | 1 + .../script/ExpressionPart.kts.conflicts | 1 + .../introduceParameter/script/FunInScript.kts | 1 + .../script/FunInScript.kts.after | 1 + .../script/TopLevelExpression.kts | 1 + .../script/TopLevelExpression.kts.conflicts | 1 + .../script/ClassInScript.kts | 4 + .../script/ClassInScript.kts.after | 6 + .../script/ExpressionPart.kts | 2 + .../script/ExpressionPart.kts.conflicts | 1 + .../script/TopLevelExpression.kts | 2 + .../script/TopLevelExpression.kts.conflicts | 1 + .../script/ExpressionPart.kts | 2 + .../script/ExpressionPart.kts.after | 3 + .../script/NotExpression.kts | 1 + .../script/NotExpression.kts.conflicts | 1 + .../script/TopLevelExpression.kts | 2 + .../script/TopLevelExpression.kts.after | 2 + .../introduce/ExtractionTestGenerated.java | 184 ++++++++++++++---- 29 files changed, 206 insertions(+), 53 deletions(-) create mode 100644 idea/testData/refactoring/extractFunction/script/NotExpression.kts create mode 100644 idea/testData/refactoring/extractFunction/script/NotExpression.kts.conflicts create mode 100644 idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts create mode 100644 idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts.after create mode 100644 idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts create mode 100644 idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts.conflicts create mode 100644 idea/testData/refactoring/introduceParameter/script/FunInScript.kts create mode 100644 idea/testData/refactoring/introduceParameter/script/FunInScript.kts.after create mode 100644 idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts create mode 100644 idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts.conflicts create mode 100644 idea/testData/refactoring/introduceProperty/script/ClassInScript.kts create mode 100644 idea/testData/refactoring/introduceProperty/script/ClassInScript.kts.after create mode 100644 idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts create mode 100644 idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts.conflicts create mode 100644 idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts create mode 100644 idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts.conflicts create mode 100644 idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts create mode 100644 idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after create mode 100644 idea/testData/refactoring/introduceVariable/script/NotExpression.kts create mode 100644 idea/testData/refactoring/introduceVariable/script/NotExpression.kts.conflicts create mode 100644 idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts create mode 100644 idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts.after diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt index 2a299e801f3..663edd0492e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt @@ -288,7 +288,7 @@ fun Pseudocode.getElementValuesRecursively(element: KtElement): List(), javaClass()) + PsiTreeUtil.getParentOfType(this, javaClass(), javaClass(), javaClass()) ?: getNonStrictParentOfType() ?: return null diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 566b8f112ea..029f5f4b0ff 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -135,6 +135,8 @@ import java.io.File import java.util.* import java.util.regex.Pattern +private val kotlinFileOrScript = "^(.+)\\.(kt|kts)\$" + fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -717,11 +719,11 @@ fun main(args: Array) { } testClass() { - model("refactoring/introduceVariable", extension = "kt", testMethod = "doIntroduceVariableTest") - model("refactoring/extractFunction", extension = "kt", testMethod = "doExtractFunctionTest") - model("refactoring/introduceProperty", extension = "kt", testMethod = "doIntroducePropertyTest") - model("refactoring/introduceParameter", extension = "kt", testMethod = "doIntroduceSimpleParameterTest") - model("refactoring/introduceLambdaParameter", extension = "kt", testMethod = "doIntroduceLambdaParameterTest") + model("refactoring/introduceVariable", pattern = kotlinFileOrScript, testMethod = "doIntroduceVariableTest") + model("refactoring/extractFunction", pattern = kotlinFileOrScript, testMethod = "doExtractFunctionTest") + model("refactoring/introduceProperty", pattern = kotlinFileOrScript, testMethod = "doIntroducePropertyTest") + model("refactoring/introduceParameter", pattern = kotlinFileOrScript, testMethod = "doIntroduceSimpleParameterTest") + model("refactoring/introduceLambdaParameter", pattern = kotlinFileOrScript, testMethod = "doIntroduceLambdaParameterTest") model("refactoring/introduceJavaParameter", extension = "java", testMethod = "doIntroduceJavaParameterTest") } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java index 374570432bd..8ee0b1ae192 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java @@ -49,6 +49,11 @@ public class CodeInsightUtils { @Nullable public static KtExpression findExpression(@NotNull PsiFile file, int startOffset, int endOffset) { KtExpression element = findElementOfClassAtRange(file, startOffset, endOffset, KtExpression.class); + + if (element instanceof KtScriptInitializer) { + element = ((KtScriptInitializer) element).getBody(); + } + if (element == null) return null; // TODO: Support binary operations in "Introduce..." refactorings diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt index 979cd5739bb..7d473a9c356 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt @@ -600,10 +600,8 @@ private fun ExtractionData.getLocalInstructions(pseudocode: Pseudocode): List true - else -> false - } + val parent = targetSibling.parent + return parent is KtClassBody || (parent is KtFile && !parent.isScript) } fun ExtractionData.getDefaultVisibility(): String { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt index 345fdf883a9..7d2d3c26b8a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt @@ -58,7 +58,7 @@ public class KotlinIntroducePropertyHandler( editor, file, { elements, parent -> - parent.getExtractionContainers(strict = true, includeAll = true).filter { it is KtClassBody || it is KtFile } + parent.getExtractionContainers(strict = true, includeAll = true).filter { it is KtClassBody || (it is KtFile && !it.isScript) } }, continuation ) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt index ca73d22fd55..3edbc0a24d2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt @@ -332,7 +332,8 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() { } private fun KtExpression.shouldReplaceOccurrence(bindingContext: BindingContext, container: PsiElement?): Boolean { - return isUsedAsExpression(bindingContext) || container != parent + val effectiveParent = (parent as? KtScriptInitializer)?.parent ?: parent + return isUsedAsExpression(bindingContext) || container != effectiveParent } private fun KtElement.getContainer(): KtElement? { diff --git a/idea/testData/refactoring/extractFunction/script/NotExpression.kts b/idea/testData/refactoring/extractFunction/script/NotExpression.kts new file mode 100644 index 00000000000..c7ac23f5ae2 --- /dev/null +++ b/idea/testData/refactoring/extractFunction/script/NotExpression.kts @@ -0,0 +1 @@ +val y = 2 + 3 \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/script/NotExpression.kts.conflicts b/idea/testData/refactoring/extractFunction/script/NotExpression.kts.conflicts new file mode 100644 index 00000000000..1568c6aea62 --- /dev/null +++ b/idea/testData/refactoring/extractFunction/script/NotExpression.kts.conflicts @@ -0,0 +1 @@ +Cannot refactor in this place diff --git a/idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts b/idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts new file mode 100644 index 00000000000..9d3b762fd72 --- /dev/null +++ b/idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts @@ -0,0 +1,3 @@ +//TODO: the result is not correct, should place function declaration before it is used +1 + 2 +2 + 3 \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts.after b/idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts.after new file mode 100644 index 00000000000..efd7c52579c --- /dev/null +++ b/idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts.after @@ -0,0 +1,7 @@ +//TODO: the result is not correct, should place function declaration before it is used +1 + 2 +__dummyTestFun__() + +fun __dummyTestFun__() { + 2 + 3 +} diff --git a/idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts b/idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts new file mode 100644 index 00000000000..fa23285b2b1 --- /dev/null +++ b/idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts @@ -0,0 +1 @@ +1 + 2 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts.conflicts b/idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts.conflicts new file mode 100644 index 00000000000..1568c6aea62 --- /dev/null +++ b/idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts.conflicts @@ -0,0 +1 @@ +Cannot refactor in this place diff --git a/idea/testData/refactoring/introduceParameter/script/FunInScript.kts b/idea/testData/refactoring/introduceParameter/script/FunInScript.kts new file mode 100644 index 00000000000..94c7437f6ab --- /dev/null +++ b/idea/testData/refactoring/introduceParameter/script/FunInScript.kts @@ -0,0 +1 @@ +fun f() = 1 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceParameter/script/FunInScript.kts.after b/idea/testData/refactoring/introduceParameter/script/FunInScript.kts.after new file mode 100644 index 00000000000..51f68873055 --- /dev/null +++ b/idea/testData/refactoring/introduceParameter/script/FunInScript.kts.after @@ -0,0 +1 @@ +fun f(i: Int = 1) = i diff --git a/idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts b/idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts new file mode 100644 index 00000000000..909b7e12d61 --- /dev/null +++ b/idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts.conflicts b/idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts.conflicts new file mode 100644 index 00000000000..1568c6aea62 --- /dev/null +++ b/idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts.conflicts @@ -0,0 +1 @@ +Cannot refactor in this place diff --git a/idea/testData/refactoring/introduceProperty/script/ClassInScript.kts b/idea/testData/refactoring/introduceProperty/script/ClassInScript.kts new file mode 100644 index 00000000000..781fda967a7 --- /dev/null +++ b/idea/testData/refactoring/introduceProperty/script/ClassInScript.kts @@ -0,0 +1,4 @@ +// EXTRACTION_TARGET: property with initializer +class A { + fun f() = 1 +} \ No newline at end of file diff --git a/idea/testData/refactoring/introduceProperty/script/ClassInScript.kts.after b/idea/testData/refactoring/introduceProperty/script/ClassInScript.kts.after new file mode 100644 index 00000000000..9bba3c35669 --- /dev/null +++ b/idea/testData/refactoring/introduceProperty/script/ClassInScript.kts.after @@ -0,0 +1,6 @@ +// EXTRACTION_TARGET: property with initializer +class A { + private val i = 1 + + fun f() = i +} diff --git a/idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts b/idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts new file mode 100644 index 00000000000..0a98ba5d41a --- /dev/null +++ b/idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts @@ -0,0 +1,2 @@ +// EXTRACTION_TARGET: property with initializer +1 + 2 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts.conflicts b/idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts.conflicts new file mode 100644 index 00000000000..1568c6aea62 --- /dev/null +++ b/idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts.conflicts @@ -0,0 +1 @@ +Cannot refactor in this place diff --git a/idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts b/idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts new file mode 100644 index 00000000000..b737ad1f147 --- /dev/null +++ b/idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts @@ -0,0 +1,2 @@ +// EXTRACTION_TARGET: property with initializer +1 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts.conflicts b/idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts.conflicts new file mode 100644 index 00000000000..1568c6aea62 --- /dev/null +++ b/idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts.conflicts @@ -0,0 +1 @@ +Cannot refactor in this place diff --git a/idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts b/idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts new file mode 100644 index 00000000000..1625c61f8f9 --- /dev/null +++ b/idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts @@ -0,0 +1,2 @@ +1 + 2 +2 + 3 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after b/idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after new file mode 100644 index 00000000000..e260b613b08 --- /dev/null +++ b/idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after @@ -0,0 +1,3 @@ +val i = 2 +1 + i +i + 3 diff --git a/idea/testData/refactoring/introduceVariable/script/NotExpression.kts b/idea/testData/refactoring/introduceVariable/script/NotExpression.kts new file mode 100644 index 00000000000..c7ac23f5ae2 --- /dev/null +++ b/idea/testData/refactoring/introduceVariable/script/NotExpression.kts @@ -0,0 +1 @@ +val y = 2 + 3 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceVariable/script/NotExpression.kts.conflicts b/idea/testData/refactoring/introduceVariable/script/NotExpression.kts.conflicts new file mode 100644 index 00000000000..1568c6aea62 --- /dev/null +++ b/idea/testData/refactoring/introduceVariable/script/NotExpression.kts.conflicts @@ -0,0 +1 @@ +Cannot refactor in this place diff --git a/idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts b/idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts new file mode 100644 index 00000000000..792645ca206 --- /dev/null +++ b/idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts @@ -0,0 +1,2 @@ +1 + 2 +2 + 3 \ No newline at end of file diff --git a/idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts.after b/idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts.after new file mode 100644 index 00000000000..9f0440f9f6c --- /dev/null +++ b/idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts.after @@ -0,0 +1,2 @@ +1 + 2 +val i = 2 + 3 diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java index 99fd40ce24c..7de1ee38986 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java @@ -34,7 +34,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class IntroduceVariable extends AbstractExtractionTest { public void testAllFilesPresentInIntroduceVariable() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("ArrayAccessExpr.kt") @@ -438,7 +438,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ExtractToScope extends AbstractExtractionTest { public void testAllFilesPresentInExtractToScope() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/extractToScope"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/extractToScope"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("implicitOuterThisInsideNestedLamba.kt") @@ -513,7 +513,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class MultiDeclarations extends AbstractExtractionTest { public void testAllFilesPresentInMultiDeclarations() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/multiDeclarations"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/multiDeclarations"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("array.kt") @@ -565,12 +565,39 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { } } + @TestMetadata("idea/testData/refactoring/introduceVariable/script") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Script extends AbstractExtractionTest { + public void testAllFilesPresentInScript() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/script"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); + } + + @TestMetadata("ExpressionPart.kts") + public void testExpressionPart() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/script/ExpressionPart.kts"); + doIntroduceVariableTest(fileName); + } + + @TestMetadata("NotExpression.kts") + public void testNotExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/script/NotExpression.kts"); + doIntroduceVariableTest(fileName); + } + + @TestMetadata("TopLevelExpression.kts") + public void testTopLevelExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/script/TopLevelExpression.kts"); + doIntroduceVariableTest(fileName); + } + } + @TestMetadata("idea/testData/refactoring/introduceVariable/stringTemplates") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class StringTemplates extends AbstractExtractionTest { public void testAllFilesPresentInStringTemplates() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/stringTemplates"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/stringTemplates"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("brokenEntryWithBlockExpr.kt") @@ -676,7 +703,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ExtractFunction extends AbstractExtractionTest { public void testAllFilesPresentInExtractFunction() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("idea/testData/refactoring/extractFunction/basic") @@ -684,7 +711,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Basic extends AbstractExtractionTest { public void testAllFilesPresentInBasic() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/basic"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/basic"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("callWithPlatformTypeReceiver.kt") @@ -951,7 +978,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ControlFlow extends AbstractExtractionTest { public void testAllFilesPresentInControlFlow() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("idea/testData/refactoring/extractFunction/controlFlow/conditionalJumps") @@ -959,7 +986,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ConditionalJumps extends AbstractExtractionTest { public void testAllFilesPresentInConditionalJumps() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/conditionalJumps"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/conditionalJumps"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("conditionalBreakWithIf.kt") @@ -1028,7 +1055,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Default extends AbstractExtractionTest { public void testAllFilesPresentInDefault() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/default"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/default"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("defaultCF.kt") @@ -1079,7 +1106,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class DefiniteReturns extends AbstractExtractionTest { public void testAllFilesPresentInDefiniteReturns() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/definiteReturns"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/definiteReturns"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("definiteReturnWithIf.kt") @@ -1136,7 +1163,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class EvaluateExpression extends AbstractExtractionTest { public void testAllFilesPresentInEvaluateExpression() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/evaluateExpression"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/evaluateExpression"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("evalExprInIfCondition.kt") @@ -1229,7 +1256,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ExitPointEquivalence extends AbstractExtractionTest { public void testAllFilesPresentInExitPointEquivalence() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/exitPointEquivalence"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/exitPointEquivalence"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("breakAndReturn.kt") @@ -1286,7 +1313,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Initializer extends AbstractExtractionTest { public void testAllFilesPresentInInitializer() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/initializer"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/initializer"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("propertyWithInitializer.kt") @@ -1337,7 +1364,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class OutputValues extends AbstractExtractionTest { public void testAllFilesPresentInOutputValues() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/outputValues"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/outputValues"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("genericPair.kt") @@ -1496,7 +1523,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ReturnTypeCandidates extends AbstractExtractionTest { public void testAllFilesPresentInReturnTypeCandidates() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("javaAnnotatedNotNull.kt") @@ -1523,7 +1550,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Throws extends AbstractExtractionTest { public void testAllFilesPresentInThrows() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/throws"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/throws"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("breakWithThrow.kt") @@ -1568,7 +1595,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Unextractable extends AbstractExtractionTest { public void testAllFilesPresentInUnextractable() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/unextractable"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/controlFlow/unextractable"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("anonymousObject.kt") @@ -1620,7 +1647,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class DefaultContainer extends AbstractExtractionTest { public void testAllFilesPresentInDefaultContainer() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/defaultContainer"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/defaultContainer"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("anonymousObject.kt") @@ -1671,7 +1698,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Delegation extends AbstractExtractionTest { public void testAllFilesPresentInDelegation() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/delegation"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/delegation"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("delegationByExpression.kt") @@ -1698,7 +1725,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Duplicates extends AbstractExtractionTest { public void testAllFilesPresentInDuplicates() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/duplicates"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/duplicates"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("branchingMatch1.kt") @@ -1773,7 +1800,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Initializers extends AbstractExtractionTest { public void testAllFilesPresentInInitializers() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("idea/testData/refactoring/extractFunction/initializers/accessors") @@ -1781,7 +1808,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Accessors extends AbstractExtractionTest { public void testAllFilesPresentInAccessors() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/accessors"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/accessors"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("memberProperty.kt") @@ -1814,7 +1841,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Classes extends AbstractExtractionTest { public void testAllFilesPresentInClasses() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/classes"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/classes"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("classInitializer.kt") @@ -1847,7 +1874,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Functions extends AbstractExtractionTest { public void testAllFilesPresentInFunctions() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/functions"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/functions"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("localFunction.kt") @@ -1928,7 +1955,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Properties extends AbstractExtractionTest { public void testAllFilesPresentInProperties() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/properties"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/initializers/properties"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("localProperty.kt") @@ -1986,7 +2013,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class Parameters extends AbstractExtractionTest { public void testAllFilesPresentInParameters() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("idea/testData/refactoring/extractFunction/parameters/candidateTypes") @@ -1994,7 +2021,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class CandidateTypes extends AbstractExtractionTest { public void testAllFilesPresentInCandidateTypes() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/candidateTypes"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/candidateTypes"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("cantLiftAnonymousToSupertype.kt") @@ -2105,7 +2132,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class CapturedFunctions extends AbstractExtractionTest { public void testAllFilesPresentInCapturedFunctions() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/capturedFunctions"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/capturedFunctions"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("deeplyLocalFun.kt") @@ -2144,7 +2171,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ExtractSuper extends AbstractExtractionTest { public void testAllFilesPresentInExtractSuper() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/extractSuper"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/extractSuper"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("labeledSuperPropertyCall.kt") @@ -2177,7 +2204,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class ExtractThis extends AbstractExtractionTest { public void testAllFilesPresentInExtractThis() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/extractThis"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/extractThis"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("explicitLabeledThisInMember.kt") @@ -2312,7 +2339,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class It extends AbstractExtractionTest { public void testAllFilesPresentInIt() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/it"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/it"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("innerIt.kt") @@ -2351,7 +2378,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { } public void testAllFilesPresentInMisc() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/misc"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/misc"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("classObject.kt") @@ -2510,7 +2537,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class NonDenotableTypes extends AbstractExtractionTest { public void testAllFilesPresentInNonDenotableTypes() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/nonDenotableTypes"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/parameters/nonDenotableTypes"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("anonymousObject.kt") @@ -2557,12 +2584,33 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { } } + @TestMetadata("idea/testData/refactoring/extractFunction/script") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Script extends AbstractExtractionTest { + public void testAllFilesPresentInScript() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/script"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); + } + + @TestMetadata("NotExpression.kts") + public void testNotExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/script/NotExpression.kts"); + doExtractFunctionTest(fileName); + } + + @TestMetadata("TopLevelExpression.kts") + public void testTopLevelExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/script/TopLevelExpression.kts"); + doExtractFunctionTest(fileName); + } + } + @TestMetadata("idea/testData/refactoring/extractFunction/stringTemplates") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class StringTemplates extends AbstractExtractionTest { public void testAllFilesPresentInStringTemplates() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/stringTemplates"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/stringTemplates"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("brokenEntryWithBlockExpr.kt") @@ -2667,7 +2715,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class TypeParameters extends AbstractExtractionTest { public void testAllFilesPresentInTypeParameters() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/typeParameters"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/typeParameters"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("localClassInBound.kt") @@ -2779,7 +2827,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class IntroduceProperty extends AbstractExtractionTest { public void testAllFilesPresentInIntroduceProperty() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceProperty"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceProperty"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("extractExtensionWithInitializer.kt") @@ -2962,12 +3010,39 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { doIntroducePropertyTest(fileName); } + @TestMetadata("idea/testData/refactoring/introduceProperty/script") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Script extends AbstractExtractionTest { + public void testAllFilesPresentInScript() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceProperty/script"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); + } + + @TestMetadata("ClassInScript.kts") + public void testClassInScript() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/script/ClassInScript.kts"); + doIntroducePropertyTest(fileName); + } + + @TestMetadata("ExpressionPart.kts") + public void testExpressionPart() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/script/ExpressionPart.kts"); + doIntroducePropertyTest(fileName); + } + + @TestMetadata("TopLevelExpression.kts") + public void testTopLevelExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/script/TopLevelExpression.kts"); + doIntroducePropertyTest(fileName); + } + } + @TestMetadata("idea/testData/refactoring/introduceProperty/stringTemplates") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class StringTemplates extends AbstractExtractionTest { public void testAllFilesPresentInStringTemplates() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceProperty/stringTemplates"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceProperty/stringTemplates"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("brokenEntryWithBlockExpr.kt") @@ -3073,7 +3148,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class IntroduceParameter extends AbstractExtractionTest { public void testAllFilesPresentInIntroduceParameter() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceParameter"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceParameter"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("assignment.kt") @@ -3364,12 +3439,39 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { doIntroduceSimpleParameterTest(fileName); } + @TestMetadata("idea/testData/refactoring/introduceParameter/script") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Script extends AbstractExtractionTest { + public void testAllFilesPresentInScript() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceParameter/script"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); + } + + @TestMetadata("ExpressionPart.kts") + public void testExpressionPart() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceParameter/script/ExpressionPart.kts"); + doIntroduceSimpleParameterTest(fileName); + } + + @TestMetadata("FunInScript.kts") + public void testFunInScript() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceParameter/script/FunInScript.kts"); + doIntroduceSimpleParameterTest(fileName); + } + + @TestMetadata("TopLevelExpression.kts") + public void testTopLevelExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceParameter/script/TopLevelExpression.kts"); + doIntroduceSimpleParameterTest(fileName); + } + } + @TestMetadata("idea/testData/refactoring/introduceParameter/stringTemplates") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class StringTemplates extends AbstractExtractionTest { public void testAllFilesPresentInStringTemplates() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceParameter/stringTemplates"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceParameter/stringTemplates"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("brokenEntryWithBlockExpr.kt") @@ -3475,7 +3577,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class IntroduceLambdaParameter extends AbstractExtractionTest { public void testAllFilesPresentInIntroduceLambdaParameter() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceLambdaParameter"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceLambdaParameter"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("lambdaArgument.kt") @@ -3537,7 +3639,7 @@ public class ExtractionTestGenerated extends AbstractExtractionTest { @RunWith(JUnit3RunnerWithInners.class) public static class StringTemplates extends AbstractExtractionTest { public void testAllFilesPresentInStringTemplates() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceLambdaParameter/stringTemplates"), Pattern.compile("^(.+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceLambdaParameter/stringTemplates"), Pattern.compile("^(.+)\\.(kt|kts)$"), true); } @TestMetadata("brokenEntryWithBlockExpr.kt")