introduce 'onDebugAdapterProtocolTracker' activation event

This commit is contained in:
Andre Weinand 2018-11-20 16:23:38 +01:00
parent f8f7e7ea00
commit b134a61eb2
4 changed files with 22 additions and 3 deletions

View file

@ -586,6 +586,8 @@ export interface IConfigurationManager {
*/
onDidSelectConfiguration: Event<void>;
activateDebuggers(activationEvent: string, debugType?: string): Thenable<void>;
needsToRunInExtHost(debugType: string): boolean;
hasDebugConfigurationProvider(debugType: string): boolean;

View file

@ -190,7 +190,7 @@ export class ConfigurationManager implements IConfigurationManager {
}
public resolveConfigurationByProviders(folderUri: uri | undefined, type: string | undefined, debugConfiguration: IConfig): Thenable<IConfig> {
return this.activateDebuggers(`onDebugResolve:${type}`).then(() => {
return this.activateDebuggers('onDebugResolve', type).then(() => {
// pipe the config through the promises sequentially. append at the end the '*' types
const providers = this.configProviders.filter(p => p.type === type && p.resolveDebugConfiguration)
.concat(this.configProviders.filter(p => p.type === '*' && p.resolveDebugConfiguration));
@ -413,7 +413,12 @@ export class ConfigurationManager implements IConfigurationManager {
});
}
private activateDebuggers(activationEvent: string): Thenable<void> {
public activateDebuggers(activationEvent: string, debugType?: string): Thenable<void> {
if (debugType) {
return this.extensionService.activateByEvent(`${activationEvent}:${debugType}`)
.then(() => this.extensionService.activateByEvent(activationEvent))
.then(() => this.extensionService.activateByEvent('onDebug'));
}
return this.extensionService.activateByEvent(activationEvent).then(() => this.extensionService.activateByEvent('onDebug'));
}

View file

@ -41,8 +41,15 @@ export class Debugger implements IDebugger {
this.mergedExtensionDescriptions = [extensionDescription];
}
public createDebugAdapter(session: IDebugSession, outputService: IOutputService): Promise<IDebugAdapter> {
return new Promise<IDebugAdapter>((resolve, reject) => {
this.configurationManager.activateDebuggers('onDebugAdapterProtocolTracker', this.type).then(_ => {
resolve(this._createDebugAdapter(session, outputService));
}, reject);
});
}
createDebugAdapter(session: IDebugSession, outputService: IOutputService): Promise<IDebugAdapter> {
private _createDebugAdapter(session: IDebugSession, outputService: IOutputService): Promise<IDebugAdapter> {
if (this.inExtHost()) {
return Promise.resolve(this.configurationManager.createDebugAdapter(session));
} else {

View file

@ -214,6 +214,11 @@ export const schema = {
description: nls.localize('vscode.extension.activationEvents.onDebugResolve', 'An activation event emitted whenever a debug session with the specific type is about to be launched (and a corresponding resolveDebugConfiguration method needs to be called).'),
body: 'onDebugResolve:${6:type}'
},
{
label: 'onDebugAdapterProtocolTracker',
description: nls.localize('vscode.extension.activationEvents.onDebugAdapterProtocolTracker', 'An activation event emitted whenever a debug session with the specific type is about to be launched and a debug protocol tracker might be needed.'),
body: 'onDebugAdapterProtocolTracker:${6:type}'
},
{
label: 'workspaceContains',
description: nls.localize('vscode.extension.activationEvents.workspaceContains', 'An activation event emitted whenever a folder is opened that contains at least a file matching the specified glob pattern.'),