diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index b9b4746182f..810e4cf1f82 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -41,7 +41,6 @@ import EditorCommon = require('vs/editor/common/editorCommon'); import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionService'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; import * as vscode from 'vscode'; @@ -72,7 +71,6 @@ export function createApiFactory( initData: IInitData, threadService: IThreadService, extensionService: ExtHostExtensionService, - contextService: IWorkspaceContextService, telemetryService: ITelemetryService ): IExtensionApiFactory { @@ -101,7 +99,7 @@ export function createApiFactory( const extHostStatusBar = new ExtHostStatusBar(threadService); const extHostProgress = new ExtHostProgress(threadService.get(MainContext.MainThreadProgress)); const extHostOutputService = new ExtHostOutputService(threadService); - const workspacePath = contextService.hasWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined; + const workspacePath = initData.workspace ? initData.workspace.resource.fsPath : undefined; const extHostWorkspace = new ExtHostWorkspace(threadService, workspacePath); const extHostLanguages = new ExtHostLanguages(threadService); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 6d92223c932..e68efd0e513 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -60,9 +60,7 @@ export interface IEnvironment { export interface IInitData { parentPid: number; environment: IEnvironment; - contextService: { - workspace: IWorkspace; - }; + workspace: IWorkspace; extensions: IExtensionDescription[]; configuration: IWorkspaceConfigurationValues; telemetryInfo: ITelemetryInfo; diff --git a/src/vs/workbench/api/node/extHostExtensionService.ts b/src/vs/workbench/api/node/extHostExtensionService.ts index ae75796c7e2..aeb68c62eda 100644 --- a/src/vs/workbench/api/node/extHostExtensionService.ts +++ b/src/vs/workbench/api/node/extHostExtensionService.ts @@ -15,7 +15,7 @@ import { ExtHostStorage } from 'vs/workbench/api/node/extHostStorage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { createApiFactory, initializeExtensionApi } from 'vs/workbench/api/node/extHost.api.impl'; import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { IWorkspace } from 'vs/platform/workspace/common/workspace'; import { MainContext, MainProcessExtensionServiceShape, IEnvironment, IInitData } from './extHost.protocol'; import { createHash } from 'crypto'; @@ -103,14 +103,14 @@ class ExtensionMemento implements IExtensionMemento { class ExtensionStoragePath { - private readonly _contextService: IWorkspaceContextService; + private readonly _workspace: IWorkspace; private readonly _environment: IEnvironment; private readonly _ready: TPromise; private _value: string; - constructor(contextService: IWorkspaceContextService, environment: IEnvironment) { - this._contextService = contextService; + constructor(workspace: IWorkspace, environment: IEnvironment) { + this._workspace = workspace; this._environment = environment; this._ready = this._getOrCreateWorkspaceStoragePath().then(value => this._value = value); } @@ -127,16 +127,13 @@ class ExtensionStoragePath { } private _getOrCreateWorkspaceStoragePath(): TPromise { - - const workspace = this._contextService.getWorkspace(); - - if (!workspace) { + if (!this._workspace) { return TPromise.as(undefined); } const storageName = createHash('md5') - .update(workspace.resource.fsPath) - .update(workspace.uid ? workspace.uid.toString() : '') + .update(this._workspace.resource.fsPath) + .update(this._workspace.uid ? this._workspace.uid.toString() : '') .digest('hex'); const storagePath = join(this._environment.appSettingsHome, 'workspaceStorage', storageName); @@ -171,23 +168,21 @@ export class ExtHostExtensionService extends AbstractExtensionService this._triggerOnReady()); } diff --git a/src/vs/workbench/electron-browser/extensionHost.ts b/src/vs/workbench/electron-browser/extensionHost.ts index 2431281d98e..6b99c054bb7 100644 --- a/src/vs/workbench/electron-browser/extensionHost.ts +++ b/src/vs/workbench/electron-browser/extensionHost.ts @@ -259,9 +259,7 @@ export class ExtensionHostProcessWorker { enableProposedApiForAll: !this.environmentService.isBuilt || (!!this.environmentService.extensionDevelopmentPath && product.nameLong.indexOf('Insiders') >= 0), enableProposedApiFor: this.environmentService.args['enable-proposed-api'] || [] }, - contextService: { - workspace: this.contextService.getWorkspace() - }, + workspace: this.contextService.getWorkspace(), extensions: extensionDescriptions, configuration: this.configurationService.values(), telemetryInfo diff --git a/src/vs/workbench/node/extensionHostMain.ts b/src/vs/workbench/node/extensionHostMain.ts index 6d38c79e651..7f4aa8b0094 100644 --- a/src/vs/workbench/node/extensionHostMain.ts +++ b/src/vs/workbench/node/extensionHostMain.ts @@ -15,10 +15,9 @@ import { ExtHostThreadService } from 'vs/workbench/services/thread/common/extHos import { QueryType, ISearchQuery } from 'vs/platform/search/common/search'; import { DiskSearch } from 'vs/workbench/services/search/node/searchService'; import { RemoteTelemetryService } from 'vs/workbench/api/node/extHostTelemetry'; -import { IWorkspaceContextService, WorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { IInitData, IEnvironment, MainContext } from 'vs/workbench/api/node/extHost.protocol'; import * as errors from 'vs/base/common/errors'; -import { NullConfigurationService } from "vs/workbench/services/configuration/node/nullConfigurationService"; +import { IWorkspace } from "vs/platform/workspace/common/workspace"; const nativeExit = process.exit.bind(process); process.exit = function () { @@ -36,25 +35,19 @@ interface ITestRunner { export class ExtensionHostMain { private _isTerminating: boolean = false; - private _contextService: IWorkspaceContextService; private _diskSearch: DiskSearch; + private _workspace: IWorkspace; private _environment: IEnvironment; private _extensionService: ExtHostExtensionService; constructor(remoteCom: IRemoteCom, initData: IInitData) { - // services this._environment = initData.environment; + this._workspace = initData.workspace; - const workspaceRaw = initData.contextService.workspace; - let workspace: Workspace; - if (workspaceRaw) { - workspace = new Workspace(workspaceRaw.resource, workspaceRaw.uid, workspaceRaw.name); - } - this._contextService = new WorkspaceContextService(new NullConfigurationService(), workspace); //TODO@Ben implement for exthost - + // services const threadService = new ExtHostThreadService(remoteCom); const telemetryService = new RemoteTelemetryService('pluginHostTelemetry', threadService); - this._extensionService = new ExtHostExtensionService(initData, threadService, telemetryService, this._contextService); + this._extensionService = new ExtHostExtensionService(initData, threadService, telemetryService); // Error forwarding const mainThreadErrors = threadService.get(MainContext.MainThreadErrors); @@ -108,12 +101,11 @@ export class ExtensionHostMain { } private handleWorkspaceContainsEagerExtensions(): TPromise { - let workspace = this._contextService.getWorkspace(); - if (!workspace || !workspace.resource) { + if (!this._workspace || !this._workspace.resource) { return TPromise.as(null); } - const folderPath = workspace.resource.fsPath; + const folderPath = this._workspace.resource.fsPath; const desiredFilesMap: { [filename: string]: boolean; @@ -143,7 +135,7 @@ export class ExtensionHostMain { } const query: ISearchQuery = { - folderResources: [workspace.resource], + folderResources: [this._workspace.resource], type: QueryType.File, maxResults: 1, includePattern: { [p]: true }