@theia/plugin-ext 1.24.0-next.68 → 1.24.0-next.71
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/common/plugin-api-rpc.d.ts +30 -0
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/main/browser/debug/debug-main.d.ts +5 -2
- package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
- package/lib/main/browser/debug/debug-main.js +17 -2
- package/lib/main/browser/debug/debug-main.js.map +1 -1
- package/lib/main/browser/debug/plugin-debug-adapter-contribution.d.ts +9 -0
- package/lib/main/browser/debug/plugin-debug-adapter-contribution.d.ts.map +1 -1
- package/lib/main/browser/debug/plugin-debug-adapter-contribution.js +9 -0
- package/lib/main/browser/debug/plugin-debug-adapter-contribution.js.map +1 -1
- package/lib/main/browser/debug/plugin-debug-configuration-provider.d.ts +13 -0
- package/lib/main/browser/debug/plugin-debug-configuration-provider.d.ts.map +1 -0
- package/lib/main/browser/debug/plugin-debug-configuration-provider.js +39 -0
- package/lib/main/browser/debug/plugin-debug-configuration-provider.js.map +1 -0
- package/lib/main/browser/debug/plugin-debug-service.d.ts +7 -25
- package/lib/main/browser/debug/plugin-debug-service.d.ts.map +1 -1
- package/lib/main/browser/debug/plugin-debug-service.js +65 -44
- package/lib/main/browser/debug/plugin-debug-service.js.map +1 -1
- package/lib/plugin/node/debug/debug.d.ts +7 -3
- package/lib/plugin/node/debug/debug.d.ts.map +1 -1
- package/lib/plugin/node/debug/debug.js +79 -64
- package/lib/plugin/node/debug/debug.js.map +1 -1
- package/package.json +23 -23
- package/src/common/plugin-api-rpc.ts +36 -0
- package/src/main/browser/debug/debug-main.ts +28 -4
- package/src/main/browser/debug/plugin-debug-adapter-contribution.ts +9 -0
- package/src/main/browser/debug/plugin-debug-configuration-provider.ts +57 -0
- package/src/main/browser/debug/plugin-debug-service.ts +80 -63
- package/src/plugin/node/debug/debug.ts +104 -64
|
@@ -34,21 +34,23 @@ import { PluginDebugAdapterTracker } from './plugin-debug-adapter-tracker';
|
|
|
34
34
|
import uuid = require('uuid');
|
|
35
35
|
import { DebugAdapter } from '@theia/debug/lib/node/debug-model';
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
interface ConfigurationProviderRecord {
|
|
38
|
+
handle: number;
|
|
39
|
+
type: string;
|
|
40
|
+
trigger: DebugConfigurationProviderTriggerKind,
|
|
41
|
+
provider: theia.DebugConfigurationProvider;
|
|
42
|
+
}
|
|
38
43
|
|
|
44
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
39
45
|
// TODO: rename file to `debug-ext.ts`
|
|
40
|
-
|
|
41
46
|
/**
|
|
42
47
|
* It is supposed to work at node only.
|
|
43
48
|
*/
|
|
44
49
|
export class DebugExtImpl implements DebugExt {
|
|
45
50
|
// debug sessions by sessionId
|
|
46
51
|
private sessions = new Map<string, PluginDebugAdapterSession>();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
private configurationProviders = new Map<string, Set<theia.DebugConfigurationProvider>>();
|
|
50
|
-
// providers by type (dynamic)
|
|
51
|
-
private dynamicConfigurationProviders = new Map<string, Set<theia.DebugConfigurationProvider>>();
|
|
52
|
+
private configurationProviderHandleGenerator: number;
|
|
53
|
+
private configurationProviders: ConfigurationProviderRecord[];
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
56
|
* Only use internally, don't send it to the frontend. It's expensive!
|
|
@@ -85,6 +87,8 @@ export class DebugExtImpl implements DebugExt {
|
|
|
85
87
|
append: (value: string) => this.proxy.$appendToDebugConsole(value),
|
|
86
88
|
appendLine: (value: string) => this.proxy.$appendLineToDebugConsole(value)
|
|
87
89
|
};
|
|
90
|
+
this.configurationProviderHandleGenerator = 0;
|
|
91
|
+
this.configurationProviders = [];
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
/**
|
|
@@ -191,24 +195,23 @@ export class DebugExtImpl implements DebugExt {
|
|
|
191
195
|
});
|
|
192
196
|
}
|
|
193
197
|
|
|
194
|
-
registerDebugConfigurationProvider(debugType: string, provider: theia.DebugConfigurationProvider, trigger:
|
|
198
|
+
registerDebugConfigurationProvider(debugType: string, provider: theia.DebugConfigurationProvider, trigger: DebugConfigurationProviderTriggerKind): Disposable {
|
|
195
199
|
console.log(`Debug configuration provider has been registered: ${debugType}, trigger: ${trigger}`);
|
|
196
|
-
const providersByTriggerKind = trigger === DebugConfigurationProviderTriggerKind.Initial ? this.configurationProviders : this.dynamicConfigurationProviders;
|
|
197
|
-
let providers = providersByTriggerKind.get(debugType);
|
|
198
|
-
if (!providers) {
|
|
199
|
-
providersByTriggerKind.set(debugType, providers = new Set());
|
|
200
|
-
}
|
|
201
|
-
providers.add(provider);
|
|
202
200
|
|
|
201
|
+
const handle = this.configurationProviderHandleGenerator++;
|
|
202
|
+
this.configurationProviders.push({ handle, type: debugType, trigger, provider });
|
|
203
|
+
const descriptor = {
|
|
204
|
+
handle,
|
|
205
|
+
type: debugType,
|
|
206
|
+
trigger,
|
|
207
|
+
provideDebugConfiguration: !!provider.provideDebugConfigurations,
|
|
208
|
+
resolveDebugConfigurations: !!provider.resolveDebugConfiguration,
|
|
209
|
+
resolveDebugConfigurationWithSubstitutedVariables: !!provider.resolveDebugConfigurationWithSubstitutedVariables
|
|
210
|
+
};
|
|
211
|
+
this.proxy.$registerDebugConfigurationProvider(descriptor);
|
|
203
212
|
return Disposable.create(() => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (providers) {
|
|
207
|
-
providers.delete(provider);
|
|
208
|
-
if (providers.size === 0) {
|
|
209
|
-
providersByTriggerKind.delete(debugType);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
213
|
+
this.configurationProviders = this.configurationProviders.filter(p => (p.handle !== handle));
|
|
214
|
+
this.proxy.$unregisterDebugConfigurationProvider(handle);
|
|
212
215
|
});
|
|
213
216
|
}
|
|
214
217
|
|
|
@@ -331,15 +334,60 @@ export class DebugExtImpl implements DebugExt {
|
|
|
331
334
|
return undefined;
|
|
332
335
|
}
|
|
333
336
|
|
|
337
|
+
private getConfigurationProviderRecord(handle: number): {
|
|
338
|
+
provider: theia.DebugConfigurationProvider
|
|
339
|
+
type: string
|
|
340
|
+
} {
|
|
341
|
+
const record = this.configurationProviders.find(p => p.handle === handle);
|
|
342
|
+
if (!record) {
|
|
343
|
+
throw new Error('No Debug configuration provider found with given handle number: ' + handle);
|
|
344
|
+
}
|
|
345
|
+
const { provider, type } = record;
|
|
346
|
+
return { provider, type };
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async $provideDebugConfigurationsByHandle(handle: number, workspaceFolderUri: string | undefined): Promise<theia.DebugConfiguration[]> {
|
|
350
|
+
const { provider, type } = this.getConfigurationProviderRecord(handle);
|
|
351
|
+
|
|
352
|
+
const configurations = await provider.provideDebugConfigurations?.(this.toWorkspaceFolder(workspaceFolderUri));
|
|
353
|
+
if (!configurations) {
|
|
354
|
+
throw new Error('nothing returned from DebugConfigurationProvider.provideDebugConfigurations, type: ' + type);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return configurations;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async $resolveDebugConfigurationByHandle(
|
|
361
|
+
handle: number,
|
|
362
|
+
workspaceFolderUri: string | undefined,
|
|
363
|
+
debugConfiguration: theia.DebugConfiguration
|
|
364
|
+
): Promise<theia.DebugConfiguration | undefined> {
|
|
365
|
+
|
|
366
|
+
const { provider } = this.getConfigurationProviderRecord(handle);
|
|
367
|
+
return provider.resolveDebugConfiguration?.(this.toWorkspaceFolder(workspaceFolderUri), debugConfiguration);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async $resolveDebugConfigurationWithSubstitutedVariablesByHandle(
|
|
371
|
+
handle: number,
|
|
372
|
+
workspaceFolderUri: string | undefined,
|
|
373
|
+
debugConfiguration: theia.DebugConfiguration
|
|
374
|
+
): Promise<theia.DebugConfiguration | undefined> {
|
|
375
|
+
|
|
376
|
+
const { provider } = this.getConfigurationProviderRecord(handle);
|
|
377
|
+
return provider.resolveDebugConfigurationWithSubstitutedVariables?.(this.toWorkspaceFolder(workspaceFolderUri), debugConfiguration);
|
|
378
|
+
}
|
|
379
|
+
|
|
334
380
|
async $provideDebugConfigurations(debugType: string, workspaceFolderUri: string | undefined, dynamic: boolean = false): Promise<theia.DebugConfiguration[]> {
|
|
335
381
|
let result: theia.DebugConfiguration[] = [];
|
|
336
382
|
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
383
|
+
const trigger = dynamic ? DebugConfigurationProviderTriggerKind.Dynamic : DebugConfigurationProviderTriggerKind.Initial;
|
|
384
|
+
const providers = this.configurationProviders
|
|
385
|
+
.filter(p => p.type === debugType && p.trigger === trigger)
|
|
386
|
+
.map(p => p.provider);
|
|
387
|
+
|
|
388
|
+
for (const provider of providers) {
|
|
389
|
+
if (provider.provideDebugConfigurations) {
|
|
390
|
+
result = result.concat(await provider.provideDebugConfigurations(this.toWorkspaceFolder(workspaceFolderUri)) || []);
|
|
343
391
|
}
|
|
344
392
|
}
|
|
345
393
|
|
|
@@ -349,25 +397,21 @@ export class DebugExtImpl implements DebugExt {
|
|
|
349
397
|
async $resolveDebugConfigurations(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined): Promise<theia.DebugConfiguration | undefined> {
|
|
350
398
|
let current = debugConfiguration;
|
|
351
399
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
} else {
|
|
365
|
-
return current;
|
|
366
|
-
}
|
|
367
|
-
} catch (e) {
|
|
368
|
-
console.error(e);
|
|
369
|
-
}
|
|
400
|
+
const providers = this.configurationProviders
|
|
401
|
+
.filter(p => p.type === debugConfiguration.type || p.type === '*')
|
|
402
|
+
.map(p => p.provider);
|
|
403
|
+
|
|
404
|
+
for (const provider of providers) {
|
|
405
|
+
if (provider.resolveDebugConfiguration) {
|
|
406
|
+
try {
|
|
407
|
+
const next = await provider.resolveDebugConfiguration(this.toWorkspaceFolder(workspaceFolderUri), current);
|
|
408
|
+
if (next) {
|
|
409
|
+
current = next;
|
|
410
|
+
} else {
|
|
411
|
+
return current;
|
|
370
412
|
}
|
|
413
|
+
} catch (e) {
|
|
414
|
+
console.error(e);
|
|
371
415
|
}
|
|
372
416
|
}
|
|
373
417
|
}
|
|
@@ -379,25 +423,21 @@ export class DebugExtImpl implements DebugExt {
|
|
|
379
423
|
Promise<theia.DebugConfiguration | undefined> {
|
|
380
424
|
let current = debugConfiguration;
|
|
381
425
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
} else {
|
|
395
|
-
return current;
|
|
396
|
-
}
|
|
397
|
-
} catch (e) {
|
|
398
|
-
console.error(e);
|
|
399
|
-
}
|
|
426
|
+
const providers = this.configurationProviders
|
|
427
|
+
.filter(p => p.type === debugConfiguration.type || p.type === '*')
|
|
428
|
+
.map(p => p.provider);
|
|
429
|
+
|
|
430
|
+
for (const provider of providers) {
|
|
431
|
+
if (provider.resolveDebugConfigurationWithSubstitutedVariables) {
|
|
432
|
+
try {
|
|
433
|
+
const next = await provider.resolveDebugConfigurationWithSubstitutedVariables(this.toWorkspaceFolder(workspaceFolderUri), current);
|
|
434
|
+
if (next) {
|
|
435
|
+
current = next;
|
|
436
|
+
} else {
|
|
437
|
+
return current;
|
|
400
438
|
}
|
|
439
|
+
} catch (e) {
|
|
440
|
+
console.error(e);
|
|
401
441
|
}
|
|
402
442
|
}
|
|
403
443
|
}
|