@opensumi/ide-debug 2.21.7-rc-1670246007.0 → 2.21.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/debug-session.d.ts.map +1 -1
- package/lib/browser/debug-session.js +1 -5
- package/lib/browser/debug-session.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +9 -2
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/preferences/launch-folder-preference-provider.d.ts +2 -2
- package/lib/browser/preferences/launch-folder-preference-provider.d.ts.map +1 -1
- package/lib/browser/preferences/launch-folder-preference-provider.js +2 -2
- package/lib/browser/preferences/launch-folder-preference-provider.js.map +1 -1
- package/lib/browser/view/configuration/debug-configuration.module.less +5 -5
- package/lib/browser/view/configuration/debug-configuration.view.d.ts.map +1 -1
- package/lib/browser/view/configuration/debug-configuration.view.js +1 -1
- package/lib/browser/view/configuration/debug-configuration.view.js.map +1 -1
- package/lib/browser/view/configuration/debug-toolbar.view.js +2 -2
- package/lib/browser/view/configuration/debug-toolbar.view.js.map +1 -1
- package/lib/browser/view/console/debug-console.module.less +1 -2
- package/lib/browser/view/console/debug-console.view.js +2 -2
- package/lib/browser/view/console/debug-console.view.js.map +1 -1
- package/lib/browser/view/variables/debug-variables.module.less +1 -2
- package/lib/browser/view/variables/debug-variables.view.js +1 -1
- package/lib/browser/view/variables/debug-variables.view.js.map +1 -1
- package/lib/browser/view/watch/debug-watch.module.less +1 -2
- package/lib/browser/view/watch/debug-watch.view.js +1 -1
- package/lib/browser/view/watch/debug-watch.view.js.map +1 -1
- package/package.json +24 -25
- package/src/browser/assets/breakpoint-conditional-disabled.svg +0 -4
- package/src/browser/assets/breakpoint-conditional-unverified.svg +0 -4
- package/src/browser/assets/breakpoint-conditional.svg +0 -4
- package/src/browser/assets/breakpoint-disabled.svg +0 -4
- package/src/browser/assets/breakpoint-hint.svg +0 -4
- package/src/browser/assets/breakpoint-log-disabled.svg +0 -4
- package/src/browser/assets/breakpoint-log-unverified.svg +0 -4
- package/src/browser/assets/breakpoint-log.svg +0 -4
- package/src/browser/assets/breakpoint-unsupported.svg +0 -4
- package/src/browser/assets/breakpoint-unverified.svg +0 -4
- package/src/browser/assets/breakpoint.svg +0 -4
- package/src/browser/assets/breakpoints-activate-inverse.svg +0 -4
- package/src/browser/assets/breakpoints-activate.svg +0 -4
- package/src/browser/assets/configure-inverse.svg +0 -4
- package/src/browser/assets/configure.svg +0 -4
- package/src/browser/assets/continue-inverse.svg +0 -4
- package/src/browser/assets/current-and-breakpoint.svg +0 -4
- package/src/browser/assets/current-arrow.svg +0 -4
- package/src/browser/assets/remove-all-inverse.svg +0 -4
- package/src/browser/assets/remove-all.svg +0 -4
- package/src/browser/assets/repl-inverse.svg +0 -4
- package/src/browser/assets/repl.svg +0 -4
- package/src/browser/assets/restart-inverse.svg +0 -4
- package/src/browser/assets/stackframe-and-breakpoint.svg +0 -4
- package/src/browser/assets/stackframe-arrow.svg +0 -4
- package/src/browser/assets/start-inverse.svg +0 -4
- package/src/browser/breakpoint/breakpoint-decoration.ts +0 -57
- package/src/browser/breakpoint/breakpoint-manager.ts +0 -348
- package/src/browser/breakpoint/breakpoint-marker.ts +0 -70
- package/src/browser/breakpoint/index.ts +0 -3
- package/src/browser/components/debug-action/index.module.less +0 -73
- package/src/browser/components/debug-action/index.tsx +0 -40
- package/src/browser/components/debug-exception-widget.less +0 -42
- package/src/browser/components/floating-click-widget/index.module.less +0 -5
- package/src/browser/components/floating-click-widget/index.tsx +0 -21
- package/src/browser/components/index.ts +0 -1
- package/src/browser/contextkeys/debug-call-stack-item-type-key.ts +0 -4
- package/src/browser/contextkeys/debug-contextkey.service.ts +0 -54
- package/src/browser/contextkeys/index.ts +0 -1
- package/src/browser/debug-ansi-handle.ts +0 -521
- package/src/browser/debug-configuration-manager.ts +0 -513
- package/src/browser/debug-configuration-model.ts +0 -66
- package/src/browser/debug-contribution.ts +0 -904
- package/src/browser/debug-exception-widget.tsx +0 -89
- package/src/browser/debug-link-detector.ts +0 -234
- package/src/browser/debug-memory.ts +0 -220
- package/src/browser/debug-preferences.ts +0 -70
- package/src/browser/debug-progress.service.ts +0 -122
- package/src/browser/debug-schema-updater.ts +0 -67
- package/src/browser/debug-service.ts +0 -42
- package/src/browser/debug-session-connection.ts +0 -333
- package/src/browser/debug-session-contribution.ts +0 -57
- package/src/browser/debug-session-manager.ts +0 -622
- package/src/browser/debug-session.ts +0 -1182
- package/src/browser/debug-style.less +0 -128
- package/src/browser/debugUtils.ts +0 -110
- package/src/browser/editor/debug-breakpoint-widget.ts +0 -99
- package/src/browser/editor/debug-breakpoint-zone-widget.tsx +0 -262
- package/src/browser/editor/debug-breakpoint.module.less +0 -31
- package/src/browser/editor/debug-editor-contribution.ts +0 -590
- package/src/browser/editor/debug-expression-provider.ts +0 -101
- package/src/browser/editor/debug-hover-model.ts +0 -38
- package/src/browser/editor/debug-hover-source.ts +0 -107
- package/src/browser/editor/debug-hover-tree.model.service.ts +0 -332
- package/src/browser/editor/debug-hover-widget.tsx +0 -200
- package/src/browser/editor/debug-hover.module.less +0 -29
- package/src/browser/editor/debug-hover.view.tsx +0 -147
- package/src/browser/editor/debug-model-manager.ts +0 -220
- package/src/browser/editor/debug-model.ts +0 -853
- package/src/browser/editor/debug-run-to-cursor.service.ts +0 -180
- package/src/browser/editor/debug-styles.ts +0 -66
- package/src/browser/editor/evaluatable-expression.ts +0 -47
- package/src/browser/editor/index.ts +0 -6
- package/src/browser/index.ts +0 -121
- package/src/browser/markers/index.ts +0 -2
- package/src/browser/markers/marker-manager.ts +0 -201
- package/src/browser/markers/marker.ts +0 -20
- package/src/browser/model/debug-source.ts +0 -144
- package/src/browser/model/debug-stack-frame.ts +0 -111
- package/src/browser/model/debug-thread.ts +0 -186
- package/src/browser/model/debug-watch.ts +0 -130
- package/src/browser/model/index.ts +0 -4
- package/src/browser/preferences/launch-folder-preference-provider.ts +0 -23
- package/src/browser/preferences/launch-preferences-contribution.ts +0 -9
- package/src/browser/preferences/launch-preferences.ts +0 -16
- package/src/browser/tree/debug-console-tree-node.define.tsx +0 -76
- package/src/browser/tree/debug-tree-node.define.ts +0 -768
- package/src/browser/tree/index.ts +0 -2
- package/src/browser/view/breakpoints/debug-breakpoints.module.less +0 -72
- package/src/browser/view/breakpoints/debug-breakpoints.service.ts +0 -217
- package/src/browser/view/breakpoints/debug-breakpoints.view.tsx +0 -174
- package/src/browser/view/configuration/debug-configuration.module.less +0 -110
- package/src/browser/view/configuration/debug-configuration.service.ts +0 -170
- package/src/browser/view/configuration/debug-configuration.view.tsx +0 -252
- package/src/browser/view/configuration/debug-toolbar.service.ts +0 -167
- package/src/browser/view/configuration/debug-toolbar.view.tsx +0 -335
- package/src/browser/view/console/debug-console-filter.model.ts +0 -49
- package/src/browser/view/console/debug-console-filter.service.ts +0 -81
- package/src/browser/view/console/debug-console-filter.view.tsx +0 -78
- package/src/browser/view/console/debug-console-model.ts +0 -48
- package/src/browser/view/console/debug-console-session.ts +0 -164
- package/src/browser/view/console/debug-console-toolbar.view.tsx +0 -28
- package/src/browser/view/console/debug-console-tree.model.service.ts +0 -550
- package/src/browser/view/console/debug-console.contribution.ts +0 -181
- package/src/browser/view/console/debug-console.module.less +0 -373
- package/src/browser/view/console/debug-console.service.ts +0 -433
- package/src/browser/view/console/debug-console.view.tsx +0 -500
- package/src/browser/view/debug-view-model.ts +0 -182
- package/src/browser/view/frames/debug-call-stack-frame.view.tsx +0 -224
- package/src/browser/view/frames/debug-call-stack-session.view.tsx +0 -244
- package/src/browser/view/frames/debug-call-stack-thread.view.tsx +0 -93
- package/src/browser/view/frames/debug-call-stack.contribution.ts +0 -88
- package/src/browser/view/frames/debug-call-stack.module.less +0 -193
- package/src/browser/view/frames/debug-call-stack.operation.tsx +0 -97
- package/src/browser/view/frames/debug-call-stack.service.ts +0 -105
- package/src/browser/view/frames/debug-call-stack.view.tsx +0 -43
- package/src/browser/view/variables/debug-variables-model.ts +0 -38
- package/src/browser/view/variables/debug-variables-tree.model.service.ts +0 -467
- package/src/browser/view/variables/debug-variables.contribution.ts +0 -244
- package/src/browser/view/variables/debug-variables.module.less +0 -149
- package/src/browser/view/variables/debug-variables.view.tsx +0 -303
- package/src/browser/view/watch/debug-watch-model.ts +0 -38
- package/src/browser/view/watch/debug-watch-tree.model.service.ts +0 -567
- package/src/browser/view/watch/debug-watch.contribution.ts +0 -167
- package/src/browser/view/watch/debug-watch.module.less +0 -189
- package/src/browser/view/watch/debug-watch.view.tsx +0 -337
- package/src/common/constants.ts +0 -81
- package/src/common/debug-breakpoint.ts +0 -43
- package/src/common/debug-configuration.ts +0 -68
- package/src/common/debug-editor.ts +0 -4
- package/src/common/debug-hover.ts +0 -31
- package/src/common/debug-model.ts +0 -247
- package/src/common/debug-progress.ts +0 -8
- package/src/common/debug-schema-updater.ts +0 -1
- package/src/common/debug-service.ts +0 -176
- package/src/common/debug-session-options.ts +0 -19
- package/src/common/debug-session.ts +0 -200
- package/src/common/evaluatable-expression.ts +0 -43
- package/src/common/index.ts +0 -14
- package/src/common/inline-values.ts +0 -77
- package/src/common/terminal.ts +0 -163
- package/src/common/types.ts +0 -86
- package/src/index.ts +0 -1
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
import { visit } from 'jsonc-parser';
|
|
2
|
-
|
|
3
|
-
import { Injectable, Autowired } from '@opensumi/di';
|
|
4
|
-
import {
|
|
5
|
-
PreferenceConfigurations,
|
|
6
|
-
IContextKey,
|
|
7
|
-
Emitter,
|
|
8
|
-
Event,
|
|
9
|
-
PreferenceService,
|
|
10
|
-
URI,
|
|
11
|
-
WaitUntilEvent,
|
|
12
|
-
IContextKeyService,
|
|
13
|
-
CommandService,
|
|
14
|
-
localize,
|
|
15
|
-
StorageProvider,
|
|
16
|
-
STORAGE_NAMESPACE,
|
|
17
|
-
IStorage,
|
|
18
|
-
ThrottledDelayer,
|
|
19
|
-
Deferred,
|
|
20
|
-
} from '@opensumi/ide-core-browser';
|
|
21
|
-
import { WorkbenchEditorService, IOpenResourceResult } from '@opensumi/ide-editor';
|
|
22
|
-
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
23
|
-
import { FileSystemError } from '@opensumi/ide-file-service';
|
|
24
|
-
import { ITextModel } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
25
|
-
import { QuickPickService } from '@opensumi/ide-quick-open';
|
|
26
|
-
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
27
|
-
import { WorkspaceVariableContribution } from '@opensumi/ide-workspace/lib/browser/workspace-variable-contribution';
|
|
28
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
29
|
-
|
|
30
|
-
import { DebugServer, IDebugServer, IDebuggerContribution, launchSchemaUri } from '../common';
|
|
31
|
-
import { DebugSessionOptions } from '../common';
|
|
32
|
-
import { DebugConfiguration } from '../common';
|
|
33
|
-
|
|
34
|
-
import { CONTEXT_DEBUGGERS_AVAILABLE } from './../common/constants';
|
|
35
|
-
import { DebugConfigurationModel } from './debug-configuration-model';
|
|
36
|
-
import { DebugPreferences } from './debug-preferences';
|
|
37
|
-
|
|
38
|
-
export type WillProvideDebugConfiguration = WaitUntilEvent;
|
|
39
|
-
export type WillInitialConfiguration = WaitUntilEvent;
|
|
40
|
-
|
|
41
|
-
export interface IDebugConfigurationData {
|
|
42
|
-
current?: {
|
|
43
|
-
name: string;
|
|
44
|
-
workspaceFolderUri?: string;
|
|
45
|
-
index: number;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Injectable()
|
|
50
|
-
export class DebugConfigurationManager {
|
|
51
|
-
static DEFAULT_UPDATE_MODEL_TIMEOUT = 500;
|
|
52
|
-
|
|
53
|
-
@Autowired(IWorkspaceService)
|
|
54
|
-
protected readonly workspaceService: IWorkspaceService;
|
|
55
|
-
|
|
56
|
-
@Autowired(WorkbenchEditorService)
|
|
57
|
-
protected readonly workbenchEditorService: WorkbenchEditorService;
|
|
58
|
-
|
|
59
|
-
@Autowired(IDebugServer)
|
|
60
|
-
protected readonly debug: DebugServer;
|
|
61
|
-
|
|
62
|
-
@Autowired(QuickPickService)
|
|
63
|
-
protected readonly quickPick: QuickPickService;
|
|
64
|
-
|
|
65
|
-
@Autowired(IContextKeyService)
|
|
66
|
-
protected readonly contextKeyService: IContextKeyService;
|
|
67
|
-
|
|
68
|
-
@Autowired(IFileServiceClient)
|
|
69
|
-
protected readonly filesystem: IFileServiceClient;
|
|
70
|
-
|
|
71
|
-
@Autowired(PreferenceService)
|
|
72
|
-
protected readonly preferences: PreferenceService;
|
|
73
|
-
|
|
74
|
-
@Autowired(PreferenceConfigurations)
|
|
75
|
-
protected readonly preferenceConfigurations: PreferenceConfigurations;
|
|
76
|
-
|
|
77
|
-
@Autowired(WorkspaceVariableContribution)
|
|
78
|
-
protected readonly workspaceVariables: WorkspaceVariableContribution;
|
|
79
|
-
|
|
80
|
-
@Autowired(StorageProvider)
|
|
81
|
-
private readonly storageProvider: StorageProvider;
|
|
82
|
-
|
|
83
|
-
@Autowired(CommandService)
|
|
84
|
-
protected readonly commandService: CommandService;
|
|
85
|
-
|
|
86
|
-
@Autowired(DebugPreferences)
|
|
87
|
-
protected readonly debugPreferences: DebugPreferences;
|
|
88
|
-
|
|
89
|
-
private contextDebuggersAvailable: IContextKey<boolean>;
|
|
90
|
-
|
|
91
|
-
// 用于存储支持断点的语言
|
|
92
|
-
private breakpointModeIdsSet = new Set<string>();
|
|
93
|
-
// 用于存储debugger信息
|
|
94
|
-
private debuggers: IDebuggerContribution[] = [];
|
|
95
|
-
|
|
96
|
-
protected readonly onDidChangeEmitter = new Emitter<void>();
|
|
97
|
-
readonly onDidChange: Event<void> = this.onDidChangeEmitter.event;
|
|
98
|
-
|
|
99
|
-
protected readonly onWillProvideDebugConfigurationEmitter = new Emitter<WillProvideDebugConfiguration>();
|
|
100
|
-
readonly onWillProvideDebugConfiguration: Event<WillProvideDebugConfiguration> =
|
|
101
|
-
this.onWillProvideDebugConfigurationEmitter.event;
|
|
102
|
-
|
|
103
|
-
private _whenReadyDeferred: Deferred<void> = new Deferred();
|
|
104
|
-
protected updateModelDelayer: ThrottledDelayer<void> = new ThrottledDelayer(
|
|
105
|
-
DebugConfigurationManager.DEFAULT_UPDATE_MODEL_TIMEOUT,
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
private debugConfigurationStorage: IStorage;
|
|
109
|
-
constructor() {
|
|
110
|
-
this.init();
|
|
111
|
-
this.contextDebuggersAvailable = CONTEXT_DEBUGGERS_AVAILABLE.bind(this.contextKeyService);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
protected async init(): Promise<void> {
|
|
115
|
-
this.preferences.onPreferenceChanged((e) => {
|
|
116
|
-
if (e.preferenceName === 'launch') {
|
|
117
|
-
this.updateModels();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
this.debugConfigurationStorage = await this.storageProvider(STORAGE_NAMESPACE.DEBUG);
|
|
121
|
-
this.updateModels();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
protected readonly models = new Map<string, DebugConfigurationModel>();
|
|
125
|
-
|
|
126
|
-
protected updateModels = () =>
|
|
127
|
-
this.updateModelDelayer.trigger(async () => {
|
|
128
|
-
const roots = await this.workspaceService.roots;
|
|
129
|
-
const toDelete = new Set(this.models.keys());
|
|
130
|
-
for (const rootStat of roots) {
|
|
131
|
-
const key = rootStat.uri;
|
|
132
|
-
toDelete.delete(key);
|
|
133
|
-
if (!this.models.has(key)) {
|
|
134
|
-
const model = new DebugConfigurationModel(key, this.preferences);
|
|
135
|
-
model.onDidChange(() => this.updateCurrent());
|
|
136
|
-
model.onDispose(() => this.models.delete(key));
|
|
137
|
-
this.models.set(key, model);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
for (const uri of toDelete) {
|
|
141
|
-
const model = this.models.get(uri);
|
|
142
|
-
if (model) {
|
|
143
|
-
model.dispose();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
this.updateCurrent();
|
|
147
|
-
let configEmpty = true;
|
|
148
|
-
this.models.forEach((model) => {
|
|
149
|
-
if (model.configurations.length) {
|
|
150
|
-
configEmpty = false;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
this.contextDebuggersAvailable.set(!configEmpty);
|
|
154
|
-
if (this._whenReadyDeferred) {
|
|
155
|
-
this._whenReadyDeferred.resolve();
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
get whenReady() {
|
|
160
|
-
return this._whenReadyDeferred.promise;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
get all(): DebugSessionOptions[] {
|
|
164
|
-
return this.getAll();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
protected getAll(): DebugSessionOptions[] {
|
|
168
|
-
const debugSessionOptions: DebugSessionOptions[] = [];
|
|
169
|
-
for (const model of this.models.values()) {
|
|
170
|
-
for (let index = 0, len = model.configurations.length; index < len; index++) {
|
|
171
|
-
debugSessionOptions.push({
|
|
172
|
-
configuration: model.configurations[index],
|
|
173
|
-
workspaceFolderUri: model.workspaceFolderUri,
|
|
174
|
-
index,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return debugSessionOptions;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
get supported(): Promise<DebugSessionOptions[]> {
|
|
182
|
-
return this.getSupported();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
protected async getSupported(): Promise<DebugSessionOptions[]> {
|
|
186
|
-
await this.whenReady;
|
|
187
|
-
const debugTypes = await this.debug.debugTypes();
|
|
188
|
-
return this.doGetSupported(new Set(debugTypes));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
protected doGetSupported(debugTypes: Set<string>): DebugSessionOptions[] {
|
|
192
|
-
const supported: DebugSessionOptions[] = [];
|
|
193
|
-
for (const options of this.getAll()) {
|
|
194
|
-
if (debugTypes.has(options.configuration.type)) {
|
|
195
|
-
supported.push(options);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return supported;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
protected _currentOptions: DebugSessionOptions | undefined;
|
|
202
|
-
get current(): DebugSessionOptions | undefined {
|
|
203
|
-
return this._currentOptions;
|
|
204
|
-
}
|
|
205
|
-
set current(option: DebugSessionOptions | undefined) {
|
|
206
|
-
this.updateCurrent(option);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
protected updateCurrent(options: DebugSessionOptions | undefined = this._currentOptions): void {
|
|
210
|
-
this._currentOptions = options && this.find(options.configuration.name, options.workspaceFolderUri, options.index);
|
|
211
|
-
if (!this._currentOptions) {
|
|
212
|
-
const { model } = this;
|
|
213
|
-
if (model) {
|
|
214
|
-
const configuration = model.configurations[0];
|
|
215
|
-
if (configuration) {
|
|
216
|
-
this._currentOptions = {
|
|
217
|
-
configuration,
|
|
218
|
-
workspaceFolderUri: model.workspaceFolderUri,
|
|
219
|
-
index: options?.index || 0,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
this.onDidChangeEmitter.fire(undefined);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
find(name: string, workspaceFolderUri: string | undefined, index?: number): DebugSessionOptions | undefined {
|
|
228
|
-
for (const model of this.models.values()) {
|
|
229
|
-
if (model.workspaceFolderUri === workspaceFolderUri) {
|
|
230
|
-
if (typeof index === 'number') {
|
|
231
|
-
const configuration = model.configurations[index];
|
|
232
|
-
if (configuration && configuration.name === name) {
|
|
233
|
-
return {
|
|
234
|
-
configuration,
|
|
235
|
-
workspaceFolderUri,
|
|
236
|
-
index,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
} else {
|
|
240
|
-
// 兼容无index的查找逻辑
|
|
241
|
-
for (let index = 0, len = model.configurations.length; index < len; index++) {
|
|
242
|
-
if (model.configurations[index].name === name) {
|
|
243
|
-
return {
|
|
244
|
-
configuration: model.configurations[index],
|
|
245
|
-
workspaceFolderUri,
|
|
246
|
-
index,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return undefined;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
async openConfiguration(uri?: string): Promise<void> {
|
|
257
|
-
let model: DebugConfigurationModel | undefined;
|
|
258
|
-
if (uri) {
|
|
259
|
-
model = this.getModelByUri(uri);
|
|
260
|
-
} else {
|
|
261
|
-
model = this.model;
|
|
262
|
-
}
|
|
263
|
-
if (model) {
|
|
264
|
-
await this.doOpen(model);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
async addConfiguration(uri?: string): Promise<void> {
|
|
269
|
-
let model: DebugConfigurationModel | undefined;
|
|
270
|
-
if (uri) {
|
|
271
|
-
model = this.getModelByUri(uri);
|
|
272
|
-
} else {
|
|
273
|
-
model = this.model;
|
|
274
|
-
}
|
|
275
|
-
if (!model) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
const resouce = await this.doOpen(model);
|
|
279
|
-
if (!resouce) {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
const { group } = resouce;
|
|
283
|
-
const editor = group.codeEditor.monacoEditor;
|
|
284
|
-
if (!editor) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
let position: monaco.Position | undefined;
|
|
289
|
-
let depthInArray = 0;
|
|
290
|
-
let lastProperty = '';
|
|
291
|
-
visit(editor.getValue(), {
|
|
292
|
-
onObjectProperty: (property) => {
|
|
293
|
-
lastProperty = property;
|
|
294
|
-
},
|
|
295
|
-
onArrayBegin: (offset) => {
|
|
296
|
-
if (lastProperty === 'configurations' && depthInArray === 0) {
|
|
297
|
-
position = editor.getModel()!.getPositionAt(offset + 1);
|
|
298
|
-
}
|
|
299
|
-
depthInArray++;
|
|
300
|
-
},
|
|
301
|
-
onArrayEnd: () => {
|
|
302
|
-
depthInArray--;
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
if (!position) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
// 判断在"configurations": [后是否有字符,如果有则新建一行
|
|
309
|
-
if (editor.getModel()!.getLineLastNonWhitespaceColumn(position.lineNumber) > position.column) {
|
|
310
|
-
editor.setPosition(position);
|
|
311
|
-
editor.trigger(launchSchemaUri, 'lineBreakInsert', undefined);
|
|
312
|
-
}
|
|
313
|
-
// 判断是否已有空行可用于插入建议,如果有,直接替换对应的光标位置
|
|
314
|
-
if (editor.getModel()!.getLineLastNonWhitespaceColumn(position.lineNumber + 1) === 0) {
|
|
315
|
-
editor.setPosition({ lineNumber: position.lineNumber + 1, column: 1 << 30 });
|
|
316
|
-
editor.trigger(null, 'editor.action.deleteLines', []);
|
|
317
|
-
}
|
|
318
|
-
editor.setPosition(position);
|
|
319
|
-
editor.trigger(null, 'editor.action.insertLineAfter', []);
|
|
320
|
-
editor.trigger(null, 'editor.action.triggerSuggest', []);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
protected get model(): DebugConfigurationModel | undefined {
|
|
324
|
-
const workspaceFolderUri = this.workspaceVariables.getWorkspaceRootUri();
|
|
325
|
-
if (workspaceFolderUri) {
|
|
326
|
-
const key = workspaceFolderUri.toString();
|
|
327
|
-
for (const model of this.models.values()) {
|
|
328
|
-
if (model.workspaceFolderUri === key) {
|
|
329
|
-
return model;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
for (const model of this.models.values()) {
|
|
334
|
-
if (model.uri) {
|
|
335
|
-
return model;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return this.models.values().next().value;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
protected getModelByUri(uri: string): DebugConfigurationModel | undefined {
|
|
342
|
-
if (uri) {
|
|
343
|
-
const key = uri;
|
|
344
|
-
for (const model of this.models.values()) {
|
|
345
|
-
if (model.workspaceFolderUri === key) {
|
|
346
|
-
return model;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
for (const model of this.models.values()) {
|
|
351
|
-
if (model.uri) {
|
|
352
|
-
return model;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return this.models.values().next().value;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
protected async doOpen(model: DebugConfigurationModel): Promise<IOpenResourceResult> {
|
|
359
|
-
let uri = model.uri;
|
|
360
|
-
if (!uri) {
|
|
361
|
-
uri = await this.doCreate(model);
|
|
362
|
-
}
|
|
363
|
-
return this.workbenchEditorService.open(uri, {
|
|
364
|
-
disableNavigate: true,
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
protected async doCreate(model: DebugConfigurationModel): Promise<URI> {
|
|
369
|
-
// 设置launch初始值
|
|
370
|
-
await this.preferences.set('launch', {});
|
|
371
|
-
// 获取可写入内容的文件
|
|
372
|
-
const { configUri } = this.preferences.resolve('launch');
|
|
373
|
-
let uri: URI;
|
|
374
|
-
if (configUri && configUri.path.base === 'launch.json') {
|
|
375
|
-
uri = configUri;
|
|
376
|
-
} else {
|
|
377
|
-
uri = new URI(model.workspaceFolderUri).resolve(`${this.preferenceConfigurations.getPaths()[0]}/launch.json`);
|
|
378
|
-
}
|
|
379
|
-
const debugType = await this.selectDebugType();
|
|
380
|
-
const configurations = debugType ? await this.provideDebugConfigurations(debugType, model.workspaceFolderUri) : [];
|
|
381
|
-
const content = this.getInitialConfigurationContent(configurations);
|
|
382
|
-
const fileStat = await this.filesystem.getFileStat(uri.toString());
|
|
383
|
-
|
|
384
|
-
if (!fileStat) {
|
|
385
|
-
await this.filesystem.createFile(uri.toString(), {
|
|
386
|
-
content,
|
|
387
|
-
});
|
|
388
|
-
} else {
|
|
389
|
-
try {
|
|
390
|
-
await this.filesystem.setContent(fileStat, content);
|
|
391
|
-
} catch (e) {
|
|
392
|
-
if (!FileSystemError.FileExists.is(e)) {
|
|
393
|
-
throw e;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return uri;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
protected async provideDebugConfigurations(
|
|
402
|
-
debugType: string,
|
|
403
|
-
workspaceFolderUri: string | undefined,
|
|
404
|
-
): Promise<DebugConfiguration[]> {
|
|
405
|
-
await this.fireWillProvideDebugConfiguration();
|
|
406
|
-
return this.debug.provideDebugConfigurations(debugType, workspaceFolderUri);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
protected async fireWillProvideDebugConfiguration(): Promise<void> {
|
|
410
|
-
await WaitUntilEvent.fire(this.onWillProvideDebugConfigurationEmitter, {});
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
protected getInitialConfigurationContent(initialConfigurations: DebugConfiguration[]): string {
|
|
414
|
-
const comment1 = localize('debug.configuration.comment1');
|
|
415
|
-
const comment2 = localize('debug.configuration.comment2');
|
|
416
|
-
const comment3 = localize('debug.configuration.comment3');
|
|
417
|
-
return `{
|
|
418
|
-
// ${comment1}
|
|
419
|
-
// ${comment2}
|
|
420
|
-
// ${comment3}
|
|
421
|
-
"version": "0.2.0",
|
|
422
|
-
"configurations": ${JSON.stringify(initialConfigurations, undefined, ' ')
|
|
423
|
-
.split('\n')
|
|
424
|
-
.map((line) => ' ' + line)
|
|
425
|
-
.join('\n')
|
|
426
|
-
.trim()}
|
|
427
|
-
}
|
|
428
|
-
`;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
protected async selectDebugType(): Promise<string | undefined> {
|
|
432
|
-
const editor = this.workbenchEditorService.currentEditor;
|
|
433
|
-
if (!editor) {
|
|
434
|
-
return undefined;
|
|
435
|
-
}
|
|
436
|
-
const document = editor.currentDocumentModel;
|
|
437
|
-
if (!document) {
|
|
438
|
-
return undefined;
|
|
439
|
-
}
|
|
440
|
-
const debuggers = await this.debug.getDebuggersForLanguage(document.languageId);
|
|
441
|
-
return this.quickPick.show(
|
|
442
|
-
debuggers.map(({ label, type }) => ({ label, value: type }), { placeholder: 'Select Environment' }),
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
async load(): Promise<void> {
|
|
447
|
-
await this.whenReady;
|
|
448
|
-
const data = this.debugConfigurationStorage.get<IDebugConfigurationData>('configurations');
|
|
449
|
-
if (data && data.current) {
|
|
450
|
-
this.current = this.find(data.current.name, data.current.workspaceFolderUri, data.current.index);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
async save(): Promise<void> {
|
|
455
|
-
const data: IDebugConfigurationData = {};
|
|
456
|
-
const { current } = this;
|
|
457
|
-
if (current) {
|
|
458
|
-
data.current = {
|
|
459
|
-
name: current.configuration.name,
|
|
460
|
-
workspaceFolderUri: current.workspaceFolderUri,
|
|
461
|
-
index: current.index,
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
this.debugConfigurationStorage.set('configurations', data);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* 判断当前文档是否支持断点
|
|
469
|
-
* @param model
|
|
470
|
-
*/
|
|
471
|
-
canSetBreakpointsIn(model: ITextModel) {
|
|
472
|
-
if (!model) {
|
|
473
|
-
return false;
|
|
474
|
-
}
|
|
475
|
-
const modeId = model.getLanguageId();
|
|
476
|
-
if (!modeId || modeId === 'jsonc' || modeId === 'log') {
|
|
477
|
-
// 不允许在JSONC类型文件及log文件中断点
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
if (this.debugPreferences['preference.debug.allowBreakpointsEverywhere']) {
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
return this.breakpointModeIdsSet.has(modeId);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
addSupportBreakpoints(languageId: string) {
|
|
487
|
-
this.breakpointModeIdsSet.add(languageId);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
removeSupportBreakpoints(languageId: string) {
|
|
491
|
-
this.breakpointModeIdsSet.delete(languageId);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
registerDebugger(debuggerContribution: IDebuggerContribution) {
|
|
495
|
-
if (debuggerContribution.type !== '*') {
|
|
496
|
-
const existing = this.getDebugger(debuggerContribution.type as string);
|
|
497
|
-
if (existing) {
|
|
498
|
-
// VSCode中会将插件贡献点根据isBuildIn进行覆盖式合并
|
|
499
|
-
return;
|
|
500
|
-
} else {
|
|
501
|
-
this.debuggers.push(debuggerContribution);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
getDebugger(type: string): IDebuggerContribution | undefined {
|
|
507
|
-
return this.debuggers.filter((dbg) => dbg.type === type).pop();
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
getDebuggers(): IDebuggerContribution[] {
|
|
511
|
-
return this.debuggers.filter((dbg) => !!dbg);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { URI, Emitter, Event, IDisposable, DisposableCollection, PreferenceService } from '@opensumi/ide-core-browser';
|
|
2
|
-
|
|
3
|
-
import { DebugConfiguration } from '../common';
|
|
4
|
-
|
|
5
|
-
export class DebugConfigurationModel implements IDisposable {
|
|
6
|
-
protected json: DebugConfigurationModel.JsonContent;
|
|
7
|
-
|
|
8
|
-
protected readonly onDidChangeEmitter = new Emitter<void>();
|
|
9
|
-
readonly onDidChange: Event<void> = this.onDidChangeEmitter.event;
|
|
10
|
-
|
|
11
|
-
protected readonly toDispose = new DisposableCollection(this.onDidChangeEmitter);
|
|
12
|
-
|
|
13
|
-
constructor(readonly workspaceFolderUri: string, protected readonly preferences: PreferenceService) {
|
|
14
|
-
this.reconcile();
|
|
15
|
-
this.toDispose.push(
|
|
16
|
-
this.preferences.onPreferenceChanged((e) => {
|
|
17
|
-
if (e.preferenceName === 'launch' && e.affects(workspaceFolderUri)) {
|
|
18
|
-
this.reconcile();
|
|
19
|
-
}
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get uri(): URI | undefined {
|
|
25
|
-
return this.json.uri;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
dispose(): void {
|
|
29
|
-
this.toDispose.dispose();
|
|
30
|
-
}
|
|
31
|
-
get onDispose(): Event<void> {
|
|
32
|
-
return this.toDispose.onDispose;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get configurations(): DebugConfiguration[] {
|
|
36
|
-
return this.json.configurations;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async reconcile(): Promise<void> {
|
|
40
|
-
this.json = this.parseConfigurations();
|
|
41
|
-
this.onDidChangeEmitter.fire(undefined);
|
|
42
|
-
}
|
|
43
|
-
protected parseConfigurations(): DebugConfigurationModel.JsonContent {
|
|
44
|
-
const configurations: DebugConfiguration[] = [];
|
|
45
|
-
const { configUri, value } = this.preferences.resolve<any>('launch', undefined, this.workspaceFolderUri);
|
|
46
|
-
if (value && typeof value === 'object' && 'configurations' in value) {
|
|
47
|
-
if (Array.isArray(value.configurations)) {
|
|
48
|
-
for (const configuration of value.configurations) {
|
|
49
|
-
if (DebugConfiguration.is(configuration)) {
|
|
50
|
-
configurations.push(configuration);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
uri: configUri,
|
|
57
|
-
configurations,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export namespace DebugConfigurationModel {
|
|
62
|
-
export interface JsonContent {
|
|
63
|
-
uri?: URI;
|
|
64
|
-
configurations: DebugConfiguration[];
|
|
65
|
-
}
|
|
66
|
-
}
|