adopt IWorkspace2, implement proper workspaceContains, #28526

This commit is contained in:
Johannes Rieken
2017-06-14 12:21:16 +02:00
parent cae242f714
commit f8eb2fa3b8
9 changed files with 52 additions and 46 deletions

View File

@@ -15,8 +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 { IWorkspace } from 'vs/platform/workspace/common/workspace';
import { MainContext, MainProcessExtensionServiceShape, IEnvironment, IInitData } from './extHost.protocol';
import { MainContext, MainProcessExtensionServiceShape, IWorkspaceData, IEnvironment, IInitData } from './extHost.protocol';
import { createHash } from 'crypto';
const hasOwnProperty = Object.hasOwnProperty;
@@ -103,13 +102,13 @@ class ExtensionMemento implements IExtensionMemento {
class ExtensionStoragePath {
private readonly _workspace: IWorkspace;
private readonly _workspace: IWorkspaceData;
private readonly _environment: IEnvironment;
private readonly _ready: TPromise<string>;
private _value: string;
constructor(workspace: IWorkspace, environment: IEnvironment) {
constructor(workspace: IWorkspaceData, environment: IEnvironment) {
this._workspace = workspace;
this._environment = environment;
this._ready = this._getOrCreateWorkspaceStoragePath().then(value => this._value = value);
@@ -130,10 +129,10 @@ class ExtensionStoragePath {
if (!this._workspace) {
return TPromise.as(undefined);
}
// TODO@joh what to do with multiple roots?
const storageName = createHash('md5')
.update(this._workspace.resource.fsPath)
.update(this._workspace.uid ? this._workspace.uid.toString() : '')
.update(this._workspace.roots[0].fsPath)
.update(this._workspace.id || '')
.digest('hex');
const storagePath = join(this._environment.appSettingsHome, 'workspaceStorage', storageName);