From b6eda3534516ced34a010e3801c02ce0268acd67 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 26 May 2015 22:56:12 +0300 Subject: [PATCH] TODOs --- .../intentions/DeprecatedCallableAddReplaceWithIntention.kt | 5 ++++- .../deprecatedCallableAddReplaceWith/DeclarationInside.kt | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt index 103aa2226d1..0e49e33b434 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt @@ -67,10 +67,13 @@ public class DeprecatedCallableAddReplaceWithIntention : JetSelfTargetingRangeIn .replace("\\", "\\\\") .replace("\"", "\\\"") + //TODO: escape $! + val argumentText = StringBuilder { append("kotlin.ReplaceWith(\"") append(escapedText) append("\"") + //TODO: who should escape keywords here? replaceWith.imports.forEach { append(",\"").append(it).append("\"") } append(")") }.toString() @@ -164,7 +167,7 @@ public class DeprecatedCallableAddReplaceWithIntention : JetSelfTargetingRangeIn if (!hasBlockBody()) return body val block = body as? JetBlockExpression ?: return null val statement = block.getStatements().singleOrNull() as? JetExpression ?: return null - val returnsUnit = (analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? FunctionDescriptor)?.getReturnType()?.isUnit() ?: true + val returnsUnit = (analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? FunctionDescriptor)?.getReturnType()?.isUnit() ?: return null return when (statement) { is JetReturnExpression -> statement.getReturnedExpression() else -> if (returnsUnit) statement else null diff --git a/idea/testData/intentions/deprecatedCallableAddReplaceWith/DeclarationInside.kt b/idea/testData/intentions/deprecatedCallableAddReplaceWith/DeclarationInside.kt index 372deb2eebc..65a300839cb 100644 --- a/idea/testData/intentions/deprecatedCallableAddReplaceWith/DeclarationInside.kt +++ b/idea/testData/intentions/deprecatedCallableAddReplaceWith/DeclarationInside.kt @@ -3,7 +3,6 @@ fun foo(p: Int) { if (p > 0) { val v = p + 1 - bar(v) } }