提交 a7da0430 编写于 作者: B Benjamin Pasero

let execPath be a property of IEnvironmentService

上级 8ddc5f32
...@@ -105,6 +105,7 @@ export interface IWindowConfiguration extends ICommandLineArguments { ...@@ -105,6 +105,7 @@ export interface IWindowConfiguration extends ICommandLineArguments {
// Used to send the main process environment over to the renderer // Used to send the main process environment over to the renderer
appRoot: string; appRoot: string;
execPath: string;
userEnv: IProcessEnvironment; userEnv: IProcessEnvironment;
} }
......
...@@ -732,6 +732,7 @@ export class WindowsManager implements IWindowsService { ...@@ -732,6 +732,7 @@ export class WindowsManager implements IWindowsService {
configuration.filesToDiff = filesToDiff; configuration.filesToDiff = filesToDiff;
configuration.extensionsToInstall = extensionsToInstall; configuration.extensionsToInstall = extensionsToInstall;
configuration.appRoot = this.envService.appRoot; configuration.appRoot = this.envService.appRoot;
configuration.execPath = process.execPath;
configuration.appSettingsHome = this.envService.appSettingsHome; configuration.appSettingsHome = this.envService.appSettingsHome;
configuration.userExtensionsHome = this.envService.userExtensionsHome; configuration.userExtensionsHome = this.envService.userExtensionsHome;
configuration.userEnv = userEnv; configuration.userEnv = userEnv;
......
...@@ -10,6 +10,7 @@ export const IEnvironmentService = createDecorator<IEnvironmentService>('environ ...@@ -10,6 +10,7 @@ export const IEnvironmentService = createDecorator<IEnvironmentService>('environ
export interface IEnvironmentService { export interface IEnvironmentService {
_serviceBrand: any; _serviceBrand: any;
execPath: string;
appRoot: string; appRoot: string;
userHome: string; userHome: string;
......
...@@ -11,6 +11,10 @@ import * as path from 'path'; ...@@ -11,6 +11,10 @@ import * as path from 'path';
import {ParsedArgs} from 'vs/code/node/argv'; import {ParsedArgs} from 'vs/code/node/argv';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
export interface IEnvironment extends ParsedArgs {
execPath: string;
}
export class EnvironmentService implements IEnvironmentService { export class EnvironmentService implements IEnvironmentService {
_serviceBrand: any; _serviceBrand: any;
...@@ -18,6 +22,8 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -18,6 +22,8 @@ export class EnvironmentService implements IEnvironmentService {
private _appRoot: string; private _appRoot: string;
get appRoot(): string { return this._appRoot; } get appRoot(): string { return this._appRoot; }
get execPath(): string { return this.args.execPath; }
private _userHome: string; private _userHome: string;
get userHome(): string { return this._userHome; } get userHome(): string { return this._userHome; }
...@@ -52,7 +58,7 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -52,7 +58,7 @@ export class EnvironmentService implements IEnvironmentService {
private _debugBrkFileWatcherPort: number; private _debugBrkFileWatcherPort: number;
get debugBrkFileWatcherPort(): number { return this._debugBrkFileWatcherPort; } get debugBrkFileWatcherPort(): number { return this._debugBrkFileWatcherPort; }
constructor(private args: ParsedArgs) { constructor(private args: IEnvironment) {
this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath); this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath);
this._userDataPath = args['user-data-dir'] || paths.getDefaultUserDataPath(process.platform); this._userDataPath = args['user-data-dir'] || paths.getDefaultUserDataPath(process.platform);
......
...@@ -10,13 +10,12 @@ import { TestInstantiationService } from 'vs/test/utils/instantiationTestUtils'; ...@@ -10,13 +10,12 @@ import { TestInstantiationService } from 'vs/test/utils/instantiationTestUtils';
import EventEmitter = require('vs/base/common/eventEmitter'); import EventEmitter = require('vs/base/common/eventEmitter');
import Paths = require('vs/base/common/paths'); import Paths = require('vs/base/common/paths');
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import {NullTelemetryService, ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import Storage = require('vs/workbench/common/storage'); import Storage = require('vs/workbench/common/storage');
import {EditorInputEvent, IEditorGroup} from 'vs/workbench/common/editor'; import {EditorInputEvent, IEditorGroup} from 'vs/workbench/common/editor';
import Event, {Emitter} from 'vs/base/common/event'; import Event, {Emitter} from 'vs/base/common/event';
import Types = require('vs/base/common/types'); import Objects = require('vs/base/common/objects');
import Severity from 'vs/base/common/severity'; import Severity from 'vs/base/common/severity';
import http = require('vs/base/common/http');
import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IContent, IStat} from 'vs/platform/configuration/common/configurationService'; import {IContent, IStat} from 'vs/platform/configuration/common/configurationService';
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'; import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
...@@ -56,7 +55,7 @@ export const TestConfiguration: IConfiguration = { ...@@ -56,7 +55,7 @@ export const TestConfiguration: IConfiguration = {
env: Object.create(null) env: Object.create(null)
}; };
export const TestEnvironmentService = new EnvironmentService(parseArgs(process.argv)); export const TestEnvironmentService = new EnvironmentService(Objects.assign(parseArgs(process.argv), { execPath: process.execPath }));
export class TestContextService implements WorkspaceContextService.IWorkspaceContextService { export class TestContextService implements WorkspaceContextService.IWorkspaceContextService {
public _serviceBrand: any; public _serviceBrand: any;
......
...@@ -16,11 +16,10 @@ import uri from 'vs/base/common/uri'; ...@@ -16,11 +16,10 @@ import uri from 'vs/base/common/uri';
import strings = require('vs/base/common/strings'); import strings = require('vs/base/common/strings');
import {IResourceInput} from 'vs/platform/editor/common/editor'; import {IResourceInput} from 'vs/platform/editor/common/editor';
import {EventService} from 'vs/platform/event/common/eventService'; import {EventService} from 'vs/platform/event/common/eventService';
import {ParsedArgs} from 'vs/code/node/argv';
import {WorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {WorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IWorkspace} from 'vs/platform/workspace/common/workspace'; import {IWorkspace} from 'vs/platform/workspace/common/workspace';
import {ConfigurationService} from 'vs/workbench/services/configuration/node/configurationService'; import {ConfigurationService} from 'vs/workbench/services/configuration/node/configurationService';
import {EnvironmentService} from 'vs/platform/environment/node/environmentService'; import {EnvironmentService, IEnvironment} from 'vs/platform/environment/node/environmentService';
import path = require('path'); import path = require('path');
import fs = require('fs'); import fs = require('fs');
import gracefulFs = require('graceful-fs'); import gracefulFs = require('graceful-fs');
...@@ -46,7 +45,7 @@ export interface IPath { ...@@ -46,7 +45,7 @@ export interface IPath {
columnNumber?: number; columnNumber?: number;
} }
export interface IConfiguration extends ParsedArgs { export interface IConfiguration extends IEnvironment {
workspacePath?: string; workspacePath?: string;
filesToOpen?: IPath[]; filesToOpen?: IPath[];
filesToCreate?: IPath[]; filesToCreate?: IPath[];
...@@ -128,7 +127,7 @@ function getWorkspace(workspacePath: string): IWorkspace { ...@@ -128,7 +127,7 @@ function getWorkspace(workspacePath: string): IWorkspace {
}; };
} }
function openWorkbench(environment: ParsedArgs, workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise<void> { function openWorkbench(environment: IEnvironment, workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise<void> {
const eventService = new EventService(); const eventService = new EventService();
const environmentService = new EnvironmentService(environment); const environmentService = new EnvironmentService(environment);
const contextService = new WorkspaceContextService(eventService, workspace, configuration, options); const contextService = new WorkspaceContextService(eventService, workspace, configuration, options);
......
...@@ -37,7 +37,7 @@ import model = require('vs/workbench/parts/debug/common/debugModel'); ...@@ -37,7 +37,7 @@ import model = require('vs/workbench/parts/debug/common/debugModel');
import {DebugStringEditorInput} from 'vs/workbench/parts/debug/browser/debugEditorInputs'; import {DebugStringEditorInput} from 'vs/workbench/parts/debug/browser/debugEditorInputs';
import viewmodel = require('vs/workbench/parts/debug/common/debugViewModel'); import viewmodel = require('vs/workbench/parts/debug/common/debugViewModel');
import debugactions = require('vs/workbench/parts/debug/browser/debugActions'); import debugactions = require('vs/workbench/parts/debug/browser/debugActions');
import {ConfigurationManager} from 'vs/workbench/parts/debug/electron-browser/debugConfigurationManager'; import {ConfigurationManager} from 'vs/workbench/parts/debug/node/debugConfigurationManager';
import {Source} from 'vs/workbench/parts/debug/common/debugSource'; import {Source} from 'vs/workbench/parts/debug/common/debugSource';
import {ITaskService, TaskEvent, TaskType, TaskServiceEvents, ITaskSummary} from 'vs/workbench/parts/tasks/common/taskService'; import {ITaskService, TaskEvent, TaskType, TaskServiceEvents, ITaskSummary} from 'vs/workbench/parts/tasks/common/taskService';
import {TaskError, TaskErrors} from 'vs/workbench/parts/tasks/common/taskSystem'; import {TaskError, TaskErrors} from 'vs/workbench/parts/tasks/common/taskSystem';
......
...@@ -29,8 +29,9 @@ import {Adapter} from 'vs/workbench/parts/debug/node/debugAdapter'; ...@@ -29,8 +29,9 @@ import {Adapter} from 'vs/workbench/parts/debug/node/debugAdapter';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService'; import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {ConfigVariables} from 'vs/workbench/parts/lib/electron-browser/configVariables'; import {ConfigVariables} from 'vs/workbench/parts/lib/node/configVariables';
import {ISystemVariables} from 'vs/base/common/parsers'; import {ISystemVariables} from 'vs/base/common/parsers';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
// debuggers extension point // debuggers extension point
export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<debug.IRawAdapter[]>('debuggers', { export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<debug.IRawAdapter[]>('debuggers', {
...@@ -183,10 +184,11 @@ export class ConfigurationManager implements debug.IConfigurationManager { ...@@ -183,10 +184,11 @@ export class ConfigurationManager implements debug.IConfigurationManager {
@ITelemetryService private telemetryService: ITelemetryService, @ITelemetryService private telemetryService: ITelemetryService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IConfigurationService private configurationService: IConfigurationService, @IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IQuickOpenService private quickOpenService: IQuickOpenService, @IQuickOpenService private quickOpenService: IQuickOpenService,
@ICommandService private commandService: ICommandService @ICommandService private commandService: ICommandService
) { ) {
this.systemVariables = this.contextService.getWorkspace() ? new ConfigVariables(this.configurationService, this.editorService, this.contextService) : null; this.systemVariables = this.contextService.getWorkspace() ? new ConfigVariables(this.configurationService, this.editorService, this.contextService, this.environmentService) : null;
this._onDidConfigurationChange = new Emitter<string>(); this._onDidConfigurationChange = new Emitter<string>();
this.setConfiguration(configName); this.setConfiguration(configName);
this.adapters = []; this.adapters = [];
......
...@@ -23,7 +23,6 @@ import { RawGitService, DelayedRawGitService } from 'vs/workbench/parts/git/node ...@@ -23,7 +23,6 @@ import { RawGitService, DelayedRawGitService } from 'vs/workbench/parts/git/node
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { spawn, exec } from 'child_process'; import { spawn, exec } from 'child_process';
import { join } from 'path'; import { join } from 'path';
import { remote } from 'electron';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { readdir } from 'vs/base/node/pfs'; import { readdir } from 'vs/base/node/pfs';
...@@ -147,7 +146,7 @@ class DisabledRawGitService extends RawGitService { ...@@ -147,7 +146,7 @@ class DisabledRawGitService extends RawGitService {
} }
} }
function createRemoteRawGitService(gitPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService { function createRemoteRawGitService(gitPath: string, execPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService {
const promise = TPromise.timeout(0) // free event loop cos finding git costs const promise = TPromise.timeout(0) // free event loop cos finding git costs
.then(() => findGit(gitPath)) .then(() => findGit(gitPath))
.then(({ path, version }) => { .then(({ path, version }) => {
...@@ -156,7 +155,7 @@ function createRemoteRawGitService(gitPath: string, workspaceRoot: string, encod ...@@ -156,7 +155,7 @@ function createRemoteRawGitService(gitPath: string, workspaceRoot: string, encod
{ {
serverName: 'Git', serverName: 'Git',
timeout: 1000 * 60, timeout: 1000 * 60,
args: [path, workspaceRoot, encoding, remote.process.execPath, version], args: [path, workspaceRoot, encoding, execPath, version],
env: { env: {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: 1, ATOM_SHELL_INTERNAL_RUN_AS_NODE: 1,
PIPE_LOGGING: 'true', PIPE_LOGGING: 'true',
...@@ -178,11 +177,11 @@ interface IRawGitServiceBootstrap { ...@@ -178,11 +177,11 @@ interface IRawGitServiceBootstrap {
createRawGitService(gitPath: string, workspaceRoot: string, defaultEncoding: string, exePath: string, version: string): TPromise<IRawGitService>; createRawGitService(gitPath: string, workspaceRoot: string, defaultEncoding: string, exePath: string, version: string): TPromise<IRawGitService>;
} }
function createRawGitService(gitPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService { function createRawGitService(gitPath: string, execPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService {
const promise = new TPromise<IRawGitService>((c, e) => { const promise = new TPromise<IRawGitService>((c, e) => {
require(['vs/workbench/parts/git/node/rawGitServiceBootstrap'], ({ createRawGitService }: IRawGitServiceBootstrap) => { require(['vs/workbench/parts/git/node/rawGitServiceBootstrap'], ({ createRawGitService }: IRawGitServiceBootstrap) => {
findGit(gitPath) findGit(gitPath)
.then(({ path, version }) => createRawGitService(path, workspaceRoot, encoding, remote.process.execPath, version)) .then(({ path, version }) => createRawGitService(path, workspaceRoot, encoding, execPath, version))
.done(c, e); .done(c, e);
}, e); }, e);
}); });
...@@ -223,9 +222,9 @@ export class ElectronGitService extends GitService { ...@@ -223,9 +222,9 @@ export class ElectronGitService extends GitService {
const verbose = !environmentService.isBuilt || environmentService.verbose; const verbose = !environmentService.isBuilt || environmentService.verbose;
if (ElectronGitService.USE_REMOTE_PROCESS_SERVICE) { if (ElectronGitService.USE_REMOTE_PROCESS_SERVICE) {
raw = createRemoteRawGitService(gitPath, workspaceRoot, encoding, verbose); raw = createRemoteRawGitService(gitPath, environmentService.execPath, workspaceRoot, encoding, verbose);
} else { } else {
raw = createRawGitService(gitPath, workspaceRoot, encoding, verbose); raw = createRawGitService(gitPath, environmentService.execPath, workspaceRoot, encoding, verbose);
} }
} }
......
...@@ -10,10 +10,18 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur ...@@ -10,10 +10,18 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export class ConfigVariables extends SystemVariables { export class ConfigVariables extends SystemVariables {
constructor(private configurationService: IConfigurationService, editorService: IWorkbenchEditorService, contextService: IWorkspaceContextService, workspaceRoot: URI = null, envVariables: { [key: string]: string } = process.env) { constructor(
super(editorService, contextService, workspaceRoot, envVariables); private configurationService: IConfigurationService,
editorService: IWorkbenchEditorService,
contextService: IWorkspaceContextService,
environmentService: IEnvironmentService,
workspaceRoot: URI = null,
envVariables: { [key: string]: string } = process.env
) {
super(editorService, contextService, environmentService, workspaceRoot, envVariables);
} }
protected resolveString(value: string): string { protected resolveString(value: string): string {
......
...@@ -12,8 +12,7 @@ import * as WorkbenchEditorCommon from 'vs/workbench/common/editor'; ...@@ -12,8 +12,7 @@ import * as WorkbenchEditorCommon from 'vs/workbench/common/editor';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { remote } from 'electron';
export class SystemVariables extends AbstractSystemVariables { export class SystemVariables extends AbstractSystemVariables {
private _workspaceRoot: string; private _workspaceRoot: string;
...@@ -23,6 +22,7 @@ export class SystemVariables extends AbstractSystemVariables { ...@@ -23,6 +22,7 @@ export class SystemVariables extends AbstractSystemVariables {
constructor( constructor(
private editorService: IWorkbenchEditorService, private editorService: IWorkbenchEditorService,
contextService: IWorkspaceContextService, contextService: IWorkspaceContextService,
environmentService: IEnvironmentService,
workspaceRoot: URI = null, workspaceRoot: URI = null,
envVariables: { [key: string]: string } = process.env envVariables: { [key: string]: string } = process.env
) { ) {
...@@ -32,7 +32,7 @@ export class SystemVariables extends AbstractSystemVariables { ...@@ -32,7 +32,7 @@ export class SystemVariables extends AbstractSystemVariables {
fsPath = workspaceRoot ? workspaceRoot.fsPath : contextService.getWorkspace().resource.fsPath; fsPath = workspaceRoot ? workspaceRoot.fsPath : contextService.getWorkspace().resource.fsPath;
} }
this._workspaceRoot = Paths.normalize(fsPath, true); this._workspaceRoot = Paths.normalize(fsPath, true);
this._execPath = remote.process.execPath; this._execPath = environmentService.execPath;
Object.keys(envVariables).forEach(key => { Object.keys(envVariables).forEach(key => {
this[`env.${key}`] = envVariables[key]; this[`env.${key}`] = envVariables[key];
}); });
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
import * as assert from 'assert'; import * as assert from 'assert';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import * as Platform from 'vs/base/common/platform'; import * as Platform from 'vs/base/common/platform';
import { ConfigVariables } from 'vs/workbench/parts/lib/electron-browser/configVariables'; import { ConfigVariables } from 'vs/workbench/parts/lib/node/configVariables';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import {TestEnvironmentService} from 'vs/test/utils/servicesTestUtils';
import {TPromise} from 'vs/base/common/winjs.base'; import {TPromise} from 'vs/base/common/winjs.base';
suite('ConfigVariables tests', () => { suite('ConfigVariables tests', () => {
...@@ -25,7 +26,7 @@ suite('ConfigVariables tests', () => { ...@@ -25,7 +26,7 @@ suite('ConfigVariables tests', () => {
} }
}); });
let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation')); let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'));
assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} xyz'), 'abc foo xyz'); assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} xyz'), 'abc foo xyz');
}); });
...@@ -42,7 +43,7 @@ suite('ConfigVariables tests', () => { ...@@ -42,7 +43,7 @@ suite('ConfigVariables tests', () => {
} }
}); });
let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation')); let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'));
assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${config.terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz'); assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${config.terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz');
}); });
test('SystemVariables: substitute one env variable', () => { test('SystemVariables: substitute one env variable', () => {
...@@ -59,7 +60,7 @@ suite('ConfigVariables tests', () => { ...@@ -59,7 +60,7 @@ suite('ConfigVariables tests', () => {
}); });
let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' };
let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables);
if (Platform.isWindows) { if (Platform.isWindows) {
assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${workspaceRoot} ${env.key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for Key1 xyz'); assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${workspaceRoot} ${env.key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for Key1 xyz');
} else { } else {
...@@ -81,7 +82,7 @@ suite('ConfigVariables tests', () => { ...@@ -81,7 +82,7 @@ suite('ConfigVariables tests', () => {
}); });
let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' };
let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables);
if (Platform.isWindows) { if (Platform.isWindows) {
assert.strictEqual(systemVariables.resolve('${config.editor.fontFamily} ${config.terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env.key1} - ${env.key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); assert.strictEqual(systemVariables.resolve('${config.editor.fontFamily} ${config.terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env.key1} - ${env.key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2');
} else { } else {
...@@ -115,7 +116,7 @@ suite('ConfigVariables tests', () => { ...@@ -115,7 +116,7 @@ suite('ConfigVariables tests', () => {
} }
}); });
let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation')); let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'));
assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${config.editor.lineNumbers} ${config.editor.insertSpaces} ${config.json.schemas[0].fileMatch[1]} xyz'), 'abc foo 123 false {{/myOtherfile}} xyz'); assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${config.editor.lineNumbers} ${config.editor.insertSpaces} ${config.json.schemas[0].fileMatch[1]} xyz'), 'abc foo 123 false {{/myOtherfile}} xyz');
}); });
}); });
......
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
import * as assert from 'assert'; import * as assert from 'assert';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import * as Platform from 'vs/base/common/platform'; import * as Platform from 'vs/base/common/platform';
import {TestEnvironmentService} from 'vs/test/utils/servicesTestUtils';
import { SystemVariables } from 'vs/workbench/parts/lib/electron-browser/systemVariables'; import { SystemVariables } from 'vs/workbench/parts/lib/node/systemVariables';
suite('SystemVariables tests', () => { suite('SystemVariables tests', () => {
test('SystemVariables: substitute one', () => { test('SystemVariables: substitute one', () => {
let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation')); let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'));
if (Platform.isWindows) { if (Platform.isWindows) {
assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} xyz'), 'abc \\VSCode\\workspaceLocation xyz'); assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} xyz'), 'abc \\VSCode\\workspaceLocation xyz');
} else { } else {
...@@ -21,7 +22,7 @@ suite('SystemVariables tests', () => { ...@@ -21,7 +22,7 @@ suite('SystemVariables tests', () => {
}); });
test('SystemVariables: substitute many', () => { test('SystemVariables: substitute many', () => {
let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation')); let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'));
if (Platform.isWindows) { if (Platform.isWindows) {
assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation'); assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation');
} else { } else {
...@@ -30,7 +31,7 @@ suite('SystemVariables tests', () => { ...@@ -30,7 +31,7 @@ suite('SystemVariables tests', () => {
}); });
test('SystemVariables: substitute one env variable', () => { test('SystemVariables: substitute one env variable', () => {
let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' };
let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables);
if (Platform.isWindows) { if (Platform.isWindows) {
assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} ${env.key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for Key1 xyz'); assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} ${env.key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for Key1 xyz');
} else { } else {
...@@ -40,7 +41,7 @@ suite('SystemVariables tests', () => { ...@@ -40,7 +41,7 @@ suite('SystemVariables tests', () => {
test('SystemVariables: substitute many env variable', () => { test('SystemVariables: substitute many env variable', () => {
let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' };
let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables);
if (Platform.isWindows) { if (Platform.isWindows) {
assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot} ${env.key1} - ${env.key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot} ${env.key1} - ${env.key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2');
} else { } else {
......
...@@ -56,7 +56,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService'; ...@@ -56,7 +56,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { ConfigVariables } from 'vs/workbench/parts/lib/electron-browser/configVariables'; import { ConfigVariables } from 'vs/workbench/parts/lib/node/configVariables';
import { ITextFileService, EventType } from 'vs/workbench/parts/files/common/files'; import { ITextFileService, EventType } from 'vs/workbench/parts/files/common/files';
import { IOutputService, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannel } from 'vs/workbench/parts/output/common/output'; import { IOutputService, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannel } from 'vs/workbench/parts/output/common/output';
...@@ -65,9 +65,11 @@ import { ITaskService, TaskServiceEvents } from 'vs/workbench/parts/tasks/common ...@@ -65,9 +65,11 @@ import { ITaskService, TaskServiceEvents } from 'vs/workbench/parts/tasks/common
import { templates as taskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates'; import { templates as taskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates';
import { LanguageServiceTaskSystem, LanguageServiceTaskConfiguration } from 'vs/workbench/parts/tasks/common/languageServiceTaskSystem'; import { LanguageServiceTaskSystem, LanguageServiceTaskConfiguration } from 'vs/workbench/parts/tasks/common/languageServiceTaskSystem';
import * as FileConfig from 'vs/workbench/parts/tasks/electron-browser/processRunnerConfiguration'; import * as FileConfig from 'vs/workbench/parts/tasks/node/processRunnerConfiguration';
import { ProcessRunnerSystem } from 'vs/workbench/parts/tasks/electron-browser/processRunnerSystem'; import { ProcessRunnerSystem } from 'vs/workbench/parts/tasks/node/processRunnerSystem';
import { ProcessRunnerDetector } from 'vs/workbench/parts/tasks/electron-browser/processRunnerDetector'; import { ProcessRunnerDetector } from 'vs/workbench/parts/tasks/node/processRunnerDetector';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
let $ = Builder.$; let $ = Builder.$;
...@@ -184,7 +186,8 @@ class ConfigureTaskRunnerAction extends Action { ...@@ -184,7 +186,8 @@ class ConfigureTaskRunnerAction extends Action {
constructor(id: string, label: string, @IConfigurationService configurationService: IConfigurationService, constructor(id: string, label: string, @IConfigurationService configurationService: IConfigurationService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService, @IFileService fileService: IFileService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IFileService fileService: IFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService, @IOutputService outputService: IOutputService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IOutputService outputService: IOutputService,
@IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService) { @IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService,
@IEnvironmentService private environmentService: IEnvironmentService) {
super(id, label); super(id, label);
this.configurationService = configurationService; this.configurationService = configurationService;
...@@ -216,7 +219,7 @@ class ConfigureTaskRunnerAction extends Action { ...@@ -216,7 +219,7 @@ class ConfigureTaskRunnerAction extends Action {
const outputChannel = this.outputService.getChannel(TaskService.OutputChannelId); const outputChannel = this.outputService.getChannel(TaskService.OutputChannelId);
outputChannel.show(); outputChannel.show();
outputChannel.append(nls.localize('ConfigureTaskRunnerAction.autoDetecting', 'Auto detecting tasks for {0}', selection.id) + '\n'); outputChannel.append(nls.localize('ConfigureTaskRunnerAction.autoDetecting', 'Auto detecting tasks for {0}', selection.id) + '\n');
let detector = new ProcessRunnerDetector(this.fileService, this.contextService, new ConfigVariables(this.configurationService, this.editorService, this.contextService)); let detector = new ProcessRunnerDetector(this.fileService, this.contextService, new ConfigVariables(this.configurationService, this.editorService, this.contextService, this.environmentService));
contentPromise = detector.detect(false, selection.id).then((value) => { contentPromise = detector.detect(false, selection.id).then((value) => {
let config = value.config; let config = value.config;
if (value.stderr && value.stderr.length > 0) { if (value.stderr && value.stderr.length > 0) {
...@@ -585,7 +588,8 @@ class TaskService extends EventEmitter implements ITaskService { ...@@ -585,7 +588,8 @@ class TaskService extends EventEmitter implements ITaskService {
@ITelemetryService telemetryService: ITelemetryService, @ITextFileService textFileService:ITextFileService, @ITelemetryService telemetryService: ITelemetryService, @ITextFileService textFileService:ITextFileService,
@ILifecycleService lifecycleService: ILifecycleService, @IEventService eventService: IEventService, @ILifecycleService lifecycleService: ILifecycleService, @IEventService eventService: IEventService,
@IModelService modelService: IModelService, @IExtensionService extensionService: IExtensionService, @IModelService modelService: IModelService, @IExtensionService extensionService: IExtensionService,
@IQuickOpenService quickOpenService: IQuickOpenService) { @IQuickOpenService quickOpenService: IQuickOpenService,
@IEnvironmentService private environmentService: IEnvironmentService) {
super(); super();
this.modeService = modeService; this.modeService = modeService;
...@@ -637,7 +641,7 @@ class TaskService extends EventEmitter implements ITaskService { ...@@ -637,7 +641,7 @@ class TaskService extends EventEmitter implements ITaskService {
this._taskSystem = new NullTaskSystem(); this._taskSystem = new NullTaskSystem();
this._taskSystemPromise = TPromise.as(this._taskSystem); this._taskSystemPromise = TPromise.as(this._taskSystem);
} else { } else {
let variables = new ConfigVariables(this.configurationService, this.editorService, this.contextService); let variables = new ConfigVariables(this.configurationService, this.editorService, this.contextService, this.environmentService);
let clearOutput = true; let clearOutput = true;
this._taskSystemPromise = TPromise.as(this.configurationService.getConfiguration<TaskConfiguration>('tasks')).then((config: TaskConfiguration) => { this._taskSystemPromise = TPromise.as(this.configurationService.getConfiguration<TaskConfiguration>('tasks')).then((config: TaskConfiguration) => {
let parseErrors: string[] = config ? (<any>config).$parseErrors : null; let parseErrors: string[] = config ? (<any>config).$parseErrors : null;
...@@ -745,7 +749,7 @@ class TaskService extends EventEmitter implements ITaskService { ...@@ -745,7 +749,7 @@ class TaskService extends EventEmitter implements ITaskService {
public configureAction(): Action { public configureAction(): Action {
return new ConfigureTaskRunnerAction(ConfigureTaskRunnerAction.ID, ConfigureTaskRunnerAction.TEXT, return new ConfigureTaskRunnerAction(ConfigureTaskRunnerAction.ID, ConfigureTaskRunnerAction.TEXT,
this.configurationService, this.editorService, this.fileService, this.contextService, this.configurationService, this.editorService, this.fileService, this.contextService,
this.outputService, this.messageService, this.quickOpenService); this.outputService, this.messageService, this.quickOpenService, this.environmentService);
} }
public build(): TPromise<ITaskSummary> { public build(): TPromise<ITaskSummary> {
......
...@@ -14,7 +14,7 @@ import { LineProcess } from 'vs/base/node/processes'; ...@@ -14,7 +14,7 @@ import { LineProcess } from 'vs/base/node/processes';
import { IFileService } from 'vs/platform/files/common/files'; import { IFileService } from 'vs/platform/files/common/files';
import { SystemVariables } from 'vs/workbench/parts/lib/electron-browser/systemVariables'; import { SystemVariables } from 'vs/workbench/parts/lib/node/systemVariables';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import * as FileConfig from './processRunnerConfiguration'; import * as FileConfig from './processRunnerConfiguration';
......
...@@ -11,7 +11,7 @@ import * as Platform from 'vs/base/common/platform'; ...@@ -11,7 +11,7 @@ import * as Platform from 'vs/base/common/platform';
import { ProblemMatcher, FileLocationKind, ProblemPattern, ApplyToKind } from 'vs/platform/markers/common/problemMatcher'; import { ProblemMatcher, FileLocationKind, ProblemPattern, ApplyToKind } from 'vs/platform/markers/common/problemMatcher';
import * as TaskSystem from 'vs/workbench/parts/tasks/common/taskSystem'; import * as TaskSystem from 'vs/workbench/parts/tasks/common/taskSystem';
import { parse, ParseResult, ILogger, ExternalTaskRunnerConfiguration } from 'vs/workbench/parts/tasks/electron-browser/processRunnerConfiguration'; import { parse, ParseResult, ILogger, ExternalTaskRunnerConfiguration } from 'vs/workbench/parts/tasks/node/processRunnerConfiguration';
class Logger implements ILogger { class Logger implements ILogger {
public receivedMessage: boolean = false; public receivedMessage: boolean = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册