[java-execution] ExceptionInfoCache: check if cached PSI is still valid

Fixes EA-261426 - PIEAE: SubstrateRef$StubRef.reportError

GitOrigin-RevId: cd7a6553850abbf103bee8c0b2c56610cbcbd12c
This commit is contained in:
Tagir Valeev
2021-03-19 05:48:14 +00:00
committed by intellij-monorepo-bot
parent 94624348d9
commit 232eab2954
@@ -67,7 +67,7 @@ public class ExceptionInfoCache {
@NotNull ClassResolveInfo resolveClass(String className) {
ClassResolveInfo cached = myCache.get(className);
if (cached != null) {
if (cached != null && cached.isValid()) {
return cached;
}
@@ -114,6 +114,11 @@ public class ExceptionInfoCache {
}
return myExceptionClasses;
}
boolean isValid() {
return ContainerUtil.and(myClasses.values(), PsiElement::isValid) &&
(myExceptionClasses == null || ContainerUtil.and(myExceptionClasses, PsiElement::isValid));
}
@NotNull
static ExceptionInfoCache.ClassResolveInfo create(Project project, PsiElement[] elements) {