From d1491f4ac54bd2045651d1448121beefee160420 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 17 Aug 2016 15:35:26 +0200 Subject: [PATCH] remove getConfiguration() from workspace service --- src/vs/platform/workspace/common/workspace.ts | 22 ------------------- .../common/workspaceContextService.ts | 10 ++------- src/vs/test/utils/servicesTestUtils.ts | 14 ++---------- src/vs/workbench/electron-browser/main.ts | 13 ++++------- src/vs/workbench/electron-browser/shell.ts | 10 ++++----- .../workbench/electron-browser/workbench.ts | 9 +++----- src/vs/workbench/node/extensionHostMain.ts | 3 +-- .../thread/electron-browser/threadService.ts | 1 - .../workspace/common/contextService.ts | 5 ++--- src/vs/workbench/test/browser/part.test.ts | 2 +- .../parts/quickOpen/quickopen.perf.test.ts | 4 ++-- .../common/editor/editorStacksModel.test.ts | 4 ++-- src/vs/workbench/test/common/memento.test.ts | 2 +- 13 files changed, 24 insertions(+), 75 deletions(-) diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 71654091cfc..68ac8d73ead 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -18,11 +18,6 @@ export interface IWorkspaceContextService { */ getWorkspace(): IWorkspace; - /** - * Provides access to the configuration object the platform is running with. - */ - getConfiguration(): IConfiguration; - /** * Provides access to the options object the platform is running with. */ @@ -75,21 +70,4 @@ export interface IWorkspace { * is just derived from the workspace name. */ uid?: number; -} - -export interface IConfiguration { - /** - * Some environmental flags - */ - env?: IEnvironment; -} - -export interface IEnvironment { - appRoot: string; - - extensionDevelopmentPath: string; - extensionTestsPath: string; - - recentFiles: string[]; - recentFolders: string[]; } \ No newline at end of file diff --git a/src/vs/platform/workspace/common/workspaceContextService.ts b/src/vs/platform/workspace/common/workspaceContextService.ts index 52c2210eed6..3d78bc4cdeb 100644 --- a/src/vs/platform/workspace/common/workspaceContextService.ts +++ b/src/vs/platform/workspace/common/workspaceContextService.ts @@ -6,7 +6,7 @@ import URI from 'vs/base/common/uri'; import paths = require('vs/base/common/paths'); -import {IWorkspaceContextService, IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService, IWorkspace} from 'vs/platform/workspace/common/workspace'; /** * Simple IWorkspaceContextService implementation to allow sharing of this service implementation @@ -19,11 +19,9 @@ export class BaseWorkspaceContextService implements IWorkspaceContextService { protected options: any; private workspace: IWorkspace; - private configuration: IConfiguration; - constructor(workspace: IWorkspace, configuration?: IConfiguration, options: any = {}) { + constructor(workspace: IWorkspace, options: any = {}) { this.workspace = workspace; - this.configuration = configuration; this.options = options; } @@ -31,10 +29,6 @@ export class BaseWorkspaceContextService implements IWorkspaceContextService { return this.workspace; } - public getConfiguration(): IConfiguration { - return this.configuration; - } - public getOptions(): any { return this.options; } diff --git a/src/vs/test/utils/servicesTestUtils.ts b/src/vs/test/utils/servicesTestUtils.ts index c6c879d7ad9..9a9a9b6755f 100644 --- a/src/vs/test/utils/servicesTestUtils.ts +++ b/src/vs/test/utils/servicesTestUtils.ts @@ -27,7 +27,7 @@ import {IEditorInput, IEditorModel, Position, Direction, IEditor, IResourceInput import {IEventService} from 'vs/platform/event/common/event'; import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService'; import {IMessageService, IConfirmation} from 'vs/platform/message/common/message'; -import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace'; +import {IWorkspace} from 'vs/platform/workspace/common/workspace'; import {ILifecycleService, ShutdownEvent} from 'vs/platform/lifecycle/common/lifecycle'; import {EditorStacksModel} from 'vs/workbench/common/editor/editorStacksModel'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; @@ -51,22 +51,16 @@ export const TestWorkspace: IWorkspace = { mtime: new Date().getTime() }; -export const TestConfiguration: IConfiguration = { - env: Object.create(null) -}; - export const TestEnvironmentService = new EnvironmentService(Objects.assign(parseArgs(process.argv), { execPath: process.execPath })); export class TestContextService implements WorkspaceContextService.IWorkspaceContextService { public _serviceBrand: any; private workspace: any; - private configuration: any; private options: any; - constructor(workspace: any = TestWorkspace, configuration: any = TestConfiguration, options: any = null) { + constructor(workspace: any = TestWorkspace, options: any = null) { this.workspace = workspace; - this.configuration = configuration; this.options = options || { globalSettings: { settings: {} @@ -78,10 +72,6 @@ export class TestContextService implements WorkspaceContextService.IWorkspaceCon return this.workspace; } - public getConfiguration(): IConfiguration { - return this.configuration; - } - public getOptions() { return this.options; } diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 6bea2edee72..59daeb13aff 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -55,11 +55,6 @@ export interface IConfiguration extends IEnvironment { export function startup(configuration: IConfiguration, globalSettings: IGlobalSettings): winjs.TPromise { - // Shell Configuration - const shellConfiguration: any = { - env: configuration - }; - // Shell Options const filesToOpen = configuration.filesToOpen && configuration.filesToOpen.length ? toInputs(configuration.filesToOpen) : null; const filesToCreate = configuration.filesToCreate && configuration.filesToCreate.length ? toInputs(configuration.filesToCreate) : null; @@ -78,7 +73,7 @@ export function startup(configuration: IConfiguration, globalSettings: IGlobalSe } // Open workbench - return openWorkbench(configuration, getWorkspace(configuration.workspacePath), shellConfiguration, shellOptions); + return openWorkbench(configuration, getWorkspace(configuration.workspacePath), shellOptions); } function toInputs(paths: IPath[]): IResourceInput[] { @@ -127,10 +122,10 @@ function getWorkspace(workspacePath: string): IWorkspace { }; } -function openWorkbench(environment: IEnvironment, workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise { +function openWorkbench(environment: IEnvironment, workspace: IWorkspace, options: IOptions): winjs.TPromise { const eventService = new EventService(); const environmentService = new EnvironmentService(environment); - const contextService = new WorkspaceContextService(eventService, workspace, configuration, options); + const contextService = new WorkspaceContextService(eventService, workspace, options); const configurationService = new ConfigurationService(contextService, eventService, environmentService); // Since the configuration service is one of the core services that is used in so many places, we initialize it @@ -148,7 +143,7 @@ function openWorkbench(environment: IEnvironment, workspace: IWorkspace, configu eventService, contextService, environmentService - }, configuration, options); + }, options); shell.open(); shell.joinCreation().then(() => { diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 1289b8d2761..080db4cdf6a 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -64,7 +64,7 @@ import {ISearchService} from 'vs/platform/search/common/search'; import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; import {ICommandService} from 'vs/platform/commands/common/commands'; import {CommandService} from 'vs/platform/commands/common/commandService'; -import {IWorkspaceContextService, IConfiguration, IWorkspace} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService, IWorkspace} from 'vs/platform/workspace/common/workspace'; import {IExtensionService} from 'vs/platform/extensions/common/extensions'; import {MainThreadModeServiceImpl} from 'vs/editor/common/services/modeServiceImpl'; import {IModeService} from 'vs/editor/common/services/modeService'; @@ -119,16 +119,14 @@ export class WorkbenchShell { private content: HTMLElement; private contentsContainer: Builder; - private configuration: IConfiguration; private workspace: IWorkspace; private options: IOptions; private workbench: Workbench; - constructor(container: HTMLElement, workspace: IWorkspace, services: ICoreServices, configuration: IConfiguration, options: IOptions) { + constructor(container: HTMLElement, workspace: IWorkspace, services: ICoreServices, options: IOptions) { this.container = container; this.workspace = workspace; - this.configuration = configuration; this.options = options; this.contextService = services.contextService; @@ -158,7 +156,7 @@ export class WorkbenchShell { } // Workbench - this.workbench = instantiationService.createInstance(Workbench, workbenchContainer.getHTMLElement(), this.workspace, this.configuration, this.options, serviceCollection); + this.workbench = instantiationService.createInstance(Workbench, workbenchContainer.getHTMLElement(), this.workspace, this.options, serviceCollection); this.workbench.startup({ onWorkbenchStarted: (customKeybindingsCount) => { this.onWorkbenchStarted(customKeybindingsCount); @@ -239,7 +237,7 @@ export class WorkbenchShell { serviceCollection.set(IWindowService, this.windowService); // Storage - const disableWorkspaceStorage = this.configuration.env.extensionTestsPath || (!this.workspace && !this.environmentService.extensionDevelopmentPath); // without workspace or in any extension test, we use inMemory storage unless we develop an extension where we want to preserve state + const disableWorkspaceStorage = this.environmentService.extensionTestsPath || (!this.workspace && !this.environmentService.extensionDevelopmentPath); // without workspace or in any extension test, we use inMemory storage unless we develop an extension where we want to preserve state this.storageService = instantiationService.createInstance(Storage, window.localStorage, disableWorkspaceStorage ? inMemoryLocalStorageInstance : window.localStorage); serviceCollection.set(IStorageService, this.storageService); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 400d513af4c..fd68a69594f 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -46,7 +46,7 @@ import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage' import {ContextMenuService} from 'vs/workbench/services/contextview/electron-browser/contextmenuService'; import {WorkbenchKeybindingService} from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; import {ContextKeyService} from 'vs/platform/contextkey/browser/contextKeyService'; -import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace'; +import {IWorkspace} from 'vs/platform/workspace/common/workspace'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; import {ContextKeyExpr, RawContextKey, IContextKeyService, IContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IActivityService} from 'vs/workbench/services/activity/common/activityService'; @@ -76,7 +76,6 @@ export const NoEditorsVisibleContext:ContextKeyExpr = EditorsVisibleContext.toNe interface WorkbenchParams { workspace?: IWorkspace; - configuration: IConfiguration; options: IOptions; serviceCollection: ServiceCollection; } @@ -131,7 +130,6 @@ export class Workbench implements IPartService { constructor( container: HTMLElement, workspace: IWorkspace, - configuration: IConfiguration, options: IOptions, serviceCollection: ServiceCollection, @IInstantiationService private instantiationService: IInstantiationService, @@ -146,7 +144,7 @@ export class Workbench implements IPartService { ) { // Validate params - this.validateParams(container, configuration, options); + this.validateParams(container, options); // If String passed in as container, try to find it in DOM if (types.isString(container)) { @@ -161,7 +159,6 @@ export class Workbench implements IPartService { this.workbenchParams = { workspace: workspace, - configuration: configuration, options: options || {}, serviceCollection }; @@ -175,7 +172,7 @@ export class Workbench implements IPartService { }); } - private validateParams(container: HTMLElement, configuration: IConfiguration, options: IOptions): void { + private validateParams(container: HTMLElement, options: IOptions): void { // Container assert.ok(container, 'Workbench requires a container to be created with'); diff --git a/src/vs/workbench/node/extensionHostMain.ts b/src/vs/workbench/node/extensionHostMain.ts index 86fb6539cfa..beb5815ef9a 100644 --- a/src/vs/workbench/node/extensionHostMain.ts +++ b/src/vs/workbench/node/extensionHostMain.ts @@ -44,7 +44,6 @@ export interface IInitData { threadService: any; contextService: { workspace: any; - configuration: any; options: any; }; } @@ -74,7 +73,7 @@ export class ExtensionHostMain { this._environment = initData.environment; - this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.configuration, initData.contextService.options); + this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.options); const workspaceStoragePath = this._getOrCreateWorkspaceStoragePath(); const threadService = new ExtHostThreadService(remoteCom); diff --git a/src/vs/workbench/services/thread/electron-browser/threadService.ts b/src/vs/workbench/services/thread/electron-browser/threadService.ts index a3d9c0cc14d..8f67b85c721 100644 --- a/src/vs/workbench/services/thread/electron-browser/threadService.ts +++ b/src/vs/workbench/services/thread/electron-browser/threadService.ts @@ -177,7 +177,6 @@ class ExtensionHostProcessManager { }, contextService: { workspace: this.contextService.getWorkspace(), - configuration: this.contextService.getConfiguration(), options: this.contextService.getOptions() }, }); diff --git a/src/vs/workbench/services/workspace/common/contextService.ts b/src/vs/workbench/services/workspace/common/contextService.ts index 7a0ef2d9e4d..ddf409f3ca3 100644 --- a/src/vs/workbench/services/workspace/common/contextService.ts +++ b/src/vs/workbench/services/workspace/common/contextService.ts @@ -8,7 +8,7 @@ import {IOptions} from 'vs/workbench/common/options'; import {EventType, OptionsChangeEvent} from 'vs/workbench/common/events'; import {IEventService} from 'vs/platform/event/common/event'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; -import {IWorkspace, IConfiguration, IWorkspaceContextService as IBaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; +import {IWorkspace, IWorkspaceContextService as IBaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspaceContextService'; export const IWorkspaceContextService = createDecorator('contextService'); @@ -33,10 +33,9 @@ export class WorkspaceContextService extends BaseWorkspaceContextService impleme constructor( private eventService: IEventService, workspace: IWorkspace, - configuration?: IConfiguration, options: any = {} ) { - super(workspace, configuration, options); + super(workspace, options); } public updateOptions(key: string, value: any): void { diff --git a/src/vs/workbench/test/browser/part.test.ts b/src/vs/workbench/test/browser/part.test.ts index 9f2e77d1f94..103da74e02b 100644 --- a/src/vs/workbench/test/browser/part.test.ts +++ b/src/vs/workbench/test/browser/part.test.ts @@ -105,7 +105,7 @@ suite('Workbench Part', () => { fixture = document.createElement('div'); fixture.id = fixtureId; document.body.appendChild(fixture); - context = new BaseWorkspaceContextService(TestUtils.TestWorkspace, TestUtils.TestConfiguration, null); + context = new BaseWorkspaceContextService(TestUtils.TestWorkspace, null); storage = new Storage(new InMemoryLocalStorage(), null, context); }); diff --git a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts index f28682a9d2e..ef668672ad1 100644 --- a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts +++ b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts @@ -21,7 +21,7 @@ import {QuickOpenHandler, IQuickOpenRegistry, Extensions} from 'vs/workbench/bro import {Registry} from 'vs/platform/platform'; import {SearchService} from 'vs/workbench/services/search/node/searchService'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; -import {TestEnvironmentService, TestConfiguration, TestEditorService, TestEditorGroupService} from 'vs/test/utils/servicesTestUtils'; +import {TestEnvironmentService, TestEditorService, TestEditorGroupService} from 'vs/test/utils/servicesTestUtils'; import {IEnvironmentService} from 'vs/platform/environment/common/environment'; import * as Timer from 'vs/base/common/timer'; import {TPromise} from 'vs/base/common/winjs.base'; @@ -50,7 +50,7 @@ suite('QuickOpen performance', () => { name: null, uid: null, mtime: null - }, TestConfiguration), + }), telemetryService }; diff --git a/src/vs/workbench/test/common/editor/editorStacksModel.test.ts b/src/vs/workbench/test/common/editor/editorStacksModel.test.ts index ee61826ab78..42ef4ef58d9 100644 --- a/src/vs/workbench/test/common/editor/editorStacksModel.test.ts +++ b/src/vs/workbench/test/common/editor/editorStacksModel.test.ts @@ -9,7 +9,7 @@ import * as assert from 'assert'; import {EditorStacksModel, EditorGroup} from 'vs/workbench/common/editor/editorStacksModel'; import {EditorInput, IFileEditorInput, IEditorIdentifier, IEditorGroup, IStacksModelChangeEvent, IEditorRegistry, Extensions as EditorExtensions, IEditorInputFactory} from 'vs/workbench/common/editor'; import URI from 'vs/base/common/uri'; -import {TestStorageService, TestConfigurationService, TestLifecycleService, TestContextService, TestWorkspace, TestConfiguration} from 'vs/test/utils/servicesTestUtils'; +import {TestStorageService, TestConfigurationService, TestLifecycleService, TestContextService, TestWorkspace} from 'vs/test/utils/servicesTestUtils'; import { TestInstantiationService } from 'vs/test/utils/instantiationTestUtils'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IStorageService} from 'vs/platform/storage/common/storage'; @@ -1384,7 +1384,7 @@ suite('Editor Stacks Model', () => { let inst = new TestInstantiationService(); inst.stub(IStorageService, new TestStorageService()); - inst.stub(IWorkspaceContextService, new TestContextService(TestWorkspace, TestConfiguration, { filesToCreate: [true] })); + inst.stub(IWorkspaceContextService, new TestContextService(TestWorkspace, { filesToCreate: [true] })); const lifecycle = new TestLifecycleService(); inst.stub(ILifecycleService, lifecycle); const config = new TestConfigurationService(); diff --git a/src/vs/workbench/test/common/memento.test.ts b/src/vs/workbench/test/common/memento.test.ts index 72411306735..dc32b740851 100644 --- a/src/vs/workbench/test/common/memento.test.ts +++ b/src/vs/workbench/test/common/memento.test.ts @@ -17,7 +17,7 @@ suite('Workbench Memento', () => { let storage; setup(() => { - context = new BaseWorkspaceContextService(TestUtils.TestWorkspace, TestUtils.TestConfiguration, null); + context = new BaseWorkspaceContextService(TestUtils.TestWorkspace, null); storage = new Storage(new InMemoryLocalStorage(), null, context); });