提交 217824cc 编写于 作者: A Alex Dima

Simplify transformers

上级 b4105815
......@@ -8,8 +8,8 @@ import { MarshalledObject } from 'vs/base/common/marshalling';
export interface IURITransformer {
transformIncoming(uri: UriComponents): UriComponents;
transformOutgoing(uri: URI): URI;
transformOutgoing(uri: UriComponents): UriComponents;
transformOutgoingURI(uri: URI): URI;
}
export const DefaultURITransformer: IURITransformer = new class {
......@@ -17,9 +17,11 @@ export const DefaultURITransformer: IURITransformer = new class {
return uri;
}
transformOutgoing(uri: URI): URI;
transformOutgoing(uri: UriComponents): UriComponents;
transformOutgoing(uri: URI | UriComponents): URI | UriComponents {
transformOutgoing(uri: UriComponents): UriComponents {
return uri;
}
transformOutgoingURI(uri: URI): URI {
return uri;
}
};
......
......@@ -63,7 +63,7 @@ export function getIdAndVersion(id: string): [string, string | undefined] {
}
class Main {
export class Main {
constructor(
@IEnvironmentService private readonly environmentService: IEnvironmentService,
......
......@@ -47,7 +47,7 @@ export class DownloadServiceChannelClient implements IDownloadService {
constructor(private channel: IChannel, private getUriTransformer: () => IURITransformer) { }
download(from: URI, to: string): Promise<void> {
from = this.getUriTransformer().transformOutgoing(from);
from = this.getUriTransformer().transformOutgoingURI(from);
const dirName = path.dirname(to);
let out: fs.WriteStream;
return new Promise((c, e) => {
......
......@@ -16,7 +16,7 @@ function transformIncomingURI(uri: UriComponents, transformer: IURITransformer |
}
function transformOutgoingURI(uri: URI, transformer: IURITransformer | null): URI {
return transformer ? transformer.transformOutgoing(uri) : uri;
return transformer ? transformer.transformOutgoingURI(uri) : uri;
}
function transformIncomingExtension(extension: ILocalExtension, transformer: IURITransformer | null): ILocalExtension {
......@@ -27,7 +27,7 @@ function transformIncomingExtension(extension: ILocalExtension, transformer: IUR
}
function transformOutgoingExtension(extension: ILocalExtension, transformer: IURITransformer | null): ILocalExtension {
return transformer ? cloneAndChange(extension, value => value instanceof URI ? transformer.transformOutgoing(value) : undefined) : extension;
return transformer ? cloneAndChange(extension, value => value instanceof URI ? transformer.transformOutgoingURI(value) : undefined) : extension;
}
export class ExtensionManagementChannel implements IServerChannel {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册