private boolean isUpToDate(@NotNull PsiFile file, @NotNull Document document) {
    return PsiDocumentManager.getInstance(myProject).isCommitted(myDocument) &&
           file.isValid() && file.getTextLength() == document.getTextLength();
  }
private boolean isUpToDate(@NotNull PsiFile file, @NotNull Document document)