@theia/plugin-ext 1.25.0-next.14 → 1.25.0-next.17

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.
Files changed (35) hide show
  1. package/lib/common/plugin-api-rpc.d.ts +5 -17
  2. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc.js.map +1 -1
  4. package/lib/main/browser/debug/plugin-debug-adapter-contribution.d.ts +0 -12
  5. package/lib/main/browser/debug/plugin-debug-adapter-contribution.d.ts.map +1 -1
  6. package/lib/main/browser/debug/plugin-debug-adapter-contribution.js +0 -18
  7. package/lib/main/browser/debug/plugin-debug-adapter-contribution.js.map +1 -1
  8. package/lib/main/browser/debug/plugin-debug-configuration-provider.d.ts +2 -2
  9. package/lib/main/browser/debug/plugin-debug-configuration-provider.d.ts.map +1 -1
  10. package/lib/main/browser/debug/plugin-debug-configuration-provider.js.map +1 -1
  11. package/lib/main/browser/debug/plugin-debug-service.d.ts +3 -2
  12. package/lib/main/browser/debug/plugin-debug-service.d.ts.map +1 -1
  13. package/lib/main/browser/debug/plugin-debug-service.js +28 -29
  14. package/lib/main/browser/debug/plugin-debug-service.js.map +1 -1
  15. package/lib/plugin/comments.js.map +1 -1
  16. package/lib/plugin/languages/lens.js.map +1 -1
  17. package/lib/plugin/node/debug/debug.d.ts +2 -5
  18. package/lib/plugin/node/debug/debug.d.ts.map +1 -1
  19. package/lib/plugin/node/debug/debug.js +0 -59
  20. package/lib/plugin/node/debug/debug.js.map +1 -1
  21. package/lib/plugin/tree/tree-views.d.ts.map +1 -1
  22. package/lib/plugin/tree/tree-views.js +2 -1
  23. package/lib/plugin/tree/tree-views.js.map +1 -1
  24. package/lib/plugin/workspace.d.ts +1 -1
  25. package/lib/plugin/workspace.d.ts.map +1 -1
  26. package/package.json +23 -23
  27. package/src/common/plugin-api-rpc.ts +19 -21
  28. package/src/main/browser/debug/plugin-debug-adapter-contribution.ts +0 -21
  29. package/src/main/browser/debug/plugin-debug-configuration-provider.ts +8 -2
  30. package/src/main/browser/debug/plugin-debug-service.ts +53 -31
  31. package/src/plugin/comments.ts +1 -1
  32. package/src/plugin/languages/lens.ts +1 -1
  33. package/src/plugin/node/debug/debug.ts +21 -77
  34. package/src/plugin/tree/tree-views.ts +2 -1
  35. package/src/plugin/workspace.ts +1 -1
@@ -147,52 +147,74 @@ export class PluginDebugService implements DebugService {
147
147
  return configurationsRecord;
148
148
  }
149
149
 
