"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProblemPatternsContributionPoint = exports.problemPatternsSchema = exports.PatternSchemas = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const common_1 = require("../../../common");
const { deepClone } = ide_core_common_1.objects;
var PatternSchemas;
(function (PatternSchemas) {
    PatternSchemas.ProblemPattern = {
        default: {
            regexp: '^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$',
            file: 1,
            location: 2,
            message: 3,
        },
        type: 'object',
        additionalProperties: false,
        properties: {
            regexp: {
                type: 'string',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.regexp', 'The regular expression to find an error, warning or info in the output.'),
            },
            kind: {
                type: 'string',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.kind', 'whether the pattern matches a location (file and line) or only a file.'),
            },
            file: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.file', 'The match group index of the filename. If omitted 1 is used.'),
            },
            location: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.location', "The match group index of the problem's location. Valid location patterns are: (line), (line,column) and (startLine,startColumn,endLine,endColumn). If omitted (line,column) is assumed."),
            },
            line: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.line', "The match group index of the problem's line. Defaults to 2"),
            },
            column: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.column', "The match group index of the problem's line character. Defaults to 3"),
            },
            endLine: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.endLine', "The match group index of the problem's end line. Defaults to undefined"),
            },
            endColumn: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.endColumn', "The match group index of the problem's end line character. Defaults to undefined"),
            },
            severity: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.severity', "The match group index of the problem's severity. Defaults to undefined"),
            },
            code: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.code', "The match group index of the problem's code. Defaults to undefined"),
            },
            message: {
                type: 'integer',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.message', 'The match group index of the message. If omitted it defaults to 4 if location is specified. Otherwise it defaults to 5.'),
            },
            loop: {
                type: 'boolean',
                description: (0, ide_core_common_1.localize)('ProblemPatternSchema.loop', 'In a multi line matcher loop indicated whether this pattern is executed in a loop as long as it matches. Can only specified on a last pattern in a multi line pattern.'),
            },
        },
    };
    PatternSchemas.NamedProblemPattern = deepClone(PatternSchemas.ProblemPattern);
    PatternSchemas.NamedProblemPattern.properties = deepClone(PatternSchemas.NamedProblemPattern.properties) || {};
    PatternSchemas.NamedProblemPattern.properties['name'] = {
        type: 'string',
        description: (0, ide_core_common_1.localize)('NamedProblemPatternSchema.name', 'The name of the problem pattern.'),
    };
    PatternSchemas.MultiLineProblemPattern = {
        type: 'array',
        items: PatternSchemas.ProblemPattern,
    };
    PatternSchemas.NamedMultiLineProblemPattern = {
        type: 'object',
        additionalProperties: false,
        properties: {
            name: {
                type: 'string',
                description: (0, ide_core_common_1.localize)('NamedMultiLineProblemPatternSchema.name', 'The name of the problem multi line problem pattern.'),
            },
            patterns: {
                type: 'array',
                description: (0, ide_core_common_1.localize)('NamedMultiLineProblemPatternSchema.patterns', 'The actual patterns.'),
                items: PatternSchemas.ProblemPattern,
            },
        },
    };
})(PatternSchemas || (exports.PatternSchemas = PatternSchemas = {}));
exports.problemPatternsSchema = {
    description: (0, ide_core_common_1.localize)('ProblemPatternExtPoint', 'Contributes problem patterns'),
    type: 'array',
    items: {
        anyOf: [PatternSchemas.NamedProblemPattern, PatternSchemas.NamedMultiLineProblemPattern],
    },
};
let ProblemPatternsContributionPoint = class ProblemPatternsContributionPoint extends common_1.VSCodeContributePoint {
    contribute() {
        for (const contrib of this.contributesMap) {
            const { contributes } = contrib;
            for (const pattern of contributes) {
                this.addDispose(this.problemPattern.register(pattern));
            }
        }
    }
};
exports.ProblemPatternsContributionPoint = ProblemPatternsContributionPoint;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_common_1.IProblemPatternRegistry),
    tslib_1.__metadata("design:type", Object)
], ProblemPatternsContributionPoint.prototype, "problemPattern", void 0);
exports.ProblemPatternsContributionPoint = ProblemPatternsContributionPoint = tslib_1.__decorate([
    (0, di_1.Injectable)(),
    (0, common_1.Contributes)('problemPatterns'),
    (0, common_1.LifeCycle)(4 /* LifeCyclePhase.Ready */)
], ProblemPatternsContributionPoint);
//# sourceMappingURL=problemPatterns.js.map