From 1af44d673fb013d94436ff3bb6915458290a7aae Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 22 Nov 2016 12:15:13 +0100 Subject: [PATCH] wip: extHostSCM, mainThreadSCM --- src/vs/workbench/api/node/extHost.api.impl.ts | 4 +- .../api/node/extHost.contribution.ts | 2 + src/vs/workbench/api/node/extHost.protocol.ts | 10 +++- src/vs/workbench/api/node/extHostSCM.ts | 46 +++++++++++++++++++ src/vs/workbench/api/node/mainThreadSCM.ts | 25 ++++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/vs/workbench/api/node/extHostSCM.ts create mode 100644 src/vs/workbench/api/node/mainThreadSCM.ts diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 39650abaa27..6358e78a423 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -20,6 +20,7 @@ import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics'; import { ExtHostTreeExplorers } from 'vs/workbench/api/node/extHostTreeExplorers'; import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace'; import { ExtHostQuickOpen } from 'vs/workbench/api/node/extHostQuickOpen'; +import { ExtHostSCM } from 'vs/workbench/api/node/extHostSCM'; import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService'; import { ExtHostStatusBar } from 'vs/workbench/api/node/extHostStatusBar'; import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands'; @@ -78,6 +79,7 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ const extHostFileSystemEvent = col.define(ExtHostContext.ExtHostFileSystemEventService).set(new ExtHostFileSystemEventService()); const extHostQuickOpen = col.define(ExtHostContext.ExtHostQuickOpen).set(new ExtHostQuickOpen(threadService)); const extHostTerminalService = col.define(ExtHostContext.ExtHostTerminalService).set(new ExtHostTerminalService(threadService)); + const extHostSCM = col.define(ExtHostContext.ExtHostSCM).set(new ExtHostSCM(threadService)); col.define(ExtHostContext.ExtHostExtensionService).set(extensionService); col.finish(false, threadService); @@ -361,7 +363,7 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ // namespace: scm const scm: typeof vscode.scm = { createSCMProvider: (id, delegate): vscode.SCMProvider => { - throw new Error('JOAO not implemented'); + return extHostSCM.createSCMProvider(id, delegate); } }; diff --git a/src/vs/workbench/api/node/extHost.contribution.ts b/src/vs/workbench/api/node/extHost.contribution.ts index e7bbcdd21fd..19e8b8bed2f 100644 --- a/src/vs/workbench/api/node/extHost.contribution.ts +++ b/src/vs/workbench/api/node/extHost.contribution.ts @@ -32,6 +32,7 @@ import { MainThreadTerminalService } from './mainThreadTerminalService'; import { MainThreadWorkspace } from './mainThreadWorkspace'; import { MainProcessExtensionService } from './mainThreadExtensionService'; import { MainThreadFileSystemEventService } from './mainThreadFileSystemEventService'; +import { MainThreadSCM } from './mainThreadSCM'; // --- other interested parties import { MainProcessTextMateSyntax } from 'vs/editor/node/textMate/TMSyntax'; @@ -81,6 +82,7 @@ export class ExtHostContribution implements IWorkbenchContribution { col.define(MainContext.MainThreadTelemetry).set(create(MainThreadTelemetry)); col.define(MainContext.MainThreadTerminalService).set(create(MainThreadTerminalService)); col.define(MainContext.MainThreadWorkspace).set(create(MainThreadWorkspace)); + col.define(MainContext.MainThreadSCM).set(create(MainThreadSCM)); if (this.extensionService instanceof MainProcessExtensionService) { col.define(MainContext.MainProcessExtensionService).set(this.extensionService); } diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index f3f2d98ab63..e0ce89c5793 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -228,6 +228,9 @@ export abstract class MainProcessExtensionServiceShape { $onExtensionActivationFailed(extensionId: string): void { throw ni(); } } +export abstract class MainThreadSCMShape { +} + // -- extension host export abstract class ExtHostCommandsShape { @@ -355,6 +358,9 @@ export abstract class ExtHostTerminalServiceShape { $acceptTerminalProcessId(id: number, processId: number): void { throw ni(); } } +export abstract class ExtHostSCMShape { +} + // --- proxy identifiers export const MainContext = { @@ -376,6 +382,7 @@ export const MainContext = { MainThreadTerminalService: createMainId('MainThreadTerminalService', MainThreadTerminalServiceShape), MainThreadWorkspace: createMainId('MainThreadWorkspace', MainThreadWorkspaceShape), MainProcessExtensionService: createMainId('MainProcessExtensionService', MainProcessExtensionServiceShape), + MainThreadSCM: createMainId('MainThreadSCM', MainThreadSCMShape) }; export const ExtHostContext = { @@ -391,5 +398,6 @@ export const ExtHostContext = { ExtHostLanguageFeatures: createExtId('ExtHostLanguageFeatures', ExtHostLanguageFeaturesShape), ExtHostQuickOpen: createExtId('ExtHostQuickOpen', ExtHostQuickOpenShape), ExtHostExtensionService: createExtId('ExtHostExtensionService', ExtHostExtensionServiceShape), - ExtHostTerminalService: createExtId('ExtHostTerminalService', ExtHostTerminalServiceShape) + ExtHostTerminalService: createExtId('ExtHostTerminalService', ExtHostTerminalServiceShape), + ExtHostSCM: createExtId('ExtHostSCM', ExtHostSCMShape) }; diff --git a/src/vs/workbench/api/node/extHostSCM.ts b/src/vs/workbench/api/node/extHostSCM.ts new file mode 100644 index 00000000000..76f48809780 --- /dev/null +++ b/src/vs/workbench/api/node/extHostSCM.ts @@ -0,0 +1,46 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; +import { SCMProvider, SCMDelegate, SCMResourceGroup } from 'vscode'; +import { MainContext, MainThreadSCMShape } from './extHost.protocol'; + +export class ExtHostSCMProvider implements SCMProvider { + + private static ID_GEN = 0; + private _id: number = ExtHostSCMProvider.ID_GEN++; + + constructor( + private _proxy: MainThreadSCMShape, + private _delegate: SCMDelegate + ) { } + + get id(): number { + return this._id; + } + + createResourceGroup(id: string, label: string): SCMResourceGroup { + // throw new Error('JOAO not implemented'); + return null; + } + + dispose(): void { + // todo + } +} + +export class ExtHostSCM { + + private _proxy: MainThreadSCMShape; + + constructor(threadService: IThreadService) { + this._proxy = threadService.get(MainContext.MainThreadSCM); + } + + createSCMProvider(id: string, delegate: SCMDelegate): ExtHostSCMProvider { + return new ExtHostSCMProvider(this._proxy, delegate); + } +} diff --git a/src/vs/workbench/api/node/mainThreadSCM.ts b/src/vs/workbench/api/node/mainThreadSCM.ts new file mode 100644 index 00000000000..c1aee379406 --- /dev/null +++ b/src/vs/workbench/api/node/mainThreadSCM.ts @@ -0,0 +1,25 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; +import { MainThreadSCMShape } from './extHost.protocol'; + +export class MainThreadSCM extends MainThreadSCMShape { + + private _toDispose: IDisposable; + + constructor( + @IThreadService threadService: IThreadService + ) { + super(); + // const proxy = threadService.get(ExtHostContext.ExtHostSCM); + } + + dispose(): void { + this._toDispose = dispose(this._toDispose); + } +} -- GitLab