From d2a413ee9a2e6491847d33d33f95a266768df95f Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 17 Aug 2016 07:22:02 +0200 Subject: [PATCH] more use of IEnvironmentService --- src/vs/code/node/cliProcessMain.ts | 4 +- src/vs/code/node/sharedProcessMain.ts | 3 +- .../environment/common/environment.ts | 5 ++- .../environment/node/environmentService.ts | 10 ++--- src/vs/platform/product.ts | 11 ++++-- .../api/node/mainThreadExtensionService.ts | 11 +++--- src/vs/workbench/electron-browser/main.ts | 13 +++++-- src/vs/workbench/electron-browser/shell.ts | 4 +- .../electron-browser/textFileServices.ts | 6 ++- .../electron-browser/electronGitService.ts | 4 +- .../files/electron-browser/fileService.ts | 15 +++---- .../services/history/browser/history.ts | 9 +++-- .../services/search/node/searchService.ts | 5 ++- .../thread/electron-browser/threadService.ts | 39 ++++++++++--------- 14 files changed, 82 insertions(+), 57 deletions(-) diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index 5f34d0ba1fb..b7c6419e073 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -7,7 +7,7 @@ import { localize } from 'vs/nls'; import product from 'vs/platform/product'; import pkg from 'vs/platform/package'; import * as path from 'path'; -import { ParsedArgs } from 'vs/code/node/argv'; +import { parseArgs, ParsedArgs } from 'vs/code/node/argv'; import { TPromise } from 'vs/base/common/winjs.base'; import { sequence } from 'vs/base/common/async'; import { IPager } from 'vs/base/common/paging'; @@ -144,7 +144,7 @@ const eventPrefix = 'monacoworkbench'; export function main(argv: ParsedArgs): TPromise { const services = new ServiceCollection(); - services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService)); + services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv))); const instantiationService: IInstantiationService = new InstantiationService(services); diff --git a/src/vs/code/node/sharedProcessMain.ts b/src/vs/code/node/sharedProcessMain.ts index 51ee0ab1c1b..7efa3076c2f 100644 --- a/src/vs/code/node/sharedProcessMain.ts +++ b/src/vs/code/node/sharedProcessMain.ts @@ -14,6 +14,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { parseArgs } from 'vs/code/node/argv'; import { IEventService } from 'vs/platform/event/common/event'; import { EventService } from 'vs/platform/event/common/eventService'; import { ExtensionManagementChannel } from 'vs/platform/extensionManagement/common/extensionManagementIpc'; @@ -57,7 +58,7 @@ function main(server: Server): void { const services = new ServiceCollection(); services.set(IEventService, new SyncDescriptor(EventService)); - services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService)); + services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv))); services.set(IConfigurationService, new SyncDescriptor(NodeConfigurationService)); services.set(IRequestService, new SyncDescriptor(RequestService)); diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index d50f7d71bc9..93ec5be66d4 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -12,7 +12,7 @@ export interface IEnvironmentService { _serviceBrand: any; appRoot: string; - + userHome: string; userDataPath: string; @@ -24,6 +24,9 @@ export interface IEnvironmentService { extensionDevelopmentPath: string; isBuilt: boolean; + verbose: boolean; + + debugBrkFileWatcherPort: number; createPaths(): TPromise; } \ No newline at end of file diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 571f05fb14d..7d2a61e150e 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -10,7 +10,7 @@ import pkg from 'vs/platform/package'; import * as os from 'os'; import * as path from 'path'; import {mkdirp} from 'vs/base/node/pfs'; -import {parseArgs} from 'vs/code/node/argv'; +import {ParsedArgs} from 'vs/code/node/argv'; import URI from 'vs/base/common/uri'; import {TPromise} from 'vs/base/common/winjs.base'; @@ -43,10 +43,11 @@ export class EnvironmentService implements IEnvironmentService { get extensionDevelopmentPath(): string { return this._extensionDevelopmentPath; } get isBuilt(): boolean { return !process.env['VSCODE_DEV']; } + get verbose(): boolean { return this.argv.verbose; } - constructor() { - const argv = parseArgs(process.argv); + get debugBrkFileWatcherPort(): number { return typeof this.argv.debugBrkFileWatcherPort === 'string' ? Number(this.argv.debugBrkFileWatcherPort) : void 0; } + constructor(private argv: ParsedArgs) { this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath); this._userDataPath = paths.getUserDataPath(process.platform, pkg.name, process.argv); @@ -62,8 +63,7 @@ export class EnvironmentService implements IEnvironmentService { } createPaths(): TPromise { - const promises = [this.userHome, this.extensionsPath] - .map(p => mkdirp(p)); + const promises = [this.userHome, this.extensionsPath].map(p => mkdirp(p)); return TPromise.join(promises) as TPromise; } diff --git a/src/vs/platform/product.ts b/src/vs/platform/product.ts index 720faaaad87..31f64376bc2 100644 --- a/src/vs/platform/product.ts +++ b/src/vs/platform/product.ts @@ -47,9 +47,14 @@ export interface IProductConfiguration { npsSurveyUrl: string; } -const rootPath = path.dirname(uri.parse(require.toUrl('')).fsPath); -const productJsonPath = path.join(rootPath, 'product.json'); -const product = require.__$__nodeRequire(productJsonPath) as IProductConfiguration; +let product: IProductConfiguration; +try { + const rootPath = path.dirname(uri.parse(require.toUrl('')).fsPath); + const productJsonPath = path.join(rootPath, 'product.json'); + product = require.__$__nodeRequire(productJsonPath) as IProductConfiguration; +} catch (error) { + product = Object.create(null); // can happen in environments where product.json is missing (e.g. when used from tests) +} if (process.env['VSCODE_DEV']) { product.nameShort += ' Dev'; diff --git a/src/vs/workbench/api/node/mainThreadExtensionService.ts b/src/vs/workbench/api/node/mainThreadExtensionService.ts index 4a19404288c..bcfa0929d2d 100644 --- a/src/vs/workbench/api/node/mainThreadExtensionService.ts +++ b/src/vs/workbench/api/node/mainThreadExtensionService.ts @@ -11,8 +11,8 @@ import {IMessage, IExtensionDescription, IExtensionsStatus} from 'vs/platform/ex import {ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry'; import {IMessageService} from 'vs/platform/message/common/message'; import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; -import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {ExtHostContext, ExtHostExtensionServiceShape} from './extHost.protocol'; +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; /** * Represents a failed extension in the ext host. @@ -33,7 +33,7 @@ class MainProcessSuccessExtension extends ActivatedExtension { } } -function messageWithSource(msg:IMessage): string { +function messageWithSource(msg: IMessage): string { return (msg.source ? '[' + msg.source + ']: ' : '') + msg.message; } @@ -49,13 +49,12 @@ export class MainProcessExtensionService extends AbstractExtensionService { + // 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 @@ -79,7 +86,7 @@ export function startup(environment: IMainEnvironment, globalSettings: IGlobalSe } // Open workbench - return openWorkbench(getWorkspace(environment), shellConfiguration, shellOptions); + return openWorkbench(parsedArgs, getWorkspace(environment), shellConfiguration, shellOptions); } function toInputs(paths: IPath[]): IResourceInput[] { @@ -128,9 +135,9 @@ function getWorkspace(environment: IMainEnvironment): IWorkspace { }; } -function openWorkbench(workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise { +function openWorkbench(args: ParsedArgs, workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise { const eventService = new EventService(); - const environmentService = new EnvironmentService(); + const environmentService = new EnvironmentService(args); const contextService = new WorkspaceContextService(eventService, workspace, configuration, options); const configurationService = new ConfigurationService(contextService, eventService); diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index cb914396331..5dd766bda93 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -237,12 +237,12 @@ export class WorkbenchShell { serviceCollection.set(IWindowService, this.windowService); // Storage - const disableWorkspaceStorage = this.configuration.env.extensionTestsPath || (!this.workspace && !this.configuration.env.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.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 this.storageService = instantiationService.createInstance(Storage, window.localStorage, disableWorkspaceStorage ? inMemoryLocalStorageInstance : window.localStorage); serviceCollection.set(IStorageService, this.storageService); // Telemetry - if (this.configuration.env.isBuilt && !this.configuration.env.extensionDevelopmentPath && !!this.configuration.env.enableTelemetry) { + if (this.configuration.env.isBuilt && !this.environmentService.extensionDevelopmentPath && !!this.configuration.env.enableTelemetry) { const channel = getDelayedChannel(sharedProcess.then(c => c.getChannel('telemetryAppender'))); const commit = this.contextService.getConfiguration().env.commitHash; const version = this.contextService.getConfiguration().env.version; diff --git a/src/vs/workbench/parts/files/electron-browser/textFileServices.ts b/src/vs/workbench/parts/files/electron-browser/textFileServices.ts index 99abe4c21e4..6b7871f3f7f 100644 --- a/src/vs/workbench/parts/files/electron-browser/textFileServices.ts +++ b/src/vs/workbench/parts/files/electron-browser/textFileServices.ts @@ -32,6 +32,7 @@ import {IEditorGroupService} from 'vs/workbench/services/group/common/groupServi import {IModelService} from 'vs/editor/common/services/modelService'; import {ModelBuilder} from 'vs/editor/node/model/modelBuilder'; import product from 'vs/platform/product'; +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; export class TextFileService extends AbstractTextFileService { @@ -50,7 +51,8 @@ export class TextFileService extends AbstractTextFileService { @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, @IWindowService private windowService: IWindowService, - @IModelService modelService: IModelService + @IModelService modelService: IModelService, + @IEnvironmentService private environmentService: IEnvironmentService ) { super(contextService, instantiationService, configurationService, telemetryService, editorService, editorGroupService, eventService, fileService, modelService); @@ -173,7 +175,7 @@ export class TextFileService extends AbstractTextFileService { } public confirmSave(resources?: URI[]): ConfirmResult { - if (!!this.contextService.getConfiguration().env.extensionDevelopmentPath) { + if (!!this.environmentService.extensionDevelopmentPath) { return ConfirmResult.DONT_SAVE; // no veto when we are in extension dev mode because we cannot assum we run interactive (e.g. tests) } diff --git a/src/vs/workbench/parts/git/electron-browser/electronGitService.ts b/src/vs/workbench/parts/git/electron-browser/electronGitService.ts index 18c83311cb9..fc39d12821b 100644 --- a/src/vs/workbench/parts/git/electron-browser/electronGitService.ts +++ b/src/vs/workbench/parts/git/electron-browser/electronGitService.ts @@ -12,6 +12,7 @@ import { IOutputService } from 'vs/workbench/parts/output/common/output'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IEventService } from 'vs/platform/event/common/event'; +import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IMessageService } from 'vs/platform/message/common/message'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -202,6 +203,7 @@ export class ElectronGitService extends GitService { @IWorkspaceContextService contextService: IWorkspaceContextService, @ILifecycleService lifecycleService: ILifecycleService, @IStorageService storageService: IStorageService, + @IEnvironmentService environmentService: IEnvironmentService, @IConfigurationService configurationService: IConfigurationService ) { const conf = configurationService.getConfiguration('git'); @@ -218,7 +220,7 @@ export class ElectronGitService extends GitService { const gitPath = conf.path || null; const encoding = filesConf.encoding || 'utf8'; const workspaceRoot = workspace.resource.fsPath; - const verbose = !contextService.getConfiguration().env.isBuilt || contextService.getConfiguration().env.verboseLogging; + const verbose = !environmentService.isBuilt || environmentService.verbose; if (ElectronGitService.USE_REMOTE_PROCESS_SERVICE) { raw = createRemoteRawGitService(gitPath, workspaceRoot, encoding, verbose); diff --git a/src/vs/workbench/services/files/electron-browser/fileService.ts b/src/vs/workbench/services/files/electron-browser/fileService.ts index c51b47d7798..fc925ced549 100644 --- a/src/vs/workbench/services/files/electron-browser/fileService.ts +++ b/src/vs/workbench/services/files/electron-browser/fileService.ts @@ -20,6 +20,7 @@ import {IEventService} from 'vs/platform/event/common/event'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {Action} from 'vs/base/common/actions'; import {IMessageService, IMessageWithAction, Severity} from 'vs/platform/message/common/message'; +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; import {shell} from 'electron'; @@ -38,14 +39,14 @@ export class FileService implements IFileService { @IConfigurationService private configurationService: IConfigurationService, @IEventService private eventService: IEventService, @IWorkspaceContextService private contextService: IWorkspaceContextService, + @IEnvironmentService private environmentService: IEnvironmentService, @IMessageService private messageService: IMessageService ) { const configuration = this.configurationService.getConfiguration(); - const env = this.contextService.getConfiguration().env; - // adjust encodings (TODO@Ben knowledge on settings location ('.vscode') is hardcoded) + // adjust encodings let encodingOverride: IEncodingOverride[] = []; - encodingOverride.push({ resource: uri.file(env.appSettingsHome), encoding: encoding.UTF8 }); + encodingOverride.push({ resource: uri.file(environmentService.appSettingsHome), encoding: encoding.UTF8 }); if (this.contextService.getWorkspace()) { encodingOverride.push({ resource: uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '.vscode')), encoding: encoding.UTF8 }); } @@ -61,12 +62,12 @@ export class FileService implements IFileService { encoding: configuration.files && configuration.files.encoding, encodingOverride: encodingOverride, watcherIgnoredPatterns: watcherIgnoredPatterns, - verboseLogging: env.verboseLogging, - debugBrkFileWatcherPort: env.debugBrkFileWatcherPort + verboseLogging: environmentService.verbose, + debugBrkFileWatcherPort: environmentService.debugBrkFileWatcherPort }; - if (typeof env.debugBrkFileWatcherPort === 'number') { - console.warn(`File Watcher STOPPED on first line for debugging on port ${env.debugBrkFileWatcherPort}`); + if (typeof environmentService.debugBrkFileWatcherPort === 'number') { + console.warn(`File Watcher STOPPED on first line for debugging on port ${environmentService.debugBrkFileWatcherPort}`); } // create service diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index 17181012891..79dca827209 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -25,6 +25,7 @@ import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle'; import {Registry} from 'vs/platform/platform'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; /** * Stores the selection & view state of an editor and allows to compare it to other selection states. @@ -85,7 +86,8 @@ export abstract class BaseHistoryService { private eventService: IEventService, protected editorGroupService: IEditorGroupService, protected editorService: IWorkbenchEditorService, - protected contextService: IWorkspaceContextService + protected contextService: IWorkspaceContextService, + private environmentService: IEnvironmentService ) { this.toUnbind = []; this.activeEditorListeners = []; @@ -154,7 +156,7 @@ export abstract class BaseHistoryService { let title = this.doGetWindowTitle(input); // Extension Development Host gets a special title to identify itself - if (this.contextService.getConfiguration().env.extensionDevelopmentPath) { + if (this.environmentService.extensionDevelopmentPath) { return nls.localize('devExtensionWindowTitle', "[Extension Development Host] - {0}", title); } @@ -234,12 +236,13 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic @IEventService eventService: IEventService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, + @IEnvironmentService environmentService: IEnvironmentService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IStorageService private storageService: IStorageService, @ILifecycleService private lifecycleService: ILifecycleService, @IInstantiationService private instantiationService: IInstantiationService ) { - super(eventService, editorGroupService, editorService, contextService); + super(eventService, editorGroupService, editorService, contextService, environmentService); this.index = -1; this.stack = []; diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index ba5197fa8b6..22c5bdd9956 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -19,6 +19,7 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IRawSearch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedFileMatch, IRawSearchService} from './search'; import {ISearchChannel, SearchChannelClient} from './searchIpc'; +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; export class SearchService implements ISearchService { public _serviceBrand: any; @@ -28,11 +29,11 @@ export class SearchService implements ISearchService { constructor( @IModelService private modelService: IModelService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService, + @IEnvironmentService private environmentService: IEnvironmentService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @IConfigurationService private configurationService: IConfigurationService ) { - let config = contextService.getConfiguration(); - this.diskSearch = new DiskSearch(!config.env.isBuilt || config.env.verboseLogging); + this.diskSearch = new DiskSearch(!environmentService.isBuilt || environmentService.verbose); } public search(query: ISearchQuery): PPromise { diff --git a/src/vs/workbench/services/thread/electron-browser/threadService.ts b/src/vs/workbench/services/thread/electron-browser/threadService.ts index 87bc8b9406d..6ded579a2f5 100644 --- a/src/vs/workbench/services/thread/electron-browser/threadService.ts +++ b/src/vs/workbench/services/thread/electron-browser/threadService.ts @@ -18,11 +18,12 @@ import {IMainProcessExtHostIPC, create} from 'vs/platform/extensions/common/ipcR import {IMessageService, Severity} from 'vs/platform/message/common/message'; import {AbstractThreadService} from 'vs/workbench/services/thread/common/abstractThreadService'; import {ILifecycleService, ShutdownEvent} from 'vs/platform/lifecycle/common/lifecycle'; -import {IConfiguration, IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {IWindowService} from 'vs/workbench/services/window/electron-browser/windowService'; import {ChildProcess, fork} from 'child_process'; import {ipcRenderer as ipc} from 'electron'; import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; export const EXTENSION_LOG_BROADCAST_CHANNEL = 'vscode:extensionLog'; export const EXTENSION_ATTACH_BROADCAST_CHANNEL = 'vscode:extensionAttach'; @@ -47,11 +48,12 @@ export class MainThreadService extends AbstractThreadService implements IThreadS @IWorkspaceContextService contextService: IWorkspaceContextService, @IMessageService messageService: IMessageService, @IWindowService windowService: IWindowService, + @IEnvironmentService private environmentService: IEnvironmentService, @ILifecycleService lifecycleService: ILifecycleService ) { super(true); - this.extensionHostProcessManager = new ExtensionHostProcessManager(contextService, messageService, windowService, lifecycleService); + this.extensionHostProcessManager = new ExtensionHostProcessManager(contextService, messageService, windowService, lifecycleService, environmentService); let logCommunication = logExtensionHostCommunication || contextService.getConfiguration().env.logExtensionHostCommunication; @@ -82,7 +84,7 @@ export class MainThreadService extends AbstractThreadService implements IThreadS this.extensionHostProcessManager.terminate(); } - protected _callOnRemote(proxyId: string, path: string, args:any[]): TPromise { + protected _callOnRemote(proxyId: string, path: string, args: any[]): TPromise { return this.remoteCom.callOnRemote(proxyId, path, args); } } @@ -105,12 +107,13 @@ class ExtensionHostProcessManager { private contextService: IWorkspaceContextService, private messageService: IMessageService, private windowService: IWindowService, - private lifecycleService: ILifecycleService + private lifecycleService: ILifecycleService, + private environmentService: IEnvironmentService ) { // 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 = !!config.env.extensionDevelopmentPath; + this.isExtensionDevelopmentHost = !!environmentService.extensionDevelopmentPath; this.isExtensionDevelopmentDebugging = !!config.env.debugBrkExtensionHost; this.isExtensionDevelopmentTestFromCli = this.isExtensionDevelopmentHost && !!config.env.extensionTestsPath && !config.env.debugBrkExtensionHost; @@ -120,14 +123,12 @@ class ExtensionHostProcessManager { } public startExtensionHostProcess(onExtensionHostMessage: (msg: any) => void): void { - let config = this.contextService.getConfiguration(); - let opts: any = { env: objects.mixin(objects.clone(process.env), { AMD_ENTRYPOINT: 'vs/workbench/node/extensionHostProcess', PIPE_LOGGING: 'true', VERBOSE_LOGGING: true }) }; // Help in case we fail to start it - if (!config.env.isBuilt || this.isExtensionDevelopmentHost) { + if (!this.environmentService.isBuilt || this.isExtensionDevelopmentHost) { this.initializeTimer = setTimeout(() => { const msg = this.isExtensionDevelopmentDebugging ? nls.localize('extensionHostProcess.startupFailDebug', "Extension host did not start in 10 seconds, it might be stopped on the first line and needs a debugger to continue.") : nls.localize('extensionHostProcess.startupFail', "Extension host did not start in 10 seconds, that might be a problem."); @@ -139,7 +140,7 @@ class ExtensionHostProcessManager { this.initializeExtensionHostProcess = new TPromise((c, e) => { // Resolve additional execution args (e.g. debug) - return this.resolveDebugPort(config, (port) => { + return this.resolveDebugPort(this.contextService.getConfiguration().env.debugExtensionHostPort, port => { if (port) { opts.execArgv = ['--nolazy', (this.isExtensionDevelopmentDebugging ? '--debug-brk=' : '--debug=') + port]; } @@ -154,7 +155,7 @@ class ExtensionHostProcessManager { payload: { port: port } - }, config.env.extensionDevelopmentPath /* target */); + }, this.environmentService.extensionDevelopmentPath /* target */); } // Messages from Extension host @@ -220,11 +221,11 @@ class ExtensionHostProcessManager { } // Broadcast to other windows if we are in development mode - else if (!config.env.isBuilt || this.isExtensionDevelopmentHost) { + else if (!this.environmentService.isBuilt || this.isExtensionDevelopmentHost) { this.windowService.broadcast({ channel: EXTENSION_LOG_BROADCAST_CHANNEL, payload: logEntry - }, config.env.extensionDevelopmentPath /* target */); + }, this.environmentService.extensionDevelopmentPath /* target */); } } @@ -278,19 +279,19 @@ class ExtensionHostProcessManager { }, () => this.terminate()); } - private resolveDebugPort(config: IConfiguration, clb: (port: number) => void): void { + private resolveDebugPort(extensionHostPort: number, clb: (port: number) => void): void { // Check for a free debugging port - if (typeof config.env.debugExtensionHostPort === 'number') { - return findFreePort(config.env.debugExtensionHostPort, 10 /* try 10 ports */, 5000 /* try up to 5 seconds */, (port) => { + if (typeof extensionHostPort === 'number') { + return findFreePort(extensionHostPort, 10 /* try 10 ports */, 5000 /* try up to 5 seconds */, (port) => { if (!port) { console.warn('%c[Extension Host] %cCould not find a free port for debugging', 'color: blue', 'color: black'); return clb(void 0); } - if (port !== config.env.debugExtensionHostPort) { - console.warn('%c[Extension Host] %cProvided debugging port ' + config.env.debugExtensionHostPort + ' is not free, using ' + port + ' instead.', 'color: blue', 'color: black'); + if (port !== extensionHostPort) { + console.warn('%c[Extension Host] %cProvided debugging port ' + extensionHostPort + ' is not free, using ' + port + ' instead.', 'color: blue', 'color: black'); } if (this.isExtensionDevelopmentDebugging) { @@ -329,7 +330,7 @@ class ExtensionHostProcessManager { } } - private _onWillShutdown(event: ShutdownEvent): void{ + private _onWillShutdown(event: ShutdownEvent): void { // If the extension development host was started without debugger attached we need // to communicate this back to the main side to terminate the debug session @@ -337,7 +338,7 @@ class ExtensionHostProcessManager { this.windowService.broadcast({ channel: EXTENSION_TERMINATE_BROADCAST_CHANNEL, payload: true - }, this.contextService.getConfiguration().env.extensionDevelopmentPath /* target */); + }, this.environmentService.extensionDevelopmentPath /* target */); event.veto(TPromise.timeout(100 /* wait a bit for IPC to get delivered */).then(() => false)); } -- GitLab