提交 1e9f594c 编写于 作者: A Andre Weinand

addressed review feedback

上级 81142e2c
......@@ -365,13 +365,13 @@ declare module 'vscode' {
export class DebugAdapterExecutable {
/**
* The command path of the debug adapter executable.
* A command must be a either an absolute path or a name of an executable looked up via the PATH environment variable.
* A command must be either an absolute path or the name of an executable looked up via the PATH environment variable.
* The special value 'node' will be mapped to VS Code's built-in node runtime.
*/
readonly command: string;
/**
* Optional arguments passed to the debug adapter.
* Optional arguments passed to the debug adapter executable.
*/
readonly args: string[];
......
......@@ -431,7 +431,7 @@ export interface IConfigurationManager {
unregisterDebugConfigurationProvider(handle: number): void;
resolveConfigurationByProviders(folderUri: uri | undefined, type: string | undefined, debugConfiguration: any): TPromise<any>;
debugAdapterExecutable(folderUri: uri | undefined, type: string): TPromise<IAdapterExecutable> | undefined;
debugAdapterExecutable(folderUri: uri | undefined, type: string): TPromise<IAdapterExecutable | undefined>;
}
export interface ILaunch {
......
......@@ -291,12 +291,12 @@ export class ConfigurationManager implements IConfigurationManager {
.then(results => results.reduce((first, second) => first.concat(second), []));
}
public debugAdapterExecutable(folderUri: uri | undefined, type: string): TPromise<IAdapterExecutable> | undefined {
public debugAdapterExecutable(folderUri: uri | undefined, type: string): TPromise<IAdapterExecutable | undefined> {
const providers = this.providers.filter(p => p.type === type && p.debugAdapterExecutable);
if (providers.length === 1) {
return providers[0].debugAdapterExecutable(folderUri);
}
return undefined;
return TPromise.as(undefined);
}
private registerListeners(lifecycleService: ILifecycleService): void {
......
......@@ -33,35 +33,32 @@ export class Adapter {
public getAdapterExecutable(root: IWorkspaceFolder, verifyAgainstFS = true): TPromise<IAdapterExecutable> {
// start with extension API
if (this.configurationManager) {
const adapterExecutablePromise = this.configurationManager.debugAdapterExecutable(root.uri, this.rawAdapter.type);
if (adapterExecutablePromise) {
return adapterExecutablePromise.then(adapterExecutable => {
return this.verifyAdapterDetails(adapterExecutable, verifyAgainstFS);
});
return this.configurationManager.debugAdapterExecutable(root ? root.uri : undefined, this.rawAdapter.type).then(adapterExecutable => {
if (adapterExecutable) {
return this.verifyAdapterDetails(adapterExecutable, verifyAgainstFS);
}
}
// try deprecated command based extension API
if (this.rawAdapter.adapterExecutableCommand && root) {
return this.commandService.executeCommand<IAdapterExecutable>(this.rawAdapter.adapterExecutableCommand, root.uri.toString()).then(ad => {
return this.verifyAdapterDetails(ad, verifyAgainstFS);
});
}
// try deprecated command based extension API
if (this.rawAdapter.adapterExecutableCommand && root) {
return this.commandService.executeCommand<IAdapterExecutable>(this.rawAdapter.adapterExecutableCommand, root.uri.toString()).then(ad => {
return this.verifyAdapterDetails(ad, verifyAgainstFS);
});
}
// old style: executable contribution specified in package.json
const adapterExecutable = <IAdapterExecutable>{
command: this.getProgram(),
args: this.getAttributeBasedOnPlatform('args')
};
const runtime = this.getRuntime();
if (runtime) {
const runtimeArgs = this.getAttributeBasedOnPlatform('runtimeArgs');
adapterExecutable.args = (runtimeArgs || []).concat([adapterExecutable.command]).concat(adapterExecutable.args || []);
adapterExecutable.command = runtime;
}
return this.verifyAdapterDetails(adapterExecutable, verifyAgainstFS);
// fallback: executable contribution specified in package.json
adapterExecutable = <IAdapterExecutable>{
command: this.getProgram(),
args: this.getAttributeBasedOnPlatform('args')
};
const runtime = this.getRuntime();
if (runtime) {
const runtimeArgs = this.getAttributeBasedOnPlatform('runtimeArgs');
adapterExecutable.args = (runtimeArgs || []).concat([adapterExecutable.command]).concat(adapterExecutable.args || []);
adapterExecutable.command = runtime;
}
return this.verifyAdapterDetails(adapterExecutable, verifyAgainstFS);
});
}
private verifyAdapterDetails(details: IAdapterExecutable, verifyAgainstFS: boolean): TPromise<IAdapterExecutable> {
......
......@@ -6,9 +6,12 @@
import * as assert from 'assert';
import * as paths from 'vs/base/common/paths';
import * as platform from 'vs/base/common/platform';
import { IRawAdapter } from 'vs/workbench/parts/debug/common/debug';
import { IRawAdapter, IAdapterExecutable, IConfigurationManager } from 'vs/workbench/parts/debug/common/debug';
import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import uri from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
suite('Debug - Adapter', () => {
let adapter: Adapter;
......@@ -41,9 +44,14 @@ suite('Debug - Adapter', () => {
}
]
};
const configurationManager = {
debugAdapterExecutable(folderUri: uri | undefined, type: string): TPromise<IAdapterExecutable | undefined> {
return TPromise.as(undefined);
}
};
setup(() => {
adapter = new Adapter(null, rawAdapter, { extensionFolderPath, id: 'adapter', name: 'myAdapter', version: '1.0.0', publisher: 'vscode', isBuiltin: false, engines: null },
adapter = new Adapter(<IConfigurationManager>configurationManager, rawAdapter, { extensionFolderPath, id: 'adapter', name: 'myAdapter', version: '1.0.0', publisher: 'vscode', isBuiltin: false, engines: null },
new TestConfigurationService(), null);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册