You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: issue_xref.go
    path of file: ./repos/gitea/models/issues
    
    the code of the file until where you have to start completion: // Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package issues

import (
	"context"
	"fmt"

	"code.gitea.io/gitea/models/db"
	access_model "code.gitea.io/gitea/models/perm/access"
	repo_model "code.gitea.io/gitea/models/repo"
	user_model "code.gitea.io/gitea/models/user"
	"code.gitea.io/gitea/modules/log"
	"code.gitea.io/gitea/modules/references"
)

type crossReference struct {
	Issue  *Issue
	Action references.XRefAction
}

// cross
    
func (issue *Issue) createCrossReferences(stdCtx context.Context, ctx *crossReferencesContext, plaincontent, mdcontent string) error {
	xreflist, err := ctx.OrigIssue.getCrossReferences(stdCtx, ctx, plaincontent, mdcontent)
	if err != nil {
		return err
	}
	if ctx.RemoveOld {
		var commentID int64
		if ctx.OrigComment != nil {
			commentID = ctx.OrigComment.ID
		}
		active, err := findOldCrossReferences(stdCtx, ctx.OrigIssue.ID, commentID)
		if err != nil {
			return err
		}
		ids := make([]int64, 0, len(active))
		for _, c := range active {
			found := false
			for i, x := range xreflist {
				if x.Issue.ID == c.IssueID && x.Action == c.RefAction {
					found = true
					xreflist = append(xreflist[:i], xreflist[i+1:]...)
					break
				}
			}
			if !found {
				ids = append(ids, c.ID)
			}
		}
		if len(ids) > 0 {
			if err = neuterCrossReferencesIDs(stdCtx, ids); err != nil {
				return err
			}
		}
	}
	for _, xref := range xreflist {
		var refCommentID int64
		if ctx.OrigComment != nil {
			refCommentID = ctx.OrigComment.ID
		}
		opts := &CreateCommentOptions{
			Type:         ctx.Type,
			Doer:         ctx.Doer,
			Repo:         xref.Issue.Repo,
			Issue:        xref.Issue,
			RefRepoID:    ctx.OrigIssue.RepoID,
			RefIssueID:   ctx.OrigIssue.ID,
			RefCommentID: refCommentID,
			RefAction:    xref.Action,
			RefIsPull:    ctx.OrigIssue.IsPull,
		}
		_, err := CreateComment(stdCtx, opts)
		if err != nil {
			return err
		}
	}
	return nil
}