diff --git a/src/vs/base/common/path.ts b/src/vs/base/common/path.ts index a93084c42b7..844cdd246a9 100644 --- a/src/vs/base/common/path.ts +++ b/src/vs/base/common/path.ts @@ -29,7 +29,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { isWindows } from 'vs/base/common/platform'; +import * as process from 'vs/base/common/process'; const CHAR_UPPERCASE_A = 65;/* A */ const CHAR_LOWERCASE_A = 97; /* a */ @@ -41,19 +41,6 @@ const CHAR_BACKWARD_SLASH = 92; /* \ */ const CHAR_COLON = 58; /* : */ const CHAR_QUESTION_MARK = 63; /* ? */ -interface IProcess { - cwd(): string; - platform: string; - env: object; -} - -declare let process: IProcess; -const safeProcess: IProcess = (typeof process === 'undefined') ? { - cwd() { return '/'; }, - env: {}, - get platform() { return isWindows ? 'win32' : 'posix'; } -} : process; - class ErrorInvalidArgType extends Error { code: 'ERR_INVALID_ARG_TYPE'; constructor(name: string, expected: string, actual: string) { @@ -219,14 +206,14 @@ export const win32: IPath = { if (i >= 0) { path = pathSegments[i]; } else if (!resolvedDevice) { - path = safeProcess.cwd(); + path = process.cwd(); } else { // Windows has the concept of drive-specific current working // directories. If we've resolved a drive letter but not yet an // absolute path, get cwd for that drive, or the process cwd if // the drive cwd is not available. We're sure the device is not // a UNC path at this points, because UNC paths are always absolute. - path = safeProcess.env['=' + resolvedDevice] || safeProcess.cwd(); + path = process.env['=' + resolvedDevice] || process.cwd(); // Verify that a cwd was found and that it actually points // to our drive. If not, default to the drive's root. @@ -1208,7 +1195,7 @@ export const posix: IPath = { path = pathSegments[i]; } else { - path = safeProcess.cwd(); + path = process.cwd(); } validateString(path, 'path'); @@ -1682,16 +1669,16 @@ export const posix: IPath = { posix.win32 = win32.win32 = win32; posix.posix = win32.posix = posix; -export const normalize = (safeProcess.platform === 'win32' ? win32.normalize : posix.normalize); -export const isAbsolute = (safeProcess.platform === 'win32' ? win32.isAbsolute : posix.isAbsolute); -export const join = (safeProcess.platform === 'win32' ? win32.join : posix.join); -export const resolve = (safeProcess.platform === 'win32' ? win32.resolve : posix.resolve); -export const relative = (safeProcess.platform === 'win32' ? win32.relative : posix.relative); -export const dirname = (safeProcess.platform === 'win32' ? win32.dirname : posix.dirname); -export const basename = (safeProcess.platform === 'win32' ? win32.basename : posix.basename); -export const extname = (safeProcess.platform === 'win32' ? win32.extname : posix.extname); -export const format = (safeProcess.platform === 'win32' ? win32.format : posix.format); -export const parse = (safeProcess.platform === 'win32' ? win32.parse : posix.parse); -export const toNamespacedPath = (safeProcess.platform === 'win32' ? win32.toNamespacedPath : posix.toNamespacedPath); -export const sep = (safeProcess.platform === 'win32' ? win32.sep : posix.sep); -export const delimiter = (safeProcess.platform === 'win32' ? win32.delimiter : posix.delimiter); +export const normalize = (process.platform === 'win32' ? win32.normalize : posix.normalize); +export const isAbsolute = (process.platform === 'win32' ? win32.isAbsolute : posix.isAbsolute); +export const join = (process.platform === 'win32' ? win32.join : posix.join); +export const resolve = (process.platform === 'win32' ? win32.resolve : posix.resolve); +export const relative = (process.platform === 'win32' ? win32.relative : posix.relative); +export const dirname = (process.platform === 'win32' ? win32.dirname : posix.dirname); +export const basename = (process.platform === 'win32' ? win32.basename : posix.basename); +export const extname = (process.platform === 'win32' ? win32.extname : posix.extname); +export const format = (process.platform === 'win32' ? win32.format : posix.format); +export const parse = (process.platform === 'win32' ? win32.parse : posix.parse); +export const toNamespacedPath = (process.platform === 'win32' ? win32.toNamespacedPath : posix.toNamespacedPath); +export const sep = (process.platform === 'win32' ? win32.sep : posix.sep); +export const delimiter = (process.platform === 'win32' ? win32.delimiter : posix.delimiter); diff --git a/src/vs/base/common/process.ts b/src/vs/base/common/process.ts new file mode 100644 index 00000000000..386ad29df56 --- /dev/null +++ b/src/vs/base/common/process.ts @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { isWindows, isMacintosh, setImmediate } from 'vs/base/common/platform'; + +interface IProcess { + platform: string; + env: object; + + cwd(): string; + nextTick(callback: (...args: any[]) => void): number; +} + +declare let process: IProcess; +const safeProcess: IProcess = (typeof process === 'undefined') ? { + cwd(): string { return '/'; }, + env: Object.create(null), + get platform(): string { return isWindows ? 'win32' : isMacintosh ? 'darwin' : 'linux'; }, + nextTick(callback: (...args: any[]) => void): number { return setImmediate(callback); } +} : process; + +export const cwd = safeProcess.cwd; +export const env = safeProcess.env; +export const platform = safeProcess.platform; +export const nextTick = safeProcess.nextTick; diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index 32d93fbbf95..c593cb4bf65 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -909,7 +909,7 @@ export class ExtHostVariableResolverService extends AbstractVariableResolverServ } return undefined; } - }); + }, process.env); } } diff --git a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts index a1f46f8ff1d..4c3a8ba75ff 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts @@ -5,6 +5,7 @@ import { RunOnceScheduler } from 'vs/base/common/async'; import { Disposable } from 'vs/base/common/lifecycle'; +import * as process from 'vs/base/common/process'; import * as platform from 'vs/base/common/platform'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; diff --git a/src/vs/workbench/contrib/codeinset/electron-browser/codeInset.contribution.ts b/src/vs/workbench/contrib/codeinset/electron-browser/codeInset.contribution.ts index bce7c3f7d4f..a0369eaff5e 100644 --- a/src/vs/workbench/contrib/codeinset/electron-browser/codeInset.contribution.ts +++ b/src/vs/workbench/contrib/codeinset/electron-browser/codeInset.contribution.ts @@ -309,7 +309,7 @@ export class CodeInsetController implements editorCommon.IEditorContribution { const widgetPromises = widgetRequests.map(request => { if (request.resolved) { - return Promise.resolve(void 0); + return Promise.resolve(undefined); } let a = new Promise(resolve => { this._pendingWebviews.set(request.symbol.id, element => { diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 7445d7b6645..c1e45f78c1c 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -44,33 +44,23 @@ import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/c import { IActivityService } from 'vs/workbench/services/activity/common/activity'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IFileService } from 'vs/platform/files/common/files'; -import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { ITitleService } from 'vs/workbench/services/title/common/titleService'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; -import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; -import { IProgressService2 } from 'vs/platform/progress/common/progress'; -import { ProgressService2 } from 'vs/workbench/services/progress/browser/progressService2'; import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { LifecyclePhase, StartupKind, ILifecycleService, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle'; import { IWindowService, IWindowConfiguration, IPath, MenuBarVisibility, getTitleBarStyle, IWindowsService } from 'vs/platform/windows/common/windows'; 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, IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing'; -import { FileDecorationsService } from 'vs/workbench/services/decorations/browser/decorationsService'; -import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations'; import { ActivityService } from 'vs/workbench/services/activity/browser/activityService'; -import { IListService, ListService } from 'vs/platform/list/browser/listService'; import { IViewsService } from 'vs/workbench/common/views'; import { ViewsService } from 'vs/workbench/browser/parts/views/views'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -102,34 +92,21 @@ import { LabelService } from 'vs/workbench/services/label/common/labelService'; import { ITelemetryServiceConfig, TelemetryService } from 'vs/platform/telemetry/common/telemetryService'; import { combinedAppender, LogAppender, NullTelemetryService, configurationTelemetry } from 'vs/platform/telemetry/common/telemetryUtils'; import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry'; -import { IDownloadService } from 'vs/platform/download/common/download'; import { IExtensionGalleryService, IExtensionManagementServerService, IExtensionManagementService, IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { ExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionEnablementService'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { CommandService } from 'vs/workbench/services/commands/common/commandService'; -import { IMarkerService } from 'vs/platform/markers/common/markers'; -import { MarkerService } from 'vs/platform/markers/common/markerService'; import { IModeService } from 'vs/editor/common/services/modeService'; import { WorkbenchModeServiceImpl } from 'vs/workbench/services/mode/common/workbenchModeService'; import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; import { TextResourceConfigurationService } from 'vs/editor/common/services/resourceConfigurationImpl'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; -import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService'; -import { MarkerDecorationsService } from 'vs/editor/common/services/markerDecorationsServiceImpl'; -import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; -import { EditorWorkerServiceImpl } from 'vs/editor/common/services/editorWorkerServiceImpl'; import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; -import { ISearchService } from 'vs/workbench/services/search/common/search'; -import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; -import { CodeEditorService } from 'vs/workbench/services/editor/browser/codeEditorService'; -import { IOpenerService } from 'vs/platform/opener/common/opener'; -import { OpenerService } from 'vs/editor/browser/services/openerService'; import { ILocalizationsService } from 'vs/platform/localizations/common/localizations'; import { HistoryService } from 'vs/workbench/services/history/browser/history'; -import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/browser/configurationResolverService'; import { WorkbenchThemeService } from 'vs/workbench/services/themes/browser/workbenchThemeService'; import { IProductService } from 'vs/platform/product/common/product'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; @@ -139,14 +116,12 @@ import { WorkbenchContextKeysHandler } from 'vs/workbench/browser/contextkeys'; import { BackupFileService, InMemoryBackupFileService } from 'vs/workbench/services/backup/node/backupFileService'; import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService'; import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService'; -import { WorkspaceEditingService } from 'vs/workbench/services/workspace/node/workspaceEditingService'; import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc'; import { connect as connectNet } from 'vs/base/parts/ipc/node/ipc.net'; import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc'; import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/node/workbenchCommonProperties'; import { IRequestService } from 'vs/platform/request/node/request'; -import { DownloadService } from 'vs/platform/download/node/downloadService'; import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService'; import { IRemoteAgentService } from 'vs/workbench/services/remote/node/remoteAgentService'; import { DownloadServiceChannel } from 'vs/platform/download/node/downloadIpc'; @@ -154,7 +129,6 @@ import { LogLevelSetterChannel } from 'vs/platform/log/node/logIpc'; import { ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/node/extensionManagementIpc'; import { ExtensionManagementServerService } from 'vs/workbench/services/extensions/node/extensionManagementServerService'; import { MultiExtensionManagementService } from 'vs/workbench/services/extensionManagement/node/multiExtensionManagement'; -import { SearchService } from 'vs/workbench/services/search/node/searchService'; import { LocalizationsChannelClient } from 'vs/platform/localizations/node/localizationsIpc'; import { AccessibilityService } from 'vs/platform/accessibility/node/accessibilityService'; import { ProductService } from 'vs/platform/product/node/productService'; @@ -164,11 +138,8 @@ import { RemoteFileService } from 'vs/workbench/services/files/node/remoteFileSe // import@electron-browser import { ContextMenuService as NativeContextMenuService } from 'vs/workbench/services/contextmenu/electron-browser/contextmenuService'; import { WorkbenchKeybindingService } from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; -import { ClipboardService } from 'vs/platform/clipboard/electron-browser/clipboardService'; import { LifecycleService } from 'vs/platform/lifecycle/electron-browser/lifecycleService'; -import { IExtensionUrlHandler, ExtensionUrlHandler } from 'vs/workbench/services/extensions/electron-browser/inactiveExtensionUrlHandler'; import { DialogService, FileDialogService } from 'vs/workbench/services/dialogs/electron-browser/dialogService'; -import { IBroadcastService, BroadcastService } from 'vs/workbench/services/broadcast/electron-browser/broadcastService'; import { WindowService } from 'vs/platform/windows/electron-browser/windowService'; import { RemoteAuthorityResolverService } from 'vs/platform/remote/electron-browser/remoteAuthorityResolverService'; import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl'; @@ -466,12 +437,6 @@ export class Workbench extends Disposable implements IPartService { // Labels serviceCollection.set(ILabelService, new SyncDescriptor(LabelService, undefined, true)); - // Clipboard - serviceCollection.set(IClipboardService, new SyncDescriptor(ClipboardService, undefined, true)); - - // Broadcast - serviceCollection.set(IBroadcastService, new SyncDescriptor(BroadcastService, [this.configuration.windowId], true)); - // Notifications this.notificationService = new NotificationService(); serviceCollection.set(INotificationService, this.notificationService); @@ -527,9 +492,6 @@ export class Workbench extends Disposable implements IPartService { // Request Service serviceCollection.set(IRequestService, new SyncDescriptor(RequestService, undefined, true)); - // Download Service - serviceCollection.set(IDownloadService, new SyncDescriptor(DownloadService, undefined, true)); - // Extension Gallery serviceCollection.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService, undefined, true)); @@ -567,9 +529,6 @@ export class Workbench extends Disposable implements IPartService { // Commands serviceCollection.set(ICommandService, new SyncDescriptor(CommandService, undefined, true)); - // Markers - serviceCollection.set(IMarkerService, new SyncDescriptor(MarkerService, undefined, true)); - // Editor Mode serviceCollection.set(IModeService, new SyncDescriptor(WorkbenchModeServiceImpl)); @@ -582,38 +541,17 @@ export class Workbench extends Disposable implements IPartService { // Editor Models serviceCollection.set(IModelService, new SyncDescriptor(ModelServiceImpl, undefined, true)); - // Marker Decorations - serviceCollection.set(IMarkerDecorationsService, new SyncDescriptor(MarkerDecorationsService)); - - // Editor Worker - serviceCollection.set(IEditorWorkerService, new SyncDescriptor(EditorWorkerServiceImpl)); - // Untitled Editors serviceCollection.set(IUntitledEditorService, new SyncDescriptor(UntitledEditorService, undefined, true)); - // Search - serviceCollection.set(ISearchService, new SyncDescriptor(SearchService)); - - // Code Editor - serviceCollection.set(ICodeEditorService, new SyncDescriptor(CodeEditorService, undefined, true)); - - // Opener - serviceCollection.set(IOpenerService, new SyncDescriptor(OpenerService, undefined, true)); - // Localization const localizationsChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('localizations'))); serviceCollection.set(ILocalizationsService, new SyncDescriptor(LocalizationsChannelClient, [localizationsChannel])); - // Hash - // serviceCollection.set(IHashService, new SyncDescriptor(HashService, undefined, true)); - // Status bar this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART); serviceCollection.set(IStatusbarService, this.statusbarPart); - // Progress 2 - serviceCollection.set(IProgressService2, new SyncDescriptor(ProgressService2)); - // Context Keys this.contextKeyService = this.instantiationService.createInstance(ContextKeyService); serviceCollection.set(IContextKeyService, this.contextKeyService); @@ -622,9 +560,6 @@ export class Workbench extends Disposable implements IPartService { this.keybindingService = this.instantiationService.createInstance(WorkbenchKeybindingService, window); serviceCollection.set(IKeybindingService, this.keybindingService); - // List - serviceCollection.set(IListService, this.instantiationService.createInstance(ListService)); - // Context view service this.contextViewService = this.instantiationService.createInstance(ContextViewService, this.workbench); serviceCollection.set(IContextViewService, this.contextViewService); @@ -636,9 +571,6 @@ export class Workbench extends Disposable implements IPartService { serviceCollection.set(IContextMenuService, new SyncDescriptor(NativeContextMenuService)); } - // Menus/Actions - serviceCollection.set(IMenuService, new SyncDescriptor(MenuService, undefined, true)); - // Sidebar part this.sidebarPart = this.instantiationService.createInstance(SidebarPart, Identifiers.SIDEBAR_PART); @@ -693,24 +625,12 @@ export class Workbench extends Disposable implements IPartService { // Text File Service serviceCollection.set(ITextFileService, new SyncDescriptor(TextFileService)); - // File Decorations - serviceCollection.set(IDecorationsService, new SyncDescriptor(FileDecorationsService)); - - // Inactive extension URL handler - serviceCollection.set(IExtensionUrlHandler, new SyncDescriptor(ExtensionUrlHandler)); - // Text Model Resolver Service serviceCollection.set(ITextModelService, new SyncDescriptor(TextModelResolverService, undefined, true)); // JSON Editing serviceCollection.set(IJSONEditingService, new SyncDescriptor(JSONEditingService, undefined, true)); - // Workspace Editing - serviceCollection.set(IWorkspaceEditingService, new SyncDescriptor(WorkspaceEditingService, undefined, true)); - - // Configuration Resolver - serviceCollection.set(IConfigurationResolverService, new SyncDescriptor(ConfigurationResolverService, [process.env], true)); - // Quick open service (quick open controller) this.quickOpen = this.instantiationService.createInstance(QuickOpenController); serviceCollection.set(IQuickOpenService, this.quickOpen); diff --git a/src/vs/workbench/services/broadcast/electron-browser/broadcastService.ts b/src/vs/workbench/services/broadcast/electron-browser/broadcastService.ts index a22264520c3..8c1b3c9f6aa 100644 --- a/src/vs/workbench/services/broadcast/electron-browser/broadcastService.ts +++ b/src/vs/workbench/services/broadcast/electron-browser/broadcastService.ts @@ -8,6 +8,8 @@ import { Event, Emitter } from 'vs/base/common/event'; import { ipcRenderer as ipc } from 'electron'; import { ILogService } from 'vs/platform/log/common/log'; import { Disposable } from 'vs/base/common/lifecycle'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { IWindowService } from 'vs/platform/windows/common/windows'; export const IBroadcastService = createDecorator('broadcastService'); @@ -30,12 +32,16 @@ export class BroadcastService extends Disposable implements IBroadcastService { private readonly _onBroadcast: Emitter = this._register(new Emitter()); get onBroadcast(): Event { return this._onBroadcast.event; } + private windowId: number; + constructor( - private windowId: number, + @IWindowService readonly windowService: IWindowService, @ILogService private readonly logService: ILogService ) { super(); + this.windowId = windowService.getCurrentWindowId(); + this.registerListeners(); } @@ -55,4 +61,6 @@ export class BroadcastService extends Disposable implements IBroadcastService { payload: b.payload }); } -} \ No newline at end of file +} + +registerSingleton(IBroadcastService, BroadcastService, true); \ No newline at end of file diff --git a/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts b/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts index 24b3264415f..71aa1fd6d00 100644 --- a/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts @@ -6,7 +6,6 @@ import { URI as uri } from 'vs/base/common/uri'; import * as nls from 'vs/nls'; import * as path from 'vs/base/common/path'; -import * as platform from 'vs/base/common/platform'; import * as Types from 'vs/base/common/types'; import { Schemas } from 'vs/base/common/network'; import { toResource } from 'vs/workbench/common/editor'; @@ -20,14 +19,16 @@ import { AbstractVariableResolverService } from 'vs/workbench/services/configura import { isCodeEditor } from 'vs/editor/browser/editorBrowser'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { IQuickInputService, IInputOptions, IQuickPickItem, IPickOptions } from 'vs/platform/quickinput/common/quickInput'; -import { ConfiguredInput } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; +import { ConfiguredInput, IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; +import { IWindowService } from 'vs/platform/windows/common/windows'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; export class ConfigurationResolverService extends AbstractVariableResolverService { static INPUT_OR_COMMAND_VARIABLES_PATTERN = /\${((input|command):(.*?))}/g; constructor( - envVariables: platform.IProcessEnvironment, + @IWindowService windowService: IWindowService, @IEditorService editorService: IEditorService, @IEnvironmentService environmentService: IEnvironmentService, @IConfigurationService private readonly configurationService: IConfigurationService, @@ -79,7 +80,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic } return undefined; } - }, envVariables); + }, windowService.getConfiguration().userEnv); } public resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): Promise { @@ -287,4 +288,6 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic } return Promise.reject(new Error(nls.localize('inputVariable.undefinedVariable', "Undefined input variable '{0}' encountered. Remove or define '{0}' to continue.", variable))); } -} \ No newline at end of file +} + +registerSingleton(IConfigurationResolverService, ConfigurationResolverService, true); \ No newline at end of file diff --git a/src/vs/workbench/services/configurationResolver/common/variableResolver.ts b/src/vs/workbench/services/configurationResolver/common/variableResolver.ts index 88d1c2de2f0..82e83a3c2cd 100644 --- a/src/vs/workbench/services/configurationResolver/common/variableResolver.ts +++ b/src/vs/workbench/services/configurationResolver/common/variableResolver.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as paths from 'vs/base/common/path'; +import * as process from 'vs/base/common/process'; import * as types from 'vs/base/common/types'; import * as objects from 'vs/base/common/objects'; import { IStringDictionary } from 'vs/base/common/collections'; @@ -32,7 +33,7 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe constructor( private _context: IVariableResolveContext, - private _envVariables: IProcessEnvironment = process.env + private _envVariables: IProcessEnvironment ) { if (isWindows) { this._envVariables = Object.create(null); diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index af81556238a..4fc62f2dfbc 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -11,16 +11,18 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/browser/configurationResolverService'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; -import { TestEnvironmentService, TestEditorService, TestContextService } from 'vs/workbench/test/workbenchTestServices'; +import { TestEnvironmentService, TestEditorService, TestContextService, TestWindowService } from 'vs/workbench/test/workbenchTestServices'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { Disposable } from 'vs/base/common/lifecycle'; import { IQuickInputService, IQuickPickItem, QuickPickInput, IPickOptions, Omit, IInputOptions, IQuickInputButton, IQuickPick, IInputBox, IQuickNavigateConfiguration } from 'vs/platform/quickinput/common/quickInput'; import { CancellationToken } from 'vs/base/common/cancellation'; import * as Types from 'vs/base/common/types'; +import { IWindowService, IWindowConfiguration } from 'vs/platform/windows/common/windows'; suite('Configuration Resolver Service', () => { let configurationResolverService: IConfigurationResolverService | null; let envVariables: { [key: string]: string } = { key1: 'Value for key1', key2: 'Value for key2' }; + let windowService: IWindowService; let mockCommandService: MockCommandService; let editorService: TestEditorService; let workspace: IWorkspaceFolder; @@ -30,13 +32,14 @@ suite('Configuration Resolver Service', () => { mockCommandService = new MockCommandService(); editorService = new TestEditorService(); quickInputService = new MockQuickInputService(); + windowService = new MockWindowService(envVariables); workspace = { uri: uri.parse('file:///VSCode/workspaceLocation'), name: 'hey', index: 0, toResource: () => null }; - configurationResolverService = new ConfigurationResolverService(envVariables, editorService, TestEnvironmentService, new MockInputsConfigurationService(), mockCommandService, new TestContextService(), quickInputService); + configurationResolverService = new ConfigurationResolverService(windowService, editorService, TestEnvironmentService, new MockInputsConfigurationService(), mockCommandService, new TestContextService(), quickInputService); }); teardown(() => { @@ -120,7 +123,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); + let service = new ConfigurationResolverService(windowService, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} xyz'), 'abc foo xyz'); }); @@ -137,7 +140,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); + let service = new ConfigurationResolverService(windowService, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz'); }); @@ -154,7 +157,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); + let service = new ConfigurationResolverService(windowService, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); if (platform.isWindows) { assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${workspaceFolder} ${env:key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for key1 xyz'); } else { @@ -175,7 +178,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); + let service = new ConfigurationResolverService(windowService, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); if (platform.isWindows) { assert.strictEqual(service.resolve(workspace, '${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceFolder} - ${workspaceFolder} ${env:key1} - ${env:key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for key1 - Value for key2'); } else { @@ -209,7 +212,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); + let service = new ConfigurationResolverService(windowService, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${config:editor.lineNumbers} ${config:editor.insertSpaces} xyz'), 'abc foo 123 false xyz'); }); @@ -219,7 +222,7 @@ suite('Configuration Resolver Service', () => { editor: {} }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); + let service = new ConfigurationResolverService(windowService, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); assert.strictEqual(service.resolve(workspace, 'abc ${unknownVariable} xyz'), 'abc ${unknownVariable} xyz'); assert.strictEqual(service.resolve(workspace, 'abc ${env:unknownVariable} xyz'), 'abc xyz'); }); @@ -232,7 +235,7 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); + let service = new ConfigurationResolverService(windowService, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(), quickInputService); assert.throws(() => service.resolve(workspace, 'abc ${env} xyz')); assert.throws(() => service.resolve(workspace, 'abc ${env:} xyz')); @@ -611,3 +614,14 @@ class MockInputsConfigurationService extends TestConfigurationService { return configuration; } } + +class MockWindowService extends TestWindowService { + + constructor(private env: platform.IProcessEnvironment) { + super(); + } + + getConfiguration(): IWindowConfiguration { + return { userEnv: this.env } as IWindowConfiguration; + } +} diff --git a/src/vs/workbench/services/decorations/browser/decorationsService.ts b/src/vs/workbench/services/decorations/browser/decorationsService.ts index e0ef2f3814f..5b3859f5fd8 100644 --- a/src/vs/workbench/services/decorations/browser/decorationsService.ts +++ b/src/vs/workbench/services/decorations/browser/decorationsService.ts @@ -18,6 +18,7 @@ import { isFalsyOrWhitespace } from 'vs/base/common/strings'; import { localize } from 'vs/nls'; import { isPromiseCanceledError } from 'vs/base/common/errors'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; class DecorationRule { @@ -353,8 +354,7 @@ export class FileDecorationsService implements IDecorationsService { ); constructor( - @IThemeService themeService: IThemeService, - cleanUpCount: number = 17 + @IThemeService themeService: IThemeService ) { this._decorationStyles = new DecorationStyles(themeService); @@ -362,7 +362,7 @@ export class FileDecorationsService implements IDecorationsService { // css styles that we don't need anymore let count = 0; let reg = this.onDidChangeDecorations(() => { - if (++count % cleanUpCount === 0) { + if (++count % 17 === 0) { this._decorationStyles.cleanUp(this._data.iterator()); } }); @@ -442,3 +442,4 @@ function getColor(theme: ITheme, color: string | undefined) { return 'inherit'; } +registerSingleton(IDecorationsService, FileDecorationsService); \ No newline at end of file diff --git a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts b/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts index 4d16b57ee49..cec0ec1ff07 100644 --- a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts +++ b/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts @@ -362,7 +362,7 @@ export class FileDialogService implements IFileDialogService { if (urisToOpen) { return this.windowService.openWindow(urisToOpen, { forceNewWindow, forceOpenWorkspaceAsFile }); } - return void 0; + return undefined; }); } diff --git a/src/vs/workbench/services/editor/browser/codeEditorService.ts b/src/vs/workbench/services/editor/browser/codeEditorService.ts index 0c98821626b..fe5bb0a5372 100644 --- a/src/vs/workbench/services/editor/browser/codeEditorService.ts +++ b/src/vs/workbench/services/editor/browser/codeEditorService.ts @@ -10,6 +10,8 @@ import { IResourceInput } from 'vs/platform/editor/common/editor'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { TextEditorOptions } from 'vs/workbench/common/editor'; import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; +import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; export class CodeEditorService extends CodeEditorServiceImpl { @@ -72,4 +74,6 @@ export class CodeEditorService extends CodeEditorServiceImpl { return null; }); } -} \ No newline at end of file +} + +registerSingleton(ICodeEditorService, CodeEditorService, true); \ No newline at end of file diff --git a/src/vs/workbench/services/extensions/electron-browser/inactiveExtensionUrlHandler.ts b/src/vs/workbench/services/extensions/electron-browser/inactiveExtensionUrlHandler.ts index 80700c6aa9a..2713af6dad8 100644 --- a/src/vs/workbench/services/extensions/electron-browser/inactiveExtensionUrlHandler.ts +++ b/src/vs/workbench/services/extensions/electron-browser/inactiveExtensionUrlHandler.ts @@ -17,6 +17,7 @@ import { IURLHandler, IURLService } from 'vs/platform/url/common/url'; import { IWindowService } from 'vs/platform/windows/common/windows'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; const FIVE_MINUTES = 5 * 60 * 1000; const THIRTY_SECONDS = 30 * 1000; @@ -271,3 +272,5 @@ export class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler { this.uriBuffer.clear(); } } + +registerSingleton(IExtensionUrlHandler, ExtensionUrlHandler); \ No newline at end of file diff --git a/src/vs/workbench/services/preferences/browser/preferencesService.ts b/src/vs/workbench/services/preferences/browser/preferencesService.ts index ee6c999089f..9646b53859d 100644 --- a/src/vs/workbench/services/preferences/browser/preferencesService.ts +++ b/src/vs/workbench/services/preferences/browser/preferencesService.ts @@ -45,7 +45,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic private lastOpenedSettingsInput: PreferencesEditorInput | null = null; - private readonly _onDispose = new Emitter(); + private readonly _onDispose = this._register(new Emitter()); private _defaultUserSettingsUriCounter = 0; private _defaultUserSettingsContentModel: DefaultSettings; @@ -74,14 +74,14 @@ export class PreferencesService extends Disposable implements IPreferencesServic super(); // The default keybindings.json updates based on keyboard layouts, so here we make sure // if a model has been given out we update it accordingly. - keybindingService.onDidUpdateKeybindings(() => { + this._register(keybindingService.onDidUpdateKeybindings(() => { const model = modelService.getModel(this.defaultKeybindingsResource); if (!model) { // model has not been given out => nothing to do return; } modelService.updateModel(model, defaultKeybindingsContents(keybindingService)); - }); + })); } readonly defaultKeybindingsResource = URI.from({ scheme: network.Schemas.vscode, authority: 'defaultsettings', path: '/keybindings.json' }); diff --git a/src/vs/workbench/services/progress/browser/progressService2.ts b/src/vs/workbench/services/progress/browser/progressService2.ts index da77ec66b8d..f61446ca4b9 100644 --- a/src/vs/workbench/services/progress/browser/progressService2.ts +++ b/src/vs/workbench/services/progress/browser/progressService2.ts @@ -15,6 +15,7 @@ import { ProgressBadge, IActivityService } from 'vs/workbench/services/activity/ import { INotificationService, Severity, INotificationHandle, INotificationActions } from 'vs/platform/notification/common/notification'; import { Action } from 'vs/base/common/actions'; import { Event } from 'vs/base/common/event'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; export class ProgressService2 implements IProgressService2 { @@ -267,3 +268,5 @@ export class ProgressService2 implements IProgressService2 { return promise; } } + +registerSingleton(IProgressService2, ProgressService2, true); \ No newline at end of file diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index 3eaafa4f31e..a61f1d7a986 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -29,6 +29,7 @@ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/un import { IRawSearchService, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, isSerializedSearchComplete, isSerializedSearchSuccess } from './search'; import { SearchChannelClient } from './searchIpc'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; export class SearchService extends Disposable implements ISearchService { _serviceBrand: any; @@ -586,3 +587,5 @@ export class DiskSearch implements ISearchResultProvider { return this.raw.clearCache(cacheKey); } } + +registerSingleton(ISearchService, SearchService, true); \ No newline at end of file diff --git a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts index c91fa335414..a1884b928a5 100644 --- a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts @@ -26,6 +26,7 @@ import { isEqual, basename } from 'vs/base/common/resources'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { IFileService } from 'vs/platform/files/common/files'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; export class WorkspaceEditingService implements IWorkspaceEditingService { @@ -329,3 +330,5 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { return this.jsonEditingService.write(toWorkspace.configPath, { key: 'settings', value: targetWorkspaceConfiguration }, true); } } + +registerSingleton(IWorkspaceEditingService, WorkspaceEditingService, true); \ No newline at end of file diff --git a/src/vs/workbench/workbench.main.ts b/src/vs/workbench/workbench.main.ts index cf08e9d08ee..cbf781391bd 100644 --- a/src/vs/workbench/workbench.main.ts +++ b/src/vs/workbench/workbench.main.ts @@ -38,12 +38,45 @@ import 'vs/workbench/api/browser/viewsExtensionPoint'; //#region --- workbench services +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { IMenuService } from 'vs/platform/actions/common/actions'; +import { MenuService } from 'vs/platform/actions/common/menuService'; +import { IListService, ListService } from 'vs/platform/list/browser/listService'; +import { OpenerService } from 'vs/editor/browser/services/openerService'; +import { IOpenerService } from 'vs/platform/opener/common/opener'; +import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; +import { EditorWorkerServiceImpl } from 'vs/editor/common/services/editorWorkerServiceImpl'; +import { MarkerDecorationsService } from 'vs/editor/common/services/markerDecorationsServiceImpl'; +import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService'; +import { IMarkerService } from 'vs/platform/markers/common/markers'; +import { MarkerService } from 'vs/platform/markers/common/markerService'; +import { IDownloadService } from 'vs/platform/download/common/download'; +import { DownloadService } from 'vs/platform/download/node/downloadService'; import 'vs/workbench/services/bulkEdit/browser/bulkEditService'; import 'vs/workbench/services/integrity/node/integrityService'; import 'vs/workbench/services/keybinding/common/keybindingEditing'; import 'vs/workbench/services/hash/node/hashService'; import 'vs/workbench/services/textMate/electron-browser/textMateService'; +import 'vs/workbench/services/configurationResolver/browser/configurationResolverService'; +import 'vs/workbench/services/workspace/node/workspaceEditingService'; +import 'vs/workbench/services/extensions/electron-browser/inactiveExtensionUrlHandler'; +import 'vs/workbench/services/decorations/browser/decorationsService'; +import 'vs/workbench/services/search/node/searchService'; +import 'vs/workbench/services/progress/browser/progressService2'; +import 'vs/workbench/services/editor/browser/codeEditorService'; +import 'vs/workbench/services/broadcast/electron-browser/broadcastService'; +import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; +import { ClipboardService } from 'vs/platform/clipboard/electron-browser/clipboardService'; + +registerSingleton(IMenuService, MenuService, true); +registerSingleton(IListService, ListService, true); +registerSingleton(IOpenerService, OpenerService, true); +registerSingleton(IEditorWorkerService, EditorWorkerServiceImpl); +registerSingleton(IMarkerDecorationsService, MarkerDecorationsService); +registerSingleton(IMarkerService, MarkerService, true); +registerSingleton(IDownloadService, DownloadService, true); +registerSingleton(IClipboardService, ClipboardService, true); //#endregion