'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.deactivate = exports.Extension = exports.activate = void 0;
const vscode = require("vscode");
const manager_1 = require("./components/manager");
const completion_1 = require("./providers/completion");
const hover_1 = require("./providers/hover");
const definition_1 = require("./providers/definition");
function activate(context) {
    const extension = new Extension();
    context.subscriptions.push(vscode.workspace.onDidOpenTextDocument(() => {
        extension.log("Reacting to document open");
        if (vscode.window.activeTextEditor) {
            extension.manager.findBib();
        }
    }));
    context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(() => {
        extension.log("Reacting to active document change");
        if ((vscode.window.activeTextEditor) &&
            (['markdown', 'rmd', 'pweave_md'].includes(vscode.window.activeTextEditor.document.languageId))) {
            extension.manager.findBib();
        }
    }));
    context.subscriptions.push(vscode.workspace.onDidSaveTextDocument(() => {
        extension.log("Reacting to document save");
        if (vscode.window.activeTextEditor) {
            extension.manager.findBib();
        }
    }));
    const selector = ['markdown', 'rmd', 'pweave_md'].map((language) => {
        return { scheme: 'file', language: language };
    });
    extension.manager.findBib();
    context.subscriptions.push(vscode.languages.registerCompletionItemProvider(selector, extension.completer, '@'));
    context.subscriptions.push(vscode.languages.registerHoverProvider(selector, extension.hover));
    context.subscriptions.push(vscode.languages.registerDefinitionProvider(selector, extension.definition));
}
exports.activate = activate;
class Extension {
    constructor() {
        this.manager = new manager_1.Manager(this);
        this.completer = new completion_1.Completer(this);
        this.hover = new hover_1.HoverProvider(this);
        this.definition = new definition_1.DefinitionProvider(this);
        this.logPanel = vscode.window.createOutputChannel('PandocCiter');
        this.log(`PandocCiter is now activated`);
    }
    log(msg) {
        if (vscode.workspace.getConfiguration('PandocCiter').get('ShowLog')) {
            this.logPanel.append(`${msg}\n`);
        }
    }
}
exports.Extension = Extension;
function deactivate() {
}
exports.deactivate = deactivate;
//# sourceMappingURL=extension.js.map