"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtensionDebugSessionContributionRegistry = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const debug_session_contribution_1 = require("@opensumi/ide-debug/lib/browser/debug-session-contribution");
let ExtensionDebugSessionContributionRegistry = class ExtensionDebugSessionContributionRegistry {
    constructor() {
        this.contribs = new Map();
        this.debug = (0, ide_core_browser_1.getDebugLogger)();
        this.init();
    }
    init() {
        for (const contrib of this.contributions.getContributions()) {
            this.contribs.set(contrib.debugType, contrib);
        }
    }
    get(debugType) {
        return this.contribs.get(debugType);
    }
    registerDebugSessionContribution(contrib) {
        const { debugType } = contrib;
        if (this.contribs.has(debugType)) {
            this.debug.warn(`Debug session contribution already registered for ${debugType}`);
            return ide_core_browser_1.Disposable.NULL;
        }
        this.contribs.set(debugType, contrib);
        return ide_core_browser_1.Disposable.create(() => this.unregisterDebugSessionContribution(debugType));
    }
    unregisterDebugSessionContribution(debugType) {
        this.contribs.delete(debugType);
    }
};
exports.ExtensionDebugSessionContributionRegistry = ExtensionDebugSessionContributionRegistry;
tslib_1.__decorate([
    (0, di_1.Autowired)(debug_session_contribution_1.DebugSessionContribution),
    tslib_1.__metadata("design:type", Object)
], ExtensionDebugSessionContributionRegistry.prototype, "contributions", void 0);
exports.ExtensionDebugSessionContributionRegistry = ExtensionDebugSessionContributionRegistry = tslib_1.__decorate([
    (0, di_1.Injectable)(),
    tslib_1.__metadata("design:paramtypes", [])
], ExtensionDebugSessionContributionRegistry);
//# sourceMappingURL=extension-debug-session-contribution-registry.js.map