-
-
Notifications
You must be signed in to change notification settings - Fork 431
/
Copy pathproblem-manager.ts
53 lines (47 loc) · 1.54 KB
/
problem-manager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {
inject,
injectable,
postConstruct,
} from '@theia/core/shared/inversify';
import { Diagnostic } from 'vscode-languageserver-types';
import URI from '@theia/core/lib/common/uri';
import { ILogger } from '@theia/core';
import { Marker } from '@theia/markers/lib/common/marker';
import { ProblemManager as TheiaProblemManager } from '@theia/markers/lib/browser/problem/problem-manager';
import { ConfigService } from '../../../common/protocol/config-service';
import debounce = require('lodash.debounce');
@injectable()
export class ProblemManager extends TheiaProblemManager {
@inject(ConfigService)
protected readonly configService: ConfigService;
@inject(ILogger)
protected readonly logger: ILogger;
protected dataDirUri: URI | undefined;
@postConstruct()
protected override init(): void {
super.init();
this.configService
.getConfiguration()
.then(({ dataDirUri }) => (this.dataDirUri = new URI(dataDirUri)))
.catch((err) =>
this.logger.error(`Failed to determine the data directory: ${err}`)
);
}
override setMarkers(
uri: URI,
owner: string,
data: Diagnostic[]
): Marker<Diagnostic>[] {
if (this.dataDirUri && this.dataDirUri.isEqualOrParent(uri)) {
return [];
}
return super.setMarkers(uri, owner, data);
}
private readonly debouncedFireOnDidChangeMakers = debounce(
(uri: URI) => this.onDidChangeMarkersEmitter.fire(uri),
500
);
protected override fireOnDidChangeMarkers(uri: URI): void {
this.debouncedFireOnDidChangeMakers(uri);
}
}