"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PmdCpdEnginesPlugin = void 0;
const code_analyzer_engine_api_1 = require("@salesforce/code-analyzer-engine-api");
const messages_1 = require("./messages");
const pmd_engine_1 = require("./pmd-engine");
const cpd_engine_1 = require("./cpd-engine");
const config_1 = require("./config");
const JavaVersionIdentifier_1 = require("./JavaVersionIdentifier");
const constants_1 = require("./constants");
class PmdCpdEnginesPlugin extends code_analyzer_engine_api_1.EnginePluginV1 {
    javaVersionIdentifier;
    constructor(javaVersionIdentifier = new JavaVersionIdentifier_1.RuntimeJavaVersionIdentifier()) {
        super();
        this.javaVersionIdentifier = javaVersionIdentifier;
    }
    getAvailableEngineNames() {
        return [constants_1.PMD_ENGINE_NAME, constants_1.CPD_ENGINE_NAME];
    }
    describeEngineConfig(engineName) {
        if (engineName === constants_1.CPD_ENGINE_NAME) {
            return config_1.CPD_ENGINE_CONFIG_DESCRIPTION;
        }
        else if (engineName === constants_1.PMD_ENGINE_NAME) {
            return config_1.PMD_ENGINE_CONFIG_DESCRIPTION;
        }
        throw new Error((0, messages_1.getMessage)('UnsupportedEngineName', engineName));
    }
    async createEngineConfig(engineName, configValueExtractor) {
        if (engineName === constants_1.CPD_ENGINE_NAME) {
            return await (0, config_1.validateAndNormalizeCpdConfig)(configValueExtractor, this.javaVersionIdentifier);
        }
        else if (engineName === constants_1.PMD_ENGINE_NAME) {
            return await (0, config_1.validateAndNormalizePmdConfig)(configValueExtractor, this.javaVersionIdentifier);
        }
        throw new Error((0, messages_1.getMessage)('UnsupportedEngineName', engineName));
    }
    async createEngine(engineName, engineConfig) {
        if (engineName === constants_1.CPD_ENGINE_NAME) {
            return new cpd_engine_1.CpdEngine(engineConfig);
        }
        else if (engineName === constants_1.PMD_ENGINE_NAME) {
            return new pmd_engine_1.PmdEngine(engineConfig);
        }
        throw new Error((0, messages_1.getMessage)('UnsupportedEngineName', engineName));
    }
}
exports.PmdCpdEnginesPlugin = PmdCpdEnginesPlugin;
//# sourceMappingURL=plugin.js.map