From 87e37253063cfde2b341cf86744b6101c574f556 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 24 May 2017 22:52:04 +0300 Subject: [PATCH] Do not report property as unused when it is used #KT-17062 Fixed --- .../idea/refactoring/inline/KotlinInlineValHandler.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt index 71c72381f9c..ebfd676eaf3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt @@ -73,9 +73,9 @@ class KotlinInlineValHandler : InlineActionHandler() { val (referenceExpressions, conflicts) = findUsages(declaration) - if (referenceExpressions.isEmpty()) { + if (referenceExpressions.isEmpty() && conflicts.isEmpty) { val kind = if (declaration.isLocal) "Variable" else "Property" - return showErrorHint(project, editor, "$kind '$name' is never used") //TODO: foreign usages! + return showErrorHint(project, editor, "$kind '$name' is never used") } val referencesInOriginalFile = referenceExpressions.filter { it.containingFile == file } @@ -105,7 +105,8 @@ class KotlinInlineValHandler : InlineActionHandler() { if (!conflicts.isEmpty) { val conflictsCopy = conflicts.copy() - conflictsCopy.putValue(null, "The following usages are not supported by the Inline refactoring. They won't be processed.") + val allOrSome = if (referenceExpressions.isEmpty()) "All" else "The following" + conflictsCopy.putValue(null, "$allOrSome usages are not supported by the Inline refactoring. They won't be processed.") project.checkConflictsInteractively(conflictsCopy) { performRefactoring(declaration, readReplacement, writeReplacement, assignmentToDelete, editor, hasHighlightings)