"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const featureWorkers_1 = require("../utils/featureWorkers");
const vscode = require("vscode-languageserver-protocol");
const common_1 = require("../utils/common");
function register(context) {
    return (uri, token = vscode.CancellationToken.None) => {
        return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, // TODO: add color capability setting
        (plugin, document) => {
            if (token.isCancellationRequested)
                return;
            return plugin.provideDocumentColors?.(document, token);
        }, (data, map) => map ? data.map(color => {
            const range = map.toSourceRange(color.range);
            if (range) {
                return vscode.ColorInformation.create(range, color.color);
            }
        }).filter(common_1.notEmpty) : data, arr => arr.flat());
    };
}
exports.register = register;
//# sourceMappingURL=documentColors.js.map