More adoption of @extHostNamedCustomer

This commit is contained in:
Alex Dima
2017-08-16 12:55:53 +02:00
parent 4d5ded68d2
commit a99eeae966
30 changed files with 197 additions and 136 deletions

View File

@@ -10,12 +10,12 @@ import URI from 'vs/base/common/uri';
import Event, { Emitter } from 'vs/base/common/event';
import { assign } from 'vs/base/common/objects';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
import { ISCMService, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations } from 'vs/workbench/services/scm/common/scm';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResource, SCMGroupFeatures } from '../node/extHost.protocol';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResource, SCMGroupFeatures, MainContext, IExtHostContext } from '../node/extHost.protocol';
import { Command } from 'vs/editor/common/modes';
import { extHostNamedCustomer } from "vs/workbench/api/electron-browser/extHostCustomers";
class MainThreadSCMResourceGroup implements ISCMResourceGroup {
@@ -205,6 +205,7 @@ class MainThreadSCMProvider implements ISCMProvider {
}
}
@extHostNamedCustomer(MainContext.MainThreadSCM)
export class MainThreadSCM implements MainThreadSCMShape {
private _proxy: ExtHostSCMShape;
@@ -213,17 +214,29 @@ export class MainThreadSCM implements MainThreadSCMShape {
private _disposables: IDisposable[] = [];
constructor(
@IThreadService threadService: IThreadService,
extHostContext: IExtHostContext,
@IInstantiationService private instantiationService: IInstantiationService,
@ISCMService private scmService: ISCMService,
@ICommandService private commandService: ICommandService
) {
this._proxy = threadService.get(ExtHostContext.ExtHostSCM);
this._proxy = extHostContext.get(ExtHostContext.ExtHostSCM);
this.scmService.onDidChangeProvider(this.onDidChangeProvider, this, this._disposables);
this.scmService.input.onDidChange(this._proxy.$onInputBoxValueChange, this._proxy, this._disposables);
}
dispose(): void {
Object.keys(this._sourceControls)
.forEach(id => this._sourceControls[id].dispose());
this._sourceControls = Object.create(null);
Object.keys(this._sourceControlDisposables)
.forEach(id => this._sourceControlDisposables[id].dispose());
this._sourceControlDisposables = Object.create(null);
this._disposables = dispose(this._disposables);
}
$registerSourceControl(handle: number, id: string, label: string): void {
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, this.scmService, this.commandService);
this._sourceControls[handle] = provider;
@@ -312,12 +325,4 @@ export class MainThreadSCM implements MainThreadSCMShape {
const handle = Object.keys(this._sourceControls).filter(handle => this._sourceControls[handle] === provider)[0];
this._proxy.$onActiveSourceControlChange(handle && parseInt(handle));
}
dispose(): void {
Object.keys(this._sourceControls)
.forEach(id => this._sourceControls[id].dispose());
this._sourceControls = Object.create(null);
this._disposables = dispose(this._disposables);
}
}