Provide a mesaage for NPE in scratch tests

This commit is contained in:
Natalia Selezneva
2019-07-17 11:23:51 +03:00
parent a32b1970e6
commit fe662fcb2e
@@ -182,7 +182,13 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
override fun onFinish(file: ScratchFile) {
ApplicationManager.getApplication().invokeLater {
if (inlays.isNotEmpty()) {
val psiFile = file.getPsiFile()!!
val psiFile = file.getPsiFile()
?: error(
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
"project.isDisposed = ${file.project.isDisposed}\n" +
"inlays = ${inlays.joinToString { it.second }}\n" +
"errors = ${errors.joinToString()}"
)
testPrint(file, inlays.map { (expression, text) ->
"/** ${getLineInfo(psiFile, expression)} $text */"
})