@Override
  public boolean isValid() {
    if (isDeleted()) return false;
    return ReadAction.compute(() -> {
      if (getRefManager().getProject().isDisposed()) return false;

      //no need to check resolve in offline mode
      if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
        final PsiFile file = getContainingFile();
        return file != null && file.isPhysical();
      }

      final PsiElement element = getPsiElement();
      return element != null && element.isPhysical();
    });
  }
@Override
  public boolean isValid()