"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode_1 = require("vscode");
const vscode = require("vscode");
const path = require("path");
const ParserManager_1 = require("../model/ParserManager");
const utils_1 = require("../utils");
function update() {
    const parserManager = ParserManager_1.default.getSingleInstance();
    parserManager.handleTimerQueue();
    parserManager.parseCurrentFile().then((parser) => {
        parser.putColors();
    });
}
function init(context) {
    context.subscriptions.push(vscode_1.window.onDidChangeActiveTextEditor(() => {
        var _a;
        const filepath = (_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.fileName;
        if (filepath) {
            if (path.isAbsolute(filepath)) {
                utils_1.default.setActiveTextEditor(vscode.window.activeTextEditor);
            }
            update();
        }
    }));
    context.subscriptions.push(vscode.workspace.onDidSaveTextDocument(() => {
        var _a;
        const filepath = (_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.fileName;
        if (filepath) {
            if (path.isAbsolute(filepath)) {
                utils_1.default.setActiveTextEditor(vscode.window.activeTextEditor);
            }
            update();
        }
    }));
    context.subscriptions.push(vscode.commands.registerCommand('vscode-intl-javascript.CHECK_DIR_LOCALE', () => {
        // 获取当前文件路径, 然后根据路径获取配置文件
        const filepath = utils_1.default.getCurrentFilePath();
        const currentDir = path.dirname(filepath);
        vscode_1.window.showInputBox({
            prompt: '请输入要check的文件夹路径',
            value: currentDir,
            valueSelection: [currentDir.lastIndexOf('/'), currentDir.length]
        }).then((dir) => {
            ParserManager_1.default.getSingleInstance().parseDir(currentDir);
        });
    }));
}
exports.default = init;
//# sourceMappingURL=check.js.map