"use strict";
// *****************************************************************************
// Copyright (C) 2020 Red Hat, Inc. and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommentsContextKeyService = void 0;
const tslib_1 = require("tslib");
const inversify_1 = require("@theia/core/shared/inversify");
const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
const common_1 = require("@theia/core/lib/common");
let CommentsContextKeyService = class CommentsContextKeyService {
    constructor() {
        this.contextKeys = new Set();
        this.onDidChangeEmitter = new common_1.Emitter();
        this.onDidChange = this.onDidChangeEmitter.event;
    }
    get commentController() {
        return this._commentController;
    }
    get comment() {
        return this._comment;
    }
    get commentIsEmpty() {
        return this._commentIsEmpty;
    }
    init() {
        this.contextKeys.add('commentIsEmpty');
        this._commentController = this.contextKeyService.createKey('commentController', undefined);
        this._comment = this.contextKeyService.createKey('comment', undefined);
        this._commentIsEmpty = this.contextKeyService.createKey('commentIsEmpty', true);
        this.contextKeyService.onDidChange(event => {
            if (event.affects(this.contextKeys)) {
                this.onDidChangeEmitter.fire();
            }
        });
    }
    setExpression(expression) {
        var _a;
        (_a = this.contextKeyService.parseKeys(expression)) === null || _a === void 0 ? void 0 : _a.forEach(key => {
            this.contextKeys.add(key);
        });
    }
    match(expression) {
        return !expression || this.contextKeyService.match(expression);
    }
};
(0, tslib_1.__decorate)([
    (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
    (0, tslib_1.__metadata)("design:type", Object)
], CommentsContextKeyService.prototype, "contextKeyService", void 0);
(0, tslib_1.__decorate)([
    (0, inversify_1.postConstruct)(),
    (0, tslib_1.__metadata)("design:type", Function),
    (0, tslib_1.__metadata)("design:paramtypes", []),
    (0, tslib_1.__metadata)("design:returntype", void 0)
], CommentsContextKeyService.prototype, "init", null);
CommentsContextKeyService = (0, tslib_1.__decorate)([
    (0, inversify_1.injectable)()
], CommentsContextKeyService);
exports.CommentsContextKeyService = CommentsContextKeyService;
//# sourceMappingURL=comments-context-key-service.js.map