提交 9baff519 编写于 作者: D Don Jayamanne

added ability to resolve varaibles in configuration settings (variables such...

added ability to resolve varaibles in configuration settings (variables such as ${workspaceRoot} and ${env...} environment variables
上级 7039f364
......@@ -39,6 +39,7 @@ import vscode = require('vscode');
import * as paths from 'vs/base/common/paths';
import {ITelemetryService, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry';
import {MainContext, ExtHostContext, InstanceCollection} from './extHostProtocol';
import {SystemVariables} from "vs/workbench/parts/lib/node/systemVariables";
/**
* This class implements the API described in vscode.d.ts,
......@@ -93,11 +94,12 @@ export class ExtHostAPIImplementation {
) {
// Addressable instances
const col = new InstanceCollection();
const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined;
const extHostDocuments = col.define(ExtHostContext.ExtHostDocuments).set<ExtHostDocuments>(new ExtHostDocuments(threadService));
const extHostEditors = col.define(ExtHostContext.ExtHostEditors).set<ExtHostEditors>(new ExtHostEditors(threadService, extHostDocuments));
const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set<ExtHostCommands>(new ExtHostCommands(threadService, extHostEditors));
const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set<ExtHostConfiguration>(new ExtHostConfiguration());
let systemVariables = new SystemVariables(null, null, URI.file(workspacePath));
const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set<ExtHostConfiguration>(new ExtHostConfiguration(systemVariables));
const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set<ExtHostDiagnostics>(new ExtHostDiagnostics(threadService));
const languageFeatures = col.define(ExtHostContext.ExtHostLanguageFeatures).set<ExtHostLanguageFeatures>(new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostDiagnostics));
const extHostFileSystemEvent = col.define(ExtHostContext.ExtHostFileSystemEventService).set<ExtHostFileSystemEventService>(new ExtHostFileSystemEventService());
......@@ -115,7 +117,6 @@ export class ExtHostAPIImplementation {
const extHostMessageService = new ExtHostMessageService(threadService);
const extHostStatusBar = new ExtHostStatusBar(threadService);
const extHostOutputService = new ExtHostOutputService(threadService);
const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined;
const extHostWorkspace = new ExtHostWorkspace(threadService, workspacePath);
const languages = new ExtHostLanguages(threadService);
......@@ -313,7 +314,7 @@ export class ExtHostAPIImplementation {
return extHostConfiguration.onDidChangeConfiguration(listener, thisArgs, disposables);
},
getConfiguration: (section?: string):vscode.WorkspaceConfiguration => {
return extHostConfiguration.getConfiguration(section);
return extHostConfiguration.getConfiguration(section, true);
}
});
......
......@@ -8,6 +8,7 @@ import {clone} from 'vs/base/common/objects';
import {illegalState} from 'vs/base/common/errors';
import Event, {Emitter} from 'vs/base/common/event';
import {WorkspaceConfiguration} from 'vscode';
import {SystemVariables} from "vs/workbench/parts/lib/node/systemVariables";
export class ExtHostConfiguration {
......@@ -15,7 +16,7 @@ export class ExtHostConfiguration {
private _hasConfig: boolean;
private _onDidChangeConfiguration: Emitter<void>;
constructor() {
constructor(private systemVariables: SystemVariables) {
this._onDidChangeConfiguration = new Emitter<void>();
}
......@@ -29,7 +30,7 @@ export class ExtHostConfiguration {
this._onDidChangeConfiguration.fire(undefined);
}
public getConfiguration(section?: string): WorkspaceConfiguration {
public getConfiguration(section?: string, resolve: boolean = false): WorkspaceConfiguration {
if (!this._hasConfig) {
throw illegalState('missing config');
}
......@@ -49,14 +50,15 @@ export class ExtHostConfiguration {
result.has = function(key: string): boolean {
return typeof ExtHostConfiguration._lookUp(key, config) !== 'undefined';
};
let that = this;
result.get = function <T>(key: string, defaultValue?: T): T {
let result = ExtHostConfiguration._lookUp(key, config);
if (typeof result === 'undefined') {
result = defaultValue;
}
return result;
return resolve ? that.systemVariables.resolveAny(result) : result;
};
return result;
return resolve ? that.systemVariables.resolveAny(result) : result;
}
private static _lookUp(section: string, config: any) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册