void (@NotNull PsiType type, @Nullable String customMessage) { if (!type.isValid()) { TimeoutUtil.sleep(1); // to see if processing in another thread suddenly makes the type valid again (which is a bug) if (type.isValid()) { LOG.error("PsiType resurrected: " + type + " of " + type.getClass() + " " + customMessage); return; } if (type instanceof PsiClassType) { try { PsiClass psiClass = ((PsiClassType)type).resolve(); // should throw exception if (psiClass != null) { ensureValid(psiClass); } } catch (ProcessCanceledException e) { throw e; } catch (Exception e) { if (customMessage == null) { throw e; } throw new RuntimeException(customMessage, e); } } throw new AssertionError("Invalid type: " + type + " of class " + type.getClass() + " " + customMessage); } }