提交 7c1c21c1 编写于 作者: J Johannes Rieken

start with a step back and use IWorkspace where needed, nuke workspace context...

start with a step back and use IWorkspace where needed, nuke workspace context service from ext host, #28526
上级 def13c6d
......@@ -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());
}
......
......@@ -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
......
......@@ -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<void> {
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 }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册