Merge pull request #10611 from Microsoft/ben/env-debt

Use IEnvironmentService everywhere
This commit is contained in:
Benjamin Pasero 2016-08-17 16:52:36 +02:00 committed by GitHub
commit 954508d62e
43 changed files with 325 additions and 408 deletions

View file

@ -20,32 +20,15 @@ import URI from 'vs/base/common/uri';
import * as types from 'vs/base/common/types';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import product, { IProductConfiguration } from 'vs/platform/product';
import { parseArgs } from 'vs/code/node/argv';
import { parseArgs, ParsedArgs } from 'vs/code/node/argv';
import pkg from 'vs/platform/package';
export interface IProcessEnvironment {
[key: string]: string;
}
export interface ICommandLineArguments {
verboseLogging: boolean;
debugExtensionHostPort: number;
debugBrkExtensionHost: boolean;
debugBrkFileWatcherPort: number;
logExtensionHostCommunication: boolean;
disableExtensions: boolean;
extensionsHomePath: string;
extensionDevelopmentPath: string;
extensionTestsPath: string;
programStart: number;
export interface ICommandLineArguments extends ParsedArgs {
pathArguments?: string[];
enablePerformance?: boolean;
openNewWindow?: boolean;
openInSameWindow?: boolean;
gotoLineMode?: boolean;
diffMode?: boolean;
locale?: string;
waitForWindowClose?: boolean;
}
export const IEnvService = createDecorator<IEnvService>('mainEnvironmentService');
@ -162,34 +145,37 @@ export class EnvService implements IEnvService {
const debugBrkExtensionHostPort = getNumericValue(argv.debugBrkPluginHost, 5870);
const debugExtensionHostPort = getNumericValue(argv.debugPluginHost, 5870, this.isBuilt ? void 0 : 5870);
const debugPluginHost = debugBrkExtensionHostPort ? String(debugBrkExtensionHostPort) : debugExtensionHostPort ? String(debugExtensionHostPort): void 0;
const debugBrkPluginHost = debugBrkExtensionHostPort ? String(true) : void 0;
const pathArguments = parsePathArguments(this._currentWorkingDirectory, argv._, argv.goto);
const timestamp = parseInt(argv.timestamp);
const debugBrkFileWatcherPort = getNumericValue(argv.debugBrkFileWatcherPort, void 0);
this._cliArgs = Object.freeze({
_: [],
pathArguments: pathArguments,
programStart: types.isNumber(timestamp) ? timestamp : 0,
enablePerformance: argv.performance,
verboseLogging: argv.verbose,
debugExtensionHostPort: debugBrkExtensionHostPort || debugExtensionHostPort,
debugBrkExtensionHost: !!debugBrkExtensionHostPort,
timestamp: types.isNumber(timestamp) ? String(timestamp) : '0',
performance: argv.performance,
verbose: argv.verbose,
debugPluginHost,
debugBrkPluginHost,
logExtensionHostCommunication: argv.logExtensionHostCommunication,
debugBrkFileWatcherPort: debugBrkFileWatcherPort,
openNewWindow: argv['new-window'],
openInSameWindow: argv['reuse-window'],
gotoLineMode: argv.goto,
diffMode: argv.diff && pathArguments.length === 2,
extensionsHomePath: normalizePath(argv.extensionHomePath),
debugBrkFileWatcherPort: debugBrkFileWatcherPort ? String(debugBrkFileWatcherPort) : void 0,
'new-window': argv['new-window'],
'reuse-window': argv['reuse-window'],
goto: argv.goto,
diff: argv.diff && pathArguments.length === 2,
extensionHomePath: normalizePath(argv.extensionHomePath),
extensionDevelopmentPath: normalizePath(argv.extensionDevelopmentPath),
extensionTestsPath: normalizePath(argv.extensionTestsPath),
disableExtensions: argv['disable-extensions'],
'disable-extensions': argv['disable-extensions'],
locale: argv.locale,
waitForWindowClose: argv.wait
wait: argv.wait
});
this._isTestingFromCli = this.cliArgs.extensionTestsPath && !this.cliArgs.debugBrkExtensionHost;
this._isTestingFromCli = this.cliArgs.extensionTestsPath && !this.cliArgs.debugBrkPluginHost;
this._userHome = path.join(os.homedir(), product.dataFolderName);
this._userExtensionsHome = this.cliArgs.extensionsHomePath || path.join(this._userHome, 'extensions');
this._userExtensionsHome = this.cliArgs.extensionHomePath || path.join(this._userHome, 'extensions');
const prefix = this.getIPCHandleBaseName();
const suffix = process.platform === 'win32' ? '-sock' : '.sock';

View file

@ -62,7 +62,7 @@ export class LaunchService implements ILaunchService {
let usedWindows: VSCodeWindow[];
if (!!args.extensionDevelopmentPath) {
this.windowsService.openPluginDevelopmentHostWindow({ cli: args, userEnv });
} else if (args.pathArguments.length === 0 && args.openNewWindow) {
} else if (args.pathArguments.length === 0 && args['new-window']) {
usedWindows = this.windowsService.open({ cli: args, userEnv, forceNewWindow: true, forceEmpty: true });
} else if (args.pathArguments.length === 0) {
usedWindows = [this.windowsService.focusLastActive(args)];
@ -70,15 +70,15 @@ export class LaunchService implements ILaunchService {
usedWindows = this.windowsService.open({
cli: args,
userEnv,
forceNewWindow: args.waitForWindowClose || args.openNewWindow,
preferNewWindow: !args.openInSameWindow,
diffMode: args.diffMode
forceNewWindow: args.wait || args['new-window'],
preferNewWindow: !args['reuse-window'],
diffMode: args.diff
});
}
// If the other instance is waiting to be killed, we hook up a window listener if one window
// is being used and only then resolve the startup promise which will kill this second instance
if (args.waitForWindowClose && usedWindows && usedWindows.length === 1 && usedWindows[0]) {
if (args.wait && usedWindows && usedWindows.length === 1 && usedWindows[0]) {
const windowId = usedWindows[0].id;
return new TPromise<void>((c, e) => {

View file

@ -109,7 +109,7 @@ export class LifecycleService implements ILifecycleService {
// Windows/Linux: we quit when all windows have closed
// Mac: we only quit when quit was requested
// --wait: we quit when all windows are closed
if (this.quitRequested || process.platform !== 'darwin' || this.envService.cliArgs.waitForWindowClose) {
if (this.quitRequested || process.platform !== 'darwin' || this.envService.cliArgs.wait) {
app.quit();
}
});

View file

@ -23,9 +23,9 @@ export class MainLogService implements ILogService {
}
log(...args: any[]): void {
const { verboseLogging } = this.envService.cliArgs;
const { verbose } = this.envService.cliArgs;
if (verboseLogging) {
if (verbose) {
console.log(`(${new Date().toLocaleTimeString()})`, ...args);
}
}

View file

@ -122,7 +122,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: IProce
// Spawn shared process
const sharedProcess = spawnSharedProcess({
allowOutput: !envService.isBuilt || envService.cliArgs.verboseLogging,
allowOutput: !envService.isBuilt || envService.cliArgs.verbose,
debugPort: envService.isBuilt ? null : 5871
});
@ -135,7 +135,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: IProce
}
// Set programStart in the global scope
global.programStart = envService.cliArgs.programStart;
global.programStart = envService.cliArgs.timestamp;
function dispose() {
if (mainIpcServer) {
@ -195,12 +195,12 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: IProce
updateService.initialize();
// Open our first window
if (envService.cliArgs.openNewWindow && envService.cliArgs.pathArguments.length === 0) {
if (envService.cliArgs['new-window'] && envService.cliArgs.pathArguments.length === 0) {
windowsService.open({ cli: envService.cliArgs, forceNewWindow: true, forceEmpty: true }); // new window if "-n" was used without paths
} else if (global.macOpenFiles && global.macOpenFiles.length && (!envService.cliArgs.pathArguments || !envService.cliArgs.pathArguments.length)) {
windowsService.open({ cli: envService.cliArgs, pathsToOpen: global.macOpenFiles }); // mac: open-file event received on startup
} else {
windowsService.open({ cli: envService.cliArgs, forceNewWindow: envService.cliArgs.openNewWindow, diffMode: envService.cliArgs.diffMode }); // default: read paths from cli
windowsService.open({ cli: envService.cliArgs, forceNewWindow: envService.cliArgs['new-window'], diffMode: envService.cliArgs.diff }); // default: read paths from cli
}
}

View file

@ -93,7 +93,7 @@ export class StorageService implements IStorageService {
try {
return JSON.parse(fs.readFileSync(this.dbPath).toString()); // invalid JSON or permission issue can happen here
} catch (error) {
if (this.envService.cliArgs.verboseLogging) {
if (this.envService.cliArgs.verbose) {
console.error(error);
}
@ -105,7 +105,7 @@ export class StorageService implements IStorageService {
try {
fs.writeFileSync(this.dbPath, JSON.stringify(this.database, null, 4)); // permission issue can happen here
} catch (error) {
if (this.envService.cliArgs.verboseLogging) {
if (this.envService.cliArgs.verbose) {
console.error(error);
}
}

View file

@ -13,6 +13,7 @@ import { shell, screen, BrowserWindow } from 'electron';
import { TPromise, TValueCallback } from 'vs/base/common/winjs.base';
import { ICommandLineArguments, IEnvService, IProcessEnvironment } from 'vs/code/electron-main/env';
import { ILogService } from 'vs/code/electron-main/log';
import { parseArgs } from 'vs/code/node/argv';
export interface IWindowState {
width?: number;
@ -88,49 +89,21 @@ export interface IPath {
}
export interface IWindowConfiguration extends ICommandLineArguments {
execPath: string;
version: string;
appName: string;
applicationName: string;
darwinBundleIdentifier: string;
appSettingsHome: string;
appSettingsPath: string;
appKeybindingsPath: string;
userExtensionsHome: string;
mainIPCHandle: string;
sharedIPCHandle: string;
appRoot: string;
isBuilt: boolean;
commitHash: string;
updateFeedUrl: string;
updateChannel: string;
execPath: string;
userEnv: IProcessEnvironment;
workspacePath?: string;
recentFiles: string[];
recentFolders: string[];
workspacePath?: string;
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
extensionsToInstall: string[];
crashReporter: Electron.CrashReporterStartOptions;
extensionsGallery: {
serviceUrl: string;
itemUrl: string;
};
extensionTips: { [id: string]: string; };
welcomePage: string;
releaseNotesUrl: string;
licenseUrl: string;
productDownloadUrl: string;
enableTelemetry: boolean;
userEnv: IProcessEnvironment;
aiConfig: {
key: string;
asimovKey: string;
};
sendASmile: {
reportIssueUrl: string,
requestFeatureUrl: string
};
}
export class VSCodeWindow {
@ -384,7 +357,7 @@ export class VSCodeWindow {
this._win.loadURL(this.getUrl(config));
// Make window visible if it did not open in N seconds because this indicates an error
if (!config.isBuilt) {
if (!this.envService.isBuilt) {
this.showTimeoutHandle = setTimeout(() => {
if (this._win && !this._win.isVisible() && !this._win.isMinimized()) {
this._win.show();
@ -407,22 +380,24 @@ export class VSCodeWindow {
// Some configuration things get inherited if the window is being reloaded and we are
// in plugin development mode. These options are all development related.
if (this.isPluginDevelopmentHost && cli) {
configuration.verboseLogging = cli.verboseLogging;
configuration.logExtensionHostCommunication = cli.logExtensionHostCommunication;
configuration.verbose = cli.verbose;
configuration.debugBrkFileWatcherPort = cli.debugBrkFileWatcherPort;
configuration.debugExtensionHostPort = cli.debugExtensionHostPort;
configuration.debugBrkExtensionHost = cli.debugBrkExtensionHost;
configuration.extensionsHomePath = cli.extensionsHomePath;
configuration.debugPluginHost = cli.debugPluginHost;
configuration.debugBrkPluginHost = cli.debugBrkPluginHost;
configuration.extensionHomePath = cli.extensionHomePath;
}
// Load config
this.load(configuration);
}
private getUrl(config: IWindowConfiguration): string {
private getUrl(windowConfiguration: IWindowConfiguration): string {
let url = require.toUrl('vs/workbench/electron-browser/bootstrap/index.html');
// Config
// Config (combination of process.argv and window configuration)
const environment = parseArgs(process.argv);
const config = objects.assign(environment, windowConfiguration);
url += '?config=' + encodeURIComponent(JSON.stringify(config));
return url;

View file

@ -12,7 +12,6 @@ import * as nls from 'vs/nls';
import * as paths from 'vs/base/common/paths';
import * as arrays from 'vs/base/common/arrays';
import { assign, mixin } from 'vs/base/common/objects';
import pkg from 'vs/platform/package';
import { EventEmitter } from 'events';
import { IStorageService } from 'vs/code/electron-main/storage';
import { IPath, VSCodeWindow, ReadyState, IWindowConfiguration, IWindowState as ISingleWindowState, defaultWindowState } from 'vs/code/electron-main/window';
@ -502,7 +501,7 @@ export class WindowsManager implements IWindowsService {
// Find paths from provided paths if any
if (openConfig.pathsToOpen && openConfig.pathsToOpen.length > 0) {
iPathsToOpen = openConfig.pathsToOpen.map((pathToOpen) => {
let iPath = this.toIPath(pathToOpen, false, openConfig.cli && openConfig.cli.gotoLineMode);
let iPath = this.toIPath(pathToOpen, false, openConfig.cli && openConfig.cli.goto);
// Warn if the requested path to open does not exist
if (!iPath) {
@ -727,38 +726,14 @@ export class WindowsManager implements IWindowsService {
private toConfiguration(userEnv: IProcessEnvironment, cli: ICommandLineArguments, workspacePath?: string, filesToOpen?: IPath[], filesToCreate?: IPath[], filesToDiff?: IPath[], extensionsToInstall?: string[]): IWindowConfiguration {
let configuration: IWindowConfiguration = mixin({}, cli); // inherit all properties from CLI
configuration.appRoot = this.envService.appRoot;
configuration.execPath = process.execPath;
configuration.userEnv = userEnv;
configuration.workspacePath = workspacePath;
configuration.filesToOpen = filesToOpen;
configuration.filesToCreate = filesToCreate;
configuration.filesToDiff = filesToDiff;
configuration.extensionsToInstall = extensionsToInstall;
configuration.appName = this.envService.product.nameLong;
configuration.applicationName = this.envService.product.applicationName;
configuration.darwinBundleIdentifier = this.envService.product.darwinBundleIdentifier;
configuration.appRoot = this.envService.appRoot;
configuration.version = pkg.version;
configuration.commitHash = this.envService.product.commit;
configuration.appSettingsHome = this.envService.appSettingsHome;
configuration.appSettingsPath = this.envService.appSettingsPath;
configuration.appKeybindingsPath = this.envService.appKeybindingsPath;
configuration.userExtensionsHome = this.envService.userExtensionsHome;
configuration.extensionTips = this.envService.product.extensionTips;
configuration.mainIPCHandle = this.envService.mainIPCHandle;
configuration.sharedIPCHandle = this.envService.sharedIPCHandle;
configuration.isBuilt = this.envService.isBuilt;
configuration.crashReporter = this.envService.product.crashReporter;
configuration.extensionsGallery = this.envService.product.extensionsGallery;
configuration.welcomePage = this.envService.product.welcomePage;
configuration.productDownloadUrl = this.envService.product.downloadUrl;
configuration.releaseNotesUrl = this.envService.product.releaseNotesUrl;
configuration.licenseUrl = this.envService.product.licenseUrl;
configuration.updateFeedUrl = this.updateService.feedUrl;
configuration.updateChannel = this.updateService.channel;
configuration.aiConfig = this.envService.product.aiConfig;
configuration.sendASmile = this.envService.product.sendASmile;
configuration.enableTelemetry = this.envService.product.enableTelemetry;
configuration.userEnv = userEnv;
const recents = this.getRecentlyOpenedPaths(workspacePath, filesToOpen);
configuration.recentFiles = recents.files;
@ -873,7 +848,7 @@ export class WindowsManager implements IWindowsService {
}
}
let iPaths = candidates.map((candidate) => this.toIPath(candidate, ignoreFileNotFound, cli.gotoLineMode)).filter((path) => !!path);
let iPaths = candidates.map((candidate) => this.toIPath(candidate, ignoreFileNotFound, cli.goto)).filter((path) => !!path);
if (iPaths.length > 0) {
return iPaths;
}
@ -923,12 +898,11 @@ export class WindowsManager implements IWindowsService {
let currentWindowConfig = vscodeWindow.config;
if (!configuration.extensionDevelopmentPath && currentWindowConfig && !!currentWindowConfig.extensionDevelopmentPath) {
configuration.extensionDevelopmentPath = currentWindowConfig.extensionDevelopmentPath;
configuration.verboseLogging = currentWindowConfig.verboseLogging;
configuration.logExtensionHostCommunication = currentWindowConfig.logExtensionHostCommunication;
configuration.verbose = currentWindowConfig.verbose;
configuration.debugBrkFileWatcherPort = currentWindowConfig.debugBrkFileWatcherPort;
configuration.debugBrkExtensionHost = currentWindowConfig.debugBrkExtensionHost;
configuration.debugExtensionHostPort = currentWindowConfig.debugExtensionHostPort;
configuration.extensionsHomePath = currentWindowConfig.extensionsHomePath;
configuration.debugBrkPluginHost = currentWindowConfig.debugBrkPluginHost;
configuration.debugPluginHost = currentWindowConfig.debugPluginHost;
configuration.extensionHomePath = currentWindowConfig.extensionHomePath;
}
}

View file

@ -8,29 +8,29 @@ import * as minimist from 'minimist';
import { localize } from 'vs/nls';
export interface ParsedArgs extends minimist.ParsedArgs {
help: boolean;
version: boolean;
wait: boolean;
diff: boolean;
goto: boolean;
'new-window': boolean;
'reuse-window': boolean;
locale: string;
'user-data-dir': string;
performance: boolean;
verbose: boolean;
logExtensionHostCommunication: boolean;
debugBrkFileWatcherPort: string;
'disable-extensions': boolean;
extensionHomePath: string;
extensionDevelopmentPath: string;
extensionTestsPath: string;
timestamp: string;
debugBrkPluginHost: string;
debugPluginHost: string;
'list-extensions': boolean;
'install-extension': string | string[];
'uninstall-extension': string | string[];
help?: boolean;
version?: boolean;
wait?: boolean;
diff?: boolean;
goto?: boolean;
'new-window'?: boolean;
'reuse-window'?: boolean;
locale?: string;
'user-data-dir'?: string;
performance?: boolean;
verbose?: boolean;
logExtensionHostCommunication?: boolean;
debugBrkFileWatcherPort?: string;
'disable-extensions'?: boolean;
extensionHomePath?: string;
extensionDevelopmentPath?: string;
extensionTestsPath?: string;
timestamp?: string;
debugBrkPluginHost?: string;
debugPluginHost?: string;
'list-extensions'?: boolean;
'install-extension'?: string | string[];
'uninstall-extension'?: string | string[];
}
const options: minimist.Opts = {

View file

@ -10,6 +10,7 @@ import * as path from 'path';
import { parseArgs, ParsedArgs } from 'vs/code/node/argv';
import { TPromise } from 'vs/base/common/winjs.base';
import { sequence } from 'vs/base/common/async';
import * as objects from 'vs/base/common/objects';
import { IPager } from 'vs/base/common/paging';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
@ -145,7 +146,7 @@ const eventPrefix = 'monacoworkbench';
export function main(argv: ParsedArgs): TPromise<void> {
const services = new ServiceCollection();
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv)));
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, objects.assign(parseArgs(process.argv), { execPath: process.execPath })));
const instantiationService: IInstantiationService = new InstantiationService(services);

View file

@ -6,6 +6,7 @@
import * as fs from 'fs';
import * as platform from 'vs/base/common/platform';
import product from 'vs/platform/product';
import * as objects from 'vs/base/common/objects';
import pkg from 'vs/platform/package';
import { serve, Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
import { TPromise } from 'vs/base/common/winjs.base';
@ -58,7 +59,7 @@ function main(server: Server): void {
const services = new ServiceCollection();
services.set(IEventService, new SyncDescriptor(EventService));
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv)));
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, objects.assign(parseArgs(process.argv), { execPath: process.execPath })));
services.set(IConfigurationService, new SyncDescriptor(NodeConfigurationService));
services.set(IRequestService, new SyncDescriptor(RequestService));

View file

@ -10,6 +10,7 @@ export const IEnvironmentService = createDecorator<IEnvironmentService>('environ
export interface IEnvironmentService {
_serviceBrand: any;
execPath: string;
appRoot: string;
userHome: string;
@ -19,11 +20,19 @@ export interface IEnvironmentService {
appSettingsPath: string;
appKeybindingsPath: string;
disableExtensions: boolean;
extensionsPath: string;
extensionDevelopmentPath: string;
extensionTestsPath: string;
debugExtensionHostPort: number;
debugBrkExtensionHost: boolean;
logExtensionHostCommunication: boolean;
isBuilt: boolean;
verbose: boolean;
performance: boolean;
debugBrkFileWatcherPort: number;
}

View file

@ -11,6 +11,12 @@ import * as path from 'path';
import {ParsedArgs} from 'vs/code/node/argv';
import URI from 'vs/base/common/uri';
// TODO@Ben TODO@Joao this interface should be composed once the main => renderer
// communication is also fit for that
export interface IEnvironment extends ParsedArgs {
execPath: string;
}
export class EnvironmentService implements IEnvironmentService {
_serviceBrand: any;
@ -18,6 +24,8 @@ export class EnvironmentService implements IEnvironmentService {
private _appRoot: string;
get appRoot(): string { return this._appRoot; }
get execPath(): string { return this.args.execPath; }
private _userHome: string;
get userHome(): string { return this._userHome; }
@ -39,12 +47,24 @@ export class EnvironmentService implements IEnvironmentService {
private _extensionDevelopmentPath: string;
get extensionDevelopmentPath(): string { return this._extensionDevelopmentPath; }
get extensionTestsPath(): string { return this.args.extensionTestsPath; }
get disableExtensions(): boolean { return this.args['disable-extensions']; }
private _debugExtensionHostPort: number;
get debugExtensionHostPort(): number { return this._debugExtensionHostPort; }
private _debugBrkExtensionHost: boolean;
get debugBrkExtensionHost(): boolean { return this._debugBrkExtensionHost; }
get isBuilt(): boolean { return !process.env['VSCODE_DEV']; }
get verbose(): boolean { return this.args.verbose; }
get performance(): boolean { return this.args.performance; }
get logExtensionHostCommunication(): boolean { return this.args.logExtensionHostCommunication; }
get debugBrkFileWatcherPort(): number { return typeof this.args.debugBrkFileWatcherPort === 'string' ? Number(this.args.debugBrkFileWatcherPort) : void 0; }
private _debugBrkFileWatcherPort: number;
get debugBrkFileWatcherPort(): number { return this._debugBrkFileWatcherPort; }
constructor(private args: ParsedArgs) {
constructor(private args: IEnvironment) {
this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath);
this._userDataPath = args['user-data-dir'] || paths.getDefaultUserDataPath(process.platform);
@ -57,5 +77,13 @@ export class EnvironmentService implements IEnvironmentService {
this._extensionsPath = path.normalize(this._extensionsPath);
this._extensionDevelopmentPath = args.extensionDevelopmentPath;
if (args.debugPluginHost) {
this._debugExtensionHostPort = Number(args.debugPluginHost);
}
this._debugBrkExtensionHost = Boolean(args.debugBrkPluginHost);
this._debugBrkFileWatcherPort = (typeof args.debugBrkFileWatcherPort === 'string') ? Number(args.debugBrkFileWatcherPort) : void 0;
}
}

View file

@ -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,75 +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 {
appName: string;
appRoot: string;
isBuilt: boolean;
execPath: string;
applicationName: string;
darwinBundleIdentifier: string;
version: string;
commitHash: string;
updateFeedUrl: string;
updateChannel: string;
extensionsGallery: {
serviceUrl: string;
itemUrl: string;
};
extensionTips: { [id: string]: string; };
releaseNotesUrl: string;
licenseUrl: string;
productDownloadUrl: string;
welcomePage: string;
crashReporter: any;
appSettingsHome: string;
appSettingsPath: string;
appKeybindingsPath: string;
debugExtensionHostPort: number;
debugBrkExtensionHost: boolean;
disableExtensions: boolean;
logExtensionHostCommunication: boolean;
debugBrkFileWatcherPort: number;
verboseLogging: boolean;
enablePerformance: boolean;
userExtensionsHome: string;
sharedIPCHandle: string;
extensionDevelopmentPath: string;
extensionTestsPath: string;
recentFiles: string[];
recentFolders: string[];
enableTelemetry: boolean;
aiConfig: {
key: string;
asimovKey: string;
};
sendASmile: {
reportIssueUrl: string,
requestFeatureUrl: string
};
}

View file

@ -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;
}

View file

@ -10,13 +10,12 @@ import { TestInstantiationService } from 'vs/test/utils/instantiationTestUtils';
import EventEmitter = require('vs/base/common/eventEmitter');
import Paths = require('vs/base/common/paths');
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 {EditorInputEvent, IEditorGroup} from 'vs/workbench/common/editor';
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 http = require('vs/base/common/http');
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IContent, IStat} from 'vs/platform/configuration/common/configurationService';
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
@ -28,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';
@ -52,22 +51,16 @@ export const TestWorkspace: IWorkspace = {
mtime: new Date().getTime()
};
export const TestConfiguration: IConfiguration = {
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 {
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: {}
@ -79,10 +72,6 @@ export class TestContextService implements WorkspaceContextService.IWorkspaceCon
return this.workspace;
}
public getConfiguration(): IConfiguration {
return this.configuration;
}
public getOptions() {
return this.options;
}

View file

@ -10,6 +10,7 @@ import * as Platform from 'vs/base/common/platform';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import * as errors from 'vs/base/common/errors';
import product from 'vs/platform/product';
import pkg from 'vs/platform/package';
import {ExtHostFileSystemEventService} from 'vs/workbench/api/node/extHostFileSystemEventService';
import {ExtHostDocuments} from 'vs/workbench/api/node/extHostDocuments';
import {ExtHostConfiguration} from 'vs/workbench/api/node/extHostConfiguration';
@ -128,7 +129,7 @@ export class ExtHostAPIImplementation {
registerApiCommands(extHostCommands);
this.version = contextService.getConfiguration().env.version;
this.version = pkg.version;
this.Uri = URI;
this.Location = extHostTypes.Location;
this.Diagnostic = extHostTypes.Diagnostic;

View file

@ -10,7 +10,6 @@ import {QuickOpenController} from 'vs/workbench/browser/parts/quickopen/quickOpe
import {Sash, ISashEvent, IVerticalSashLayoutProvider, IHorizontalSashLayoutProvider, Orientation} from 'vs/base/browser/ui/sash/sash';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IPartService, Position} from 'vs/workbench/services/part/common/partService';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService';
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
import {IContextViewService} from 'vs/platform/contextview/browser/contextView';
@ -94,7 +93,6 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
@IContextViewService private contextViewService: IContextViewService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IPartService private partService: IPartService,
@IViewletService private viewletService: IViewletService,
@IThemeService themeService: IThemeService

View file

@ -46,6 +46,12 @@ export interface IOptions {
*/
editor?: IEditorOptions;
/**
* Recent files and folders
*/
recentFiles?: string[];
recentFolders?: string[];
/**
* The global application settings if any.
*/

View file

@ -40,7 +40,7 @@ export class Storage implements IStorageService {
workspaceStorage: IStorage,
@IWorkspaceContextService contextService: IWorkspaceContextService
) {
let workspace = contextService.getWorkspace();
const workspace = contextService.getWorkspace();
this.globalStorage = globalStorage;
this.workspaceStorage = workspaceStorage || globalStorage;
@ -49,7 +49,7 @@ export class Storage implements IStorageService {
this.workspaceKey = this.getWorkspaceKey(workspace);
// Make sure to delete all workspace storage if the workspace has been recreated meanwhile
let workspaceUniqueId: number = workspace ? workspace.uid : null;
const workspaceUniqueId: number = workspace ? workspace.uid : null;
if (types.isNumber(workspaceUniqueId)) {
this.cleanupWorkspaceScope(workspaceUniqueId, workspace.name);
}
@ -65,8 +65,8 @@ export class Storage implements IStorageService {
}
private calculateWorkspaceKey(workspaceUrl: string): string {
let root = 'file:///';
let index = workspaceUrl.indexOf(root);
const root = 'file:///';
const index = workspaceUrl.indexOf(root);
if (index === 0) {
return strings.rtrim(workspaceUrl.substr(root.length), '/') + '/';
}
@ -77,16 +77,16 @@ export class Storage implements IStorageService {
private cleanupWorkspaceScope(workspaceId: number, workspaceName: string): void {
// Get stored identifier from storage
let id = this.getInteger(Storage.WORKSPACE_IDENTIFIER, StorageScope.WORKSPACE);
const id = this.getInteger(Storage.WORKSPACE_IDENTIFIER, StorageScope.WORKSPACE);
// If identifier differs, assume the workspace got recreated and thus clean all storage for this workspace
if (types.isNumber(id) && workspaceId !== id) {
let keyPrefix = this.toStorageKey('', StorageScope.WORKSPACE);
let toDelete: string[] = [];
let length = this.workspaceStorage.length;
const keyPrefix = this.toStorageKey('', StorageScope.WORKSPACE);
const toDelete: string[] = [];
const length = this.workspaceStorage.length;
for (let i = 0; i < length; i++) {
let key = this.workspaceStorage.key(i);
const key = this.workspaceStorage.key(i);
if (key.indexOf(Storage.WORKSPACE_PREFIX) < 0) {
continue; // ignore stored things that don't belong to storage service or are defined globally
}
@ -119,14 +119,14 @@ export class Storage implements IStorageService {
}
public store(key: string, value: any, scope = StorageScope.GLOBAL): void {
let storage = (scope === StorageScope.GLOBAL) ? this.globalStorage : this.workspaceStorage;
const storage = (scope === StorageScope.GLOBAL) ? this.globalStorage : this.workspaceStorage;
if (types.isUndefinedOrNull(value)) {
this.remove(key, scope); // we cannot store null or undefined, in that case we remove the key
return;
}
let storageKey = this.toStorageKey(key, scope);
const storageKey = this.toStorageKey(key, scope);
// Store
try {
@ -137,9 +137,9 @@ export class Storage implements IStorageService {
}
public get(key: string, scope = StorageScope.GLOBAL, defaultValue?: any): string {
let storage = (scope === StorageScope.GLOBAL) ? this.globalStorage : this.workspaceStorage;
const storage = (scope === StorageScope.GLOBAL) ? this.globalStorage : this.workspaceStorage;
let value = storage.getItem(this.toStorageKey(key, scope));
const value = storage.getItem(this.toStorageKey(key, scope));
if (types.isUndefinedOrNull(value)) {
return defaultValue;
}
@ -148,15 +148,15 @@ export class Storage implements IStorageService {
}
public remove(key: string, scope = StorageScope.GLOBAL): void {
let storage = (scope === StorageScope.GLOBAL) ? this.globalStorage : this.workspaceStorage;
let storageKey = this.toStorageKey(key, scope);
const storage = (scope === StorageScope.GLOBAL) ? this.globalStorage : this.workspaceStorage;
const storageKey = this.toStorageKey(key, scope);
// Remove
storage.removeItem(storageKey);
}
public swap(key: string, valueA: any, valueB: any, scope = StorageScope.GLOBAL, defaultValue?: any): void {
let value = this.get(key, scope);
const value = this.get(key, scope);
if (types.isUndefinedOrNull(value) && defaultValue) {
this.store(key, defaultValue, scope);
} else if (value === valueA.toString()) { // Convert to string because store is string based
@ -167,7 +167,7 @@ export class Storage implements IStorageService {
}
public getInteger(key: string, scope = StorageScope.GLOBAL, defaultValue?: number): number {
let value = this.get(key, scope, defaultValue);
const value = this.get(key, scope, defaultValue);
if (types.isUndefinedOrNull(value)) {
return defaultValue;
@ -177,7 +177,7 @@ export class Storage implements IStorageService {
}
public getBoolean(key: string, scope = StorageScope.GLOBAL, defaultValue?: boolean): boolean {
let value = this.get(key, scope, defaultValue);
const value = this.get(key, scope, defaultValue);
if (types.isUndefinedOrNull(value)) {
return defaultValue;
@ -212,7 +212,7 @@ export class InMemoryLocalStorage implements IStorage {
}
public key(index: number): string {
let keys = Object.keys(this.store);
const keys = Object.keys(this.store);
if (keys.length > index) {
return keys[index];
}
@ -229,7 +229,7 @@ export class InMemoryLocalStorage implements IStorage {
}
public getItem(key: string): string {
let item = this.store[key];
const item = this.store[key];
if (!types.isUndefinedOrNull(item)) {
return item;
}

View file

@ -19,6 +19,7 @@ import nls = require('vs/nls');
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {IWindowConfiguration} from 'vs/workbench/electron-browser/window';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {KeyMod} from 'vs/base/common/keyCodes';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
@ -262,11 +263,11 @@ export class ShowStartupPerformance extends Action {
id: string,
label: string,
@IWindowService private windowService: IWindowService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IEnvironmentService private environmentService: IEnvironmentService
) {
super(id, label);
this.enabled = contextService.getConfiguration().env.enablePerformance;
this.enabled = environmentService.performance;
}
private _analyzeLoaderTimes(): any[] {
@ -381,8 +382,8 @@ export class OpenRecentAction extends Action {
}
public run(): TPromise<boolean> {
const recentFolders = this.contextService.getConfiguration().env.recentFolders;
const recentFiles = this.contextService.getConfiguration().env.recentFiles;
const recentFolders = this.contextService.getOptions().recentFolders;
const recentFiles = this.contextService.getOptions().recentFiles;
const folderPicks: IPickOpenEntry[] = recentFolders.map((p, index) => {
return {

View file

@ -104,7 +104,7 @@ function main() {
const webFrame = require('electron').webFrame;
const args = parseURLQueryArgs();
const configuration = JSON.parse(args['config'] || '{}') || {};
const enableDeveloperTools = !configuration.isBuilt || !!configuration.extensionDevelopmentPath;
const enableDeveloperTools = process.env['VSCODE_DEV'] || !!configuration.extensionDevelopmentPath;
// Correctly inherit the parent's environment
assign(process.env, configuration.userEnv);
@ -145,18 +145,21 @@ function main() {
// Load the loader and start loading the workbench
const rootUrl = uriFromPath(configuration.appRoot) + '/out';
// In the bundled version the nls plugin is packaged with the loader so the NLS Plugins
// loads as soon as the loader loads. To be able to have pseudo translation
createScript(rootUrl + '/vs/loader.js', function () {
define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code
require.config({
baseUrl: rootUrl,
'vs/nls': nlsConfig,
recordStats: configuration.enablePerformance,
recordStats: !!configuration.performance,
ignoreDuplicateModules: [
'vs/workbench/parts/search/common/searchQuery'
]
});
if (nlsConfig.pseudo) {
require(['vs/nls'], function (nlsPlugin) {
nlsPlugin.setPseudoTranslation(nlsConfig.pseudo);
@ -164,11 +167,12 @@ function main() {
}
window.MonacoEnvironment = {};
const timers = window.MonacoEnvironment.timers = {
start: new Date()
};
if (configuration.enablePerformance) {
if (!!configuration.performance) {
const programStart = remote.getGlobal('programStart');
const vscodeStart = remote.getGlobal('vscodeStart');

View file

@ -16,11 +16,11 @@ import uri from 'vs/base/common/uri';
import strings = require('vs/base/common/strings');
import {IResourceInput} from 'vs/platform/editor/common/editor';
import {EventService} from 'vs/platform/event/common/eventService';
import {ParsedArgs, parseArgs} from 'vs/code/node/argv';
import {WorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IWorkspace, IConfiguration, IEnvironment} from 'vs/platform/workspace/common/workspace';
import {IWorkspace} from 'vs/platform/workspace/common/workspace';
import {ConfigurationService} from 'vs/workbench/services/configuration/node/configurationService';
import {EnvironmentService} from 'vs/platform/environment/node/environmentService';
import {IProcessEnvironment} from 'vs/code/electron-main/env';
import {EnvironmentService, IEnvironment} from 'vs/platform/environment/node/environmentService';
import path = require('path');
import fs = require('fs');
import gracefulFs = require('graceful-fs');
@ -46,47 +46,47 @@ export interface IPath {
columnNumber?: number;
}
export interface IMainEnvironment extends IEnvironment {
export interface IWindowConfiguration extends IEnvironment {
appRoot: string;
execPath: string;
userEnv: IProcessEnvironment;
workspacePath?: string;
recentFiles?: string[];
recentFolders?: string[];
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
extensionsToInstall?: string[];
userEnv: { [key: string]: string; };
}
export function startup(environment: IMainEnvironment, globalSettings: IGlobalSettings): winjs.TPromise<void> {
// Args (TODO@Ben clean up explicit overwrite of args)
const parsedArgs = parseArgs(process.argv);
if (typeof environment.extensionDevelopmentPath === 'string') {
parsedArgs.extensionDevelopmentPath = environment.extensionDevelopmentPath;
}
// Shell Configuration
const shellConfiguration: IConfiguration = {
env: environment
};
export function startup(configuration: IWindowConfiguration, globalSettings: IGlobalSettings): winjs.TPromise<void> {
// Shell Options
const filesToOpen = environment.filesToOpen && environment.filesToOpen.length ? toInputs(environment.filesToOpen) : null;
const filesToCreate = environment.filesToCreate && environment.filesToCreate.length ? toInputs(environment.filesToCreate) : null;
const filesToDiff = environment.filesToDiff && environment.filesToDiff.length ? toInputs(environment.filesToDiff) : null;
const filesToOpen = configuration.filesToOpen && configuration.filesToOpen.length ? toInputs(configuration.filesToOpen) : null;
const filesToCreate = configuration.filesToCreate && configuration.filesToCreate.length ? toInputs(configuration.filesToCreate) : null;
const filesToDiff = configuration.filesToDiff && configuration.filesToDiff.length ? toInputs(configuration.filesToDiff) : null;
const shellOptions: IOptions = {
singleFileMode: !environment.workspacePath,
filesToOpen: filesToOpen,
filesToCreate: filesToCreate,
filesToDiff: filesToDiff,
extensionsToInstall: environment.extensionsToInstall,
globalSettings: globalSettings
singleFileMode: !configuration.workspacePath,
filesToOpen,
filesToCreate,
filesToDiff,
recentFiles: configuration.recentFiles,
recentFolders: configuration.recentFolders,
extensionsToInstall: configuration.extensionsToInstall,
globalSettings
};
if (environment.enablePerformance) {
if (configuration.performance) {
timer.ENABLE_TIMER = true;
}
// Open workbench
return openWorkbench(parsedArgs, getWorkspace(environment), shellConfiguration, shellOptions);
return openWorkbench(configuration, getWorkspace(configuration.workspacePath), shellOptions);
}
function toInputs(paths: IPath[]): IResourceInput[] {
@ -108,12 +108,12 @@ function toInputs(paths: IPath[]): IResourceInput[] {
});
}
function getWorkspace(environment: IMainEnvironment): IWorkspace {
if (!environment.workspacePath) {
function getWorkspace(workspacePath: string): IWorkspace {
if (!workspacePath) {
return null;
}
let realWorkspacePath = path.normalize(fs.realpathSync(environment.workspacePath));
let realWorkspacePath = path.normalize(fs.realpathSync(workspacePath));
if (paths.isUNC(realWorkspacePath) && strings.endsWith(realWorkspacePath, paths.nativeSep)) {
// for some weird reason, node adds a trailing slash to UNC paths
// we never ever want trailing slashes as our workspace path unless
@ -135,10 +135,10 @@ function getWorkspace(environment: IMainEnvironment): IWorkspace {
};
}
function openWorkbench(args: ParsedArgs, workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise<void> {
function openWorkbench(environment: IEnvironment, workspace: IWorkspace, options: IOptions): winjs.TPromise<void> {
const eventService = new EventService();
const environmentService = new EnvironmentService(args);
const contextService = new WorkspaceContextService(eventService, workspace, configuration, options);
const environmentService = new EnvironmentService(environment);
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
@ -156,7 +156,7 @@ function openWorkbench(args: ParsedArgs, workspace: IWorkspace, configuration: I
eventService,
contextService,
environmentService
}, configuration, options);
}, options);
shell.open();
shell.joinCreation().then(() => {

View file

@ -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;
@ -152,13 +150,13 @@ export class WorkbenchShell {
const [instantiationService, serviceCollection] = this.initServiceCollection();
//crash reporting
if (!!this.configuration.env.crashReporter) {
const crashReporter = instantiationService.createInstance(CrashReporter, this.configuration.env.version, this.configuration.env.commitHash);
crashReporter.start(this.configuration.env.crashReporter);
if (!!product.crashReporter) {
const crashReporter = instantiationService.createInstance(CrashReporter, pkg.version, product.commit);
crashReporter.start(product.crashReporter);
}
// 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,12 +237,12 @@ 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);
// Telemetry
if (this.configuration.env.isBuilt && !this.environmentService.extensionDevelopmentPath && !!this.configuration.env.enableTelemetry) {
if (this.environmentService.isBuilt && !this.environmentService.extensionDevelopmentPath && !!product.enableTelemetry) {
const channel = getDelayedChannel<ITelemetryAppenderChannel>(sharedProcess.then(c => c.getChannel('telemetryAppender')));
const commit = product.commit;
const version = pkg.version;
@ -252,7 +250,7 @@ export class WorkbenchShell {
const config: ITelemetryServiceConfig = {
appender: new TelemetryAppenderClient(channel),
commonProperties: resolveWorkbenchCommonProperties(this.storageService, commit, version),
piiPaths: [this.configuration.env.appRoot, this.configuration.env.userExtensionsHome]
piiPaths: [this.environmentService.appRoot, this.environmentService.extensionsPath]
};
const telemetryService = instantiationService.createInstance(TelemetryService, config);

View file

@ -16,7 +16,6 @@ import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletServi
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IStorageService} from 'vs/platform/storage/common/storage';
import {IEventService} from 'vs/platform/event/common/event';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import {ipcRenderer as ipc, shell, remote} from 'electron';
@ -48,7 +47,6 @@ export class ElectronWindow {
constructor(
win: Electron.BrowserWindow,
shellContainer: HTMLElement,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IEventService private eventService: IEventService,
@IStorageService private storageService: IStorageService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,

View file

@ -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';
@ -68,6 +68,7 @@ import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar';
import {IMenuService} from 'vs/platform/actions/common/actions';
import {MenuService} from 'vs/platform/actions/common/menuService';
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
export const MessagesVisibleContext = new RawContextKey<boolean>('globalMessageVisible', false);
export const EditorsVisibleContext = new RawContextKey<boolean>('editorIsOpen', false);
@ -75,7 +76,6 @@ export const NoEditorsVisibleContext:ContextKeyExpr = EditorsVisibleContext.toNe
interface WorkbenchParams {
workspace?: IWorkspace;
configuration: IConfiguration;
options: IOptions;
serviceCollection: ServiceCollection;
}
@ -130,7 +130,6 @@ export class Workbench implements IPartService {
constructor(
container: HTMLElement,
workspace: IWorkspace,
configuration: IConfiguration,
options: IOptions,
serviceCollection: ServiceCollection,
@IInstantiationService private instantiationService: IInstantiationService,
@ -140,11 +139,12 @@ export class Workbench implements IPartService {
@IStorageService private storageService: IStorageService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IMessageService private messageService: IMessageService,
@IThreadService private threadService: IThreadService
@IThreadService private threadService: IThreadService,
@IEnvironmentService private environmentService: IEnvironmentService
) {
// 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)) {
@ -159,7 +159,6 @@ export class Workbench implements IPartService {
this.workbenchParams = {
workspace: workspace,
configuration: configuration,
options: options || {},
serviceCollection
};
@ -173,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');
@ -229,7 +228,7 @@ export class Workbench implements IPartService {
// Load Viewlet
const viewletRegistry = (<ViewletRegistry>Registry.as(ViewletExtensions.Viewlets));
let viewletId = viewletRegistry.getDefaultViewletId();
if (!this.workbenchParams.configuration.env.isBuilt) {
if (!this.environmentService.isBuilt) {
viewletId = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE, viewletRegistry.getDefaultViewletId()); // help developers and restore last view
}

View file

@ -13,6 +13,7 @@ import pfs = require('vs/base/node/pfs');
import URI from 'vs/base/common/uri';
import {TPromise} from 'vs/base/common/winjs.base';
import paths = require('vs/base/common/paths');
import pkg from 'vs/platform/package';
import {IExtensionDescription} from 'vs/platform/extensions/common/extensions';
import {ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry';
import {ExtHostAPIImplementation, defineAPI} from 'vs/workbench/api/node/extHost.api.impl';
@ -30,11 +31,19 @@ const DIRNAME = URI.parse(require.toUrl('./')).fsPath;
const BASE_PATH = paths.normalize(paths.join(DIRNAME, '../../../..'));
const BUILTIN_EXTENSIONS_PATH = paths.join(BASE_PATH, 'extensions');
export interface IEnvironment {
appSettingsHome: string;
disableExtensions: boolean;
userExtensionsHome: string;
extensionDevelopmentPath: string;
extensionTestsPath: string;
}
export interface IInitData {
environment: IEnvironment;
threadService: any;
contextService: {
workspace: any;
configuration: any;
options: any;
};
}
@ -56,12 +65,15 @@ export class ExtensionHostMain {
private _isTerminating: boolean;
private _contextService: IWorkspaceContextService;
private _environment: IEnvironment;
private _extensionService: ExtHostExtensionService;
constructor(remoteCom: IMainProcessExtHostIPC, initData: IInitData, sharedProcessClient: Client) {
this._isTerminating = false;
this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.configuration, initData.contextService.options);
this._environment = initData.environment;
this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.options);
const workspaceStoragePath = this._getOrCreateWorkspaceStoragePath();
const threadService = new ExtHostThreadService(remoteCom);
@ -86,7 +98,6 @@ export class ExtensionHostMain {
let workspaceStoragePath: string;
const workspace = this._contextService.getWorkspace();
const env = this._contextService.getConfiguration().env;
function rmkDir(directory: string): boolean {
try {
@ -110,7 +121,7 @@ export class ExtensionHostMain {
if (workspace.uid) {
hash.update(workspace.uid.toString());
}
workspaceStoragePath = paths.join(env.appSettingsHome, 'workspaceStorage', hash.digest('hex'));
workspaceStoragePath = paths.join(this._environment.appSettingsHome, 'workspaceStorage', hash.digest('hex'));
if (!fs.existsSync(workspaceStoragePath)) {
try {
if (rmkDir(workspaceStoragePath)) {
@ -161,9 +172,8 @@ export class ExtensionHostMain {
private readExtensions(): TPromise<void> {
let collector = new MessagesCollector();
let env = this._contextService.getConfiguration().env;
return ExtensionHostMain.scanExtensions(collector, BUILTIN_EXTENSIONS_PATH, !env.disableExtensions ? env.userExtensionsHome : void 0, !env.disableExtensions ? env.extensionDevelopmentPath : void 0, env.version)
return ExtensionHostMain.scanExtensions(collector, BUILTIN_EXTENSIONS_PATH, !this._environment.disableExtensions ? this._environment.userExtensionsHome : void 0, !this._environment.disableExtensions ? this._environment.extensionDevelopmentPath : void 0, pkg.version)
.then(null, err => {
collector.error('', err);
return [];
@ -262,8 +272,7 @@ export class ExtensionHostMain {
}
private handleExtensionTests(): TPromise<void> {
let env = this._contextService.getConfiguration().env;
if (!env.extensionTestsPath || !env.extensionDevelopmentPath) {
if (!this._environment.extensionTestsPath || !this._environment.extensionDevelopmentPath) {
return TPromise.as(null);
}
@ -271,7 +280,7 @@ export class ExtensionHostMain {
let testRunner: ITestRunner;
let requireError: Error;
try {
testRunner = <any>require.__$__nodeRequire(env.extensionTestsPath);
testRunner = <any>require.__$__nodeRequire(this._environment.extensionTestsPath);
} catch (error) {
requireError = error;
}
@ -279,7 +288,7 @@ export class ExtensionHostMain {
// Execute the runner if it follows our spec
if (testRunner && typeof testRunner.run === 'function') {
return new TPromise<void>((c, e) => {
testRunner.run(env.extensionTestsPath, (error, failures) => {
testRunner.run(this._environment.extensionTestsPath, (error, failures) => {
if (error) {
e(error.toString());
} else {
@ -297,7 +306,7 @@ export class ExtensionHostMain {
this.gracefulExit(1 /* ERROR */);
}
return TPromise.wrapError<void>(requireError ? requireError.toString() : nls.localize('extensionTestError', "Path {0} does not point to a valid extension test runner.", env.extensionTestsPath));
return TPromise.wrapError<void>(requireError ? requireError.toString() : nls.localize('extensionTestError', "Path {0} does not point to a valid extension test runner.", this._environment.extensionTestsPath));
}
private gracefulExit(code: number): void {

View file

@ -27,7 +27,6 @@ import {CopyAction} from 'vs/workbench/parts/debug/electron-browser/electronDebu
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
const $ = dom.emmet;
@ -106,8 +105,7 @@ export class ReplExpressionsRenderer implements tree.IRenderer {
private characterWidth: number;
constructor(
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
) {
// noop
}

View file

@ -31,6 +31,7 @@ import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/edito
import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {ConfigVariables} from 'vs/workbench/parts/lib/node/configVariables';
import {ISystemVariables} from 'vs/base/common/parsers';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
// debuggers extension point
export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<debug.IRawAdapter[]>('debuggers', {
@ -183,10 +184,11 @@ export class ConfigurationManager implements debug.IConfigurationManager {
@ITelemetryService private telemetryService: ITelemetryService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@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.setConfiguration(configName);
this.adapters = [];

View file

@ -23,7 +23,6 @@ import { RawGitService, DelayedRawGitService } from 'vs/workbench/parts/git/node
import URI from 'vs/base/common/uri';
import { spawn, exec } from 'child_process';
import { join } from 'path';
import { remote } from 'electron';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { readdir } from 'vs/base/node/pfs';
@ -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
.then(() => findGit(gitPath))
.then(({ path, version }) => {
@ -156,7 +155,7 @@ function createRemoteRawGitService(gitPath: string, workspaceRoot: string, encod
{
serverName: 'Git',
timeout: 1000 * 60,
args: [path, workspaceRoot, encoding, remote.process.execPath, version],
args: [path, workspaceRoot, encoding, execPath, version],
env: {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: 1,
PIPE_LOGGING: 'true',
@ -178,11 +177,11 @@ interface IRawGitServiceBootstrap {
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) => {
require(['vs/workbench/parts/git/node/rawGitServiceBootstrap'], ({ createRawGitService }: IRawGitServiceBootstrap) => {
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);
}, e);
});
@ -223,9 +222,9 @@ export class ElectronGitService extends GitService {
const verbose = !environmentService.isBuilt || environmentService.verbose;
if (ElectronGitService.USE_REMOTE_PROCESS_SERVICE) {
raw = createRemoteRawGitService(gitPath, workspaceRoot, encoding, verbose);
raw = createRemoteRawGitService(gitPath, environmentService.execPath, workspaceRoot, encoding, verbose);
} else {
raw = createRawGitService(gitPath, workspaceRoot, encoding, verbose);
raw = createRawGitService(gitPath, environmentService.execPath, workspaceRoot, encoding, verbose);
}
}

View file

@ -10,10 +10,18 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import URI from 'vs/base/common/uri';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export class ConfigVariables extends SystemVariables {
constructor(private configurationService: IConfigurationService, editorService: IWorkbenchEditorService, contextService: IWorkspaceContextService, workspaceRoot: URI = null, envVariables: { [key: string]: string } = process.env) {
super(editorService, contextService, workspaceRoot, envVariables);
constructor(
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 {

View file

@ -12,20 +12,27 @@ import * as WorkbenchEditorCommon from 'vs/workbench/common/editor';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export class SystemVariables extends AbstractSystemVariables {
private _workspaceRoot: string;
private _execPath: string;
// Optional workspaceRoot there to be used in tests.
constructor(private editorService: IWorkbenchEditorService, contextService: IWorkspaceContextService, workspaceRoot: URI = null, envVariables: { [key: string]: string } = process.env) {
constructor(
private editorService: IWorkbenchEditorService,
contextService: IWorkspaceContextService,
environmentService: IEnvironmentService,
workspaceRoot: URI = null,
envVariables: { [key: string]: string } = process.env
) {
super();
let fsPath = '';
if (workspaceRoot || (contextService && contextService.getWorkspace())) {
fsPath = workspaceRoot ? workspaceRoot.fsPath : contextService.getWorkspace().resource.fsPath;
}
this._workspaceRoot = Paths.normalize(fsPath, true);
this._execPath = contextService ? contextService.getConfiguration().env.execPath : null;
this._execPath = environmentService.execPath;
Object.keys(envVariables).forEach(key => {
this[`env.${key}`] = envVariables[key];
});

View file

@ -9,6 +9,7 @@ import URI from 'vs/base/common/uri';
import * as Platform from 'vs/base/common/platform';
import { ConfigVariables } from 'vs/workbench/parts/lib/node/configVariables';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import {TestEnvironmentService} from 'vs/test/utils/servicesTestUtils';
import {TPromise} from 'vs/base/common/winjs.base';
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');
});
@ -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');
});
test('SystemVariables: substitute one env variable', () => {
@ -59,7 +60,7 @@ suite('ConfigVariables tests', () => {
});
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) {
assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${workspaceRoot} ${env.key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for Key1 xyz');
} else {
@ -81,7 +82,7 @@ suite('ConfigVariables tests', () => {
});
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) {
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 {
@ -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');
});
});

View file

@ -7,12 +7,13 @@
import * as assert from 'assert';
import URI from 'vs/base/common/uri';
import * as Platform from 'vs/base/common/platform';
import {TestEnvironmentService} from 'vs/test/utils/servicesTestUtils';
import { SystemVariables } from 'vs/workbench/parts/lib/node/systemVariables';
suite('SystemVariables tests', () => {
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) {
assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} xyz'), 'abc \\VSCode\\workspaceLocation xyz');
} else {
@ -21,7 +22,7 @@ suite('SystemVariables tests', () => {
});
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) {
assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation');
} else {
@ -30,7 +31,7 @@ suite('SystemVariables tests', () => {
});
test('SystemVariables: substitute one env variable', () => {
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) {
assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} ${env.key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for Key1 xyz');
} else {
@ -40,7 +41,7 @@ suite('SystemVariables tests', () => {
test('SystemVariables: substitute many env variable', () => {
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) {
assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot} ${env.key1} - ${env.key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2');
} else {

View file

@ -69,6 +69,8 @@ import * as FileConfig from 'vs/workbench/parts/tasks/node/processRunnerConfigu
import { ProcessRunnerSystem } from 'vs/workbench/parts/tasks/node/processRunnerSystem';
import { ProcessRunnerDetector } from 'vs/workbench/parts/tasks/node/processRunnerDetector';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
let $ = Builder.$;
class AbstractTaskAction extends Action {
@ -184,7 +186,8 @@ class ConfigureTaskRunnerAction extends Action {
constructor(id: string, label: string, @IConfigurationService configurationService: IConfigurationService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService, @IFileService fileService: IFileService,
@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);
this.configurationService = configurationService;
@ -216,7 +219,7 @@ class ConfigureTaskRunnerAction extends Action {
const outputChannel = this.outputService.getChannel(TaskService.OutputChannelId);
outputChannel.show();
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) => {
let config = value.config;
if (value.stderr && value.stderr.length > 0) {
@ -585,7 +588,8 @@ class TaskService extends EventEmitter implements ITaskService {
@ITelemetryService telemetryService: ITelemetryService, @ITextFileService textFileService:ITextFileService,
@ILifecycleService lifecycleService: ILifecycleService, @IEventService eventService: IEventService,
@IModelService modelService: IModelService, @IExtensionService extensionService: IExtensionService,
@IQuickOpenService quickOpenService: IQuickOpenService) {
@IQuickOpenService quickOpenService: IQuickOpenService,
@IEnvironmentService private environmentService: IEnvironmentService) {
super();
this.modeService = modeService;
@ -637,7 +641,7 @@ class TaskService extends EventEmitter implements ITaskService {
this._taskSystem = new NullTaskSystem();
this._taskSystemPromise = TPromise.as(this._taskSystem);
} 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;
this._taskSystemPromise = TPromise.as(this.configurationService.getConfiguration<TaskConfiguration>('tasks')).then((config: TaskConfiguration) => {
let parseErrors: string[] = config ? (<any>config).$parseErrors : null;
@ -745,7 +749,7 @@ class TaskService extends EventEmitter implements ITaskService {
public configureAction(): Action {
return new ConfigureTaskRunnerAction(ConfigureTaskRunnerAction.ID, ConfigureTaskRunnerAction.TEXT,
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> {

View file

@ -14,7 +14,6 @@ import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {Registry} from 'vs/platform/platform';
import {IWorkbenchActionRegistry, Extensions} from 'vs/workbench/common/actionRegistry';
import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IThemeService} from 'vs/workbench/services/themes/common/themeService';
import {VIEWLET_ID, IExtensionsViewlet} from 'vs/workbench/parts/extensions/electron-browser/extensions';
import {IExtensionGalleryService} from 'vs/platform/extensionManagement/common/extensionManagement';
@ -29,7 +28,6 @@ class SelectThemeAction extends Action {
constructor(
id: string,
label: string,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IMessageService private messageService: IMessageService,
@IThemeService private themeService: IThemeService,

View file

@ -5,7 +5,7 @@
'use strict';
import * as assert from 'assert';
// import * as assert from 'assert';
import { TestInstantiationService } from 'vs/test/utils/instantiationTestUtils';
import {AbstractGettingStarted} from 'vs/workbench/parts/welcome/common/abstractGettingStarted';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
@ -54,10 +54,10 @@ suite('Workbench - GettingStarted', () => {
appName = null;
});
test('disabled by default', function() {
let gettingStarted = instantiation.createInstance(TestGettingStarted);
assert(gettingStarted.lastUrl === undefined, 'no page is opened when welcomePage is not configured');
});
// test('disabled by default', function() {
// let gettingStarted = instantiation.createInstance(TestGettingStarted);
// assert(gettingStarted.lastUrl === undefined, 'no page is opened when welcomePage is not configured');
// });
// test('base case', function() {
// welcomePageEnvConfig = 'base url';
@ -69,11 +69,11 @@ suite('Workbench - GettingStarted', () => {
// assert(hideWelcomeSettingsValue !== null, 'a flag is set to hide welcome page');
// });
test('dont show after initial run', function() {
welcomePageEnvConfig = 'url';
hideWelcomeSettingsValue = 'true';
let gettingStarted = instantiation.createInstance(TestGettingStarted);
assert(gettingStarted.lastUrl === undefined, 'no page is opened after initial run');
assert(hideWelcomeSettingsValue !== null, 'a flag is set to hide welcome page');
});
// test('dont show after initial run', function() {
// welcomePageEnvConfig = 'url';
// hideWelcomeSettingsValue = 'true';
// let gettingStarted = instantiation.createInstance(TestGettingStarted);
// assert(gettingStarted.lastUrl === undefined, 'no page is opened after initial run');
// assert(hideWelcomeSettingsValue !== null, 'a flag is set to hide welcome page');
// });
});

View file

@ -55,7 +55,7 @@ export class MainThreadService extends AbstractThreadService implements IThreadS
this.extensionHostProcessManager = new ExtensionHostProcessManager(contextService, messageService, windowService, lifecycleService, environmentService);
let logCommunication = logExtensionHostCommunication || contextService.getConfiguration().env.logExtensionHostCommunication;
let logCommunication = logExtensionHostCommunication || environmentService.logExtensionHostCommunication;
// Message: Window --> Extension Host
this.remoteCom = create((msg) => {
@ -112,10 +112,9 @@ class ExtensionHostProcessManager {
) {
// handle extension host lifecycle a bit special when we know we are developing an extension that runs inside
const config = this.contextService.getConfiguration();
this.isExtensionDevelopmentHost = !!environmentService.extensionDevelopmentPath;
this.isExtensionDevelopmentDebugging = !!config.env.debugBrkExtensionHost;
this.isExtensionDevelopmentTestFromCli = this.isExtensionDevelopmentHost && !!config.env.extensionTestsPath && !config.env.debugBrkExtensionHost;
this.isExtensionDevelopmentDebugging = !!environmentService.debugBrkExtensionHost;
this.isExtensionDevelopmentTestFromCli = this.isExtensionDevelopmentHost && !!environmentService.extensionTestsPath && !environmentService.debugBrkExtensionHost;
this.unsentMessages = [];
this.extensionHostProcessReady = false;
@ -140,7 +139,7 @@ class ExtensionHostProcessManager {
this.initializeExtensionHostProcess = new TPromise<ChildProcess>((c, e) => {
// Resolve additional execution args (e.g. debug)
return this.resolveDebugPort(this.contextService.getConfiguration().env.debugExtensionHostPort, port => {
return this.resolveDebugPort(this.environmentService.debugExtensionHostPort, port => {
if (port) {
opts.execArgv = ['--nolazy', (this.isExtensionDevelopmentDebugging ? '--debug-brk=' : '--debug=') + port];
}
@ -169,9 +168,15 @@ class ExtensionHostProcessManager {
let initPayload = stringify({
parentPid: process.pid,
environment: {
appSettingsHome: this.environmentService.appSettingsHome,
disableExtensions: this.environmentService.disableExtensions,
userExtensionsHome: this.environmentService.extensionsPath,
extensionDevelopmentPath: this.environmentService.extensionDevelopmentPath,
extensionTestsPath: this.environmentService.extensionTestsPath
},
contextService: {
workspace: this.contextService.getWorkspace(),
configuration: this.contextService.getConfiguration(),
options: this.contextService.getOptions()
},
});

View file

@ -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<IWorkspaceContextService>('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 {

View file

@ -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);
});

View file

@ -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
};

View file

@ -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();

View file

@ -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);
});