Skip to content

Commit f51220d

Browse files
committed
Fixes microsoft#22066: Allow extensions to contribute named problem matchers via package.json
1 parent e140159 commit f51220d

8 files changed

Lines changed: 898 additions & 425 deletions

File tree

extensions/typescript/package.json

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,42 @@
365365
"fileMatch": "typings.json",
366366
"url": "http://json.schemastore.org/typings"
367367
}
368+
],
369+
"problemPatterns": [
370+
{
371+
"name": "tsc",
372+
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
373+
"file": 1,
374+
"location": 2,
375+
"severity": 3,
376+
"code": 4,
377+
"message": 5
378+
}
379+
],
380+
"problemMatchers": [
381+
{
382+
"name": "tsc",
383+
"owner": "typescript",
384+
"applyTo": "closedDocuments",
385+
"fileLocation": ["relative", "$cwd"],
386+
"pattern": "$tsc"
387+
},
388+
{
389+
"name": "tsc-watch",
390+
"owner": "typescript",
391+
"applyTo": "closedDocuments",
392+
"fileLocation": ["relative", "$cwd"],
393+
"pattern": "$tsc",
394+
"watching": {
395+
"activeOnStart": true,
396+
"beginsPattern": {
397+
"regexp": "^\\s*(?:message TS6032:|\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? -) File change detected\\. Starting incremental compilation\\.\\.\\."
398+
},
399+
"endsPattern": {
400+
"regexp": "^\\s*(?:message TS6042:|\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? -) Compilation complete\\. Watching for file changes\\."
401+
}
402+
}
403+
}
368404
]
369405
}
370-
}
406+
}

src/vs/base/common/parsers.ts

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,48 +41,62 @@ export class ValidationStatus {
4141
}
4242
}
4343

44-
export interface ILogger {
45-
log(value: string): void;
44+
export interface IProblemReporter {
45+
info(message: string): void;
46+
warn(message: string): void;
47+
error(message: string): void;
48+
fatal(message: string): void;
49+
status: ValidationStatus;
4650
}
4751

4852
export abstract class Parser {
4953

50-
private _logger: ILogger;
51-
private validationStatus: ValidationStatus;
54+
private _problemReporter: IProblemReporter;
5255

53-
constructor(logger: ILogger, validationStatus: ValidationStatus = new ValidationStatus()) {
54-
this._logger = logger;
55-
this.validationStatus = validationStatus;
56+
constructor(problemReporter: IProblemReporter) {
57+
this._problemReporter = problemReporter;
5658
}
5759

58-
public get logger(): ILogger {
59-
return this._logger;
60+
public reset(): void {
61+
this._problemReporter.status.state = ValidationState.OK;
6062
}
6163

62-
public get status(): ValidationStatus {
63-
return this.validationStatus;
64+
public get problemReporter(): IProblemReporter {
65+
return this._problemReporter;
6466
}
6567

66-
protected log(message: string): void {
67-
this._logger.log(message);
68+
public info(message: string): void {
69+
this._problemReporter.info(message);
70+
}
71+
72+
public warn(message: string): void {
73+
this._problemReporter.warn(message);
74+
}
75+
76+
public error(message: string): void {
77+
this._problemReporter.error(message);
78+
}
79+
80+
public fatal(message: string): void {
81+
this._problemReporter.fatal(message);
6882
}
6983

7084
protected is(value: any, func: (value: any) => boolean, wrongTypeState?: ValidationState, wrongTypeMessage?: string, undefinedState?: ValidationState, undefinedMessage?: string): boolean {
7185
if (Types.isUndefined(value)) {
7286
if (undefinedState) {
73-
this.validationStatus.state = undefinedState;
87+
this._problemReporter.status.state = undefinedState;
7488
}
7589
if (undefinedMessage) {
76-
this.log(undefinedMessage);
90+
this._problemReporter.info(undefinedMessage);
7791
}
7892
return false;
7993
}
8094
if (!func(value)) {
8195
if (wrongTypeState) {
82-
this.validationStatus.state = wrongTypeState;
96+
this._problemReporter.status.state = wrongTypeState;
8397
}
8498
if (wrongTypeMessage) {
85-
this.log(wrongTypeMessage);
99+
this.info(wrongTypeMessage);
86100
}
87101
return false;
88102
}

src/vs/base/common/processes.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as Platform from 'vs/base/common/platform';
1111
import { IStringDictionary } from 'vs/base/common/collections';
1212
import * as Types from 'vs/base/common/types';
1313

14-
import { ValidationStatus, ValidationState, ILogger, Parser } from 'vs/base/common/parsers';
14+
import { ValidationState, IProblemReporter, Parser } from 'vs/base/common/parsers';
1515

1616
/**
1717
* Options to be passed to the external program or shell.
@@ -172,13 +172,13 @@ export interface ParserOptions {
172172

173173
export class ExecutableParser extends Parser {
174174

175-
constructor(logger: ILogger, validationStatus: ValidationStatus = new ValidationStatus()) {
176-
super(logger, validationStatus);
175+
constructor(logger: IProblemReporter) {
176+
super(logger);
177177
}
178178

179179
public parse(json: Config.Executable, parserOptions: ParserOptions = { globals: null, emptyCommand: false, noDefaults: false }): Executable {
180180
let result = this.parseExecutable(json, parserOptions.globals);
181-
if (this.status.isFatal()) {
181+
if (this.problemReporter.status.isFatal()) {
182182
return result;
183183
}
184184
let osExecutable: Executable;
@@ -193,8 +193,7 @@ export class ExecutableParser extends Parser {
193193
result = ExecutableParser.mergeExecutable(result, osExecutable);
194194
}
195195
if ((!result || !result.command) && !parserOptions.emptyCommand) {
196-
this.status.state = ValidationState.Fatal;
197-
this.log(NLS.localize('ExecutableParser.commandMissing', 'Error: executable info must define a command of type string.'));
196+
this.fatal(NLS.localize('ExecutableParser.commandMissing', 'Error: executable info must define a command of type string.'));
198197
return null;
199198
}
200199
if (!parserOptions.noDefaults) {

0 commit comments

Comments
 (0)