in patched-vscode/src/vs/workbench/contrib/tasks/common/problemMatcher.ts [1438:1540]
private createProblemMatcher(description: Config.ProblemMatcher): ProblemMatcher | null {
let result: ProblemMatcher | null = null;
const owner = Types.isString(description.owner) ? description.owner : UUID.generateUuid();
const source = Types.isString(description.source) ? description.source : undefined;
let applyTo = Types.isString(description.applyTo) ? ApplyToKind.fromString(description.applyTo) : ApplyToKind.allDocuments;
if (!applyTo) {
applyTo = ApplyToKind.allDocuments;
}
let fileLocation: FileLocationKind | undefined = undefined;
let filePrefix: string | Config.SearchFileLocationArgs | undefined = undefined;
let kind: FileLocationKind | undefined;
if (Types.isUndefined(description.fileLocation)) {
fileLocation = FileLocationKind.Relative;
filePrefix = '${workspaceFolder}';
} else if (Types.isString(description.fileLocation)) {
kind = FileLocationKind.fromString(<string>description.fileLocation);
if (kind) {
fileLocation = kind;
if ((kind === FileLocationKind.Relative) || (kind === FileLocationKind.AutoDetect)) {
filePrefix = '${workspaceFolder}';
} else if (kind === FileLocationKind.Search) {
filePrefix = { include: ['${workspaceFolder}'] };
}
}
} else if (Types.isStringArray(description.fileLocation)) {
const values = <string[]>description.fileLocation;
if (values.length > 0) {
kind = FileLocationKind.fromString(values[0]);
if (values.length === 1 && kind === FileLocationKind.Absolute) {
fileLocation = kind;
} else if (values.length === 2 && (kind === FileLocationKind.Relative || kind === FileLocationKind.AutoDetect) && values[1]) {
fileLocation = kind;
filePrefix = values[1];
}
}
} else if (Array.isArray(description.fileLocation)) {
const kind = FileLocationKind.fromString(description.fileLocation[0]);
if (kind === FileLocationKind.Search) {
fileLocation = FileLocationKind.Search;
filePrefix = description.fileLocation[1] ?? { include: ['${workspaceFolder}'] };
}
}
const pattern = description.pattern ? this.createProblemPattern(description.pattern) : undefined;
let severity = description.severity ? Severity.fromValue(description.severity) : undefined;
if (severity === Severity.Ignore) {
this.info(localize('ProblemMatcherParser.unknownSeverity', 'Info: unknown severity {0}. Valid values are error, warning and info.\n', description.severity));
severity = Severity.Error;
}
if (Types.isString(description.base)) {
const variableName = <string>description.base;
if (variableName.length > 1 && variableName[0] === '$') {
const base = ProblemMatcherRegistry.get(variableName.substring(1));
if (base) {
result = Objects.deepClone(base);
if (description.owner !== undefined && owner !== undefined) {
result.owner = owner;
}
if (description.source !== undefined && source !== undefined) {
result.source = source;
}
if (description.fileLocation !== undefined && fileLocation !== undefined) {
result.fileLocation = fileLocation;
result.filePrefix = filePrefix;
}
if (description.pattern !== undefined && pattern !== undefined && pattern !== null) {
result.pattern = pattern;
}
if (description.severity !== undefined && severity !== undefined) {
result.severity = severity;
}
if (description.applyTo !== undefined && applyTo !== undefined) {
result.applyTo = applyTo;
}
}
}
} else if (fileLocation && pattern) {
result = {
owner: owner,
applyTo: applyTo,
fileLocation: fileLocation,
pattern: pattern,
};
if (source) {
result.source = source;
}
if (filePrefix) {
result.filePrefix = filePrefix;
}
if (severity) {
result.severity = severity;
}
}
if (Config.isNamedProblemMatcher(description)) {
(result as INamedProblemMatcher).name = description.name;
(result as INamedProblemMatcher).label = Types.isString(description.label) ? description.label : description.name;
}
return result;
}