private static @Nullable PsiMethod getRecordCanonicalConstructor(PsiElement element, int offset) {
    PsiElement parent = element.getParent();
    if ((PsiUtil.isJavaToken(element, JavaTokenType.RPARENTH) || PsiUtil.isJavaToken(element, JavaTokenType.LPARENTH)) &&
        parent instanceof PsiRecordHeader) {
      PsiClass recordClass = ObjectUtils.tryCast(parent.getParent(), PsiClass.class);
      if (recordClass != null) {
        return JavaPsiRecordUtil.findCanonicalConstructor(recordClass);
      }
    }

    if (element instanceof PsiIdentifier &&
        parent instanceof PsiClass &&
        ((PsiClass)parent).isRecord() &&
        offset == element.getTextRange().getEndOffset()) {
      return JavaPsiRecordUtil.findCanonicalConstructor((PsiClass)parent);
    }
    return null;
  }
private static @Nullable PsiMethod getRecordCanonicalConstructor(PsiElement element, int offset)