private <Psi extends PsiElement> boolean checkType(@NotNull Class<Psi> requiredClass, PsiFile psiFile, @Nullable PsiElement psiElement,
                                                     @NotNull Computable<String> debugOperationName,
                                                     @NotNull StubIdList debugStubIdList, int stubIdListIdx,
                                                     @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source) {
    if (requiredClass.isInstance(psiElement)) return true;

    String extraMessage = "psiElement is not instance of requiredClass.\n" +
                          "psiElement=" + psiElement +
                          (psiElement != null ? ", psiElement.class=" + psiElement.getClass() : "") +
                          ", requiredClass=" + requiredClass +
                          ", operation=" + debugOperationName.get() +
                          ", stubIdList=" + debugStubIdList + "@" + stubIdListIdx +
                          ".\nref: 20240717";

    StubTree stubTree = ((PsiFileWithStubSupport)psiFile).getStubTree();
    if (stubTree == null && psiFile instanceof PsiFileImpl) stubTree = ((PsiFileImpl)psiFile).calcStubTree();
    inconsistencyDetected(stubTree, (PsiFileWithStubSupport)psiFile, extraMessage, source);
    return false;
  }
private <Psi extends PsiElement> boolean checkType(@NotNull Class<Psi> requiredClass, PsiFile psiFile, @Nullable PsiElement psiElement,
                                                     @NotNull Computable<String> debugOperationName,
                                                     @NotNull StubIdList debugStubIdList, int stubIdListIdx,
                                                     @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source)