From 20bff9f121df9046c45ee064cd1c5978f76446ab Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 13 May 2016 17:23:51 +0300 Subject: [PATCH] Unused symbol inspection refactoring: no use of bundled unused.* --- .../kotlin/idea/KotlinBundle.properties | 7 ------- .../inspections/UnusedSymbolInspection.kt | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties index 08ed24b5e66..f76a6a1042b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties @@ -46,13 +46,6 @@ goto.super.function.chooser.title=Choose super function goto.super.property.chooser.title=Choose super property goto.super.class.chooser.title=Choose super class or interface -unused.class=Class ''{0}'' is never used -unused.object=Object ''{0}'' is never used -unused.function=Function ''{0}'' is never used -unused.property=Property ''{0}'' is never used -unused.type.parameter=Type parameter ''{0}'' is never used -unused.constructor=Constructor is never used - unused.receiver.parameter=Receiver parameter is never used unused.receiver.parameter.remove=Remove redundant receiver parameter diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 5905c551202..7630e9d90c3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -131,13 +131,14 @@ class UnusedSymbolInspection : AbstractKotlinInspection() { return object : KtVisitorVoid() { override fun visitDeclaration(declaration: KtDeclaration) { if (declaration !is KtNamedDeclaration) return - val messageKey = when (declaration) { - is KtClass -> "unused.class" - is KtObjectDeclaration -> "unused.object" - is KtNamedFunction -> "unused.function" - is KtSecondaryConstructor -> "unused.constructor" - is KtProperty, is KtParameter -> "unused.property" - is KtTypeParameter -> "unused.type.parameter" + val name = declaration.name ?: return + val message = when (declaration) { + is KtClass -> "Class ''$name'' is never used" + is KtObjectDeclaration -> "Object ''$name'' is never used" + is KtNamedFunction -> "Function ''$name'' is never used" + is KtSecondaryConstructor -> "Constructor is never used" + is KtProperty, is KtParameter -> "Property ''$name'' is never used" + is KtTypeParameter -> "Type parameter ''$name'' is never used" else -> return } @@ -145,7 +146,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() { // Simple PSI-based checks if (declaration is KtObjectDeclaration && declaration.isCompanion()) return // never mark companion object as unused (there are too many reasons it can be needed for) - declaration.name ?: return + if (declaration is KtEnumEntry) return if (declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) return if (declaration is KtProperty && declaration.isLocal) return @@ -168,7 +169,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() { val problemDescriptor = holder.manager.createProblemDescriptor( psiElement, null, - KotlinBundle.message(messageKey, declaration.name), + message, ProblemHighlightType.LIKE_UNUSED_SYMBOL, true, *createQuickFixes(declaration).toTypedArray()