提交 0f489329 编写于 作者: A Andre Weinand

check debugServer property first; improved fix for #58847

上级 8d48055f
...@@ -120,7 +120,7 @@ export function createApiFactory( ...@@ -120,7 +120,7 @@ export function createApiFactory(
const extHostFileSystemEvent = rpcProtocol.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService(rpcProtocol, extHostDocumentsAndEditors)); const extHostFileSystemEvent = rpcProtocol.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService(rpcProtocol, extHostDocumentsAndEditors));
const extHostQuickOpen = rpcProtocol.set(ExtHostContext.ExtHostQuickOpen, new ExtHostQuickOpen(rpcProtocol, extHostWorkspace, extHostCommands)); const extHostQuickOpen = rpcProtocol.set(ExtHostContext.ExtHostQuickOpen, new ExtHostQuickOpen(rpcProtocol, extHostWorkspace, extHostCommands));
const extHostTerminalService = rpcProtocol.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(rpcProtocol, extHostConfiguration, extHostLogService)); const extHostTerminalService = rpcProtocol.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(rpcProtocol, extHostConfiguration, extHostLogService));
const extHostDebugService = rpcProtocol.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(rpcProtocol, extHostWorkspace, extensionService, extHostDocumentsAndEditors, extHostConfiguration, extHostTerminalService)); const extHostDebugService = rpcProtocol.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(rpcProtocol, extHostWorkspace, extensionService, extHostDocumentsAndEditors, extHostConfiguration, extHostTerminalService, extHostCommands));
const extHostSCM = rpcProtocol.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(rpcProtocol, extHostCommands, extHostLogService)); const extHostSCM = rpcProtocol.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(rpcProtocol, extHostCommands, extHostLogService));
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, schemeTransformer)); const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, schemeTransformer));
const extHostTask = rpcProtocol.set(ExtHostContext.ExtHostTask, new ExtHostTask(rpcProtocol, extHostWorkspace, extHostDocumentsAndEditors, extHostConfiguration)); const extHostTask = rpcProtocol.set(ExtHostContext.ExtHostTask, new ExtHostTask(rpcProtocol, extHostWorkspace, extHostDocumentsAndEditors, extHostConfiguration));
......
...@@ -16,7 +16,7 @@ import { ...@@ -16,7 +16,7 @@ import {
IMainContext, IBreakpointsDeltaDto, ISourceMultiBreakpointDto, IFunctionBreakpointDto, IDebugSessionDto IMainContext, IBreakpointsDeltaDto, ISourceMultiBreakpointDto, IFunctionBreakpointDto, IDebugSessionDto
} from 'vs/workbench/api/node/extHost.protocol'; } from 'vs/workbench/api/node/extHost.protocol';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { Disposable, Position, Location, SourceBreakpoint, FunctionBreakpoint, DebugAdapterServer } from 'vs/workbench/api/node/extHostTypes'; import { Disposable, Position, Location, SourceBreakpoint, FunctionBreakpoint, DebugAdapterServer, DebugAdapterExecutable } from 'vs/workbench/api/node/extHostTypes';
import { generateUuid } from 'vs/base/common/uuid'; import { generateUuid } from 'vs/base/common/uuid';
import { DebugAdapter, SocketDebugAdapter } from 'vs/workbench/parts/debug/node/debugAdapter'; import { DebugAdapter, SocketDebugAdapter } from 'vs/workbench/parts/debug/node/debugAdapter';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace'; import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
...@@ -32,6 +32,7 @@ import { ExtHostTerminalService } from 'vs/workbench/api/node/extHostTerminalSer ...@@ -32,6 +32,7 @@ import { ExtHostTerminalService } from 'vs/workbench/api/node/extHostTerminalSer
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { CancellationToken } from 'vs/base/common/cancellation'; import { CancellationToken } from 'vs/base/common/cancellation';
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
export class ExtHostDebugService implements ExtHostDebugServiceShape { export class ExtHostDebugService implements ExtHostDebugServiceShape {
...@@ -66,6 +67,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -66,6 +67,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
private readonly _onDidChangeBreakpoints: Emitter<vscode.BreakpointsChangeEvent>; private readonly _onDidChangeBreakpoints: Emitter<vscode.BreakpointsChangeEvent>;
private _aexCommands: Map<string, string>;
private _debugAdapters: Map<number, IDebugAdapter>; private _debugAdapters: Map<number, IDebugAdapter>;
private _variableResolver: IConfigurationResolverService; private _variableResolver: IConfigurationResolverService;
...@@ -79,9 +81,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -79,9 +81,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
private _extensionService: ExtHostExtensionService, private _extensionService: ExtHostExtensionService,
private _editorsService: ExtHostDocumentsAndEditors, private _editorsService: ExtHostDocumentsAndEditors,
private _configurationService: ExtHostConfiguration, private _configurationService: ExtHostConfiguration,
private _terminalService: ExtHostTerminalService private _terminalService: ExtHostTerminalService,
private _commandService: ExtHostCommands
) { ) {
this._aexCommands = new Map();
this._handleCounter = 0; this._handleCounter = 0;
this._providerByHandle = new Map(); this._providerByHandle = new Map();
this._providerByType = new Map(); this._providerByType = new Map();
...@@ -116,6 +119,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -116,6 +119,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
// only debugger contributions with a "label" are considered a "main" debugger contribution // only debugger contributions with a "label" are considered a "main" debugger contribution
if (dbg.type && dbg.label) { if (dbg.type && dbg.label) {
debugTypes.push(dbg.type); debugTypes.push(dbg.type);
if (dbg.adapterExecutableCommand) {
this._aexCommands.set(dbg.type, dbg.adapterExecutableCommand);
}
} }
} }
} }
...@@ -526,21 +532,34 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -526,21 +532,34 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
// private & dto helpers // private & dto helpers
private getAdapterDescriptor(debugConfigProvider, sessionDto: IDebugSessionDto, folderUri: UriComponents | undefined, config: vscode.DebugConfiguration): Thenable<vscode.DebugAdapterDescriptor> { private getAdapterDescriptor(debugConfigProvider, sessionDto: IDebugSessionDto, folderUri: UriComponents | undefined, config: vscode.DebugConfiguration): Thenable<vscode.DebugAdapterDescriptor> {
// a "debugServer" attribute in the launch config takes precedence
if (typeof config.debugServer === 'number') {
return TPromise.wrap(new DebugAdapterServer(config.debugServer));
}
if (debugConfigProvider) { if (debugConfigProvider) {
// try the proposed "provideDebugAdapter" API
if (debugConfigProvider.provideDebugAdapter) { if (debugConfigProvider.provideDebugAdapter) {
const adapterExecutable = DebugAdapter.platformAdapterExecutable(this._extensionService.getAllExtensionDescriptions(), config.type); const adapterExecutable = DebugAdapter.platformAdapterExecutable(this._extensionService.getAllExtensionDescriptions(), config.type);
return asThenable(() => debugConfigProvider.provideDebugAdapter(this.getSession(sessionDto), this.getFolder(folderUri), adapterExecutable, config, CancellationToken.None)); return asThenable(() => debugConfigProvider.provideDebugAdapter(this.getSession(sessionDto), this.getFolder(folderUri), adapterExecutable, config, CancellationToken.None));
} }
// deprecated // try the deprecated "debugAdapterExecutable" API
if (debugConfigProvider.debugAdapterExecutable) { if (debugConfigProvider.debugAdapterExecutable) {
return asThenable(() => debugConfigProvider.debugAdapterExecutable(this.getFolder(folderUri), CancellationToken.None)); return asThenable(() => debugConfigProvider.debugAdapterExecutable(this.getFolder(folderUri), CancellationToken.None));
} }
} }
// fallback: use serverport or executable information from package.json
// TODO@AW support legacy command based mechanism // try deprecated command based extension API "adapterExecutableCommand" to determine the executable
if (typeof config.debugServer === 'number') { const aex = this._aexCommands.get(config.type);
return TPromise.wrap(new DebugAdapterServer(config.debugServer)); if (aex) {
const rootFolder = folderUri ? URI.revive(folderUri).toString() : undefined;
return this._commandService.executeCommand(aex, rootFolder).then((ae: { command: string, args: string[] }) => {
return new DebugAdapterExecutable(ae.command, ae.args || []);
});
} }
// fallback: use executable information from package.json
return TPromise.wrap(DebugAdapter.platformAdapterExecutable(this._extensionService.getAllExtensionDescriptions(), config.type)); return TPromise.wrap(DebugAdapter.platformAdapterExecutable(this._extensionService.getAllExtensionDescriptions(), config.type));
} }
......
...@@ -58,28 +58,34 @@ export class Debugger implements IDebugger { ...@@ -58,28 +58,34 @@ export class Debugger implements IDebugger {
private getAdapterDescriptor(session: IDebugSession, root: IWorkspaceFolder, config: IConfig): TPromise<IAdapterDescriptor> { private getAdapterDescriptor(session: IDebugSession, root: IWorkspaceFolder, config: IConfig): TPromise<IAdapterDescriptor> {
// try deprecated command based extension API to receive an executable // a "debugServer" attribute in the launch config takes precedence
if (this.debuggerContribution.adapterExecutableCommand) { if (typeof config.debugServer === 'number') {
return this.commandService.executeCommand<IAdapterExecutable>(this.debuggerContribution.adapterExecutableCommand, root ? root.uri.toString() : undefined).then(ae => { return TPromise.wrap(<IAdapterServer>{
return <IAdapterExecutable>{ type: 'server',
type: 'executable', port: config.debugServer
command: ae.command,
args: ae.args || []
};
}); });
} }
// try the proposed and the deprecated "provideDebugAdapter" API
return this.configurationManager.provideDebugAdapter(session, root ? root.uri : undefined, config).then(adapter => { return this.configurationManager.provideDebugAdapter(session, root ? root.uri : undefined, config).then(adapter => {
if (adapter) { if (adapter) {
return adapter; return adapter;
} }
if (typeof config.debugServer === 'number') {
return <IAdapterServer>{ // try deprecated command based extension API "adapterExecutableCommand" to determine the executable
type: 'server', if (this.debuggerContribution.adapterExecutableCommand) {
port: config.debugServer const rootFolder = root ? root.uri.toString() : undefined;
}; return this.commandService.executeCommand<IAdapterExecutable>(this.debuggerContribution.adapterExecutableCommand, rootFolder).then((ae: { command: string, args: string[] }) => {
return <IAdapterDescriptor>{
type: 'executable',
command: ae.command,
args: ae.args || []
};
});
} }
// fallback: use information from package.json
// fallback: use executable information from package.json
return DebugAdapter.platformAdapterExecutable(this.mergedExtensionDescriptions, this.type); return DebugAdapter.platformAdapterExecutable(this.mergedExtensionDescriptions, this.type);
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册