private static boolean skipInvalid(@NotNull PsiElement element) {
    try {
      PsiUtilCore.ensureValid(element);
    }
    catch (ProcessCanceledException e) {
      throw e;
    }
    catch (Throwable e) {
      LOG.error(e);
      return true;
    }
    return false;
  }
private static boolean skipInvalid(@NotNull PsiElement element)