"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode = require("vscode-languageserver-protocol");
const references = require("./references");
function register(context) {
    const findReferences = references.register(context);
    return async (item, token = vscode.CancellationToken.None) => {
        const data = item.data;
        if (data?.kind === 'normal') {
            const plugin = context.plugins[data.pluginId];
            if (!plugin.resolveCodeLens)
                return item;
            Object.assign(item, data.original);
            item = await plugin.resolveCodeLens(item, token);
            // item.range already transformed in codeLens request
        }
        if (data?.kind === 'references') {
            let references = await findReferences(data.uri, item.range.start, token) ?? [];
            const plugin = context.plugins[data.pluginId];
            const document = context.getTextDocument(data.uri);
            if (document && plugin.resolveReferencesCodeLensLocations) {
                references = await plugin.resolveReferencesCodeLensLocations(document, data.range, references, token);
            }
            item.command = context.commands.createShowReferencesCommand(data.uri, data.range.start, references);
        }
        return item;
    };
}
exports.register = register;
//# sourceMappingURL=codeLensResolve.js.map