mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
start with a step back and use IWorkspace where needed, nuke workspace context service from ext host, #28526
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<string>;
|
||||
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<string> {
|
||||
|
||||
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<ExtHostExt
|
||||
private _storagePath: ExtensionStoragePath;
|
||||
private _proxy: MainProcessExtensionServiceShape;
|
||||
private _telemetryService: ITelemetryService;
|
||||
private _contextService: IWorkspaceContextService;
|
||||
|
||||
/**
|
||||
* This class is constructed manually because it is a service, so it doesn't use any ctor injection
|
||||
*/
|
||||
constructor(initData: IInitData, threadService: IThreadService, telemetryService: ITelemetryService, contextService: IWorkspaceContextService) {
|
||||
constructor(initData: IInitData, threadService: IThreadService, telemetryService: ITelemetryService) {
|
||||
super(false);
|
||||
this._registry.registerExtensions(initData.extensions);
|
||||
this._threadService = threadService;
|
||||
this._storage = new ExtHostStorage(threadService);
|
||||
this._storagePath = new ExtensionStoragePath(contextService, initData.environment);
|
||||
this._storagePath = new ExtensionStoragePath(initData.workspace, initData.environment);
|
||||
this._proxy = this._threadService.get(MainContext.MainProcessExtensionService);
|
||||
this._telemetryService = telemetryService;
|
||||
this._contextService = contextService;
|
||||
|
||||
// initialize API first
|
||||
const apiFactory = createApiFactory(initData, threadService, this, this._contextService, this._telemetryService);
|
||||
const apiFactory = createApiFactory(initData, threadService, this, this._telemetryService);
|
||||
initializeExtensionApi(this, apiFactory).then(() => this._triggerOnReady());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user