diff --git a/src/vs/workbench/api/electron-browser/extHostCustomers.ts b/src/vs/workbench/api/electron-browser/extHostCustomers.ts new file mode 100644 index 00000000000..33b87d17da4 --- /dev/null +++ b/src/vs/workbench/api/electron-browser/extHostCustomers.ts @@ -0,0 +1,64 @@ +/*--------------------------------------------------------------------------------------------- + * 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 } from "vs/base/common/lifecycle"; +import { ProxyIdentifier } from "vs/workbench/services/thread/common/threadService"; +import { IConstructorSignature1 } from "vs/platform/instantiation/common/instantiation"; +import { IExtHostContext } from "vs/workbench/api/node/extHost.protocol"; + +export type IExtHostNamedCustomer = [ProxyIdentifier, IExtHostCustomerCtor]; + +export type IExtHostCustomerCtor = IConstructorSignature1; + +export function extHostNamedCustomer(id: ProxyIdentifier) { + return function (ctor: IExtHostCustomerCtor): void { + ExtHostCustomersRegistryImpl.INSTANCE.registerNamedCustomer(id, ctor); + }; +} + +export function extHostCustomer(ctor: IExtHostCustomerCtor): void { + ExtHostCustomersRegistryImpl.INSTANCE.registerCustomer(ctor); +} + +export namespace ExtHostCustomersRegistry { + + export function getNamedCustomers(): IExtHostNamedCustomer[] { + return ExtHostCustomersRegistryImpl.INSTANCE.getNamedCustomers(); + } + + export function getCustomers(): IExtHostCustomerCtor[] { + return ExtHostCustomersRegistryImpl.INSTANCE.getCustomers(); + } +} + +class ExtHostCustomersRegistryImpl { + + public static INSTANCE = new ExtHostCustomersRegistryImpl(); + + private _namedCustomers: IExtHostNamedCustomer[]; + private _customers: IExtHostCustomerCtor[]; + + constructor() { + this._namedCustomers = []; + this._customers = []; + } + + public registerNamedCustomer(id: ProxyIdentifier, ctor: IExtHostCustomerCtor): void { + const entry: IExtHostNamedCustomer = [id, ctor]; + this._namedCustomers.push(entry); + } + public getNamedCustomers(): IExtHostNamedCustomer[] { + return this._namedCustomers; + } + + public registerCustomer(ctor: IExtHostCustomerCtor): void { + this._customers.push(ctor); + } + public getCustomers(): IExtHostCustomerCtor[] { + return this._customers; + } +} diff --git a/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts b/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts index 8b2299049e2..82a3e209042 100644 --- a/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts +++ b/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts @@ -11,9 +11,9 @@ import { IInstantiationService, IConstructorSignature0 } from 'vs/platform/insta import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { MainContext, InstanceCollection } from '../node/extHost.protocol'; import { IExtensionService } from 'vs/platform/extensions/common/extensions'; +import { ExtHostCustomersRegistry } from "vs/workbench/api/electron-browser/extHostCustomers"; // --- addressable -import { MainThreadCommands } from './mainThreadCommands'; import { MainThreadConfiguration } from './mainThreadConfiguration'; import { MainThreadDebugService } from './mainThreadDebugService'; import { MainThreadDiagnostics } from './mainThreadDiagnostics'; @@ -48,6 +48,36 @@ import { SaveParticipant } from './mainThreadSaveParticipant'; // --- registers itself as service import './mainThreadHeapService'; +// --- mainThread participants +import './mainThreadCommands'; +// import './mainThreadConfiguration'; +// import './mainThreadCredentials'; +// import './mainThreadDebugService'; +// import './mainThreadDiagnostics'; +// import './mainThreadDocuments'; +// import './mainThreadDocumentsAndEditors'; +import './mainThreadEditor'; +// import './mainThreadEditors'; +// import './mainThreadErrors'; +// import './mainThreadExtensionService'; +// import './mainThreadFileSystemEventService'; +// import './mainThreadHeapService'; +// import './mainThreadLanguageFeatures'; +// import './mainThreadLanguages'; +// import './mainThreadMessageService'; +// import './mainThreadOutputService'; +// import './mainThreadProgress'; +// import './mainThreadQuickOpen'; +// import './mainThreadSCM'; +// import './mainThreadSaveParticipant'; +// import './mainThreadStatusBar'; +// import './mainThreadStorage'; +// import './mainThreadTask'; +// import './mainThreadTelemetry'; +// import './mainThreadTerminalService'; +// import './mainThreadTreeViews'; +// import './mainThreadWorkspace'; + export class ExtHostContribution implements IWorkbenchContribution { constructor( @@ -71,7 +101,6 @@ export class ExtHostContribution implements IWorkbenchContribution { // Addressable instances const col = new InstanceCollection(); - col.define(MainContext.MainThreadCommands).set(create(MainThreadCommands)); col.define(MainContext.MainThreadConfiguration).set(create(MainThreadConfiguration)); col.define(MainContext.MainThreadDebugService).set(create(MainThreadDebugService)); col.define(MainContext.MainThreadDiagnostics).set(create(MainThreadDiagnostics)); @@ -94,11 +123,27 @@ export class ExtHostContribution implements IWorkbenchContribution { col.define(MainContext.MainThreadTask).set(create(MainThreadTask)); col.define(MainContext.MainThreadCredentials).set(create(MainThreadCredentials)); col.define(MainContext.MainProcessExtensionService).set(create(MainProcessExtensionServiceAPI)); + + // Registered named customers + const namedCustomers = ExtHostCustomersRegistry.getNamedCustomers(); + for (let i = 0, len = namedCustomers.length; i < len; i++) { + const [id, ctor] = namedCustomers[i]; + const obj = this.instantiationService.createInstance(ctor, this.threadService); + col.define(id).set(obj); + } + + // Registered customers + const customers = ExtHostCustomersRegistry.getCustomers(); + for (let i = 0, len = customers.length; i < len; i++) { + const ctor = customers[i]; + this.instantiationService.createInstance(ctor, this.threadService); + } + col.finish(true, this.threadService); // Other interested parties create(JSONValidationExtensionPoint); // TODO@rehost: can survive an ext host restart - create(ColorExtensionPoint); + create(ColorExtensionPoint); // TODO@rehost: can survive an ext host restart this.instantiationService.createInstance(LanguageConfigurationFileHandler); // TODO@rehost: can survive an ext host restart create(MainThreadFileSystemEventService); create(SaveParticipant); diff --git a/src/vs/workbench/api/electron-browser/mainThreadCommands.ts b/src/vs/workbench/api/electron-browser/mainThreadCommands.ts index 17a107c894d..2cc372223a0 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadCommands.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadCommands.ts @@ -8,19 +8,21 @@ import { IThreadService } from 'vs/workbench/services/thread/common/threadServic import { ICommandService, CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands'; import { IDisposable } from 'vs/base/common/lifecycle'; import { TPromise } from 'vs/base/common/winjs.base'; -import { ExtHostContext, MainThreadCommandsShape, ExtHostCommandsShape } from '../node/extHost.protocol'; +import { ExtHostContext, MainThreadCommandsShape, ExtHostCommandsShape, MainContext, IExtHostContext } from '../node/extHost.protocol'; +import { extHostNamedCustomer } from "vs/workbench/api/electron-browser/extHostCustomers"; +@extHostNamedCustomer(MainContext.MainThreadCommands) export class MainThreadCommands extends MainThreadCommandsShape { private readonly _disposables = new Map(); private readonly _proxy: ExtHostCommandsShape; constructor( - @IThreadService private readonly _threadService: IThreadService, - @ICommandService private readonly _commandService: ICommandService + extHostContext: IExtHostContext, + @ICommandService private readonly _commandService: ICommandService, ) { super(); - this._proxy = this._threadService.get(ExtHostContext.ExtHostCommands); + this._proxy = extHostContext.get(ExtHostContext.ExtHostCommands); } dispose() { diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index f6e794f2e00..0857002653a 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -73,6 +73,20 @@ export interface IInitData { telemetryInfo: ITelemetryInfo; } +export interface IExtHostContext { + /** + * Returns a proxy to an object addressable/named in the extension host process. + */ + get(identifier: ProxyIdentifier): T; +} + +export interface IMainContext { + /** + * Returns a proxy to an object addressable/named in the main/renderer process. + */ + get(identifier: ProxyIdentifier): T; +} + export interface InstanceSetter { set(instance: T): R; } diff --git a/src/vs/workbench/api/node/extHostCommands.ts b/src/vs/workbench/api/node/extHostCommands.ts index 00ff4f00c4f..fed0dadf9cb 100644 --- a/src/vs/workbench/api/node/extHostCommands.ts +++ b/src/vs/workbench/api/node/extHostCommands.ts @@ -4,14 +4,13 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { validateConstraint } from 'vs/base/common/types'; import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands'; import { TPromise } from 'vs/base/common/winjs.base'; import * as extHostTypes from 'vs/workbench/api/node/extHostTypes'; import * as extHostTypeConverter from 'vs/workbench/api/node/extHostTypeConverters'; import { cloneAndChange } from 'vs/base/common/objects'; -import { MainContext, MainThreadCommandsShape, ExtHostCommandsShape, ObjectIdentifier } from './extHost.protocol'; +import { MainContext, MainThreadCommandsShape, ExtHostCommandsShape, ObjectIdentifier, IMainContext } from './extHost.protocol'; import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService'; import { isFalsyOrEmpty } from 'vs/base/common/arrays'; import * as modes from 'vs/editor/common/modes'; @@ -35,11 +34,11 @@ export class ExtHostCommands extends ExtHostCommandsShape { private _argumentProcessors: ArgumentProcessor[] = []; constructor( - threadService: IThreadService, + mainContext: IMainContext, heapService: ExtHostHeapService ) { super(); - this._proxy = threadService.get(MainContext.MainThreadCommands); + this._proxy = mainContext.get(MainContext.MainThreadCommands); this._converter = new CommandsConverter(this, heapService); } diff --git a/src/vs/workbench/api/node/extHostCredentials.ts b/src/vs/workbench/api/node/extHostCredentials.ts index dd15dcc3f7a..0ef4e2dfc0e 100644 --- a/src/vs/workbench/api/node/extHostCredentials.ts +++ b/src/vs/workbench/api/node/extHostCredentials.ts @@ -4,17 +4,16 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { MainContext, MainThreadCredentialsShape, ExtHostCredentialsShape } from 'vs/workbench/api/node/extHost.protocol'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; +import { MainContext, MainThreadCredentialsShape, ExtHostCredentialsShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol'; export class ExtHostCredentials extends ExtHostCredentialsShape { private _proxy: MainThreadCredentialsShape; - constructor(threadService: IThreadService) { + constructor(mainContext: IMainContext) { super(); - this._proxy = threadService.get(MainContext.MainThreadCredentials); + this._proxy = mainContext.get(MainContext.MainThreadCredentials); }; readSecret(service: string, account: string): Thenable { diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index 0e35c3afa56..c131769ff86 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -7,8 +7,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import Event, { Emitter } from 'vs/base/common/event'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; -import { MainContext, MainThreadDebugServiceShape, ExtHostDebugServiceShape, DebugSessionUUID } from 'vs/workbench/api/node/extHost.protocol'; +import { MainContext, MainThreadDebugServiceShape, ExtHostDebugServiceShape, DebugSessionUUID, IMainContext } from 'vs/workbench/api/node/extHost.protocol'; import * as vscode from 'vscode'; import URI from 'vs/base/common/uri'; @@ -35,7 +34,7 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape { get onDidReceiveDebugSessionCustomEvent(): Event { return this._onDidReceiveDebugSessionCustomEvent.event; } - constructor(threadService: IThreadService) { + constructor(mainContext: IMainContext) { super(); this._onDidStartDebugSession = new Emitter(); @@ -43,7 +42,7 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape { this._onDidChangeActiveDebugSession = new Emitter(); this._onDidReceiveDebugSessionCustomEvent = new Emitter(); - this._debugServiceProxy = threadService.get(MainContext.MainThreadDebugService); + this._debugServiceProxy = mainContext.get(MainContext.MainThreadDebugService); } public startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration): TPromise { diff --git a/src/vs/workbench/api/node/extHostDiagnostics.ts b/src/vs/workbench/api/node/extHostDiagnostics.ts index eeb41c0b0e9..1a24e644fe5 100644 --- a/src/vs/workbench/api/node/extHostDiagnostics.ts +++ b/src/vs/workbench/api/node/extHostDiagnostics.ts @@ -5,12 +5,11 @@ 'use strict'; import { localize } from 'vs/nls'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { IMarkerData } from 'vs/platform/markers/common/markers'; import URI from 'vs/base/common/uri'; import Severity from 'vs/base/common/severity'; import * as vscode from 'vscode'; -import { MainContext, MainThreadDiagnosticsShape, ExtHostDiagnosticsShape } from './extHost.protocol'; +import { MainContext, MainThreadDiagnosticsShape, ExtHostDiagnosticsShape, IMainContext } from './extHost.protocol'; import { DiagnosticSeverity } from './extHostTypes'; import { mergeSort } from 'vs/base/common/arrays'; @@ -224,9 +223,9 @@ export class ExtHostDiagnostics extends ExtHostDiagnosticsShape { private _proxy: MainThreadDiagnosticsShape; private _collections: DiagnosticCollection[]; - constructor(threadService: IThreadService) { + constructor(mainContext: IMainContext) { super(); - this._proxy = threadService.get(MainContext.MainThreadDiagnostics); + this._proxy = mainContext.get(MainContext.MainThreadDiagnostics); this._collections = []; } diff --git a/src/vs/workbench/api/node/extHostDocuments.ts b/src/vs/workbench/api/node/extHostDocuments.ts index 745460d188f..68c7f5a524d 100644 --- a/src/vs/workbench/api/node/extHostDocuments.ts +++ b/src/vs/workbench/api/node/extHostDocuments.ts @@ -6,7 +6,6 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import * as editorCommon from 'vs/editor/common/editorCommon'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import Event, { Emitter } from 'vs/base/common/event'; import URI from 'vs/base/common/uri'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; @@ -16,7 +15,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import * as vscode from 'vscode'; import { asWinJsPromise } from 'vs/base/common/async'; import { TextSource } from 'vs/editor/common/model/textSource'; -import { MainContext, MainThreadDocumentsShape, ExtHostDocumentsShape } from './extHost.protocol'; +import { MainContext, MainThreadDocumentsShape, ExtHostDocumentsShape, IMainContext } from './extHost.protocol'; import { ExtHostDocumentData, setWordDefinitionFor } from './extHostDocumentData'; import { ExtHostDocumentsAndEditors } from './extHostDocumentsAndEditors'; import { IModelChangedEvent } from 'vs/editor/common/model/mirrorModel'; @@ -42,9 +41,9 @@ export class ExtHostDocuments extends ExtHostDocumentsShape { private _documentContentProviders = new Map(); - constructor(threadService: IThreadService, documentsAndEditors: ExtHostDocumentsAndEditors) { + constructor(mainContext: IMainContext, documentsAndEditors: ExtHostDocumentsAndEditors) { super(); - this._proxy = threadService.get(MainContext.MainThreadDocuments); + this._proxy = mainContext.get(MainContext.MainThreadDocuments); this._documentsAndEditors = documentsAndEditors; this._toDispose = [ diff --git a/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts b/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts index 27baef47f89..516478d15ea 100644 --- a/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts +++ b/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts @@ -6,10 +6,9 @@ import Event, { Emitter } from 'vs/base/common/event'; import { dispose } from 'vs/base/common/lifecycle'; -import { MainContext, ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta } from './extHost.protocol'; +import { MainContext, ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta, IMainContext } from './extHost.protocol'; import { ExtHostDocumentData } from './extHostDocumentData'; import { ExtHostTextEditor } from './extHostTextEditor'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import * as assert from 'assert'; import * as typeConverters from './extHostTypeConverters'; @@ -30,7 +29,7 @@ export class ExtHostDocumentsAndEditors extends ExtHostDocumentsAndEditorsShape readonly onDidChangeActiveTextEditor: Event = this._onDidChangeActiveTextEditor.event; constructor( - @IThreadService private _threadService: IThreadService + private readonly _mainContext: IMainContext ) { super(); } @@ -54,7 +53,7 @@ export class ExtHostDocumentsAndEditors extends ExtHostDocumentsAndEditorsShape assert.ok(!this._documents.has(data.url.toString()), `document '${data.url} already exists!'`); const documentData = new ExtHostDocumentData( - this._threadService.get(MainContext.MainThreadDocuments), + this._mainContext.get(MainContext.MainThreadDocuments), data.url, data.lines, data.EOL, @@ -82,7 +81,7 @@ export class ExtHostDocumentsAndEditors extends ExtHostDocumentsAndEditorsShape const documentData = this._documents.get(data.document.toString()); const editor = new ExtHostTextEditor( - this._threadService.get(MainContext.MainThreadEditors), + this._mainContext.get(MainContext.MainThreadEditors), data.id, documentData, data.selections.map(typeConverters.toSelection), diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index 61c1f84e156..9cac000209a 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -7,7 +7,6 @@ import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { mixin } from 'vs/base/common/objects'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import * as vscode from 'vscode'; import * as TypeConverters from 'vs/workbench/api/node/extHostTypeConverters'; import { Range, Disposable, CompletionList, CompletionItem, SnippetString } from 'vs/workbench/api/node/extHostTypes'; @@ -19,7 +18,7 @@ import { ExtHostCommands, CommandsConverter } from 'vs/workbench/api/node/extHos import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics'; import { IWorkspaceSymbolProvider } from 'vs/workbench/parts/search/common/search'; import { asWinJsPromise } from 'vs/base/common/async'; -import { MainContext, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesShape, ObjectIdentifier, IRawColorInfo, IRawColorFormatMap } from './extHost.protocol'; +import { MainContext, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesShape, ObjectIdentifier, IRawColorInfo, IRawColorFormatMap, IMainContext } from './extHost.protocol'; import { regExpLeadsToEndlessLoop } from 'vs/base/common/strings'; import { IPosition } from 'vs/editor/common/core/position'; import { IRange } from 'vs/editor/common/core/range'; @@ -737,14 +736,14 @@ export class ExtHostLanguageFeatures extends ExtHostLanguageFeaturesShape { private _colorFormatCache = new Map(); constructor( - threadService: IThreadService, + mainContext: IMainContext, documents: ExtHostDocuments, commands: ExtHostCommands, heapMonitor: ExtHostHeapService, diagnostics: ExtHostDiagnostics ) { super(); - this._proxy = threadService.get(MainContext.MainThreadLanguageFeatures); + this._proxy = mainContext.get(MainContext.MainThreadLanguageFeatures); this._documents = documents; this._commands = commands; this._heapService = heapMonitor; diff --git a/src/vs/workbench/api/node/extHostLanguages.ts b/src/vs/workbench/api/node/extHostLanguages.ts index 15ec295b42a..e480ac1b40d 100644 --- a/src/vs/workbench/api/node/extHostLanguages.ts +++ b/src/vs/workbench/api/node/extHostLanguages.ts @@ -5,17 +5,16 @@ 'use strict'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; -import { MainContext, MainThreadLanguagesShape } from './extHost.protocol'; +import { MainContext, MainThreadLanguagesShape, IMainContext } from './extHost.protocol'; export class ExtHostLanguages { private _proxy: MainThreadLanguagesShape; constructor( - threadService: IThreadService + mainContext: IMainContext ) { - this._proxy = threadService.get(MainContext.MainThreadLanguages); + this._proxy = mainContext.get(MainContext.MainThreadLanguages); } getLanguages(): TPromise { diff --git a/src/vs/workbench/api/node/extHostMessageService.ts b/src/vs/workbench/api/node/extHostMessageService.ts index 31d5cbdcd22..6ae9309f3ce 100644 --- a/src/vs/workbench/api/node/extHostMessageService.ts +++ b/src/vs/workbench/api/node/extHostMessageService.ts @@ -4,10 +4,9 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import Severity from 'vs/base/common/severity'; import vscode = require('vscode'); -import { MainContext, MainThreadMessageServiceShape } from './extHost.protocol'; +import { MainContext, MainThreadMessageServiceShape, IMainContext } from './extHost.protocol'; const emptyMessageOptions: vscode.MessageOptions = Object.create(null); @@ -27,8 +26,8 @@ export class ExtHostMessageService { private _proxy: MainThreadMessageServiceShape; - constructor(threadService: IThreadService) { - this._proxy = threadService.get(MainContext.MainThreadMessageService); + constructor(mainContext: IMainContext) { + this._proxy = mainContext.get(MainContext.MainThreadMessageService); } showMessage(severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string, rest: string[]): Thenable; diff --git a/src/vs/workbench/api/node/extHostOutputService.ts b/src/vs/workbench/api/node/extHostOutputService.ts index 9a0190ae7e5..ff39a9e2feb 100644 --- a/src/vs/workbench/api/node/extHostOutputService.ts +++ b/src/vs/workbench/api/node/extHostOutputService.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; -import { MainContext, MainThreadOutputServiceShape } from './extHost.protocol'; +import { MainContext, MainThreadOutputServiceShape, IMainContext } from './extHost.protocol'; import * as vscode from 'vscode'; export class ExtHostOutputChannel implements vscode.OutputChannel { @@ -64,8 +63,8 @@ export class ExtHostOutputService { private _proxy: MainThreadOutputServiceShape; - constructor(threadService: IThreadService) { - this._proxy = threadService.get(MainContext.MainThreadOutputService); + constructor(mainContext: IMainContext) { + this._proxy = mainContext.get(MainContext.MainThreadOutputService); } createOutputChannel(name: string): vscode.OutputChannel { diff --git a/src/vs/workbench/api/node/extHostQuickOpen.ts b/src/vs/workbench/api/node/extHostQuickOpen.ts index 183dcd1d7bc..a96e27f9f61 100644 --- a/src/vs/workbench/api/node/extHostQuickOpen.ts +++ b/src/vs/workbench/api/node/extHostQuickOpen.ts @@ -7,9 +7,8 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { wireCancellationToken } from 'vs/base/common/async'; import { CancellationToken } from 'vs/base/common/cancellation'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { QuickPickOptions, QuickPickItem, InputBoxOptions } from 'vscode'; -import { MainContext, MainThreadQuickOpenShape, ExtHostQuickOpenShape, MyQuickPickItems } from './extHost.protocol'; +import { MainContext, MainThreadQuickOpenShape, ExtHostQuickOpenShape, MyQuickPickItems, IMainContext } from './extHost.protocol'; export type Item = string | QuickPickItem; @@ -19,9 +18,9 @@ export class ExtHostQuickOpen extends ExtHostQuickOpenShape { private _onDidSelectItem: (handle: number) => void; private _validateInput: (input: string) => string; - constructor(threadService: IThreadService) { + constructor(mainContext: IMainContext) { super(); - this._proxy = threadService.get(MainContext.MainThreadQuickOpen); + this._proxy = mainContext.get(MainContext.MainThreadQuickOpen); } showQuickPick(itemsOrItemsPromise: string[] | Thenable, options?: QuickPickOptions, token?: CancellationToken): Thenable; diff --git a/src/vs/workbench/api/node/extHostSCM.ts b/src/vs/workbench/api/node/extHostSCM.ts index 126466f2f14..7cb0041cf3f 100644 --- a/src/vs/workbench/api/node/extHostSCM.ts +++ b/src/vs/workbench/api/node/extHostSCM.ts @@ -8,9 +8,8 @@ import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import Event, { Emitter } from 'vs/base/common/event'; import { asWinJsPromise } from 'vs/base/common/async'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { ExtHostCommands, CommandsConverter } from 'vs/workbench/api/node/extHostCommands'; -import { MainContext, MainThreadSCMShape, SCMRawResource } from './extHost.protocol'; +import { MainContext, MainThreadSCMShape, SCMRawResource, IMainContext } from './extHost.protocol'; import * as vscode from 'vscode'; function getIconPath(decorations: vscode.SourceControlResourceThemableDecorations) { @@ -277,10 +276,10 @@ export class ExtHostSCM { get inputBox(): ExtHostSCMInputBox { return this._inputBox; } constructor( - threadService: IThreadService, + mainContext: IMainContext, private _commands: ExtHostCommands ) { - this._proxy = threadService.get(MainContext.MainThreadSCM); + this._proxy = mainContext.get(MainContext.MainThreadSCM); this._inputBox = new ExtHostSCMInputBox(this._proxy); _commands.registerArgumentProcessor({ diff --git a/src/vs/workbench/api/node/extHostStatusBar.ts b/src/vs/workbench/api/node/extHostStatusBar.ts index 6e91e7dbf9a..2de2bec359b 100644 --- a/src/vs/workbench/api/node/extHostStatusBar.ts +++ b/src/vs/workbench/api/node/extHostStatusBar.ts @@ -4,11 +4,10 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/platform/statusbar/common/statusbar'; import { StatusBarAlignment as ExtHostStatusBarAlignment, Disposable, ThemeColor } from './extHostTypes'; import { StatusBarItem, StatusBarAlignment } from 'vscode'; -import { MainContext, MainThreadStatusBarShape } from './extHost.protocol'; +import { MainContext, MainThreadStatusBarShape, IMainContext } from './extHost.protocol'; export class ExtHostStatusBarEntry implements StatusBarItem { private static ID_GEN = 0; @@ -163,8 +162,8 @@ export class ExtHostStatusBar { private _proxy: MainThreadStatusBarShape; private _statusMessage: StatusBarMessage; - constructor(threadService: IThreadService) { - this._proxy = threadService.get(MainContext.MainThreadStatusBar); + constructor(mainContext: IMainContext) { + this._proxy = mainContext.get(MainContext.MainThreadStatusBar); this._statusMessage = new StatusBarMessage(this); } diff --git a/src/vs/workbench/api/node/extHostStorage.ts b/src/vs/workbench/api/node/extHostStorage.ts index 80499005ff7..d24797a397f 100644 --- a/src/vs/workbench/api/node/extHostStorage.ts +++ b/src/vs/workbench/api/node/extHostStorage.ts @@ -5,15 +5,14 @@ 'use strict'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; -import { MainContext, MainThreadStorageShape } from './extHost.protocol'; +import { MainContext, MainThreadStorageShape, IMainContext } from './extHost.protocol'; export class ExtHostStorage { private _proxy: MainThreadStorageShape; - constructor(threadService: IThreadService) { - this._proxy = threadService.get(MainContext.MainThreadStorage); + constructor(mainContext: IMainContext) { + this._proxy = mainContext.get(MainContext.MainThreadStorage); } getValue(shared: boolean, key: string, defaultValue?: T): TPromise { diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 36195a1b02a..cca7188f101 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -12,8 +12,7 @@ import { asWinJsPromise } from 'vs/base/common/async'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import * as TaskSystem from 'vs/workbench/parts/tasks/common/tasks'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; -import { MainContext, MainThreadTaskShape, ExtHostTaskShape } from 'vs/workbench/api/node/extHost.protocol'; +import { MainContext, MainThreadTaskShape, ExtHostTaskShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol'; import * as types from 'vs/workbench/api/node/extHostTypes'; import * as vscode from 'vscode'; @@ -402,9 +401,9 @@ export class ExtHostTask extends ExtHostTaskShape { private _handleCounter: number; private _handlers: Map; - constructor(threadService: IThreadService) { + constructor(mainContext: IMainContext) { super(); - this._proxy = threadService.get(MainContext.MainThreadTask); + this._proxy = mainContext.get(MainContext.MainThreadTask); this._handleCounter = 0; this._handlers = new Map(); }; diff --git a/src/vs/workbench/api/node/extHostTelemetry.ts b/src/vs/workbench/api/node/extHostTelemetry.ts index 35849674f38..cd9e4a1f9da 100644 --- a/src/vs/workbench/api/node/extHostTelemetry.ts +++ b/src/vs/workbench/api/node/extHostTelemetry.ts @@ -7,8 +7,7 @@ import { notImplemented } from 'vs/base/common/errors'; import { TPromise } from 'vs/base/common/winjs.base'; import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; -import { MainContext, MainThreadTelemetryShape } from './extHost.protocol'; +import { MainContext, MainThreadTelemetryShape, IMainContext } from './extHost.protocol'; export class RemoteTelemetryService implements ITelemetryService { @@ -17,9 +16,9 @@ export class RemoteTelemetryService implements ITelemetryService { private _name: string; private _proxy: MainThreadTelemetryShape; - constructor(name: string, threadService: IThreadService) { + constructor(name: string, mainContext: IMainContext) { this._name = name; - this._proxy = threadService.get(MainContext.MainThreadTelemetry); + this._proxy = mainContext.get(MainContext.MainThreadTelemetry); } get isOptedIn(): boolean { diff --git a/src/vs/workbench/api/node/extHostTerminalService.ts b/src/vs/workbench/api/node/extHostTerminalService.ts index 2729f12071b..e42fc83d1f6 100644 --- a/src/vs/workbench/api/node/extHostTerminalService.ts +++ b/src/vs/workbench/api/node/extHostTerminalService.ts @@ -7,8 +7,7 @@ import vscode = require('vscode'); import { TPromise, TValueCallback } from 'vs/base/common/winjs.base'; import Event, { Emitter } from 'vs/base/common/event'; -import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape } from './extHost.protocol'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; +import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, IMainContext } from './extHost.protocol'; export class ExtHostTerminal implements vscode.Terminal { @@ -101,9 +100,9 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape { private _proxy: MainThreadTerminalServiceShape; private _terminals: ExtHostTerminal[]; - constructor(threadService: IThreadService) { + constructor(mainContext: IMainContext) { this._onDidCloseTerminal = new Emitter(); - this._proxy = threadService.get(MainContext.MainThreadTerminalService); + this._proxy = mainContext.get(MainContext.MainThreadTerminalService); this._terminals = []; } diff --git a/src/vs/workbench/api/node/extHostTextEditors.ts b/src/vs/workbench/api/node/extHostTextEditors.ts index 493dd531412..95306ae27e3 100644 --- a/src/vs/workbench/api/node/extHostTextEditors.ts +++ b/src/vs/workbench/api/node/extHostTextEditors.ts @@ -8,13 +8,12 @@ import URI from 'vs/base/common/uri'; import Event, { Emitter } from 'vs/base/common/event'; import { toThenable } from 'vs/base/common/async'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { TextEditorSelectionChangeKind } from './extHostTypes'; import * as TypeConverters from './extHostTypeConverters'; import { TextEditorDecorationType, ExtHostTextEditor } from './extHostTextEditor'; import { ExtHostDocumentsAndEditors } from './extHostDocumentsAndEditors'; import { Position as EditorPosition } from 'vs/platform/editor/common/editor'; -import { MainContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IResolvedTextEditorConfiguration, ISelectionChangeEvent } from './extHost.protocol'; +import { MainContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IResolvedTextEditorConfiguration, ISelectionChangeEvent, IMainContext } from './extHost.protocol'; import * as vscode from 'vscode'; export class ExtHostEditors extends ExtHostEditorsShape { @@ -36,11 +35,11 @@ export class ExtHostEditors extends ExtHostEditorsShape { private _extHostDocumentsAndEditors: ExtHostDocumentsAndEditors; constructor( - threadService: IThreadService, + mainContext: IMainContext, extHostDocumentsAndEditors: ExtHostDocumentsAndEditors, ) { super(); - this._proxy = threadService.get(MainContext.MainThreadEditors); + this._proxy = mainContext.get(MainContext.MainThreadEditors); this._extHostDocumentsAndEditors = extHostDocumentsAndEditors; this._extHostDocumentsAndEditors.onDidChangeVisibleTextEditors(e => this._onDidChangeVisibleTextEditors.fire(e)); diff --git a/src/vs/workbench/api/node/extHostWorkspace.ts b/src/vs/workbench/api/node/extHostWorkspace.ts index c4e78b98bb8..2d1c370653f 100644 --- a/src/vs/workbench/api/node/extHostWorkspace.ts +++ b/src/vs/workbench/api/node/extHostWorkspace.ts @@ -10,11 +10,10 @@ import { normalize } from 'vs/base/common/paths'; import { delta } from 'vs/base/common/arrays'; import { relative, basename } from 'path'; import { Workspace } from 'vs/platform/workspace/common/workspace'; -import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { IResourceEdit } from 'vs/editor/common/services/bulkEdit'; import { TPromise } from 'vs/base/common/winjs.base'; import { fromRange, EndOfLine } from 'vs/workbench/api/node/extHostTypeConverters'; -import { IWorkspaceData, ExtHostWorkspaceShape, MainContext, MainThreadWorkspaceShape } from './extHost.protocol'; +import { IWorkspaceData, ExtHostWorkspaceShape, MainContext, MainThreadWorkspaceShape, IMainContext } from './extHost.protocol'; import * as vscode from 'vscode'; import { compare } from "vs/base/common/strings"; import { asWinJsPromise } from 'vs/base/common/async'; @@ -76,9 +75,9 @@ export class ExtHostWorkspace extends ExtHostWorkspaceShape { readonly onDidChangeWorkspace: Event = this._onDidChangeWorkspace.event; - constructor(threadService: IThreadService, data: IWorkspaceData) { + constructor(mainContext: IMainContext, data: IWorkspaceData) { super(); - this._proxy = threadService.get(MainContext.MainThreadWorkspace); + this._proxy = mainContext.get(MainContext.MainThreadWorkspace); this._workspace = Workspace2.fromData(data); } diff --git a/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts b/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts index bdc0d30f2a4..38f0a099cc7 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts @@ -31,6 +31,7 @@ import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumen import { MainContext, ExtHostContext } from 'vs/workbench/api/node/extHost.protocol'; import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics'; import * as vscode from 'vscode'; +import { IInstantiationService } from "vs/platform/instantiation/common/instantiation"; const defaultSelector = { scheme: 'far' }; const model: EditorCommon.IModel = EditorModel.createFromString( @@ -57,40 +58,45 @@ suite('ExtHostLanguageFeatureCommands', function () { originalErrorHandler = errorHandler.getUnexpectedErrorHandler(); setUnexpectedErrorHandler(() => { }); - let instantiationService = new TestInstantiationService(); - threadService = new TestThreadService(); - instantiationService.stub(IHeapService, { - _serviceBrand: undefined, - trackRecursive(args) { - // nothing - return args; - } - }); - instantiationService.stub(ICommandService, { - _serviceBrand: undefined, - executeCommand(id, args): any { - if (!CommandsRegistry.getCommands()[id]) { - return TPromise.wrapError(new Error(id + ' NOT known')); + // Use IInstantiationService to get typechecking when instantiating + let inst: IInstantiationService; + { + let instantiationService = new TestInstantiationService(); + threadService = new TestThreadService(); + instantiationService.stub(IHeapService, { + _serviceBrand: undefined, + trackRecursive(args) { + // nothing + return args; } - let { handler } = CommandsRegistry.getCommands()[id]; - return TPromise.as(instantiationService.invokeFunction(handler, args)); - } - }); - instantiationService.stub(IMarkerService, new MarkerService()); - instantiationService.stub(IThreadService, threadService); - instantiationService.stub(IModelService, { - _serviceBrand: IModelService, - getModel(): any { return model; }, - createModel(): any { throw new Error(); }, - updateModel(): any { throw new Error(); }, - setMode(): any { throw new Error(); }, - destroyModel(): any { throw new Error(); }, - getModels(): any { throw new Error(); }, - onModelAdded: undefined, - onModelModeChanged: undefined, - onModelRemoved: undefined, - getCreationOptions(): any { throw new Error(); } - }); + }); + instantiationService.stub(ICommandService, { + _serviceBrand: undefined, + executeCommand(id, args): any { + if (!CommandsRegistry.getCommands()[id]) { + return TPromise.wrapError(new Error(id + ' NOT known')); + } + let { handler } = CommandsRegistry.getCommands()[id]; + return TPromise.as(instantiationService.invokeFunction(handler, args)); + } + }); + instantiationService.stub(IMarkerService, new MarkerService()); + instantiationService.stub(IThreadService, threadService); + instantiationService.stub(IModelService, { + _serviceBrand: IModelService, + getModel(): any { return model; }, + createModel(): any { throw new Error(); }, + updateModel(): any { throw new Error(); }, + setMode(): any { throw new Error(); }, + destroyModel(): any { throw new Error(); }, + getModels(): any { throw new Error(); }, + onModelAdded: undefined, + onModelModeChanged: undefined, + onModelRemoved: undefined, + getCreationOptions(): any { throw new Error(); } + }); + inst = instantiationService; + } const extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(threadService); extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({ @@ -110,7 +116,7 @@ suite('ExtHostLanguageFeatureCommands', function () { commands = new ExtHostCommands(threadService, heapService); threadService.set(ExtHostContext.ExtHostCommands, commands); - threadService.setTestInstance(MainContext.MainThreadCommands, instantiationService.createInstance(MainThreadCommands)); + threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService)); ExtHostApiCommands.register(commands); const diagnostics = new ExtHostDiagnostics(threadService); @@ -119,7 +125,7 @@ suite('ExtHostLanguageFeatureCommands', function () { extHost = new ExtHostLanguageFeatures(threadService, extHostDocuments, commands, heapService, diagnostics); threadService.set(ExtHostContext.ExtHostLanguageFeatures, extHost); - mainThread = threadService.setTestInstance(MainContext.MainThreadLanguageFeatures, instantiationService.createInstance(MainThreadLanguageFeatures)); + mainThread = threadService.setTestInstance(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures)); threadService.sync().then(done, done); }); diff --git a/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts index fc14d9e5382..e7be9b92b3a 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts @@ -17,9 +17,7 @@ suite('ExtHostDocumentsAndEditors', () => { setup(function () { editors = new ExtHostDocumentsAndEditors({ - _serviceBrand: undefined, - get() { return undefined; }, - set() { } + get() { return undefined; } }); }); diff --git a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts index fed577004d3..e87a45cecad 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts @@ -44,6 +44,7 @@ import { MainContext, ExtHostContext } from 'vs/workbench/api/node/extHost.proto import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics'; import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService'; import * as vscode from 'vscode'; +import { IInstantiationService } from "vs/platform/instantiation/common/instantiation"; const defaultSelector = { scheme: 'far' }; const model: EditorCommon.IModel = EditorModel.createFromString( @@ -67,16 +68,22 @@ suite('ExtHostLanguageFeatures', function () { suiteSetup(() => { threadService = new TestThreadService(); - let instantiationService = new TestInstantiationService(); - instantiationService.stub(IThreadService, threadService); - instantiationService.stub(IMarkerService, MarkerService); - instantiationService.stub(IHeapService, { - _serviceBrand: undefined, - trackRecursive(args) { - // nothing - return args; - } - }); + + // Use IInstantiationService to get typechecking when instantiating + let inst: IInstantiationService; + { + let instantiationService = new TestInstantiationService(); + instantiationService.stub(IThreadService, threadService); + instantiationService.stub(IMarkerService, MarkerService); + instantiationService.stub(IHeapService, { + _serviceBrand: undefined, + trackRecursive(args) { + // nothing + return args; + } + }); + inst = instantiationService; + } originalErrorHandler = errorHandler.getUnexpectedErrorHandler(); setUnexpectedErrorHandler(() => { }); @@ -99,7 +106,7 @@ suite('ExtHostLanguageFeatures', function () { const commands = new ExtHostCommands(threadService, heapService); threadService.set(ExtHostContext.ExtHostCommands, commands); - threadService.setTestInstance(MainContext.MainThreadCommands, instantiationService.createInstance(MainThreadCommands)); + threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService)); const diagnostics = new ExtHostDiagnostics(threadService); threadService.set(ExtHostContext.ExtHostDiagnostics, diagnostics); @@ -107,7 +114,7 @@ suite('ExtHostLanguageFeatures', function () { extHost = new ExtHostLanguageFeatures(threadService, extHostDocuments, commands, heapService, diagnostics); threadService.set(ExtHostContext.ExtHostLanguageFeatures, extHost); - mainThread = threadService.setTestInstance(MainContext.MainThreadLanguageFeatures, instantiationService.createInstance(MainThreadLanguageFeatures)); + mainThread = threadService.setTestInstance(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures)); }); suiteTeardown(() => { diff --git a/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts index fdcf96360e9..7cac271a037 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts @@ -16,6 +16,7 @@ import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { MainThreadCommands } from 'vs/workbench/api/electron-browser/mainThreadCommands'; +import { IInstantiationService } from "vs/platform/instantiation/common/instantiation"; suite('ExtHostConfiguration', function () { @@ -38,10 +39,15 @@ suite('ExtHostConfiguration', function () { setup(() => { let threadService = new TestThreadService(); - let instantiationService = new TestInstantiationService(); - instantiationService.stub(IThreadService, threadService); + // Use IInstantiationService to get typechecking when instantiating + let inst: IInstantiationService; + { + let instantiationService = new TestInstantiationService(); + instantiationService.stub(IThreadService, threadService); + inst = instantiationService; + } - threadService.setTestInstance(MainContext.MainThreadCommands, instantiationService.createInstance(MainThreadCommands)); + threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService)); target = new RecordingShape(); testObject = new ExtHostTreeViews(target, new ExtHostCommands(threadService, new ExtHostHeapService())); onDidChangeTreeData = new Emitter();