150
- async resolveDebugConfiguration(config: DebugConfiguration, workspaceFolderUri: string | undefined): Promise<DebugConfiguration> {
151
- let resolved = config;
152
-
150
+ async resolveDebugConfiguration(
151
+ config: DebugConfiguration,
152
+ workspaceFolderUri: string | undefined
153
+ ): Promise<DebugConfiguration | undefined | null> {
153
154
  const allProviders = Array.from(this.configurationProviders.values());
155
+
156
+ const resolvers = allProviders
157
+ .filter(p => p.type === config.type && !!p.resolveDebugConfiguration)
158
+ .map(p => p.resolveDebugConfiguration);
159
+
154
160
  // Append debug type '*' at the end
155
- const pluginProviders = allProviders.filter(p => p.type === config.type && !!p.resolveDebugConfiguration);
156
- pluginProviders.push(...allProviders.filter(p => p.type === '*' && !!p.resolveDebugConfiguration));
161
+ resolvers.push(
162
+ ...allProviders
163
+ .filter(p => p.type === '*' && !!p.resolveDebugConfiguration)
164
+ .map(p => p.resolveDebugConfiguration)
165
+ );
157
166
 
158
- for (const provider of pluginProviders) {
159
- try {
160
- const next = await provider.resolveDebugConfiguration(workspaceFolderUri, resolved);
161
- if (next) {
162
- resolved = next;
163
- } else {
164
- return resolved;
165
- }
166
- } catch (e) {
167
- console.error(e);
168
- }
169
- }
167
+ const resolved = await this.resolveDebugConfigurationByResolversChain(config, workspaceFolderUri, resolvers);
170
168
 
171
- return this.delegated.resolveDebugConfiguration(resolved, workspaceFolderUri);
169
+ return resolved ? this.delegated.resolveDebugConfiguration(resolved, workspaceFolderUri) : resolved;
172
170
  }
173
171
 
174
- async resolveDebugConfigurationWithSubstitutedVariables(config: DebugConfiguration, workspaceFolderUri: string | undefined): Promise<DebugConfiguration> {
175
- let resolved = config;
176
-
172
+ async resolveDebugConfigurationWithSubstitutedVariables(
173
+ config: DebugConfiguration,
174
+ workspaceFolderUri: string | undefined
175
+ ): Promise<DebugConfiguration | undefined | null> {
177
176
  const allProviders = Array.from(this.configurationProviders.values());
177
+
178
+ const resolvers = allProviders
179
+ .filter(p => p.type === config.type && !!p.resolveDebugConfigurationWithSubstitutedVariables)
180
+ .map(p => p.resolveDebugConfigurationWithSubstitutedVariables);
181
+
178
182
  // Append debug type '*' at the end
179
- const pluginProviders = allProviders.filter(p => p.type === config.type && !!p.resolveDebugConfigurationWithSubstitutedVariables);
180
- pluginProviders.push(...allProviders.filter(p => p.type === '*' && !!p.resolveDebugConfigurationWithSubstitutedVariables));
183
+ resolvers.push(
184
+ ...allProviders
185
+ .filter(p => p.type === '*' && !!p.resolveDebugConfigurationWithSubstitutedVariables)
186
+ .map(p => p.resolveDebugConfigurationWithSubstitutedVariables)
187
+ );
181
188
 
182
- for (const provider of pluginProviders) {
189
+ const resolved = await this.resolveDebugConfigurationByResolversChain(config, workspaceFolderUri, resolvers);
190
+
191
+ return resolved
192
+ ? this.delegated.resolveDebugConfigurationWithSubstitutedVariables(resolved, workspaceFolderUri)
193
+ : resolved;
194
+ }
195
+
196
+ protected async resolveDebugConfigurationByResolversChain(
197
+ config: DebugConfiguration,
198
+ workspaceFolderUri: string | undefined,
199
+ resolvers: ((
200
+ folder: string | undefined,
201
+ debugConfiguration: DebugConfiguration
202
+ ) => Promise<DebugConfiguration | null | undefined>)[]
203
+ ): Promise<DebugConfiguration | undefined | null> {
204
+ let resolved: DebugConfiguration | undefined | null = config;
205
+ for (const resolver of resolvers) {
183
206
  try {
184
- const next = await provider.resolveDebugConfigurationWithSubstitutedVariables(workspaceFolderUri, resolved);
185
- if (next) {
186
- resolved = next;
187
- } else {
188
- return resolved;
207
+ if (!resolved) {
208
+ // A provider has indicated to stop and process undefined or null as per specified in the vscode API
209
+ // https://code.visualstudio.com/api/references/vscode-api#DebugConfigurationProvider
210
+ break;
189
211
  }
212
+ resolved = await resolver(workspaceFolderUri, resolved);
190
213
  } catch (e) {
191
214
  console.error(e);
192
215
  }
193
216
  }
194
-
195
- return this.delegated.resolveDebugConfigurationWithSubstitutedVariables(resolved, workspaceFolderUri);
217
+ return resolved;
196
218
  }
197
219
 
198
220
  registerDebugger(contribution: DebuggerContribution): Disposable {
@@ -171,7 +171,7 @@ export class CommentsExtImpl implements CommentsExt {
171
171
 
172
172
  const documentData = this._documents.getDocumentData(URI.revive(uriComponents));
173
173
  if (documentData) {
174
- const ranges: theia.Range[] | undefined = await commentController.commentingRangeProvider!.provideCommentingRanges(documentData.document, token);
174
+ const ranges: theia.Range[] | undefined | null = await commentController.commentingRangeProvider!.provideCommentingRanges(documentData.document, token);
175
175
  if (ranges) {
176
176
  return ranges.map(x => fromRange(x));
177
177
  }
@@ -71,7 +71,7 @@ export class CodeLensAdapter {
71
71
  return undefined;
72
72
  }
73
73
 
74
- let newLens: theia.CodeLens | undefined;
74
+ let newLens: theia.CodeLens | undefined | null;
75
75
  if (typeof this.provider.resolveCodeLens === 'function' && !lens.isResolved) {
76
76
  newLens = await this.provider.resolveCodeLens(lens, token);
77
77
  if (token.isCancellationRequested) {
@@ -346,12 +346,20 @@ export class DebugExtImpl implements DebugExt {
346
346
  return { provider, type };
347
347
  }
348
348
 
349
- async $provideDebugConfigurationsByHandle(handle: number, workspaceFolderUri: string | undefined): Promise<theia.DebugConfiguration[]> {
349
+ async $provideDebugConfigurationsByHandle(
350
+ handle: number,
351
+ workspaceFolderUri: string | undefined
352
+ ): Promise<theia.DebugConfiguration[]> {
350
353
  const { provider, type } = this.getConfigurationProviderRecord(handle);
351
354
 
352
- const configurations = await provider.provideDebugConfigurations?.(this.toWorkspaceFolder(workspaceFolderUri));
355
+ const configurations = await provider.provideDebugConfigurations?.(
356
+ this.toWorkspaceFolder(workspaceFolderUri)
357
+ );
358
+
353
359
  if (!configurations) {
354
- throw new Error('nothing returned from DebugConfigurationProvider.provideDebugConfigurations, type: ' + type);
360
+ throw new Error(
361
+ 'nothing returned from DebugConfigurationProvider.provideDebugConfigurations, type: ' + type
362
+ );
355
363
  }
356
364
 
357
365
  return configurations;
@@ -361,88 +369,24 @@ export class DebugExtImpl implements DebugExt {
361
369
  handle: number,
362
370
  workspaceFolderUri: string | undefined,
363
371
  debugConfiguration: theia.DebugConfiguration
364
- ): Promise<theia.DebugConfiguration | undefined> {
365
-
372
+ ): Promise<theia.DebugConfiguration | undefined | null> {
366
373
  const { provider } = this.getConfigurationProviderRecord(handle);
367
- return provider.resolveDebugConfiguration?.(this.toWorkspaceFolder(workspaceFolderUri), debugConfiguration);
374
+ return provider.resolveDebugConfiguration?.(
375
+ this.toWorkspaceFolder(workspaceFolderUri),
376
+ debugConfiguration
377
+ );
368
378
  }
369
379
 
370
380
  async $resolveDebugConfigurationWithSubstitutedVariablesByHandle(
371
381
  handle: number,
372
382
  workspaceFolderUri: string | undefined,
373
383
  debugConfiguration: theia.DebugConfiguration
374
- ): Promise<theia.DebugConfiguration | undefined> {
375
-
384
+ ): Promise<theia.DebugConfiguration | undefined | null> {
376
385
  const { provider } = this.getConfigurationProviderRecord(handle);
377
- return provider.resolveDebugConfigurationWithSubstitutedVariables?.(this.toWorkspaceFolder(workspaceFolderUri), debugConfiguration);
378
- }
379
-
380
- async $provideDebugConfigurations(debugType: string, workspaceFolderUri: string | undefined, dynamic: boolean = false): Promise<theia.DebugConfiguration[]> {
381
- let result: theia.DebugConfiguration[] = [];
382
-
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)) || []);
391
- }
392
- }
393
-
394
- return result;
395
- }
396
-
397
- async $resolveDebugConfigurations(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined): Promise<theia.DebugConfiguration | undefined> {
398
- let current = debugConfiguration;
399
-
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;
412
- }
413
- } catch (e) {
414
- console.error(e);
415
- }
416
- }
417
- }
418
-
419
- return current;
420
- }
421
-
422
- async $resolveDebugConfigurationWithSubstitutedVariables(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined):
423
- Promise<theia.DebugConfiguration | undefined> {
424
- let current = debugConfiguration;
425
-
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;
438
- }
439
- } catch (e) {
440
- console.error(e);
441
- }
442
- }
443
- }
444
-
445
- return current;
386
+ return provider.resolveDebugConfigurationWithSubstitutedVariables?.(
387
+ this.toWorkspaceFolder(workspaceFolderUri),
388
+ debugConfiguration
389
+ );
446
390
  }
447
391
 
448
392
  protected async createDebugAdapterTracker(session: theia.DebugSession): Promise<theia.DebugAdapterTracker> {
@@ -262,7 +262,8 @@ class TreeViewExtImpl<T> implements Disposable {
262
262
  // root
263
263
  return [];
264
264
  }
265
- const parent = this.treeDataProvider.getParent && await this.treeDataProvider.getParent(element);
265
+ const result = this.treeDataProvider.getParent && await this.treeDataProvider.getParent(element);
266
+ const parent = result ? result : undefined;
266
267
  const chain = await this.calculateRevealParentChain(parent);
267
268
  if (!chain) {
268
269
  // parents are inconsistent
@@ -276,7 +276,7 @@ export class WorkspaceExtImpl implements WorkspaceExt {
276
276
  };
277
277
  }
278
278
 
279
- async $provideTextDocumentContent(documentURI: string): Promise<string | undefined> {
279
+ async $provideTextDocumentContent(documentURI: string): Promise<string | undefined | null> {
280
280
  const uri = URI.parse(documentURI);
281
281
  const provider = this.documentContentProviders.get(uri.scheme);
282
282
  if (provider) {