protected boolean isValid() {
    if (myProject.isDisposed()) {
      return false;
    }
    if (!DumbService.getInstance(myProject).isUsableInCurrentContext(this)) {
      return false;
    }

    if (PsiModificationTracker.getInstance(myProject).getModificationCount() != myInitialPsiStamp) {
      return false;
    }

    if (myDocument.getModificationStamp() != myInitialDocStamp) return false;
    PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
    PsiElement context;
    return file != null
           && file.isValid()
           && ((context = file.getContext()) == null || context == file || context.isValid());
  }
protected boolean isValid()