"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FoldingProviderAdapter = void 0;
const tslib_1 = require("tslib");
const Converter = tslib_1.__importStar(require("../../../../common/vscode/converter"));
class FoldingProviderAdapter {
    constructor(documents, provider) {
        this.documents = documents;
        this.provider = provider;
    }
    async provideFoldingRanges(resource, context, token) {
        const documentData = this.documents.getDocumentData(resource);
        if (!documentData) {
            return Promise.reject(new Error(`There is no document for ${resource}`));
        }
        const doc = documentData.document;
        const ranges = await this.provider.provideFoldingRanges(doc, context, token);
        if (!Array.isArray(ranges)) {
            return undefined;
        }
        return ranges.map(Converter.fromFoldingRange);
    }
}
exports.FoldingProviderAdapter = FoldingProviderAdapter;
//# sourceMappingURL=folding.js.map