Search for KtTypeAlias in safe delete processor
Related to KT-16046
This commit is contained in:
@@ -725,6 +725,7 @@ fun main(args: Array<String>) {
|
||||
model("refactoring/safeDelete/deleteProperty/kotlinProperty", testMethod = "doPropertyTest")
|
||||
model("refactoring/safeDelete/deleteProperty/kotlinPropertyWithJava", testMethod = "doPropertyTestWithJava")
|
||||
model("refactoring/safeDelete/deleteProperty/javaPropertyWithKotlin", testMethod = "doJavaPropertyTest")
|
||||
model("refactoring/safeDelete/deleteTypeAlias/kotlinTypeAlias", testMethod = "doTypeAliasTest")
|
||||
model("refactoring/safeDelete/deleteTypeParameter/kotlinTypeParameter", testMethod = "doTypeParameterTest")
|
||||
model("refactoring/safeDelete/deleteTypeParameter/kotlinTypeParameterWithJava", testMethod = "doTypeParameterTestWithJava")
|
||||
model("refactoring/safeDelete/deleteValueParameter/kotlinValueParameter", testMethod = "doValueParameterTest")
|
||||
|
||||
@@ -237,6 +237,10 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
is KtParameter ->
|
||||
findUsagesByJavaProcessor(element)
|
||||
|
||||
is KtTypeAlias -> {
|
||||
findKotlinDeclarationUsages(element)
|
||||
}
|
||||
|
||||
else -> null
|
||||
} ?: getSearchInfo(element)
|
||||
}
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
typealias <caret>MyString = String
|
||||
@@ -0,0 +1,7 @@
|
||||
typealias <caret>MyString = String
|
||||
|
||||
val ms: MyString = ""
|
||||
|
||||
class My {
|
||||
val mms: MyString = ""
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
type alias MyString has 1 usage that is not safe to delete.
|
||||
+4
@@ -91,6 +91,10 @@ public abstract class AbstractSafeDeleteTest extends KotlinLightCodeInsightFixtu
|
||||
doTest(path, PsiMethod.class, true);
|
||||
}
|
||||
|
||||
public void doTypeAliasTest(@NotNull String path) throws Exception {
|
||||
doTest(path, KtTypeAlias.class, false);
|
||||
}
|
||||
|
||||
public void doTypeParameterTest(@NotNull String path) throws Exception {
|
||||
doTest(path, KtTypeParameter.class, false);
|
||||
}
|
||||
|
||||
+21
@@ -720,6 +720,27 @@ public class SafeDeleteTestGenerated extends AbstractSafeDeleteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/refactoring/safeDelete/deleteTypeAlias/kotlinTypeAlias")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class KotlinTypeAlias extends AbstractSafeDeleteTest {
|
||||
public void testAllFilesPresentInKotlinTypeAlias() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/safeDelete/deleteTypeAlias/kotlinTypeAlias"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/safeDelete/deleteTypeAlias/kotlinTypeAlias/simple.kt");
|
||||
doTypeAliasTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("used.kt")
|
||||
public void testUsed() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/safeDelete/deleteTypeAlias/kotlinTypeAlias/used.kt");
|
||||
doTypeAliasTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/refactoring/safeDelete/deleteTypeParameter/kotlinTypeParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user