User: rednesto Date: 10 Jul 23 09:21 Revision: 6c0bb4f497848691c2347289261c750722940b19 Summary: Intercept KTIJ exceptions in two more places Fixes minecraft-dev/mcdev-error-report#1065 Fixes minecraft-dev/mcdev-error-report#526 TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=8628&personal=false Index: src/main/kotlin/insight/ListenerEventAnnotator.kt =================================================================== --- src/main/kotlin/insight/ListenerEventAnnotator.kt (revision 31c927bd012aa3c1d54aa136eec8ae52f4ac4212) +++ src/main/kotlin/insight/ListenerEventAnnotator.kt (revision 6c0bb4f497848691c2347289261c750722940b19) @@ -22,6 +22,7 @@ import com.demonwav.mcdev.MinecraftSettings import com.demonwav.mcdev.facet.MinecraftFacet +import com.demonwav.mcdev.util.runCatchingKtIdeaExceptions import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.Annotator import com.intellij.lang.annotation.HighlightSeverity @@ -53,10 +54,11 @@ return } - val method: UMethod = element.toUElement()?.uastParent as? UMethod + val method: UMethod = runCatchingKtIdeaExceptions { + element.toUElement()?.uastParent as? UMethod - ?: element.getUastParentOfType() - ?.getParentOfType()?.uastParent as? UMethod // Be sure to be on the type of a parameter + ?: element.getUastParentOfType() + ?.getParentOfType()?.uastParent as? UMethod // Be sure to be on the type of a parameter - ?: return + } ?: return if (method.javaPsi.hasModifierProperty(PsiModifier.ABSTRACT)) { // I don't think any implementation allows for abstract return Index: src/main/kotlin/platform/sponge/reference/SpongeReferenceContributor.kt =================================================================== --- src/main/kotlin/platform/sponge/reference/SpongeReferenceContributor.kt (revision 31c927bd012aa3c1d54aa136eec8ae52f4ac4212) +++ src/main/kotlin/platform/sponge/reference/SpongeReferenceContributor.kt (revision 6c0bb4f497848691c2347289261c750722940b19) @@ -22,6 +22,7 @@ import com.demonwav.mcdev.insight.uastEventListener import com.demonwav.mcdev.platform.sponge.util.SpongeConstants +import com.demonwav.mcdev.util.runCatchingKtIdeaExceptions import com.intellij.codeInsight.completion.JavaLookupElementBuilder import com.intellij.patterns.PlatformPatterns import com.intellij.psi.CommonClassNames @@ -98,7 +99,7 @@ private object GetterAnnotationFilter : ElementFilter { override fun isAcceptable(element: Any, context: PsiElement?): Boolean { val type = context.toUElement() ?: return false - val annotation = type.getParentOfType() ?: return false + val annotation = runCatchingKtIdeaExceptions { type.getParentOfType() } ?: return false return annotation.qualifiedName == SpongeConstants.GETTER_ANNOTATION }