public static void ensureValidType(@NotNull PsiType type, @Nullable PsiElement sourceOfType) {
    try {
      ensureValidType(type);
    }
    catch (ProcessCanceledException e) {
      throw e;
    }
    catch (Throwable e) {
      if (sourceOfType == null) throw e;

      PsiUtilCore.ensureValid(sourceOfType);
      throw new RuntimeException("Via " + sourceOfType.getClass() + " #" + sourceOfType.getLanguage(), e);
    }
  }
public static void ensureValidType(@NotNull PsiType type, @Nullable PsiElement sourceOfType)