Merge from vscode 0f73473c08055054f317c1c94502f7f39fdbb164 (#6892)

* Merge from vscode 0f73473c08055054f317c1c94502f7f39fdbb164

* fix tslinting
This commit is contained in:
Anthony Dresser
2019-08-22 22:07:01 -07:00
committed by GitHub
parent 1372cbaee1
commit 658cf51887
91 changed files with 1092 additions and 317 deletions

View File

@@ -3,8 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { URI, UriComponents } from 'vs/base/common/uri';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable } from 'vs/base/common/lifecycle';
export const IURLService = createDecorator<IURLService>('urlService');
@@ -14,8 +14,17 @@ export interface IURLHandler {
}
export interface IURLService {
_serviceBrand: any;
_serviceBrand: ServiceIdentifier<any>;
/**
* Create a URL that can be called to trigger IURLhandlers.
* The URL that gets passed to the IURLHandlers carries over
* any of the provided IURLCreateOption values.
*/
create(options?: Partial<UriComponents>): URI;
open(url: URI): Promise<boolean>;
registerHandler(handler: IURLHandler): IDisposable;
}

View File

@@ -4,18 +4,20 @@
*--------------------------------------------------------------------------------------------*/
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
import { URI } from 'vs/base/common/uri';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { first } from 'vs/base/common/async';
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 class URLService implements IURLService {
export abstract class AbstractURLService extends Disposable implements IURLService {
_serviceBrand!: ServiceIdentifier<any>;
private handlers = new Set<IURLHandler>();
abstract create(options?: Partial<UriComponents>): URI;
open(uri: URI): Promise<boolean> {
const handlers = values(this.handlers);
return first(handlers.map(h => () => h.handleURL(uri)), undefined, false).then(val => val || false);