[PSI] do not throw exception on incorrect expression in KtPsiFactory.createExpressionIfPossible

This commit is contained in:
Ilya Kirillov
2022-07-06 23:03:20 +02:00
parent 0ea7e8b70a
commit a6b6c79dc2
@@ -69,7 +69,11 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
}
fun createExpressionIfPossible(@NonNls text: String): KtExpression? {
val expression = doCreateExpression(text) ?: return null
val expression = try {
doCreateExpression(text) ?: return null
} catch (ignored: Throwable) {
return null
}
return if (expression.text == text) expression else null
}