提交 a5248f36 编写于 作者: S Sandeep Somavarapu

#28538 Proposed API to read configuration in a multi root workspace

上级 fbfe7007
......@@ -353,6 +353,15 @@ declare module 'vscode' {
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
export function getConfiguration2(section?: string, resource?: Uri): WorkspaceConfiguration2;
}
export interface WorkspaceConfiguration2 extends WorkspaceConfiguration {
inspect<T>(section: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, folderValue?: T } | undefined;
}
export namespace window {
......
......@@ -429,6 +429,9 @@ export function createApiFactory(
getConfiguration: (section?: string): vscode.WorkspaceConfiguration => {
return extHostConfiguration.getConfiguration(section);
},
getConfiguration2: proposedApiFunction(extension, (section?: string, resource?: vscode.Uri): vscode.WorkspaceConfiguration => {
return extHostConfiguration.getConfiguration(section, <URI>resource);
}),
registerTaskProvider: proposedApiFunction(extension, (type: string, provider: vscode.TaskProvider) => {
return extHostTask.registerTaskProvider(extension, provider);
})
......
......@@ -5,6 +5,7 @@
'use strict';
import { mixin } from 'vs/base/common/objects';
import URI from 'vs/base/common/uri';
import Event, { Emitter } from 'vs/base/common/event';
import { WorkspaceConfiguration } from 'vscode';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
......@@ -46,11 +47,11 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
this._onDidChangeConfiguration.fire(undefined);
}
getConfiguration(section?: string): WorkspaceConfiguration {
getConfiguration(section?: string, resource?: URI): WorkspaceConfiguration {
const config = section
? lookUp(this._configuration.getValue(), section)
: this._configuration.getValue();
? lookUp(this._configuration.getValue(null, { resource }), section)
: this._configuration.getValue(null, { resource });
const result: WorkspaceConfiguration = {
has(key: string): boolean {
......@@ -72,7 +73,7 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
return this._proxy.$removeConfigurationOption(target, key);
}
},
inspect: <T>(key: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T } => {
inspect: <T>(key: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, folderValue?: T } => {
key = section ? `${section}.${key}` : key;
const config = this._configuration.values()[key];
if (config) {
......@@ -80,7 +81,8 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
key,
defaultValue: config.default,
globalValue: config.user,
workspaceValue: config.workspace
workspaceValue: config.workspace,
folderValue: config.folder
};
}
return undefined;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册