Do not report property as unused when it is used

#KT-17062 Fixed
This commit is contained in:
Valentin Kipyatkov
2017-05-24 22:52:04 +03:00
parent 986eaeb7ea
commit 87e3725306
@@ -73,9 +73,9 @@ class KotlinInlineValHandler : InlineActionHandler() {
val (referenceExpressions, conflicts) = findUsages(declaration) val (referenceExpressions, conflicts) = findUsages(declaration)
if (referenceExpressions.isEmpty()) { if (referenceExpressions.isEmpty() && conflicts.isEmpty) {
val kind = if (declaration.isLocal) "Variable" else "Property" 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 } val referencesInOriginalFile = referenceExpressions.filter { it.containingFile == file }
@@ -105,7 +105,8 @@ class KotlinInlineValHandler : InlineActionHandler() {
if (!conflicts.isEmpty) { if (!conflicts.isEmpty) {
val conflictsCopy = conflicts.copy() 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) { project.checkConflictsInteractively(conflictsCopy) {
performRefactoring(declaration, readReplacement, writeReplacement, assignmentToDelete, editor, hasHighlightings) performRefactoring(declaration, readReplacement, writeReplacement, assignmentToDelete, editor, hasHighlightings)