提交 3d3cda18 编写于 作者: B Benjamin Pasero

more workspace service simplification

上级 c6497e86
......@@ -28,7 +28,7 @@ import {IMessageService} from 'vs/platform/message/common/message';
import {IProgressService} from 'vs/platform/progress/common/progress';
import {IStorageService, NullStorageService} from 'vs/platform/storage/common/storage';
import {ITelemetryService, NullTelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IWorkspaceContextService, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IWorkspaceContextService, WorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {EditorWorkerServiceImpl} from 'vs/editor/common/services/editorWorkerServiceImpl';
......@@ -237,12 +237,8 @@ export function getOrCreateStaticServices(services?: IEditorOverrideServices): I
let serviceCollection = new ServiceCollection();
const instantiationService = new InstantiationService(serviceCollection, true);
let contextService = services.contextService || new BaseWorkspaceContextService({
resource: URI.from({ scheme: 'inmemory', authority: 'model', path: '/' }),
id: null,
name: null,
uid: null,
mtime: null
let contextService = services.contextService || new WorkspaceContextService({
resource: URI.from({ scheme: 'inmemory', authority: 'model', path: '/' })
});
serviceCollection.set(IWorkspaceContextService, contextService);
......
......@@ -45,34 +45,20 @@ export interface IWorkspace {
*/
resource: URI;
/**
* the identifier that uniquely identifies this workspace among others.
*/
id: string;
/**
* the name of the workspace
*/
name: string;
/**
* the last modified date of the workspace if known
*/
mtime?: number;
/**
* the unique identifier of the workspace. if the workspace is deleted and recreated
* the identifier also changes. this makes the uid more unique compared to the id which
* is just derived from the workspace name.
*/
uid?: number;
/**
* the name of the workspace
*/
name?: string;
}
/**
* Simple IWorkspaceContextService implementation to allow sharing of this service implementation
* between different layers of the platform.
*/
export class BaseWorkspaceContextService implements IWorkspaceContextService {
export class WorkspaceContextService implements IWorkspaceContextService {
public _serviceBrand: any;
......
......@@ -45,10 +45,8 @@ import {EnvironmentService} from 'vs/platform/environment/node/environmentServic
export const TestWorkspace: IWorkspace = {
resource: URI.file('C:\\testWorkspace'),
id: 'testWorkspace',
name: 'Test Workspace',
uid: new Date().getTime(),
mtime: new Date().getTime()
uid: new Date().getTime()
};
export const TestEnvironmentService = new EnvironmentService(Objects.assign(parseArgs(process.argv), { execPath: process.execPath }));
......
......@@ -49,7 +49,7 @@ export class Storage implements IStorageService {
this.workspaceKey = this.getWorkspaceKey(workspace);
// Make sure to delete all workspace storage if the workspace has been recreated meanwhile
const workspaceUniqueId: number = workspace ? workspace.uid : null;
const workspaceUniqueId: number = workspace ? workspace.uid : void 0;
if (types.isNumber(workspaceUniqueId)) {
this.cleanupWorkspaceScope(workspaceUniqueId, workspace.name);
}
......
......@@ -122,10 +122,8 @@ function getWorkspace(workspacePath: string): IWorkspace {
return <IWorkspace>{
'resource': workspaceResource,
'id': platform.isLinux ? realWorkspacePath : realWorkspacePath.toLowerCase(),
'name': folderName,
'uid': platform.isLinux ? folderStat.ino : folderStat.birthtime.getTime(), // On Linux, birthtime is ctime, so we cannot use it! We use the ino instead!
'mtime': folderStat.mtime.getTime()
'uid': platform.isLinux ? folderStat.ino : folderStat.birthtime.getTime() // On Linux, birthtime is ctime, so we cannot use it! We use the ino instead!
};
}
......
......@@ -22,7 +22,7 @@ import {ExtHostExtensionService} from 'vs/workbench/api/node/extHostExtensionSer
import {ExtHostThreadService} from 'vs/workbench/services/thread/common/extHostThreadService';
import {RemoteTelemetryService} from 'vs/workbench/api/node/extHostTelemetry';
import {ExtensionScanner, MessagesCollector} from 'vs/workbench/node/extensionPoints';
import {IWorkspaceContextService, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IWorkspaceContextService, WorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {Client} from 'vs/base/parts/ipc/node/ipc.net';
import {IExtensionManagementChannel, ExtensionManagementChannelClient} from 'vs/platform/extensionManagement/common/extensionManagementIpc';
......@@ -72,7 +72,7 @@ export class ExtensionHostMain {
this._environment = initData.environment;
this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace);
this._contextService = new WorkspaceContextService(initData.contextService.workspace);
const workspaceStoragePath = this._getOrCreateWorkspaceStoragePath();
const threadService = new ExtHostThreadService(remoteCom);
......
......@@ -7,9 +7,9 @@
import {IOptions} from 'vs/workbench/common/options';
import {EventType, OptionsChangeEvent} from 'vs/workbench/common/events';
import {IEventService} from 'vs/platform/event/common/event';
import {IWorkspace, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IWorkspace, WorkspaceContextService} from 'vs/platform/workspace/common/workspace';
export class LegacyWorkspaceContextService extends BaseWorkspaceContextService {
export class LegacyWorkspaceContextService extends WorkspaceContextService {
constructor(
private eventService: IEventService,
......
......@@ -10,7 +10,7 @@ import {Build, Builder} from 'vs/base/browser/builder';
import {Part} from 'vs/workbench/browser/part';
import * as Types from 'vs/base/common/types';
import * as TestUtils from 'vs/test/utils/servicesTestUtils';
import {IWorkspaceContextService, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IWorkspaceContextService, WorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IStorageService} from 'vs/platform/storage/common/storage';
import {Storage, InMemoryLocalStorage} from 'vs/workbench/common/storage';
......@@ -104,7 +104,7 @@ suite('Workbench Part', () => {
fixture = document.createElement('div');
fixture.id = fixtureId;
document.body.appendChild(fixture);
context = new BaseWorkspaceContextService(TestUtils.TestWorkspace);
context = new WorkspaceContextService(TestUtils.TestWorkspace);
storage = new Storage(new InMemoryLocalStorage(), null, context);
});
......
......@@ -7,7 +7,7 @@
import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions
import * as assert from 'assert';
import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {WorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {createSyncDescriptor} from 'vs/platform/instantiation/common/descriptors';
import {ensureStaticPlatformServices, IEditorOverrideServices} from 'vs/editor/browser/standalone/standaloneServices';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
......@@ -44,14 +44,7 @@ suite('QuickOpen performance', () => {
const telemetryService = new TestTelemetryService();
const overrides: IEditorOverrideServices = {
contextService: new BaseWorkspaceContextService({
resource: URI.file(testWorkspacePath),
id: null,
name: null,
uid: null,
mtime: null
}),
contextService: new WorkspaceContextService({ resource: URI.file(testWorkspacePath) }),
telemetryService
};
......
......@@ -6,7 +6,7 @@
'use strict';
import * as assert from 'assert';
import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {WorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {StorageScope} from 'vs/platform/storage/common/storage';
import * as TestUtils from 'vs/test/utils/servicesTestUtils';
import {Memento, Scope} from 'vs/workbench/common/memento';
......@@ -17,7 +17,7 @@ suite('Workbench Memento', () => {
let storage;
setup(() => {
context = new BaseWorkspaceContextService(TestUtils.TestWorkspace);
context = new WorkspaceContextService(TestUtils.TestWorkspace);
storage = new Storage(new InMemoryLocalStorage(), null, context);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册