private boolean isAffected(@NotNull DocumentReference reference) {
    // `DocumentReference.getDocument()` can throw if it refers to a deleted file
    // (see an implementation for `DocumentReferenceByVirtualFile`),
    // so it's safer to compare two virtual files first
    DocumentReference affected = getAffectedDocuments()[0];
    VirtualFile affectedFile = affected.getFile();
    if (affectedFile != null) {
      return affectedFile.equals(reference.getFile());
    } else {
      return affected.getDocument() == reference.getDocument();
    }
  }
private boolean isAffected(@NotNull DocumentReference reference)