Tests for Sealed Class move + Fix invalid move declaration test
MoveDeclarationToSeparateFile.testSealed test was threated to check that the intention is not applicable but it currently is.
This commit is contained in:
committed by
Igor Yakovlev
parent
91d603292c
commit
60e3787800
@@ -73,12 +73,10 @@ private fun Module.collectKotlinAwareDestinationSourceRoots(): List<VirtualFile>
|
||||
}
|
||||
|
||||
fun isOutsideSourceRootSet(psiFile : PsiFile?, sourceRootTypes: Set<JpsModuleSourceRootType<*>>): Boolean {
|
||||
if (psiFile == null) return false
|
||||
if (psiFile is PsiCodeFragment) return false
|
||||
val file = psiFile.getVirtualFile()
|
||||
if (file == null) return false
|
||||
if (file.getFileSystem() is NonPhysicalFileSystem) return false
|
||||
val projectFileIndex = ProjectRootManager.getInstance(psiFile.getProject()).getFileIndex()
|
||||
if (psiFile == null || psiFile is PsiCodeFragment) return false
|
||||
val file = psiFile.virtualFile ?: return false
|
||||
if (file.fileSystem is NonPhysicalFileSystem) return false
|
||||
val projectFileIndex = ProjectRootManager.getInstance(psiFile.project).fileIndex
|
||||
return !projectFileIndex.isUnderSourceRootOfType(file, sourceRootTypes) && !projectFileIndex.isInLibrary(file)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// IS_APPLICABLE: false
|
||||
// INTENTION_TEXT: Extract 'A' and subclasses from current file
|
||||
sealed class A<caret>
|
||||
class B : A()
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package bar
|
||||
|
||||
public sealed class SealedClass {
|
||||
public class Impl1 : SealedClass() {}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package foo
|
||||
|
||||
import bar.SealedClass
|
||||
|
||||
val v = SealedClass::Impl1
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package foo
|
||||
|
||||
import bar.SealedClass
|
||||
|
||||
public class Impl2 : SealedClass() {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
val v = SealedClass::Impl1
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package foo
|
||||
|
||||
public sealed class <caret>SealedClass {
|
||||
public class Impl1 : SealedClass() {}
|
||||
}
|
||||
|
||||
public class Impl2 : SealedClass() {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Sealed class 'SealedClass' must be moved with all its subclasses
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "foo/SealedClass.kt",
|
||||
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||
"targetPackage": "bar"
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package bar
|
||||
|
||||
public sealed class SealedClass {
|
||||
public class Impl1 : SealedClass() {}
|
||||
public class Impl2 : SealedClass() {}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package foo
|
||||
|
||||
import bar.SealedClass
|
||||
|
||||
val v = SealedClass::Impl1
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package foo
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
val v = SealedClass::Impl1
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package foo
|
||||
|
||||
public sealed class <caret>SealedClass {
|
||||
public class Impl1 : SealedClass() {}
|
||||
public class Impl2 : SealedClass() {}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "foo/SealedClass.kt",
|
||||
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||
"targetPackage": "bar"
|
||||
}
|
||||
+10
@@ -739,6 +739,16 @@ public class MoveTestGenerated extends AbstractMoveTest {
|
||||
runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyToPackage/movePropertyToPackage.test");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test")
|
||||
public void testKotlin_moveTopLevelDeclarations_moveSealedClassWithImplsToAnotherPackage_MoveSealedClassWithNestedImplsToAnotherPackage() throws Exception {
|
||||
runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlin/moveTopLevelDeclarations/moveSealedClassWithNestedImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test")
|
||||
public void testKotlin_moveTopLevelDeclarations_moveSealedClassWithNestedImplsToAnotherPackage_MoveSealedClassWithNestedImplsToAnotherPackage() throws Exception {
|
||||
runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithNestedImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlin/moveTopLevelDeclarations/objectAlreadyInaccessible/objectAlreadyInaccessible.test")
|
||||
public void testKotlin_moveTopLevelDeclarations_objectAlreadyInaccessible_ObjectAlreadyInaccessible() throws Exception {
|
||||
runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/objectAlreadyInaccessible/objectAlreadyInaccessible.test");
|
||||
|
||||
Reference in New Issue
Block a user