Add type aliases into UnusedSymbolInspection / safe delete

So #KT-16046 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-07-21 13:09:13 +03:00
parent 951e8cd91a
commit dd0cf8219e
6 changed files with 33 additions and 0 deletions
@@ -145,6 +145,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
is KtSecondaryConstructor -> "Constructor is never used"
is KtProperty, is KtParameter -> "Property ''$name'' is never used"
is KtTypeParameter -> "Type parameter ''$name'' is never used"
is KtTypeAlias -> "Type alias ''$name'' is never used"
else -> return
}
@@ -49,6 +49,7 @@ fun PsiElement.canDeleteElement(): Boolean {
|| this is PsiClass
|| this is KtProperty
|| this is KtTypeParameter
|| this is KtTypeAlias
}
fun PsiElement.removeOverrideModifier() {
@@ -0,0 +1,18 @@
<problems>
<problem>
<file>test.kt</file>
<line>4</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused symbol</problem_class>
<description>Type alias ''YourString'' is never used</description>
</problem>
<problem>
<file>test.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused symbol</problem_class>
<description>Property ''ms'' is never used</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
@@ -0,0 +1,6 @@
typealias MyString = String
// unused
typealias YourString = String
val ms: MyString = ""
@@ -413,6 +413,12 @@ public class InspectionTestGenerated extends AbstractInspectionTest {
doTest(fileName);
}
@TestMetadata("unusedSymbol/typeAlias/inspectionData/inspections.test")
public void testUnusedSymbol_typeAlias_inspectionData_Inspections_test() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/inspections.test");
doTest(fileName);
}
@TestMetadata("unusedSymbol/typeParameter/inspectionData/inspections.test")
public void testUnusedSymbol_typeParameter_inspectionData_Inspections_test() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/unusedSymbol/typeParameter/inspectionData/inspections.test");