Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/electron-browser/actions/developerActions.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { localize, localize2 } from '../../../nls.js';
7
import { INativeHostService } from '../../../platform/native/common/native.js';
8
import { IEditorService } from '../../services/editor/common/editorService.js';
9
import { Action2, MenuId } from '../../../platform/actions/common/actions.js';
10
import { Categories } from '../../../platform/action/common/actionCommonCategories.js';
11
import { ServicesAccessor } from '../../../platform/instantiation/common/instantiation.js';
12
import { IWorkbenchEnvironmentService } from '../../services/environment/common/environmentService.js';
13
import { KeybindingWeight } from '../../../platform/keybinding/common/keybindingsRegistry.js';
14
import { IsDevelopmentContext } from '../../../platform/contextkey/common/contextkeys.js';
15
import { KeyCode, KeyMod } from '../../../base/common/keyCodes.js';
16
import { INativeWorkbenchEnvironmentService } from '../../services/environment/electron-browser/environmentService.js';
17
import { URI } from '../../../base/common/uri.js';
18
import { getActiveWindow } from '../../../base/browser/dom.js';
19
import { IDialogService } from '../../../platform/dialogs/common/dialogs.js';
20
import { INativeEnvironmentService } from '../../../platform/environment/common/environment.js';
21
import { IProgressService, ProgressLocation } from '../../../platform/progress/common/progress.js';
22
23
export class ToggleDevToolsAction extends Action2 {
24
25
constructor() {
26
super({
27
id: 'workbench.action.toggleDevTools',
28
title: localize2('toggleDevTools', 'Toggle Developer Tools'),
29
category: Categories.Developer,
30
f1: true,
31
keybinding: {
32
weight: KeybindingWeight.WorkbenchContrib + 50,
33
when: IsDevelopmentContext,
34
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyI,
35
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyI }
36
},
37
menu: {
38
id: MenuId.MenubarHelpMenu,
39
group: '5_tools',
40
order: 1
41
}
42
});
43
}
44
45
async run(accessor: ServicesAccessor): Promise<void> {
46
const nativeHostService = accessor.get(INativeHostService);
47
48
return nativeHostService.toggleDevTools({ targetWindowId: getActiveWindow().vscodeWindowId });
49
}
50
}
51
52
export class ConfigureRuntimeArgumentsAction extends Action2 {
53
54
constructor() {
55
super({
56
id: 'workbench.action.configureRuntimeArguments',
57
title: localize2('configureRuntimeArguments', 'Configure Runtime Arguments'),
58
category: Categories.Preferences,
59
f1: true
60
});
61
}
62
63
async run(accessor: ServicesAccessor): Promise<void> {
64
const editorService = accessor.get(IEditorService);
65
const environmentService = accessor.get(IWorkbenchEnvironmentService);
66
67
await editorService.openEditor({
68
resource: environmentService.argvResource,
69
options: { pinned: true }
70
});
71
}
72
}
73
74
export class ReloadWindowWithExtensionsDisabledAction extends Action2 {
75
76
constructor() {
77
super({
78
id: 'workbench.action.reloadWindowWithExtensionsDisabled',
79
title: localize2('reloadWindowWithExtensionsDisabled', 'Reload with Extensions Disabled'),
80
category: Categories.Developer,
81
f1: true
82
});
83
}
84
85
async run(accessor: ServicesAccessor): Promise<void> {
86
return accessor.get(INativeHostService).reload({ disableExtensions: true });
87
}
88
}
89
90
export class OpenUserDataFolderAction extends Action2 {
91
92
constructor() {
93
super({
94
id: 'workbench.action.revealUserDataFolder',
95
title: localize2('revealUserDataFolder', 'Reveal User Data Folder'),
96
category: Categories.Developer,
97
f1: true
98
});
99
}
100
101
async run(accessor: ServicesAccessor): Promise<void> {
102
const nativeHostService = accessor.get(INativeHostService);
103
const environmentService = accessor.get(INativeWorkbenchEnvironmentService);
104
105
return nativeHostService.showItemInFolder(URI.file(environmentService.userDataPath).fsPath);
106
}
107
}
108
109
export class ShowGPUInfoAction extends Action2 {
110
111
constructor() {
112
super({
113
id: 'workbench.action.showGPUInfo',
114
title: localize2('showGPUInfo', 'Show GPU Info'),
115
category: Categories.Developer,
116
f1: true
117
});
118
}
119
120
run(accessor: ServicesAccessor) {
121
const nativeHostService = accessor.get(INativeHostService);
122
nativeHostService.openGPUInfoWindow();
123
}
124
}
125
126
export class StopTracing extends Action2 {
127
128
static readonly ID = 'workbench.action.stopTracing';
129
130
constructor() {
131
super({
132
id: StopTracing.ID,
133
title: localize2('stopTracing', 'Stop Tracing'),
134
category: Categories.Developer,
135
f1: true
136
});
137
}
138
139
override async run(accessor: ServicesAccessor): Promise<void> {
140
const environmentService = accessor.get(INativeEnvironmentService);
141
const dialogService = accessor.get(IDialogService);
142
const nativeHostService = accessor.get(INativeHostService);
143
const progressService = accessor.get(IProgressService);
144
145
if (!environmentService.args.trace) {
146
const { confirmed } = await dialogService.confirm({
147
message: localize('stopTracing.message', "Tracing requires to launch with a '--trace' argument"),
148
primaryButton: localize({ key: 'stopTracing.button', comment: ['&& denotes a mnemonic'] }, "&&Relaunch and Enable Tracing"),
149
});
150
151
if (confirmed) {
152
return nativeHostService.relaunch({ addArgs: ['--trace'] });
153
}
154
}
155
156
await progressService.withProgress({
157
location: ProgressLocation.Dialog,
158
title: localize('stopTracing.title', "Creating trace file..."),
159
cancellable: false,
160
detail: localize('stopTracing.detail', "This can take up to one minute to complete.")
161
}, () => nativeHostService.stopTracing());
162
}
163
}
164
165