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)
This commit is contained in:
Pavel V. Talanov
2015-12-02 14:42:32 +03:00
parent ffd8863875
commit b9ce9f8576
29 changed files with 206 additions and 53 deletions
@@ -288,7 +288,7 @@ fun Pseudocode.getElementValuesRecursively(element: KtElement): List<PseudoValue
public fun KtElement.getContainingPseudocode(context: BindingContext): Pseudocode? {
val pseudocodeDeclaration =
PsiTreeUtil.getParentOfType(this, javaClass<KtDeclarationWithBody>(), javaClass<KtClassOrObject>())
PsiTreeUtil.getParentOfType(this, javaClass<KtDeclarationWithBody>(), javaClass<KtClassOrObject>(), javaClass<KtScript>())
?: getNonStrictParentOfType<KtProperty>()
?: return null
@@ -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<String>) {
System.setProperty("java.awt.headless", "true")
@@ -717,11 +719,11 @@ fun main(args: Array<String>) {
}
testClass<AbstractExtractionTest>() {
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")
}
@@ -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
@@ -600,10 +600,8 @@ private fun ExtractionData.getLocalInstructions(pseudocode: Pseudocode): List<In
}
fun ExtractionData.isVisibilityApplicable(): Boolean {
return when (targetSibling.parent) {
is KtClassBody, is KtFile -> true
else -> false
}
val parent = targetSibling.parent
return parent is KtClassBody || (parent is KtFile && !parent.isScript)
}
fun ExtractionData.getDefaultVisibility(): String {
@@ -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
)
@@ -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? {
@@ -0,0 +1 @@
<selection>val y = 2 + 3</selection>
@@ -0,0 +1 @@
Cannot refactor in this place
@@ -0,0 +1,3 @@
//TODO: the result is not correct, should place function declaration before it is used
1 + 2
<selection>2 + 3</selection>
@@ -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
}
@@ -0,0 +1 @@
<selection>1</selection> + 2
@@ -0,0 +1 @@
Cannot refactor in this place
@@ -0,0 +1 @@
fun f() = <selection>1</selection>
@@ -0,0 +1 @@
fun f(i: Int = 1) = i
@@ -0,0 +1 @@
<selection>1</selection>
@@ -0,0 +1 @@
Cannot refactor in this place
@@ -0,0 +1,4 @@
// EXTRACTION_TARGET: property with initializer
class A {
fun f() = <selection>1</selection>
}
@@ -0,0 +1,6 @@
// EXTRACTION_TARGET: property with initializer
class A {
private val i = 1
fun f() = i
}
@@ -0,0 +1,2 @@
// EXTRACTION_TARGET: property with initializer
<selection>1</selection> + 2
@@ -0,0 +1 @@
Cannot refactor in this place
@@ -0,0 +1,2 @@
// EXTRACTION_TARGET: property with initializer
<selection>1</selection>
@@ -0,0 +1 @@
Cannot refactor in this place
@@ -0,0 +1,2 @@
1 + 2
<selection>2</selection> + 3
@@ -0,0 +1,3 @@
val i = 2
1 + i
i + 3
@@ -0,0 +1 @@
<selection>val y = 2 + 3</selection>
@@ -0,0 +1 @@
Cannot refactor in this place
@@ -0,0 +1,2 @@
1 + 2
<selection>2 + 3</selection>
@@ -0,0 +1,2 @@
1 + 2
val i = 2 + 3
@@ -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")