Fix KNPE in Introduce new variable (EA-132675)

This commit is contained in:
Andrey Uskov
2018-12-24 18:51:47 +03:00
parent 7dcb9db8cb
commit 1ec63c16f8
@@ -213,7 +213,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
}
}
//ugly logic to make sure we are working with right actual expression
var actualExpression = reference!!
var actualExpression = reference ?: return
var diff = actualExpression.textRange.startOffset - oldElement.textRange.startOffset
var actualExpressionText = actualExpression.text
val newElement = emptyBody.addAfter(oldElement, firstChild)
@@ -224,7 +224,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
emptyBody.addAfter(psiFactory.createNewLine(), firstChild)
property = emptyBody.addAfter(property, firstChild) as KtProperty
emptyBody.addAfter(psiFactory.createNewLine(), firstChild)
actualExpression = reference!!
actualExpression = reference ?: return
diff = actualExpression.textRange.startOffset - emptyBody.textRange.startOffset
actualExpressionText = actualExpression.text
emptyBody = anchor.replace(emptyBody) as KtBlockExpression