提交 b81ceba1 编写于 作者: A Andre Weinand

strict null for extHostDebugService.ts

上级 8c217344
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
"./vs/workbench/api/node/extHostCommands.ts", "./vs/workbench/api/node/extHostCommands.ts",
"./vs/workbench/api/node/extHostComments.ts", "./vs/workbench/api/node/extHostComments.ts",
"./vs/workbench/api/node/extHostConfiguration.ts", "./vs/workbench/api/node/extHostConfiguration.ts",
// "./vs/workbench/api/node/extHostDebugService.ts",
"./vs/workbench/api/node/extHostDecorations.ts", "./vs/workbench/api/node/extHostDecorations.ts",
"./vs/workbench/api/node/extHostDiagnostics.ts", "./vs/workbench/api/node/extHostDiagnostics.ts",
"./vs/workbench/api/node/extHostDialogs.ts", "./vs/workbench/api/node/extHostDialogs.ts",
......
...@@ -638,8 +638,8 @@ export interface MainThreadDebugServiceShape extends IDisposable { ...@@ -638,8 +638,8 @@ export interface MainThreadDebugServiceShape extends IDisposable {
$registerDebugTypes(debugTypes: string[]): void; $registerDebugTypes(debugTypes: string[]): void;
$sessionCached(sessionID: string): void; $sessionCached(sessionID: string): void;
$acceptDAMessage(handle: number, message: DebugProtocol.ProtocolMessage): void; $acceptDAMessage(handle: number, message: DebugProtocol.ProtocolMessage): void;
$acceptDAError(handle: number, name: string, message: string, stack: string): void; $acceptDAError(handle: number, name: string, message: string, stack: string | undefined): void;
$acceptDAExit(handle: number, code: number, signal: string): void; $acceptDAExit(handle: number, code: number | undefined, signal: string | undefined): void;
$registerDebugConfigurationProvider(type: string, hasProvideMethod: boolean, hasResolveMethod: boolean, hasProvideDaMethod: boolean, handle: number): Promise<void>; $registerDebugConfigurationProvider(type: string, hasProvideMethod: boolean, hasResolveMethod: boolean, hasProvideDaMethod: boolean, handle: number): Promise<void>;
$registerDebugAdapterDescriptorFactory(type: string, handle: number): Promise<void>; $registerDebugAdapterDescriptorFactory(type: string, handle: number): Promise<void>;
$registerDebugAdapterTrackerFactory(type: string, handle: number); $registerDebugAdapterTrackerFactory(type: string, handle: number);
......
...@@ -32,6 +32,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; ...@@ -32,6 +32,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands'; import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/node/extensionDescriptionRegistry'; import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/node/extensionDescriptionRegistry';
import { IProcessEnvironment } from 'vs/base/common/platform';
export class ExtHostDebugService implements ExtHostDebugServiceShape { export class ExtHostDebugService implements ExtHostDebugServiceShape {
...@@ -77,7 +78,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -77,7 +78,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
private _variableResolver: IConfigurationResolverService; private _variableResolver: IConfigurationResolverService;
private _integratedTerminalInstance: vscode.Terminal; private _integratedTerminalInstance?: vscode.Terminal;
private _terminalDisposedListener: IDisposable; private _terminalDisposedListener: IDisposable;
...@@ -324,7 +325,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -324,7 +325,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
// React on terminal disposed and check if that is the debug terminal #12956 // React on terminal disposed and check if that is the debug terminal #12956
this._terminalDisposedListener = this._terminalService.onDidCloseTerminal(terminal => { this._terminalDisposedListener = this._terminalService.onDidCloseTerminal(terminal => {
if (this._integratedTerminalInstance && this._integratedTerminalInstance === terminal) { if (this._integratedTerminalInstance && this._integratedTerminalInstance === terminal) {
this._integratedTerminalInstance = null; this._integratedTerminalInstance = undefined;
} }
}); });
} }
...@@ -341,16 +342,17 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -341,16 +342,17 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
} }
}).then(needNewTerminal => { }).then(needNewTerminal => {
if (needNewTerminal) { if (needNewTerminal || !this._integratedTerminalInstance) {
this._integratedTerminalInstance = this._terminalService.createTerminal(args.title || nls.localize('debug.terminal.title', "debuggee")); this._integratedTerminalInstance = this._terminalService.createTerminal(args.title || nls.localize('debug.terminal.title', "debuggee"));
} }
const terminal: vscode.Terminal = this._integratedTerminalInstance;
this._integratedTerminalInstance.show(); terminal.show();
return this._integratedTerminalInstance.processId.then(shellProcessId => { return this._integratedTerminalInstance.processId.then(shellProcessId => {
const command = prepareCommand(args, config); const command = prepareCommand(args, config);
this._integratedTerminalInstance.sendText(command, true); terminal.sendText(command, true);
return shellProcessId; return shellProcessId;
}); });
...@@ -363,13 +365,13 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -363,13 +365,13 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
return terminalLauncher.runInTerminal(args, config); return terminalLauncher.runInTerminal(args, config);
} }
} }
return undefined; return Promise.resolve(undefined);
} }
public async $substituteVariables(folderUri: UriComponents | undefined, config: IConfig): Promise<IConfig> { public async $substituteVariables(folderUri: UriComponents | undefined, config: IConfig): Promise<IConfig> {
const [workspaceFolders, configProvider] = await Promise.all([this._workspaceService.getWorkspaceFolders2(), this._configurationService.getConfigProvider()]);
if (!this._variableResolver) { if (!this._variableResolver) {
this._variableResolver = new ExtHostVariableResolverService(workspaceFolders, this._editorsService, configProvider); const [workspaceFolders, configProvider] = await Promise.all([this._workspaceService.getWorkspaceFolders2(), this._configurationService.getConfigProvider()]);
this._variableResolver = new ExtHostVariableResolverService(workspaceFolders || [], this._editorsService, configProvider);
} }
let ws: IWorkspaceFolder | undefined; let ws: IWorkspaceFolder | undefined;
const folder = await this.getFolder(folderUri); const folder = await this.getFolder(folderUri);
...@@ -390,9 +392,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -390,9 +392,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
const mythis = this; const mythis = this;
const session = await this.getSession(sessionDto); const session = await this.getSession(sessionDto);
return this.getAdapterDescriptor(this.getAdapterFactoryByType(session.type), session).then(x => {
const adapter = this.convertToDto(x); return this.getAdapterDescriptor(this.getAdapterFactoryByType(session.type), session).then(daDescriptor => {
const adapter = this.convertToDto(daDescriptor);
let da: AbstractDebugAdapter | undefined = undefined; let da: AbstractDebugAdapter | undefined = undefined;
switch (adapter.type) { switch (adapter.type) {
...@@ -413,8 +416,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -413,8 +416,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
break; break;
} }
if (da) { const debugAdapter = da;
this._debugAdapters.set(debugAdapterHandle, da);
if (debugAdapter) {
this._debugAdapters.set(debugAdapterHandle, debugAdapter);
return this.getDebugAdapterTrackers(session).then(tracker => { return this.getDebugAdapterTrackers(session).then(tracker => {
...@@ -422,9 +427,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -422,9 +427,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
this._debugAdaptersTrackers.set(debugAdapterHandle, tracker); this._debugAdaptersTrackers.set(debugAdapterHandle, tracker);
} }
da.onMessage(message => { debugAdapter.onMessage(message => {
if (tracker) { if (tracker && tracker.onDidSendMessage) {
tracker.onDidSendMessage(message); tracker.onDidSendMessage(message);
} }
...@@ -433,24 +438,24 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -433,24 +438,24 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
mythis._debugServiceProxy.$acceptDAMessage(debugAdapterHandle, message); mythis._debugServiceProxy.$acceptDAMessage(debugAdapterHandle, message);
}); });
da.onError(err => { debugAdapter.onError(err => {
if (tracker) { if (tracker && tracker.onError) {
tracker.onError(err); tracker.onError(err);
} }
this._debugServiceProxy.$acceptDAError(debugAdapterHandle, err.name, err.message, err.stack); this._debugServiceProxy.$acceptDAError(debugAdapterHandle, err.name, err.message, err.stack);
}); });
da.onExit(code => { debugAdapter.onExit((code: number) => {
if (tracker) { if (tracker && tracker.onExit) {
tracker.onExit(code, undefined); tracker.onExit(code, undefined);
} }
this._debugServiceProxy.$acceptDAExit(debugAdapterHandle, code, null); this._debugServiceProxy.$acceptDAExit(debugAdapterHandle, code, undefined);
}); });
if (tracker) { if (tracker && tracker.onWillStartSession) {
tracker.onWillStartSession(); tracker.onWillStartSession();
} }
return da.startSession(); return debugAdapter.startSession();
}); });
} }
...@@ -458,13 +463,13 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -458,13 +463,13 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
}); });
} }
public $sendDAMessage(debugAdapterHandle: number, message: DebugProtocol.ProtocolMessage): Promise<void> { public $sendDAMessage(debugAdapterHandle: number, message: DebugProtocol.ProtocolMessage): void {
// VS Code -> DA // VS Code -> DA
message = convertToDAPaths(message, false); message = convertToDAPaths(message, false);
const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle); // TODO@AW: same handle? const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle); // TODO@AW: same handle?
if (tracker) { if (tracker && tracker.onWillReceiveMessage) {
tracker.onWillReceiveMessage(message); tracker.onWillReceiveMessage(message);
} }
...@@ -472,14 +477,13 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -472,14 +477,13 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
if (da) { if (da) {
da.sendMessage(message); da.sendMessage(message);
} }
return undefined;
} }
public $stopDASession(debugAdapterHandle: number): Promise<void> { public $stopDASession(debugAdapterHandle: number): Promise<void> {
const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle); const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle);
this._debugAdaptersTrackers.delete(debugAdapterHandle); this._debugAdaptersTrackers.delete(debugAdapterHandle);
if (tracker) { if (tracker && tracker.onWillStopSession) {
tracker.onWillStopSession(); tracker.onWillStopSession();
} }
...@@ -488,7 +492,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -488,7 +492,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
if (da) { if (da) {
return da.stopSession(); return da.stopSession();
} else { } else {
return undefined; return Promise.resolve(void 0);
} }
} }
...@@ -500,8 +504,8 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -500,8 +504,8 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
if (delta.added) { if (delta.added) {
for (const bpd of delta.added) { for (const bpd of delta.added) {
const id = bpd.id;
if (!this._breakpoints.has(bpd.id)) { if (id && !this._breakpoints.has(id)) {
let bp: vscode.Breakpoint; let bp: vscode.Breakpoint;
if (bpd.type === 'function') { if (bpd.type === 'function') {
bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage); bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage);
...@@ -509,8 +513,8 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -509,8 +513,8 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
const uri = URI.revive(bpd.uri); const uri = URI.revive(bpd.uri);
bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage); bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage);
} }
(bp as any)._id = bpd.id; (bp as any)._id = id;
this._breakpoints.set(bpd.id, bp); this._breakpoints.set(id, bp);
a.push(bp); a.push(bp);
} }
} }
...@@ -528,24 +532,26 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -528,24 +532,26 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
if (delta.changed) { if (delta.changed) {
for (const bpd of delta.changed) { for (const bpd of delta.changed) {
const bp = this._breakpoints.get(bpd.id); if (bpd.id) {
if (bp) { const bp = this._breakpoints.get(bpd.id);
if (bp instanceof FunctionBreakpoint && bpd.type === 'function') { if (bp) {
const fbp = <any>bp; if (bp instanceof FunctionBreakpoint && bpd.type === 'function') {
fbp.enabled = bpd.enabled; const fbp = <any>bp;
fbp.condition = bpd.condition; fbp.enabled = bpd.enabled;
fbp.hitCondition = bpd.hitCondition; fbp.condition = bpd.condition;
fbp.logMessage = bpd.logMessage; fbp.hitCondition = bpd.hitCondition;
fbp.functionName = bpd.functionName; fbp.logMessage = bpd.logMessage;
} else if (bp instanceof SourceBreakpoint && bpd.type === 'source') { fbp.functionName = bpd.functionName;
const sbp = <any>bp; } else if (bp instanceof SourceBreakpoint && bpd.type === 'source') {
sbp.enabled = bpd.enabled; const sbp = <any>bp;
sbp.condition = bpd.condition; sbp.enabled = bpd.enabled;
sbp.hitCondition = bpd.hitCondition; sbp.condition = bpd.condition;
sbp.logMessage = bpd.logMessage; sbp.hitCondition = bpd.hitCondition;
sbp.location = new Location(URI.revive(bpd.uri), new Position(bpd.line, bpd.character)); sbp.logMessage = bpd.logMessage;
sbp.location = new Location(URI.revive(bpd.uri), new Position(bpd.line, bpd.character));
}
c.push(bp);
} }
c.push(bp);
} }
} }
} }
...@@ -553,41 +559,57 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -553,41 +559,57 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
this.fireBreakpointChanges(a, r, c); this.fireBreakpointChanges(a, r, c);
} }
public async $provideDebugConfigurations(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<vscode.DebugConfiguration[]> { public $provideDebugConfigurations(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<vscode.DebugConfiguration[]> {
const provider = this.getConfigProviderByHandle(configProviderHandle); return asPromise(async () => {
if (!provider) { const provider = this.getConfigProviderByHandle(configProviderHandle);
return Promise.reject(new Error('no handler found')); if (!provider) {
} throw new Error('no DebugConfigurationProvider found');
if (!provider.provideDebugConfigurations) { }
return Promise.reject(new Error('handler has no method provideDebugConfigurations')); if (!provider.provideDebugConfigurations) {
} throw new Error('DebugConfigurationProvider has no method provideDebugConfigurations');
const folder = await this.getFolder(folderUri); }
return asPromise(() => provider.provideDebugConfigurations(folder, CancellationToken.None)); const folder = await this.getFolder(folderUri);
return provider.provideDebugConfigurations(folder, CancellationToken.None);
}).then(debugConfigurations => {
if (!debugConfigurations) {
throw new Error('nothing returned from DebugConfigurationProvider.provideDebugConfigurations');
}
return debugConfigurations;
});
} }
public async $resolveDebugConfiguration(configProviderHandle: number, folderUri: UriComponents | undefined, debugConfiguration: vscode.DebugConfiguration): Promise<vscode.DebugConfiguration> { public $resolveDebugConfiguration(configProviderHandle: number, folderUri: UriComponents | undefined, debugConfiguration: vscode.DebugConfiguration): Promise<vscode.DebugConfiguration | null | undefined> {
const provider = this.getConfigProviderByHandle(configProviderHandle); return asPromise(async () => {
if (!provider) { const provider = this.getConfigProviderByHandle(configProviderHandle);
return Promise.reject(new Error('no handler found')); if (!provider) {
} throw new Error('no DebugConfigurationProvider found');
if (!provider.resolveDebugConfiguration) { }
return Promise.reject(new Error('handler has no method resolveDebugConfiguration')); if (!provider.resolveDebugConfiguration) {
} throw new Error('DebugConfigurationProvider has no method resolveDebugConfiguration');
const folder = await this.getFolder(folderUri); }
return asPromise(() => provider.resolveDebugConfiguration(folder, debugConfiguration, CancellationToken.None)); const folder = await this.getFolder(folderUri);
return provider.resolveDebugConfiguration(folder, debugConfiguration, CancellationToken.None);
});
} }
// TODO@AW legacy // TODO@AW deprecated and legacy
public async $legacyDebugAdapterExecutable(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<IAdapterDescriptor> { public $legacyDebugAdapterExecutable(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<IAdapterDescriptor> {
const provider = this.getConfigProviderByHandle(configProviderHandle); return asPromise(async () => {
if (!provider) { const provider = this.getConfigProviderByHandle(configProviderHandle);
return Promise.reject(new Error('no handler found')); if (!provider) {
} throw new Error('no DebugConfigurationProvider found');
if (!provider.debugAdapterExecutable) { }
return Promise.reject(new Error('handler has no method debugAdapterExecutable')); if (!provider.debugAdapterExecutable) {
} throw new Error('DebugConfigurationProvider has no method debugAdapterExecutable');
const folder = await this.getFolder(folderUri); }
return asPromise(() => provider.debugAdapterExecutable(folder, CancellationToken.None)).then(x => this.convertToDto(x)); const folder = await this.getFolder(folderUri);
return provider.debugAdapterExecutable(folder, CancellationToken.None);
}).then(executable => {
if (!executable) {
throw new Error('nothing returned from DebugConfigurationProvider.debugAdapterExecutable');
}
return this.convertToDto(executable);
});
} }
public async $provideDebugAdapter(adapterProviderHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> { public async $provideDebugAdapter(adapterProviderHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> {
...@@ -629,7 +651,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -629,7 +651,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
// private & dto helpers // private & dto helpers
private convertToDto(x: vscode.DebugAdapterDescriptor): IAdapterDescriptor { private convertToDto(x: vscode.DebugAdapterDescriptor | undefined): IAdapterDescriptor {
if (x instanceof DebugAdapterExecutable) { if (x instanceof DebugAdapterExecutable) {
return <IDebugAdapterExecutable>{ return <IDebugAdapterExecutable>{
type: 'executable', type: 'executable',
...@@ -649,11 +671,11 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -649,11 +671,11 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
implementation: x.implementation implementation: x.implementation
}; };
} else */ { } else */ {
throw new Error('unexpected type'); throw new Error('convertToDto unexpected type');
} }
} }
private getAdapterFactoryByType(type: string): vscode.DebugAdapterDescriptorFactory { private getAdapterFactoryByType(type: string): vscode.DebugAdapterDescriptorFactory | undefined {
const results = this._adapterFactories.filter(p => p.type === type); const results = this._adapterFactories.filter(p => p.type === type);
if (results.length > 0) { if (results.length > 0) {
return results[0].factory; return results[0].factory;
...@@ -661,7 +683,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -661,7 +683,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
return undefined; return undefined;
} }
private getAdapterProviderByHandle(handle: number): vscode.DebugAdapterDescriptorFactory { private getAdapterProviderByHandle(handle: number): vscode.DebugAdapterDescriptorFactory | undefined {
const results = this._adapterFactories.filter(p => p.handle === handle); const results = this._adapterFactories.filter(p => p.handle === handle);
if (results.length > 0) { if (results.length > 0) {
return results[0].factory; return results[0].factory;
...@@ -669,7 +691,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -669,7 +691,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
return undefined; return undefined;
} }
private getConfigProviderByHandle(handle: number): vscode.DebugConfigurationProvider { private getConfigProviderByHandle(handle: number): vscode.DebugConfigurationProvider | undefined {
const results = this._configProviders.filter(p => p.handle === handle); const results = this._configProviders.filter(p => p.handle === handle);
if (results.length > 0) { if (results.length > 0) {
return results[0].provider; return results[0].provider;
...@@ -694,18 +716,18 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -694,18 +716,18 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
return false; return false;
} }
private getDebugAdapterTrackers(session: ExtHostDebugSession): Promise<vscode.DebugAdapterTracker> { private getDebugAdapterTrackers(session: ExtHostDebugSession): Promise<vscode.DebugAdapterTracker | undefined> {
const config = session.configuration; const config = session.configuration;
const type = config.type; const type = config.type;
const promises = this._trackerFactories const promises = this._trackerFactories
.filter(tuple => tuple.type === type || tuple.type === '*') .filter(tuple => tuple.type === type || tuple.type === '*')
.map(tuple => asPromise(() => tuple.factory.createDebugAdapterTracker(session)).then(p => p).catch(err => null)); .map(tuple => asPromise<vscode.ProviderResult<vscode.DebugAdapterTracker>>(() => tuple.factory.createDebugAdapterTracker(session)).then(p => p, err => null));
return Promise.race([ return Promise.race([
Promise.all(promises).then(trackers => { Promise.all(promises).then(result => {
trackers = trackers.filter(t => t); // filter null const trackers = <vscode.DebugAdapterTracker[]>result.filter(t => !!t); // filter null
if (trackers.length > 0) { if (trackers.length > 0) {
return new MultiTracker(trackers); return new MultiTracker(trackers);
} }
...@@ -723,7 +745,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -723,7 +745,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
}); });
} }
private async getAdapterDescriptor(adapterProvider: vscode.DebugAdapterDescriptorFactory, session: ExtHostDebugSession): Promise<vscode.DebugAdapterDescriptor> { private async getAdapterDescriptor(adapterProvider: vscode.DebugAdapterDescriptorFactory | undefined, session: ExtHostDebugSession): Promise<vscode.DebugAdapterDescriptor | undefined> {
// a "debugServer" attribute in the launch config takes precedence // a "debugServer" attribute in the launch config takes precedence
const serverPort = session.configuration.debugServer; const serverPort = session.configuration.debugServer;
...@@ -732,16 +754,25 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -732,16 +754,25 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
} }
// TODO@AW legacy // TODO@AW legacy
const pairs = this._configProviders.filter(p => p.type === session.type); const pair = this._configProviders.filter(p => p.type === session.type).pop();
if (pairs.length > 0) { if (pair && pair.provider.debugAdapterExecutable) {
if (pairs[0].provider.debugAdapterExecutable) { const func = pair.provider.debugAdapterExecutable;
return asPromise(() => pairs[0].provider.debugAdapterExecutable(session.workspaceFolder, CancellationToken.None)); return asPromise(() => func(session.workspaceFolder, CancellationToken.None)).then(executable => {
} if (executable) {
return executable;
}
return undefined;
});
} }
if (adapterProvider) { if (adapterProvider) {
const extensionRegistry = await this._extensionService.getExtensionRegistry(); const extensionRegistry = await this._extensionService.getExtensionRegistry();
return asPromise(() => adapterProvider.createDebugAdapterDescriptor(session, this.daExecutableFromPackage(session, extensionRegistry))); return asPromise(() => adapterProvider.createDebugAdapterDescriptor(session, this.daExecutableFromPackage(session, extensionRegistry))).then(daDescriptor => {
if (daDescriptor) {
return daDescriptor;
}
return undefined;
});
} }
// try deprecated command based extension API "adapterExecutableCommand" to determine the executable // try deprecated command based extension API "adapterExecutableCommand" to determine the executable
...@@ -788,7 +819,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -788,7 +819,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
private async getSession(dto: IDebugSessionDto): Promise<ExtHostDebugSession> { private async getSession(dto: IDebugSessionDto): Promise<ExtHostDebugSession> {
if (dto) { if (dto) {
if (typeof dto === 'string') { if (typeof dto === 'string') {
return this._debugSessions.get(dto); const ds = this._debugSessions.get(dto);
if (ds) {
return ds;
}
} else { } else {
let ds = this._debugSessions.get(dto.id); let ds = this._debugSessions.get(dto.id);
if (!ds) { if (!ds) {
...@@ -800,7 +834,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -800,7 +834,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
return ds; return ds;
} }
} }
return undefined; throw new Error('cannot find session');
} }
private getFolder(_folderUri: UriComponents | undefined): Promise<vscode.WorkspaceFolder | undefined> { private getFolder(_folderUri: UriComponents | undefined): Promise<vscode.WorkspaceFolder | undefined> {
...@@ -808,7 +842,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -808,7 +842,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
const folderURI = URI.revive(_folderUri); const folderURI = URI.revive(_folderUri);
return this._workspaceService.resolveWorkspaceFolder(folderURI); return this._workspaceService.resolveWorkspaceFolder(folderURI);
} }
return undefined; return Promise.resolve(undefined);
} }
} }
...@@ -909,7 +943,7 @@ export class ExtHostVariableResolverService extends AbstractVariableResolverServ ...@@ -909,7 +943,7 @@ export class ExtHostVariableResolverService extends AbstractVariableResolverServ
} }
return undefined; return undefined;
} }
}, process.env); }, process.env as IProcessEnvironment);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册