未验证 提交 b1523b43 编写于 作者: A Alex Ross

Update port attributes api to not use array

Par of #115616
上级 30dcb112
...@@ -2888,11 +2888,11 @@ declare module 'vscode' { ...@@ -2888,11 +2888,11 @@ declare module 'vscode' {
export interface PortAttributesProvider { export interface PortAttributesProvider {
/** /**
* Provides attributes for the given ports. For ports that your extension doesn't know about, simply don't include * Provides attributes for the given port. For ports that your extension doesn't know about, simply
* them in the returned array. For example, if `providePortAttributes` is called with ports [3000, 4000] but your * return undefined. For example, if `providePortAttributes` is called with ports 3000 but your
* extension doesn't know anything about those ports you can return an empty array. * extension doesn't know anything about 3000 you should return undefined.
*/ */
providePortAttributes(ports: number[], pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes[]>; providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
} }
export namespace workspace { export namespace workspace {
......
...@@ -22,7 +22,6 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions' ...@@ -22,7 +22,6 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
import { MovingAverage } from 'vs/base/common/numbers'; import { MovingAverage } from 'vs/base/common/numbers';
import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService'; import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { flatten } from 'vs/base/common/arrays';
class ExtensionTunnel implements vscode.Tunnel { class ExtensionTunnel implements vscode.Tunnel {
private _onDispose: Emitter<void> = new Emitter(); private _onDispose: Emitter<void> = new Emitter();
...@@ -240,17 +239,20 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe ...@@ -240,17 +239,20 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
} }
async $providePortAttributes(handles: number[], ports: number[], pid: number | undefined, commandline: string | undefined, cancellationToken: vscode.CancellationToken): Promise<ProvidedPortAttributes[]> { async $providePortAttributes(handles: number[], ports: number[], pid: number | undefined, commandline: string | undefined, cancellationToken: vscode.CancellationToken): Promise<ProvidedPortAttributes[]> {
const providedAttributes = await Promise.all(handles.map(handle => { const providedAttributes: vscode.ProviderResult<vscode.PortAttributes>[] = [];
for (const handle of handles) {
const provider = this._portAttributesProviders.get(handle); const provider = this._portAttributesProviders.get(handle);
if (!provider) { if (!provider) {
return []; return [];
} }
return provider.provider.providePortAttributes(ports, pid, commandline, cancellationToken); providedAttributes.push(...(await Promise.all(ports.map(async (port) => {
})); return provider.provider.providePortAttributes(port, pid, commandline, cancellationToken);
}))));
}
const allAttributes = <vscode.PortAttributes[][]>providedAttributes.filter(attribute => !!attribute && attribute.length > 0); const allAttributes = <vscode.PortAttributes[]>providedAttributes.filter(attribute => !!attribute);
return (allAttributes.length > 0) ? flatten(allAttributes).map(attributes => { return (allAttributes.length > 0) ? allAttributes.map(attributes => {
return { return {
autoForwardAction: <ProvidedOnAutoForward><unknown>attributes.autoForwardAction, autoForwardAction: <ProvidedOnAutoForward><unknown>attributes.autoForwardAction,
port: attributes.port port: attributes.port
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册