-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathprojectStatus.ts
More file actions
1314 lines (1141 loc) · 45.8 KB
/
projectStatus.ts
File metadata and controls
1314 lines (1141 loc) · 45.8 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import CMakeProject from '@cmt/cmakeProject';
import * as preset from '@cmt/presets/preset';
import { runCommand } from '@cmt/util';
import { OptionConfig, checkBuildOverridesPresent, checkConfigureOverridesPresent, checkTestOverridesPresent, checkPackageOverridesPresent } from '@cmt/config';
import { CMakeCache, CacheEntryType } from '@cmt/cache';
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
const noKitSelected = localize('no.kit.selected', '[No Kit Selected]');
const noConfigPresetSelected = localize('no.configure.preset.selected', '[No Configure Preset Selected]');
const noBuildPresetSelected = localize('no.build.preset.selected', '[No Build Preset Selected]');
const noTestPresetSelected = localize('no.test.preset.selected', '[No Test Preset Selected]');
const noPackagePresetSelected = localize('no.package.preset.selected', '[No Package Preset Selected]');
const noWorkflowPresetSelected = localize('no.workflow.preset.selected', '[No Workflow Preset Selected]');
export let treeDataProvider: TreeDataProvider;
const pinnedCacheVariablesKey = 'cmake.pinnedCacheVariables';
export class ProjectStatus {
protected disposables: vscode.Disposable[] = [];
constructor(extensionContext?: vscode.ExtensionContext) {
treeDataProvider = new TreeDataProvider(extensionContext);
this.disposables.push(...[
// Commands for projectStatus items
vscode.commands.registerCommand('cmake.projectStatus.stop', async (_node: Node) => {
await runCommand('stop');
}),
vscode.commands.registerCommand('cmake.projectStatus.cleanConfigure', async (_node: Node) => {
await runCommand('cleanConfigure');
await this.refresh();
}),
vscode.commands.registerCommand('cmake.projectStatus.openSettings', async(_node: Node) => {
await runCommand('openSettings');
}),
vscode.commands.registerCommand('cmake.projectStatus.openVisibilitySettings', async(_node: Node) => {
await this.openVisibilitySettings();
}),
vscode.commands.registerCommand('cmake.projectStatus.selectKit', async (_node: Node) => {
await runCommand('selectKit');
await this.refresh();
}),
vscode.commands.registerCommand('cmake.projectStatus.selectConfigurePreset', async (node: Node) => {
await runCommand('selectConfigurePreset');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.viewConfigureSettings', async (_node: Node) => {
await runCommand('viewConfigureSettings');
}),
vscode.commands.registerCommand('cmake.projectStatus.configure', async (_node: Node) => {
void runCommand('configure');
}),
vscode.commands.registerCommand('cmake.projectStatus.setVariant', async (node: Node) => {
await runCommand('setVariant');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.build', async (_node: Node) => {
void runCommand('build');
}),
vscode.commands.registerCommand('cmake.projectStatus.setDefaultTarget', async (node: Node) => {
await runCommand('setDefaultTarget');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.selectBuildPreset', async (node: Node) => {
await runCommand('selectBuildPreset');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.viewBuildSettings', async (_node: Node) => {
await runCommand('viewBuildSettings');
}),
vscode.commands.registerCommand('cmake.projectStatus.ctest', async (_node: Node) => {
void runCommand('ctest');
}),
vscode.commands.registerCommand('cmake.projectStatus.cpack', async (_node: Node) => {
void runCommand('cpack');
}),
vscode.commands.registerCommand('cmake.projectStatus.workflow', async (_node: Node) => {
void runCommand('workflow');
}),
vscode.commands.registerCommand('cmake.projectStatus.setTestTarget', async (_node: Node) => {
// Do nothing
}),
vscode.commands.registerCommand('cmake.projectStatus.selectTestPreset', async (node: Node) => {
await runCommand('selectTestPreset');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.viewTestSettings', async (_node: Node) => {
await runCommand('viewTestSettings');
}),
vscode.commands.registerCommand('cmake.projectStatus.selectPackagePreset', async (node: Node) => {
await runCommand('selectPackagePreset');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.viewPackageSettings', async (_node: Node) => {
await runCommand('viewPackageSettings');
}),
vscode.commands.registerCommand('cmake.projectStatus.selectWorkflowPreset', async (node: Node) => {
await runCommand('selectWorkflowPreset');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.debugTarget', async (_node: Node) => {
await runCommand('debugTarget');
}),
vscode.commands.registerCommand('cmake.projectStatus.setDebugTarget', async (node: Node) => {
await runCommand('selectLaunchTarget');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.launchTarget', async (_node: Node) => {
await runCommand('launchTarget');
}),
vscode.commands.registerCommand('cmake.projectStatus.setLaunchTarget', async (node: Node) => {
await runCommand('selectLaunchTarget');
await this.refresh(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.selectActiveProject', async () => {
await runCommand('selectActiveFolder');
await this.refresh();
}),
vscode.commands.registerCommand('cmake.projectStatus.update', async () => {
await this.refresh();
}),
vscode.commands.registerCommand('cmake.projectStatus.pinCacheVariable', async () => {
await treeDataProvider.pinCacheVariable();
}),
vscode.commands.registerCommand('cmake.projectStatus.editPinnedCacheVariable', async (node: PinnedCacheVariableNode) => {
await treeDataProvider.editPinnedCacheVariable(node);
}),
vscode.commands.registerCommand('cmake.projectStatus.unpinCacheVariable', async (node: PinnedCacheVariableNode) => {
await treeDataProvider.unpinCacheVariable(node);
})
]);
}
async openVisibilitySettings(): Promise<void> {
await vscode.commands.executeCommand('workbench.action.openSettingsJson', { revealSetting: { key: 'cmake.options.advanced' }});
}
async updateActiveProject(cmakeProject?: CMakeProject, options?: OptionConfig): Promise<void> {
// Update Active Project
await treeDataProvider.updateActiveProject(cmakeProject, options);
}
refresh(node?: Node): Promise<any> {
return treeDataProvider.refresh(node);
}
clear(): Promise<any> {
return treeDataProvider.clear();
}
dispose() {
vscode.Disposable.from(...this.disposables).dispose();
treeDataProvider.dispose();
}
async hideBuildButton(isHidden: boolean) {
await treeDataProvider.hideBuildButton(isHidden);
}
async hideDebugButton(isHidden: boolean) {
await treeDataProvider.hideDebugButton(isHidden);
}
async hideLaunchButton(isHidden: boolean) {
await treeDataProvider.hideLaunchButton(isHidden);
}
async setIsBusy(isBusy: boolean) {
await treeDataProvider.setIsBusy(isBusy);
}
async doStatusChange(options: OptionConfig) {
await treeDataProvider.doStatusChange(options);
}
}
class TreeDataProvider implements vscode.TreeDataProvider<Node>, vscode.Disposable {
private treeView: vscode.TreeView<Node>;
private _onDidChangeTreeData: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
private activeCMakeProject?: CMakeProject;
private isFolderButtonHidden: boolean = false;
private isConfigButtonHidden: boolean = false;
private isBuildButtonHidden: boolean = false;
private isTestButtonHidden: boolean = false;
private isPackageButtonHidden: boolean = false;
private isWorkflowButtonHidden: boolean = false;
private isDebugButtonHidden: boolean = false;
private isLaunchButtonHidden: boolean = false;
private isBusy: boolean = false;
private configNode: ConfigNode | undefined;
private buildNode: BuildNode | undefined;
private testNode: TestNode | undefined;
private packageNode: PackageNode | undefined;
private workflowNode: WorkflowNode | undefined;
private extensionContext?: vscode.ExtensionContext;
get onDidChangeTreeData(): vscode.Event<Node | undefined> {
return this._onDidChangeTreeData.event;
}
constructor(extensionContext?: vscode.ExtensionContext) {
this.extensionContext = extensionContext;
this.treeView = vscode.window.createTreeView('cmake.projectStatus', { treeDataProvider: this });
}
get cmakeProject(): CMakeProject | undefined {
return this.activeCMakeProject;
}
async updateActiveProject(cmakeProject?: CMakeProject, options?: OptionConfig): Promise<void> {
// Use project to create the tree
if (cmakeProject) {
this.activeCMakeProject = cmakeProject;
await this.doStatusChange(options);
} else {
this.isConfigButtonHidden = false;
this.isFolderButtonHidden = false;
this.isBuildButtonHidden = false;
this.isTestButtonHidden = false;
this.isPackageButtonHidden = false;
this.isWorkflowButtonHidden = false;
this.isDebugButtonHidden = false;
this.isLaunchButtonHidden = false;
}
await this.refresh();
}
public async refreshNode(node: ConfigNode | BuildNode | TestNode | PackageNode | WorkflowNode | undefined): Promise<any> {
if (node) {
await node.refresh();
this._onDidChangeTreeData.fire(node);
}
}
public async refreshConfigNode(): Promise<any> {
await this.refreshNode(this.configNode);
}
public async refreshBuildNode(): Promise<any> {
await this.refreshNode(this.buildNode);
}
public async refreshTestNode(): Promise<any> {
await this.refreshNode(this.testNode);
}
public async refreshPackageNode(): Promise<any> {
await this.refreshNode(this.packageNode);
}
public async refreshWorkflowNode(): Promise<any> {
await this.refreshNode(this.workflowNode);
}
public async refresh(node?: Node): Promise<any> {
if (node) {
await node.refresh();
this._onDidChangeTreeData.fire(node);
} else {
this._onDidChangeTreeData.fire(undefined);
}
}
clear(): Promise<any> {
this.activeCMakeProject = undefined;
return this.refresh();
}
dispose(): void {
this.treeView.dispose();
}
getTreeItem(node: Node): vscode.TreeItem {
return node.getTreeItem();
}
async getChildren(node?: Node | undefined): Promise<Node[]> {
if (node) {
return node.getChildren();
} else {
// Initializing the tree for the first time
const nodes: Node[] = [];
if (!this.isFolderButtonHidden) {
const folderNode = new FolderNode();
await folderNode.initialize();
if (this.isBusy) {
folderNode.convertToStopCommand();
}
nodes.push(folderNode);
}
if (!this.isConfigButtonHidden) {
const configNode = new ConfigNode();
this.configNode = configNode;
await configNode.initialize();
if (this.isBusy) {
configNode.convertToStopCommand();
}
nodes.push(configNode);
}
// Add pinned cache variables between configure and build
const pinnedNames = this.getPinnedCacheVariableNames();
if (pinnedNames.length > 0) {
const pinnedNode = new PinnedCacheVariablesNode(pinnedNames);
await pinnedNode.initialize();
nodes.push(pinnedNode);
}
if (!this.isBuildButtonHidden) {
const buildNode = new BuildNode();
this.buildNode = buildNode;
await buildNode.initialize();
if (this.isBusy) {
buildNode.convertToStopCommand();
}
nodes.push(buildNode);
}
if (!this.isTestButtonHidden) {
const testNode = new TestNode();
this.testNode = testNode;
await testNode.initialize();
if (this.isBusy) {
testNode.convertToStopCommand();
}
nodes.push(testNode);
}
if (this.cmakeProject?.useCMakePresets) {
if (!this.isPackageButtonHidden) {
const packageNode = new PackageNode();
this.packageNode = packageNode;
await packageNode.initialize();
if (this.isBusy) {
packageNode.convertToStopCommand();
}
nodes.push(packageNode);
}
if (!this.isWorkflowButtonHidden) {
const workflowNode = new WorkflowNode();
this.workflowNode = workflowNode;
await workflowNode.initialize();
if (this.isBusy) {
workflowNode.convertToStopCommand();
}
nodes.push(workflowNode);
}
}
if (!this.isDebugButtonHidden) {
const debugNode = new DebugNode();
await debugNode.initialize();
if (this.isBusy) {
debugNode.convertToStopCommand();
}
nodes.push(debugNode);
}
if (!this.isLaunchButtonHidden) {
const launchNode = new LaunchNode();
await launchNode.initialize();
if (this.isBusy) {
launchNode.convertToStopCommand();
}
nodes.push(launchNode);
}
return nodes;
}
}
// TODO: get rid of undefined?
public async doStatusChange(options: OptionConfig | undefined) {
let didChange: boolean = false;
if (this.activeCMakeProject) {
const folderVisibility = options?.advanced?.folder?.projectStatusVisibility !== "hidden";
if (folderVisibility === this.isFolderButtonHidden) {
didChange = true;
this.isFolderButtonHidden = !folderVisibility;
}
const configureVisibility = options?.advanced?.configure?.projectStatusVisibility !== "hidden";
if (configureVisibility === this.isConfigButtonHidden) {
didChange = true;
this.isConfigButtonHidden = !configureVisibility;
}
const buildVisibility = options?.advanced?.build?.projectStatusVisibility !== "hidden";
if (buildVisibility === this.isBuildButtonHidden) {
didChange = true;
this.isBuildButtonHidden = !buildVisibility;
}
const testVisibility = options?.advanced?.ctest?.projectStatusVisibility !== "hidden";
if (testVisibility === this.isTestButtonHidden) {
didChange = true;
this.isTestButtonHidden = !testVisibility;
}
const packageVisibility = options?.advanced?.cpack?.projectStatusVisibility !== "hidden";
if (packageVisibility === this.isPackageButtonHidden) {
didChange = true;
this.isPackageButtonHidden = !packageVisibility;
}
const workflowVisibility = options?.advanced?.workflow?.projectStatusVisibility !== "hidden";
if (workflowVisibility === this.isWorkflowButtonHidden) {
didChange = true;
this.isWorkflowButtonHidden = !workflowVisibility;
}
const debugVisibility = options?.advanced?.debug?.projectStatusVisibility !== "hidden";
if (debugVisibility === this.isDebugButtonHidden) {
didChange = true;
this.isDebugButtonHidden = !debugVisibility;
}
const launchVisibility = options?.advanced?.launch?.projectStatusVisibility !== "hidden";
if (launchVisibility === this.isLaunchButtonHidden) {
didChange = true;
this.isLaunchButtonHidden = !launchVisibility;
}
}
if (didChange) {
await this.refresh();
}
}
public async hideBuildButton(isHidden: boolean) {
if (isHidden !== this.isBuildButtonHidden) {
if (this.activeCMakeProject) {
this.activeCMakeProject.hideBuildButton = isHidden;
}
this.isBuildButtonHidden = isHidden;
await this.refresh();
}
}
public async hideDebugButton(isHidden: boolean): Promise<void> {
if (isHidden !== this.isDebugButtonHidden) {
if (this.activeCMakeProject) {
this.activeCMakeProject.hideDebugButton = isHidden;
}
this.isDebugButtonHidden = isHidden;
await this.refresh();
}
}
public async hideLaunchButton(isHidden: boolean): Promise<void> {
if (isHidden !== this.isLaunchButtonHidden) {
if (this.activeCMakeProject) {
this.activeCMakeProject.hideLaunchButton = isHidden;
}
this.isLaunchButtonHidden = isHidden;
await this.refresh();
}
}
async setIsBusy(isBusy: boolean): Promise<void> {
if (this.isBusy !== isBusy) {
this.isBusy = isBusy;
await this.refresh();
}
}
// Pinned cache variable management
getPinnedCacheVariableNames(): string[] {
if (!this.extensionContext) {
return [];
}
return this.extensionContext.workspaceState.get<string[]>(pinnedCacheVariablesKey, []);
}
private async savePinnedCacheVariableNames(names: string[]): Promise<void> {
if (!this.extensionContext) {
return;
}
await this.extensionContext.workspaceState.update(pinnedCacheVariablesKey, names);
}
async pinCacheVariable(): Promise<void> {
if (!this.activeCMakeProject) {
return;
}
const cachePathStr = await this.activeCMakeProject.cachePath;
if (!cachePathStr) {
void vscode.window.showErrorMessage(localize('no.cache.available', 'No CMake cache available. Please configure the project first.'));
return;
}
const cache = await CMakeCache.fromPath(cachePathStr);
const entries = cache.allEntries.filter(e => e.type !== CacheEntryType.Internal && e.type !== CacheEntryType.Static);
const alreadyPinned = new Set(this.getPinnedCacheVariableNames());
const items = entries
.filter(e => !alreadyPinned.has(e.key))
.map(e => ({
label: e.key,
description: String(e.value),
detail: e.helpString
}));
if (items.length === 0) {
void vscode.window.showInformationMessage(localize('no.variables.to.pin', 'No cache variables available to pin.'));
return;
}
const chosen = await vscode.window.showQuickPick(items, {
placeHolder: localize('select.variable.to.pin', 'Select a cache variable to pin')
});
if (chosen) {
const names = this.getPinnedCacheVariableNames();
names.push(chosen.label);
await this.savePinnedCacheVariableNames(names);
await this.refresh();
}
}
async editPinnedCacheVariable(node: PinnedCacheVariableNode): Promise<void> {
if (!this.activeCMakeProject || !node.variableName) {
return;
}
const currentValue = node.variableValue ?? '';
const newValue = await vscode.window.showInputBox({
prompt: localize('enter.new.value', 'Enter new value for {0}', node.variableName),
value: currentValue
});
if (newValue !== undefined && newValue !== currentValue) {
// Update cmake.configureSettings with the new value
const configurationScope = this.activeCMakeProject.workspaceFolder;
const config = vscode.workspace.getConfiguration('cmake', configurationScope);
const currentSettings = config.get<{ [key: string]: any }>('configureSettings') ?? {};
currentSettings[node.variableName] = newValue;
await config.update('configureSettings', currentSettings, vscode.ConfigurationTarget.WorkspaceFolder);
// configureOnEdit is handled automatically by the config onChange subscription
await this.refresh();
}
}
async unpinCacheVariable(node: PinnedCacheVariableNode): Promise<void> {
if (!node.variableName) {
return;
}
const names = this.getPinnedCacheVariableNames().filter(n => n !== node.variableName);
await this.savePinnedCacheVariableNames(names);
await this.refresh();
}
}
class Node extends vscode.TreeItem {
constructor(label?: string | vscode.TreeItemLabel) {
super(label ? label : "");
}
getTreeItem(): vscode.TreeItem {
return this;
}
getChildren(): Node[] {
return [];
}
async initialize(): Promise<void> {
}
async refresh(): Promise<void> {
}
convertToStopCommand(): void {
}
convertToOriginalCommand(): void {
}
}
class ConfigNode extends Node {
private kit?: Kit;
private variant?: Variant;
private configPreset?: ConfigPreset;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Configure', 'Configure');
this.tooltip = this.label;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this.contextValue = "configure";
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
if (!treeDataProvider.cmakeProject.useCMakePresets) {
this.kit = new Kit();
await this.kit.initialize();
this.variant = new Variant();
await this.variant.initialize();
} else {
this.configPreset = new ConfigPreset();
await this.configPreset.initialize();
}
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
if (!treeDataProvider.cmakeProject.useCMakePresets) {
return [this.kit!, this.variant!];
} else {
return [this.configPreset!];
}
}
convertToStopCommand(): void {
this.label = localize("configure.running", "Configure (Running)");
const title: string = localize('Stop', 'Stop');
this.tooltip = title;
this.contextValue = "stop";
}
convertToOriginalCommand(): Promise<void> {
return this.initialize();
}
async refresh(): Promise<void> {
await this.configPreset?.refresh();
}
}
class BuildNode extends Node {
private buildTarget?: BuildTarget;
private buildPreset?: BuildPreset;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Build', 'Build');
this.tooltip = this.label;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this.contextValue = 'build';
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
if (treeDataProvider.cmakeProject.useCMakePresets) {
this.buildPreset = new BuildPreset();
await this.buildPreset.initialize();
}
this.buildTarget = new BuildTarget();
await this.buildTarget.initialize();
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
if (!treeDataProvider.cmakeProject.useCMakePresets) {
return [this.buildTarget!];
} else {
return [this.buildPreset!, this.buildTarget!];
}
}
convertToStopCommand(): void {
this.label = localize("build.running", "Build (Running)");
const title: string = localize('Stop', 'Stop');
this.tooltip = title;
this.contextValue = "stop";
}
convertToOriginalCommand(): Promise<void> {
return this.initialize();
}
async refresh(): Promise<void> {
await this.buildPreset?.refresh();
}
}
class TestNode extends Node {
private testTarget?: TestTarget;
private testPreset?: TestPreset;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Test', 'Test');
this.tooltip = this.label;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this.contextValue = 'test';
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
if (!treeDataProvider.cmakeProject.useCMakePresets) {
this.testTarget = new TestTarget();
await this.testTarget.initialize();
} else {
this.testPreset = new TestPreset();
await this.testPreset.initialize();
}
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
if (!treeDataProvider.cmakeProject.useCMakePresets) {
return [this.testTarget!];
} else {
return [this.testPreset!];
}
}
async refresh(): Promise<void> {
await this.testPreset?.refresh();
}
}
class PackageNode extends Node {
private packagePreset?: PackagePreset;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Package', 'Package');
this.tooltip = this.label;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this.contextValue = "package";
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
if (treeDataProvider.cmakeProject.useCMakePresets) {
this.packagePreset = new PackagePreset();
await this.packagePreset.initialize();
}
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
if (treeDataProvider.cmakeProject.useCMakePresets) {
return [this.packagePreset!];
} else {
return [];
}
}
convertToStopCommand(): void {
this.label = localize("cpack.running", "CPack (packaging)");
const title: string = localize('Stop', 'Stop');
this.tooltip = title;
this.contextValue = "stop";
}
convertToOriginalCommand(): Promise<void> {
return this.initialize();
}
async refresh(): Promise<void> {
await this.packagePreset?.refresh();
}
}
class WorkflowNode extends Node {
private workflowPreset?: WorkflowPreset;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Workflow', 'Workflow');
this.tooltip = this.label;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this.contextValue = "workflow";
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
if (treeDataProvider.cmakeProject.useCMakePresets) {
this.workflowPreset = new WorkflowPreset();
await this.workflowPreset.initialize();
}
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
if (treeDataProvider.cmakeProject.useCMakePresets) {
return [this.workflowPreset!];
} else {
return [];
}
}
convertToStopCommand(): void {
this.label = localize("workflow.running", "Workflow (Running)");
const title: string = localize('Stop', 'Stop');
this.tooltip = title;
this.contextValue = "stop";
}
convertToOriginalCommand(): Promise<void> {
return this.initialize();
}
}
class DebugNode extends Node {
private target?: DebugTarget;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Debug', 'Debug');
this.tooltip = this.label;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this.contextValue = 'debug';
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.target = new DebugTarget();
await this.target.initialize();
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
return [this.target!];
}
}
class LaunchNode extends Node {
private launchTarget?: LaunchTarget;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Launch', 'Launch');
this.tooltip = this.label;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this.contextValue = 'launch';
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.launchTarget = new LaunchTarget();
await this.launchTarget.initialize();
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
return [this.launchTarget!];
}
}
class FolderNode extends Node {
private project?: Project;
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = localize('Folder', 'Folder');
this.tooltip = localize('active.folder', 'Active Folder');
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
await this.InitializeChildren();
}
async InitializeChildren(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
this.project = new Project();
await this.project!.initialize();
}
getChildren(): Node[] {
if (!treeDataProvider.cmakeProject) {
return [];
}
return [this.project!];
}
}
class ConfigPreset extends Node {
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject || !treeDataProvider.cmakeProject.useCMakePresets) {
return;
}
this.label = (treeDataProvider.cmakeProject.configurePreset?.displayName || treeDataProvider.cmakeProject.configurePreset?.name) || noConfigPresetSelected;
this.tooltip = localize("configPreset.change", "Change Configure Preset");
this.contextValue = 'configPreset';
this.collapsibleState = vscode.TreeItemCollapsibleState.None;
await this.updateDescription();
}
async refresh() {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = (treeDataProvider.cmakeProject.configurePreset?.displayName || treeDataProvider.cmakeProject.configurePreset?.name) || noConfigPresetSelected;
await this.updateDescription();
}
private async updateDescription(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
const config = (await treeDataProvider.cmakeProject.getCMakeDriverInstance())?.config;
if (config && checkConfigureOverridesPresent(config)) {
this.description = localize("override.settings.applied", "Override settings applied");
this.contextValue = 'configPreset - overrides present';
} else {
this.description = "";
this.contextValue = 'configPreset';
}
}
}
class BuildPreset extends Node {
async initialize(): Promise<void> {
if (!treeDataProvider.cmakeProject || !treeDataProvider.cmakeProject.useCMakePresets) {
return;
}
this.label = (treeDataProvider.cmakeProject.buildPreset?.displayName || treeDataProvider.cmakeProject.buildPreset?.name) || noBuildPresetSelected;
if (this.label === preset.defaultBuildPreset.name) {
this.label = preset.defaultBuildPreset.displayName;
}
this.tooltip = localize("buildPreset.change", "Change Build Preset");
this.contextValue = 'buildPreset';
this.collapsibleState = vscode.TreeItemCollapsibleState.None;
await this.updateDescription();
}
async refresh() {
if (!treeDataProvider.cmakeProject) {
return;
}
this.label = (treeDataProvider.cmakeProject.buildPreset?.displayName || treeDataProvider.cmakeProject.buildPreset?.name) || noBuildPresetSelected;
await this.updateDescription();
}
private async updateDescription(): Promise<void> {
if (!treeDataProvider.cmakeProject) {
return;
}
const config = (await treeDataProvider.cmakeProject.getCMakeDriverInstance())?.config;
if (config && checkBuildOverridesPresent(config)) {
this.description = localize("override.settings.applied", "Override settings applied");
this.contextValue = 'buildPreset - overrides present';
} else {
this.description = "";
this.contextValue = 'buildPreset';