mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 18:48:33 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export const IURLService = createDecorator<IURLService>('urlService');
|
||||
@@ -15,7 +15,7 @@ export interface IURLHandler {
|
||||
|
||||
export interface IURLService {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<any>;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
* Create a URL that can be called to trigger IURLhandlers.
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IChannel, IServerChannel, IClientRouter, IConnectionHub, Client } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { first } from 'vs/base/common/arrays';
|
||||
|
||||
export class URLServiceChannel implements IServerChannel {
|
||||
|
||||
@@ -28,7 +30,7 @@ export class URLServiceChannel implements IServerChannel {
|
||||
|
||||
export class URLServiceChannelClient implements IURLService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
@@ -70,3 +72,37 @@ export class URLHandlerChannelClient implements IURLHandler {
|
||||
return this.channel.call('handleURL', uri.toJSON());
|
||||
}
|
||||
}
|
||||
|
||||
export class URLHandlerRouter implements IClientRouter<string> {
|
||||
|
||||
constructor(private next: IClientRouter<string>) { }
|
||||
|
||||
async routeCall(hub: IConnectionHub<string>, command: string, arg?: any, cancellationToken?: CancellationToken): Promise<Client<string>> {
|
||||
if (command !== 'handleURL') {
|
||||
throw new Error(`Call not found: ${command}`);
|
||||
}
|
||||
|
||||
if (arg) {
|
||||
const uri = URI.revive(arg);
|
||||
|
||||
if (uri && uri.query) {
|
||||
const match = /\bwindowId=([^&]+)/.exec(uri.query);
|
||||
|
||||
if (match) {
|
||||
const windowId = match[1];
|
||||
const connection = first(hub.connections, c => c.ctx === windowId);
|
||||
|
||||
if (connection) {
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.next.routeCall(hub, command, arg, cancellationToken);
|
||||
}
|
||||
|
||||
routeEvent(_: IConnectionHub<string>, event: string): Promise<Client<string>> {
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,10 @@ import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { values } from 'vs/base/common/map';
|
||||
import { first } from 'vs/base/common/async';
|
||||
import { toDisposable, IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export abstract class AbstractURLService extends Disposable implements IURLService {
|
||||
|
||||
_serviceBrand!: ServiceIdentifier<any>;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private handlers = new Set<IURLHandler>();
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ import { AbstractURLService } from 'vs/platform/url/common/urlService';
|
||||
export class URLService extends AbstractURLService {
|
||||
|
||||
create(options?: Partial<UriComponents>): URI {
|
||||
const { authority, path, query, fragment } = options ? options : { authority: undefined, path: undefined, query: undefined, fragment: undefined };
|
||||
let { authority, path, query, fragment } = options ? options : { authority: undefined, path: undefined, query: undefined, fragment: undefined };
|
||||
|
||||
if (authority && path && path.indexOf('/') !== 0) {
|
||||
path = `/${path}`; // URI validation requires a path if there is an authority
|
||||
}
|
||||
|
||||
return URI.from({ scheme: product.urlProtocol, authority, path, query, fragment });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user