Fix KNPE in introduce new variable (EA-131176)

This commit is contained in:
Andrey Uskov
2018-12-24 20:30:34 +03:00
parent 710baf969f
commit 95caabf22f
2 changed files with 3 additions and 3 deletions
@@ -154,8 +154,8 @@ fun selectElementsWithTargetParent(
selectSingleElement()
}
fun PsiElement.findExpressionByCopyableDataAndClearIt(key: Key<Boolean>): KtExpression {
val result = findDescendantOfType<KtExpression> { it.getCopyableUserData(key) != null }!!
fun PsiElement.findExpressionByCopyableDataAndClearIt(key: Key<Boolean>): KtExpression? {
val result = findDescendantOfType<KtExpression> { it.getCopyableUserData(key) != null } ?: return null
result.putCopyableUserData(key, null)
return result
}
@@ -324,7 +324,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
} ?: newReplace
}
runRefactoring(isVar, newExpression, newCommonContainer, newCommonParent, newAllReplaces)
runRefactoring(isVar, newExpression ?: return, newCommonContainer, newCommonParent, newAllReplaces)
}
}