💥 scm id -> contextKey

This commit is contained in:
Joao Moreno
2017-03-27 11:50:39 +02:00
parent d4efff6cf2
commit 75576e3cca
13 changed files with 81 additions and 93 deletions

View File

@@ -24,8 +24,9 @@ class MainThreadSCMProvider implements ISCMProvider {
private disposables: IDisposable[] = [];
get id(): string { return this._id; }
get handle(): number { return this._handle; }
get label(): string { return this.features.label; }
get contextKey(): string { return this.features.contextKey; }
private _count: number | undefined = undefined;
get count(): number | undefined { return this._count; }
@@ -34,7 +35,7 @@ class MainThreadSCMProvider implements ISCMProvider {
get state(): string | undefined { return this._state; }
constructor(
private _id: string,
private _handle: number,
private proxy: ExtHostSCMShape,
private features: SCMProviderFeatures,
@ISCMService scmService: ISCMService,
@@ -49,7 +50,7 @@ class MainThreadSCMProvider implements ISCMProvider {
return TPromise.as(null);
}
return this.proxy.$open(this.id, resource.uri.toString());
return this.proxy.$open(this.handle, resource.uri.toString());
}
getOriginalResource(uri: URI): TPromise<URI> {
@@ -57,7 +58,7 @@ class MainThreadSCMProvider implements ISCMProvider {
return TPromise.as(null);
}
return this.proxy.$getOriginalResource(this.id, uri);
return this.proxy.$getOriginalResource(this.handle, uri);
}
private onDidChangeProvider(provider: ISCMProvider): void {
@@ -68,29 +69,29 @@ class MainThreadSCMProvider implements ISCMProvider {
$onChange(rawResourceGroups: SCMRawResourceGroup[], count: number | undefined, state: string | undefined): void {
this._resources = rawResourceGroups.map(rawGroup => {
const [uri, id, label, rawResources] = rawGroup;
const [uri, contextKey, label, rawResources] = rawGroup;
const resources: ISCMResource[] = [];
const group: ISCMResourceGroup = { uri: URI.parse(uri), contextKey, label, resources };
const resources = rawResources.map(rawResource => {
rawResources.forEach(rawResource => {
const [uri, sourceUri, icons, strikeThrough] = rawResource;
const icon = icons[0];
const iconDark = icons[1] || icon;
const decorations = {
icon: icon && URI.parse(icon),
iconDark: iconDark && URI.parse(iconDark),
strikeThrough
};
return {
resourceGroupId: id,
resources.push({
resourceGroup: group,
uri: URI.parse(uri),
sourceUri: URI.parse(sourceUri),
decorations
};
});
});
return { uri: URI.parse(uri), id, label, resources };
return group;
});
this._count = count;
@@ -107,7 +108,7 @@ class MainThreadSCMProvider implements ISCMProvider {
export class MainThreadSCM extends MainThreadSCMShape {
private proxy: ExtHostSCMShape;
private providers: { [id: string]: MainThreadSCMProvider; } = Object.create(null);
private providers: { [handle: number]: MainThreadSCMProvider; } = Object.create(null);
private inputBoxListeners: IDisposable[] = [];
constructor(
@@ -122,23 +123,23 @@ export class MainThreadSCM extends MainThreadSCMShape {
this.scmService.input.onDidAccept(this.proxy.$onInputBoxAcceptChanges, this.proxy, this.inputBoxListeners);
}
$register(id: string, features: SCMProviderFeatures): void {
this.providers[id] = this.instantiationService.createInstance(MainThreadSCMProvider, id, this.proxy, features);
$register(handle: number, features: SCMProviderFeatures): void {
this.providers[handle] = this.instantiationService.createInstance(MainThreadSCMProvider, handle, this.proxy, features);
}
$unregister(id: string): void {
const provider = this.providers[id];
$unregister(handle: number): void {
const provider = this.providers[handle];
if (!provider) {
return;
}
provider.dispose();
delete this.providers[id];
delete this.providers[handle];
}
$onChange(id: string, rawResourceGroups: SCMRawResourceGroup[], count: number | undefined, state: string | undefined): void {
const provider = this.providers[id];
$onChange(handle: number, rawResourceGroups: SCMRawResourceGroup[], count: number | undefined, state: string | undefined): void {
const provider = this.providers[handle];
if (!provider) {
return;