-
-
Notifications
You must be signed in to change notification settings - Fork 435
/
Copy pathdebug-configuration-model.ts
55 lines (52 loc) · 1.85 KB
/
debug-configuration-model.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
54
55
import { Event } from '@theia/core/lib/common/event';
import URI from '@theia/core/lib/common/uri';
import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service';
import { DebugConfiguration } from '@theia/debug/lib/common/debug-common';
import { DebugConfigurationModel as TheiaDebugConfigurationModel } from '@theia/debug/lib/browser/debug-configuration-model';
export class DebugConfigurationModel extends TheiaDebugConfigurationModel {
constructor(
override readonly workspaceFolderUri: string,
protected override readonly preferences: PreferenceService,
protected readonly config: DebugConfiguration[],
protected configUri: URI | undefined,
protected readonly onConfigDidChange: Event<TheiaDebugConfigurationModel.JsonContent>
) {
super(workspaceFolderUri, preferences);
this.toDispose.push(
onConfigDidChange((content) => {
const { uri, configurations } = content;
this.configUri = uri;
this.config.length = 0;
this.config.push(...configurations);
this.reconcile();
})
);
this.reconcile();
}
protected override parseConfigurations(): TheiaDebugConfigurationModel.JsonContent {
return {
uri: this.configUri,
configurations: this.config,
compounds: [],
};
}
}
export namespace DebugConfigurationModel {
export function parse(launchConfig: any): DebugConfiguration[] {
const configurations: DebugConfiguration[] = [];
if (
launchConfig &&
typeof launchConfig === 'object' &&
'configurations' in launchConfig
) {
if (Array.isArray(launchConfig.configurations)) {
for (const configuration of launchConfig.configurations) {
if (DebugConfiguration.is(configuration)) {
configurations.push(configuration);
}
}
}
}
return configurations;
}
}