[jvm] Fix exception when making inner class runnable

Don't generate action when nested class hierarchy is empty. #EA-1081624 Fixed

GitOrigin-RevId: 934b238d81d6c1696e226199a75e37c8ed2ae883
This commit is contained in:
Bart van Helvert
2024-02-16 13:52:33 +01:00
committed by intellij-monorepo-bot
parent 7e78082cce
commit d6b40e6c72

View File

@@ -340,7 +340,7 @@ private class JUnitMalformedSignatureVisitor(
override fun getActions(project: Project): List<(JvmModifiersOwner) -> List<IntentionAction>> {
val list = super.getActions(project).toMutableList()
list.add { owner ->
val outerClass = owner.sourceElement?.toUElementOfType<UClass>()?.nestedClassHierarchy()?.last()!!
val outerClass = owner.sourceElement?.toUElementOfType<UClass>()?.nestedClassHierarchy()?.lastOrNull() ?: return@add emptyList()
val request = annotationRequest(ORG_JUNIT_RUNNER_RUN_WITH, classAttribute(
PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME,
ORG_JUNIT_EXPERIMENTAL_RUNNERS_ENCLOSED