Store project to avoid creating psi factory from invalid element

Fix ConvertLineCommentToBlockCommentIntention tests
This commit is contained in:
Nikolay Krasko
2019-09-26 16:19:26 +03:00
parent 057c16bf10
commit 7e691a0864
@@ -23,6 +23,7 @@ class ConvertLineCommentToBlockCommentIntention : SelfTargetingIntention<PsiComm
}
override fun applyTo(element: PsiComment, editor: Editor?) {
val project = element.project
var firstComment = element
while (true) {
firstComment = firstComment.prevComment() ?: break
@@ -48,7 +49,7 @@ class ConvertLineCommentToBlockCommentIntention : SelfTargetingIntention<PsiComm
(it.prevSibling as? PsiWhiteSpace)?.delete()
it.delete()
}
firstComment.replace(KtPsiFactory(element).createComment(blockComment))
firstComment.replace(KtPsiFactory(project).createComment(blockComment))
}
}