@@ -24,16 +24,18 @@ import { Event, Emitter } from '@theia/core/lib/common';
24
24
import { Disposable , DisposableCollection } from '@theia/core/lib/common/disposable' ;
25
25
import {
26
26
ApplyToKind , FileLocationKind , NamedProblemMatcher ,
27
- ProblemPattern , ProblemMatcher , ProblemMatcherContribution , WatchingMatcher
27
+ ProblemPattern , ProblemMatcher , ProblemMatcherContribution , WatchingMatcher ,
28
+ fromVariableName
28
29
} from '../common' ;
29
30
import { ProblemPatternRegistry } from './task-problem-pattern-registry' ;
30
31
import { Severity } from '@theia/core/lib/common/severity' ;
32
+ import { Deferred } from '@theia/core/lib/common/promise-util' ;
31
33
32
34
@injectable ( )
33
35
export class ProblemMatcherRegistry {
34
36
35
37
private readonly matchers = new Map < string , NamedProblemMatcher > ( ) ;
36
- private readyPromise : Promise < void > ;
38
+ private readyPromise = new Deferred < void > ( ) ;
37
39
38
40
@inject ( ProblemPatternRegistry )
39
41
protected readonly problemPatternRegistry : ProblemPatternRegistry ;
@@ -47,13 +49,13 @@ export class ProblemMatcherRegistry {
47
49
protected init ( ) : void {
48
50
this . problemPatternRegistry . onReady ( ) . then ( ( ) => {
49
51
this . fillDefaults ( ) ;
50
- this . readyPromise = new Promise < void > ( ( res , rej ) => res ( undefined ) ) ;
52
+ this . readyPromise . resolve ( ) ;
51
53
this . onDidChangeProblemMatcherEmitter . fire ( undefined ) ;
52
54
} ) ;
53
55
}
54
56
55
57
onReady ( ) : Promise < void > {
56
- return this . readyPromise ;
58
+ return this . readyPromise . promise ;
57
59
}
58
60
59
61
/**
@@ -73,6 +75,7 @@ export class ProblemMatcherRegistry {
73
75
this . doRegister ( matcher , toDispose ) . then ( ( ) => this . onDidChangeProblemMatcherEmitter . fire ( undefined ) ) ;
74
76
return toDispose ;
75
77
}
78
+
76
79
protected async doRegister ( matcher : ProblemMatcherContribution , toDispose : DisposableCollection ) : Promise < void > {
77
80
const problemMatcher = await this . getProblemMatcherFromContribution ( matcher ) ;
78
81
if ( toDispose . disposed ) {
@@ -88,10 +91,7 @@ export class ProblemMatcherRegistry {
88
91
* @return the problem matcher. If the task definition is not found, `undefined` is returned.
89
92
*/
90
93
get ( name : string ) : NamedProblemMatcher | undefined {
91
- if ( name . startsWith ( '$' ) ) {
92
- return this . matchers . get ( name . slice ( 1 ) ) ;
93
- }
94
- return this . matchers . get ( name ) ;
94
+ return this . matchers . get ( fromVariableName ( name ) ) ;
95
95
}
96
96
97
97
/**
@@ -132,7 +132,7 @@ export class ProblemMatcherRegistry {
132
132
if ( matcher . pattern ) {
133
133
if ( typeof matcher . pattern === 'string' ) {
134
134
await this . problemPatternRegistry . onReady ( ) ;
135
- const registeredPattern = this . problemPatternRegistry . get ( matcher . pattern ) ;
135
+ const registeredPattern = this . problemPatternRegistry . get ( fromVariableName ( matcher . pattern ) ) ;
136
136
if ( Array . isArray ( registeredPattern ) ) {
137
137
patterns . push ( ...registeredPattern ) ;
138
138
} else if ( ! ! registeredPattern ) {
0 commit comments