Skip to content

Commit

Permalink
Update port attributes arguments to be a property bag (#189976)
Browse files Browse the repository at this point in the history
* Update port attributes arguments to be a property bag
Part of #115616

* Gracefully handle API breakage
  • Loading branch information
alexr00 authored Aug 9, 2023
1 parent 31b4ba6 commit 8429ea9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/vs/workbench/api/common/extHostTunnelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,22 @@ 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: { providedAttributes: vscode.PortAttributes | null | undefined; port: number }[] = [];
for (const handle of handles) {
const provider = this._portAttributesProviders.get(handle);
if (!provider) {
return [];
}
providedAttributes.push(...(await Promise.all(ports.map(async (port) => {
return { providedAttributes: (await provider.provider.providePortAttributes(port, pid, commandline, cancellationToken)), port };
let providedAttributes: vscode.PortAttributes | null | undefined;
try {
providedAttributes = await provider.provider.providePortAttributes({ port, pid, commandLine }, cancellationToken);
} catch (e) {
// Call with old signature for breaking API change
providedAttributes = await (provider.provider.providePortAttributes as any as (port: number, pid: number | undefined, commandLine: string | undefined, token: vscode.CancellationToken) => vscode.ProviderResult<vscode.PortAttributes>)(port, pid, commandLine, cancellationToken);
}
return { providedAttributes, port };
}))));
}

Expand Down
2 changes: 1 addition & 1 deletion src/vscode-dts/vscode.proposed.portsAttributes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ declare module 'vscode' {
* @param commandLine The command line of the process that is listening on the port. If the command line is unknown, undefined will be passed.
* @param token A cancellation token that indicates the result is no longer needed.
*/
providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
providePortAttributes(attributes: { port: number; pid?: number; commandLine?: string }, token: CancellationToken): ProviderResult<PortAttributes>;
}

/**
Expand Down

0 comments on commit 8429ea9

Please sign in to comment.