diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 9ae7f71253084c16839987cf6cfb93b299cfa47b..47698340041595726c57583ba3b17c7b998d7fdb 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -243,6 +243,7 @@ "./vs/workbench/contrib/debug/common/debugViewModel.ts", "./vs/workbench/contrib/debug/electron-browser/rawDebugSession.ts", "./vs/workbench/contrib/debug/node/debugAdapter.ts", + "./vs/workbench/contrib/debug/node/debugger.ts", "./vs/workbench/contrib/debug/node/telemetryApp.ts", "./vs/workbench/contrib/debug/test/common/debugSource.test.ts", "./vs/workbench/contrib/debug/test/common/debugUtils.test.ts", diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index 39fe368818e79b267c824c3a99e2230e35699dd3..000458a22fc3ca43a985e2a48c9f19f4bb5cb8c5 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -112,7 +112,7 @@ export interface IExpression extends IReplElement, IExpressionContainer { export interface IDebugger { createDebugAdapter(session: IDebugSession, outputService: IOutputService): Promise; runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments): Promise; - getCustomTelemetryService(): Promise; + getCustomTelemetryService(): Promise; } export const enum State { @@ -516,7 +516,7 @@ export interface IPlatformSpecificAdapterContribution { } export interface IDebuggerContribution extends IPlatformSpecificAdapterContribution { - type?: string; + type: string; label?: string; // debug adapter executable adapterExecutableCommand?: string; diff --git a/src/vs/workbench/contrib/debug/node/debugAdapter.ts b/src/vs/workbench/contrib/debug/node/debugAdapter.ts index 1f0a6b7e6dcbe95b22c95010257c6a1a9c3b6bc9..2f3845662d4bf7900252c002c2738436fd3c24fd 100644 --- a/src/vs/workbench/contrib/debug/node/debugAdapter.ts +++ b/src/vs/workbench/contrib/debug/node/debugAdapter.ts @@ -435,33 +435,35 @@ export class ExecutableDebugAdapter extends StreamDebugAdapter { } } - private static extract(contribution: IDebuggerContribution, extensionFolderPath: string): IDebuggerContribution | undefined { - if (!contribution) { + private static extract(platformContribution: IPlatformSpecificAdapterContribution, extensionFolderPath: string): IDebuggerContribution | undefined { + if (!platformContribution) { return undefined; } const result: IDebuggerContribution = Object.create(null); - if (contribution.runtime) { - if (contribution.runtime.indexOf('./') === 0) { // TODO - result.runtime = path.join(extensionFolderPath, contribution.runtime); + if (platformContribution.runtime) { + if (platformContribution.runtime.indexOf('./') === 0) { // TODO + result.runtime = path.join(extensionFolderPath, platformContribution.runtime); } else { - result.runtime = contribution.runtime; + result.runtime = platformContribution.runtime; } } - if (contribution.runtimeArgs) { - result.runtimeArgs = contribution.runtimeArgs; + if (platformContribution.runtimeArgs) { + result.runtimeArgs = platformContribution.runtimeArgs; } - if (contribution.program) { - if (!path.isAbsolute(contribution.program)) { - result.program = path.join(extensionFolderPath, contribution.program); + if (platformContribution.program) { + if (!path.isAbsolute(platformContribution.program)) { + result.program = path.join(extensionFolderPath, platformContribution.program); } else { - result.program = contribution.program; + result.program = platformContribution.program; } } - if (contribution.args) { - result.args = contribution.args; + if (platformContribution.args) { + result.args = platformContribution.args; } + const contribution = platformContribution as IDebuggerContribution; + if (contribution.win) { result.win = ExecutableDebugAdapter.extract(contribution.win, extensionFolderPath); } @@ -490,7 +492,7 @@ export class ExecutableDebugAdapter extends StreamDebugAdapter { const debuggers = ed.contributes['debuggers']; if (debuggers && debuggers.length > 0) { debuggers.filter(dbg => typeof dbg.type === 'string' && strings.equalsIgnoreCase(dbg.type, debugType)).forEach(dbg => { - // extract relevant attributes and make then absolute where needed + // extract relevant attributes and make them absolute where needed const extractedDbg = ExecutableDebugAdapter.extract(dbg, ed.extensionLocation.fsPath); // merge diff --git a/src/vs/workbench/contrib/debug/node/debugger.ts b/src/vs/workbench/contrib/debug/node/debugger.ts index a8072f51aab6c6cdb964c01023676113355072c5..0b858507e552a544b2e044402b461fd431e6e94f 100644 --- a/src/vs/workbench/contrib/debug/node/debugger.ts +++ b/src/vs/workbench/contrib/debug/node/debugger.ts @@ -31,7 +31,7 @@ import { isDebuggerMainContribution } from 'vs/workbench/contrib/debug/common/de export class Debugger implements IDebugger { - private debuggerContribution: IDebuggerContribution = {}; + private debuggerContribution: IDebuggerContribution; private mergedExtensionDescriptions: IExtensionDescription[] = []; private mainExtensionDescription: IExtensionDescription | undefined; @@ -42,6 +42,7 @@ export class Debugger implements IDebugger { @IConfigurationResolverService private readonly configurationResolverService: IConfigurationResolverService, @ITelemetryService private readonly telemetryService: ITelemetryService, ) { + this.debuggerContribution = { type: dbgContribution.type }; this.merge(dbgContribution, extensionDescription); } @@ -149,12 +150,15 @@ export class Debugger implements IDebugger { if (this.debuggerContribution.adapterExecutableCommand) { console.info('debugAdapterExecutable attribute in package.json is deprecated and support for it will be removed soon; please use DebugAdapterDescriptorFactory.createDebugAdapterDescriptor instead.'); const rootFolder = session.root ? session.root.uri.toString() : undefined; - return this.commandService.executeCommand(this.debuggerContribution.adapterExecutableCommand, rootFolder).then((ae: { command: string, args: string[] }) => { - return { - type: 'executable', - command: ae.command, - args: ae.args || [] - }; + return this.commandService.executeCommand(this.debuggerContribution.adapterExecutableCommand, rootFolder).then(ae => { + if (ae) { + return { + type: 'executable', + command: ae.command, + args: ae.args || [] + }; + } + throw new Error('command adapterExecutableCommand did not return proper command.'); }); } @@ -197,15 +201,15 @@ export class Debugger implements IDebugger { return this.debuggerContribution.type; } - get variables(): { [key: string]: string } { + get variables(): { [key: string]: string } | undefined { return this.debuggerContribution.variables; } - get configurationSnippets(): IJSONSchemaSnippet[] { + get configurationSnippets(): IJSONSchemaSnippet[] | undefined { return this.debuggerContribution.configurationSnippets; } - get languages(): string[] { + get languages(): string[] | undefined { return this.debuggerContribution.languages; } @@ -254,8 +258,11 @@ export class Debugger implements IDebugger { } @memoize - getCustomTelemetryService(): Promise { - if (!this.debuggerContribution.aiKey) { + getCustomTelemetryService(): Promise { + + const aiKey = this.debuggerContribution.aiKey; + + if (!aiKey) { return Promise.resolve(undefined); } @@ -270,7 +277,7 @@ export class Debugger implements IDebugger { { serverName: 'Debug Telemetry', timeout: 1000 * 60 * 5, - args: [`${this.getMainExtensionDescriptor().publisher}.${this.type}`, JSON.stringify(data), this.debuggerContribution.aiKey], + args: [`${this.getMainExtensionDescriptor().publisher}.${this.type}`, JSON.stringify(data), aiKey], env: { ELECTRON_RUN_AS_NODE: 1, PIPE_LOGGING: 'true', @@ -286,10 +293,12 @@ export class Debugger implements IDebugger { }); } - getSchemaAttributes(): IJSONSchema[] { + getSchemaAttributes(): IJSONSchema[] | null { + if (!this.debuggerContribution.configurationAttributes) { return null; } + // fill in the default configuration attributes shared by all adapters. const taskSchema = TaskDefinitionRegistry.getJsonSchema(); return Object.keys(this.debuggerContribution.configurationAttributes).map(request => { @@ -339,9 +348,9 @@ export class Debugger implements IDebugger { }; properties['internalConsoleOptions'] = INTERNAL_CONSOLE_OPTIONS_SCHEMA; // Clear out windows, linux and osx fields to not have cycles inside the properties object - properties['windows'] = undefined; - properties['osx'] = undefined; - properties['linux'] = undefined; + delete properties['windows']; + delete properties['osx']; + delete properties['linux']; const osProperties = objects.deepClone(properties); properties['windows'] = { @@ -359,11 +368,10 @@ export class Debugger implements IDebugger { description: nls.localize('debugLinuxConfiguration', "Linux specific launch configuration attributes."), properties: osProperties }; - Object.keys(attributes.properties).forEach(name => { + Object.keys(properties).forEach(name => { // Use schema allOf property to get independent error reporting #21113 - ConfigurationResolverUtils.applyDeprecatedVariableMessage(attributes.properties[name]); + ConfigurationResolverUtils.applyDeprecatedVariableMessage(properties[name]); }); - return attributes; }); }