diff --git a/src/vs/editor/browser/standalone/simpleServices.ts b/src/vs/editor/browser/standalone/simpleServices.ts index 769138fea5f..2058553626b 100644 --- a/src/vs/editor/browser/standalone/simpleServices.ts +++ b/src/vs/editor/browser/standalone/simpleServices.ts @@ -297,12 +297,4 @@ export class SimpleConfigurationService implements IConfigurationService { public loadConfiguration(section?: string): TPromise { return TPromise.as(this.getConfiguration(section)); } - - public hasWorkspaceConfiguration(): boolean { - return false; - } - - public setUserConfiguration(key: any, value: any): TPromise { - return TPromise.as(null); - } } diff --git a/src/vs/platform/configuration/common/configuration.ts b/src/vs/platform/configuration/common/configuration.ts index b602407957b..d04fec071da 100644 --- a/src/vs/platform/configuration/common/configuration.ts +++ b/src/vs/platform/configuration/common/configuration.ts @@ -6,7 +6,6 @@ import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; import Event from 'vs/base/common/event'; import {TPromise} from 'vs/base/common/winjs.base'; -import {JSONPath} from 'vs/base/common/json'; export const IConfigurationService = createDecorator('configurationService'); @@ -25,21 +24,10 @@ export interface IConfigurationService { */ loadConfiguration(section?: string): TPromise; - /** - * Returns iff the workspace has configuration or not. - */ - hasWorkspaceConfiguration(): boolean; - /** * Event that fires when the configuration changes. */ onDidUpdateConfiguration: Event; - - /** - * Sets a user configuration. An the setting does not yet exist in the settings, it will be - * added. - */ - setUserConfiguration(key: string | JSONPath, value: any): Thenable; } export interface IConfigurationServiceEvent { @@ -60,6 +48,6 @@ export function getConfigurationValue(config: any, settingPath: string, defau const path = settingPath.split('.'); const result = accessSetting(config, path); - + return typeof result === 'undefined' ? defaultValue : result; } \ No newline at end of file diff --git a/src/vs/platform/configuration/node/configurationService.ts b/src/vs/platform/configuration/node/configurationService.ts index 05c97057e62..b91dac45c86 100644 --- a/src/vs/platform/configuration/node/configurationService.ts +++ b/src/vs/platform/configuration/node/configurationService.ts @@ -5,7 +5,6 @@ 'use strict'; import {TPromise} from 'vs/base/common/winjs.base'; -import {JSONPath} from 'vs/base/common/json'; import * as objects from 'vs/base/common/objects'; import {getDefaultValues, flatten} from 'vs/platform/configuration/common/model'; import {ConfigWatcher} from 'vs/base/node/config'; @@ -84,14 +83,6 @@ export class ConfigurationService implements IConfigurationService, IDisposab ); } - public setUserConfiguration(key: string | JSONPath, value: any): Thenable { - return TPromise.as(null); - } - - public hasWorkspaceConfiguration(): boolean { - return false; - } - public dispose(): void { this.disposables = dispose(this.disposables); } diff --git a/src/vs/platform/telemetry/test/node/telemetryService.test.ts b/src/vs/platform/telemetry/test/node/telemetryService.test.ts index 6d8463cd43e..924619d039f 100644 --- a/src/vs/platform/telemetry/test/node/telemetryService.test.ts +++ b/src/vs/platform/telemetry/test/node/telemetryService.test.ts @@ -646,9 +646,6 @@ suite('TelemetryService', () => { appender: testAppender }, { _serviceBrand: undefined, - hasWorkspaceConfiguration() { - return false; - }, getConfiguration() { return { enableTelemetry @@ -657,10 +654,7 @@ suite('TelemetryService', () => { loadConfiguration() { return TPromise.as(this.getConfiguration()); }, - onDidUpdateConfiguration: emitter.event, - setUserConfiguration(key: any, value: any) { - return TPromise.as(null); - } + onDidUpdateConfiguration: emitter.event }); assert.equal(service.isOptedIn, false); diff --git a/src/vs/test/utils/servicesTestUtils.ts b/src/vs/test/utils/servicesTestUtils.ts index 4b357e390fe..1a6ec77a9c3 100644 --- a/src/vs/test/utils/servicesTestUtils.ts +++ b/src/vs/test/utils/servicesTestUtils.ts @@ -551,10 +551,6 @@ export class TestConfigurationService extends EventEmitter.EventEmitter implemen return this.configuration; } - public hasWorkspaceConfiguration(): boolean { - return false; - } - public setUserConfiguration(key: any, value: any): Thenable { this.configuration[key] = value; return TPromise.as(null); diff --git a/src/vs/workbench/browser/actions/openSettings.ts b/src/vs/workbench/browser/actions/openSettings.ts index f03eeafa288..a54152cecd1 100644 --- a/src/vs/workbench/browser/actions/openSettings.ts +++ b/src/vs/workbench/browser/actions/openSettings.ts @@ -17,7 +17,7 @@ import {StringEditorInput} from 'vs/workbench/common/editor/stringEditorInput'; import {getDefaultValuesContent} from 'vs/platform/configuration/common/model'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; -import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; +import {IWorkbenchConfigurationService} from 'vs/workbench/services/configuration/common/configuration'; import {Position} from 'vs/platform/editor/common/editor'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'; @@ -45,7 +45,7 @@ export class BaseTwoEditorsAction extends Action { @IWorkbenchEditorService protected editorService: IWorkbenchEditorService, @IEditorGroupService private editorGroupService: IEditorGroupService, @IFileService protected fileService: IFileService, - @IConfigurationService protected configurationService: IConfigurationService, + @IWorkbenchConfigurationService protected configurationService: IWorkbenchConfigurationService, @IMessageService protected messageService: IMessageService, @IWorkspaceContextService protected contextService: IWorkspaceContextService, @IKeybindingService protected keybindingService: IKeybindingService, @@ -94,7 +94,7 @@ export class BaseOpenSettingsAction extends BaseTwoEditorsAction { @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, @IFileService fileService: IFileService, - @IConfigurationService configurationService: IConfigurationService, + @IWorkbenchConfigurationService configurationService: IWorkbenchConfigurationService, @IMessageService messageService: IMessageService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IKeybindingService keybindingService: IKeybindingService, @@ -130,7 +130,7 @@ export class OpenGlobalSettingsAction extends BaseOpenSettingsAction { @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, @IFileService fileService: IFileService, - @IConfigurationService configurationService: IConfigurationService, + @IWorkbenchConfigurationService configurationService: IWorkbenchConfigurationService, @IMessageService messageService: IMessageService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IKeybindingService keybindingService: IKeybindingService, @@ -183,7 +183,7 @@ export class OpenGlobalKeybindingsAction extends BaseTwoEditorsAction { @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, @IFileService fileService: IFileService, - @IConfigurationService configurationService: IConfigurationService, + @IWorkbenchConfigurationService configurationService: IWorkbenchConfigurationService, @IMessageService messageService: IMessageService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IKeybindingService keybindingService: IKeybindingService, @@ -225,7 +225,7 @@ export class OpenWorkspaceSettingsAction extends BaseOpenSettingsAction { class DefaultSettingsInput extends StringEditorInput { private static INSTANCE: DefaultSettingsInput; - public static getInstance(instantiationService: IInstantiationService, configurationService: IConfigurationService): DefaultSettingsInput { + public static getInstance(instantiationService: IInstantiationService, configurationService: IWorkbenchConfigurationService): DefaultSettingsInput { if (!DefaultSettingsInput.INSTANCE) { let editorConfig = configurationService.getConfiguration(); let defaults = getDefaultValuesContent(editorConfig.editor.insertSpaces ? strings.repeat(' ', editorConfig.editor.tabSize) : '\t'); diff --git a/src/vs/workbench/parts/lib/test/node/configVariables.test.ts b/src/vs/workbench/parts/lib/test/node/configVariables.test.ts index 31173a20bef..a988c3bb31b 100644 --- a/src/vs/workbench/parts/lib/test/node/configVariables.test.ts +++ b/src/vs/workbench/parts/lib/test/node/configVariables.test.ts @@ -127,7 +127,5 @@ class MockConfigurationService implements IConfigurationService { public constructor(private configuration: any = {}) { } public loadConfiguration(section?: string): TPromise { return TPromise.as(this.getConfiguration()); } public getConfiguration(): any { return this.configuration; } - public hasWorkspaceConfiguration(): boolean { return false; } public onDidUpdateConfiguration() { return { dispose() { } }; } - public setUserConfiguration(key: any, value: any): Thenable { return TPromise.as(null); } } \ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/test/terminalConfigHelper.test.ts b/src/vs/workbench/parts/terminal/test/terminalConfigHelper.test.ts index 4b85ad8a4e2..a670fa37cf3 100644 --- a/src/vs/workbench/parts/terminal/test/terminalConfigHelper.test.ts +++ b/src/vs/workbench/parts/terminal/test/terminalConfigHelper.test.ts @@ -19,9 +19,7 @@ class MockConfigurationService implements IConfigurationService { public constructor(private configuration: any = {}) {} public loadConfiguration(section?: string): TPromise { return TPromise.as(this.getConfiguration()); } public getConfiguration(): any { return this.configuration; } - public hasWorkspaceConfiguration(): boolean { return false; } public onDidUpdateConfiguration() { return { dispose() { } }; } - public setUserConfiguration(key: any, value: any): Thenable { return TPromise.as(null); } } suite('Workbench - TerminalConfigHelper', () => { diff --git a/src/vs/workbench/services/configuration/common/configuration.ts b/src/vs/workbench/services/configuration/common/configuration.ts new file mode 100644 index 00000000000..d7eacfc0aa4 --- /dev/null +++ b/src/vs/workbench/services/configuration/common/configuration.ts @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import {JSONPath} from 'vs/base/common/json'; +import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; +import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; + +export const IWorkbenchConfigurationService = createDecorator('configurationService'); + +export interface IWorkbenchConfigurationService extends IConfigurationService { + + /** + * Returns iff the workspace has configuration or not. + */ + hasWorkspaceConfiguration(): boolean; + + /** + * Sets a user configuration. An the setting does not yet exist in the settings, it will be + * added. + */ + setUserConfiguration(key: string | JSONPath, value: any): Thenable; +} \ No newline at end of file diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/node/configurationService.ts index f89cac49f9e..5eb91bcaa16 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/node/configurationService.ts @@ -26,7 +26,8 @@ import {applyEdits} from 'vs/base/common/jsonFormatter'; import {setProperty} from 'vs/base/common/jsonEdit'; import errors = require('vs/base/common/errors'); import {IConfigFile, consolidate, CONFIG_DEFAULT_NAME, newConfigFile, getDefaultValues} from 'vs/platform/configuration/common/model'; -import {IConfigurationService, IConfigurationServiceEvent} from 'vs/platform/configuration/common/configuration'; +import {IConfigurationServiceEvent} from 'vs/platform/configuration/common/configuration'; +import {IWorkbenchConfigurationService} from 'vs/workbench/services/configuration/common/configuration'; import {EventType as FileEventType, FileChangeType, FileChangesEvent} from 'vs/platform/files/common/files'; import {IConfigurationRegistry, Extensions} from 'vs/platform/configuration/common/configurationRegistry'; import {Registry} from 'vs/platform/platform'; @@ -48,7 +49,7 @@ interface ILoadConfigResult { parseErrors?: string[]; } -export class ConfigurationService implements IConfigurationService, IDisposable { +export class ConfigurationService implements IWorkbenchConfigurationService, IDisposable { public _serviceBrand: any; @@ -347,7 +348,7 @@ export class ConfigurationService implements IConfigurationService, IDisposable if (this.reloadConfigurationScheduler) { this.reloadConfigurationScheduler.dispose(); } - + this.callOnDispose.dispose(); this._onDidUpdateConfiguration.dispose(); }