No more usages of createReturn(text)

This commit is contained in:
Valentin Kipyatkov
2015-05-11 15:33:16 +03:00
parent 67a5e8a69d
commit 71d9c4726b
3 changed files with 3 additions and 7 deletions
@@ -342,10 +342,6 @@ public class JetPsiFactory(private val project: Project) {
return JetBlockCodeFragment(project, "fragment.kt", text, null, context)
}
public fun createReturn(text: String): JetReturnExpression {
return createExpression("return $text") as JetReturnExpression
}
public fun createReturn(expression: JetExpression): JetReturnExpression {
return createExpressionByPattern("return $0", expression) as JetReturnExpression
}
@@ -157,7 +157,8 @@ abstract class OutputValueBoxer(val outputValues: List<OutputValue>) {
abstract val boxingRequired: Boolean
fun getReturnExpression(arguments: List<String>, psiFactory: JetPsiFactory): JetReturnExpression? {
return getBoxingExpressionText(arguments)?.let { psiFactory.createReturn(it) }
val expressionText = getBoxingExpressionText(arguments) ?: return null
return psiFactory.createExpression("return $expressionText") as JetReturnExpression
}
protected abstract fun extractExpressionByIndex(boxedExpression: JetExpression, index: Int): JetExpression?
@@ -515,8 +515,7 @@ fun ExtractionGeneratorConfiguration.generateDeclaration(
lastExpression to null
}
val returnExpression = descriptor.controlFlow.outputValueBoxer.getReturnExpression(getReturnArguments(defaultExpression), psiFactory)
if (returnExpression == null) return
val returnExpression = descriptor.controlFlow.outputValueBoxer.getReturnExpression(getReturnArguments(defaultExpression), psiFactory) ?: return
when(generatorOptions.target) {
ExtractionTarget.LAZY_PROPERTY, ExtractionTarget.FAKE_LAMBDALIKE_FUNCTION -> {