From b24be3a8cefb387df045d465936285656f2fe44e Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Mon, 2 May 2016 16:03:40 +0200 Subject: [PATCH] cleanup imports --- .../code/electron-main/auto-updater.linux.ts | 4 +- .../code/electron-main/auto-updater.win32.ts | 22 +-- src/vs/code/electron-main/env.ts | 30 ++--- src/vs/code/electron-main/lifecycle.ts | 19 ++- src/vs/code/electron-main/main.ts | 48 +++---- src/vs/code/electron-main/menus.ts | 19 ++- src/vs/code/electron-main/settings.ts | 2 +- src/vs/code/electron-main/sharedProcess.ts | 2 +- src/vs/code/electron-main/storage.ts | 15 +-- src/vs/code/electron-main/update-manager.ts | 12 +- src/vs/code/electron-main/window.ts | 14 +- src/vs/code/electron-main/windows.ts | 127 +++++++++--------- 12 files changed, 155 insertions(+), 159 deletions(-) diff --git a/src/vs/code/electron-main/auto-updater.linux.ts b/src/vs/code/electron-main/auto-updater.linux.ts index dbb72b65b47..9f088b3868c 100644 --- a/src/vs/code/electron-main/auto-updater.linux.ts +++ b/src/vs/code/electron-main/auto-updater.linux.ts @@ -5,7 +5,7 @@ 'use strict'; -import events = require('events'); +import { EventEmitter } from 'events'; import { isString } from 'vs/base/common/types'; import { Promise } from 'vs/base/common/winjs.base'; import { json } from 'vs/base/node/request'; @@ -20,7 +20,7 @@ export interface IUpdate { version?: string; } -export class LinuxAutoUpdaterImpl extends events.EventEmitter { +export class LinuxAutoUpdaterImpl extends EventEmitter { private url: string; private currentRequest: Promise; diff --git a/src/vs/code/electron-main/auto-updater.win32.ts b/src/vs/code/electron-main/auto-updater.win32.ts index 79a1c79b346..5707288c5e2 100644 --- a/src/vs/code/electron-main/auto-updater.win32.ts +++ b/src/vs/code/electron-main/auto-updater.win32.ts @@ -5,11 +5,11 @@ 'use strict'; -import events = require('events'); -import path = require('path'); -import os = require('os'); -import cp = require('child_process'); -import pfs = require('vs/base/node/pfs'); +import * as path from 'path'; +import * as pfs from 'vs/base/node/pfs'; +import { EventEmitter } from 'events'; +import { tmpdir } from 'os'; +import { spawn } from 'child_process'; import { mkdirp } from 'vs/base/node/extfs'; import { isString } from 'vs/base/common/types'; import { Promise, TPromise } from 'vs/base/common/winjs.base'; @@ -26,7 +26,7 @@ export interface IUpdate { version?: string; } -export class Win32AutoUpdaterImpl extends events.EventEmitter { +export class Win32AutoUpdaterImpl extends EventEmitter { private url: string; private currentRequest: Promise; @@ -42,16 +42,16 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter { this.currentRequest = null; } - public get cachePath(): TPromise { - let result = path.join(os.tmpdir(), 'vscode-update'); + get cachePath(): TPromise { + let result = path.join(tmpdir(), 'vscode-update'); return new TPromise((c, e) => mkdirp(result, null, err => err ? e(err) : c(result))); } - public setFeedURL(url: string): void { + setFeedURL(url: string): void { this.url = url; } - public checkForUpdates(): void { + checkForUpdates(): void { if (!this.url) { throw new Error('No feed url set.'); } @@ -123,7 +123,7 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter { return; } - cp.spawn(updatePackagePath, ['/silent', '/mergetasks=runcode,!desktopicon,!quicklaunchicon'], { + spawn(updatePackagePath, ['/silent', '/mergetasks=runcode,!desktopicon,!quicklaunchicon'], { detached: true, stdio: ['ignore', 'ignore', 'ignore'] }); diff --git a/src/vs/code/electron-main/env.ts b/src/vs/code/electron-main/env.ts index bced8f211f9..94e7da8666d 100644 --- a/src/vs/code/electron-main/env.ts +++ b/src/vs/code/electron-main/env.ts @@ -5,19 +5,19 @@ 'use strict'; -import crypto = require('crypto'); -import fs = require('fs'); -import path = require('path'); -import os = require('os'); -import {app} from 'electron'; -import arrays = require('vs/base/common/arrays'); -import strings = require('vs/base/common/strings'); -import paths = require('vs/base/common/paths'); -import platform = require('vs/base/common/platform'); -import uri from 'vs/base/common/uri'; -import types = require('vs/base/common/types'); -import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/common/instantiation'; -import product, {IProductConfiguration} from 'vs/code/node/product'; +import * as crypto from 'crypto'; +import * as fs from 'fs'; +import * as path from 'path'; +import { tmpdir } from 'os'; +import { app } from 'electron'; +import * as arrays from 'vs/base/common/arrays'; +import * as strings from 'vs/base/common/strings'; +import * as paths from 'vs/base/common/paths'; +import * as platform from 'vs/base/common/platform'; +import URI from 'vs/base/common/uri'; +import * as types from 'vs/base/common/types'; +import { ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/common/instantiation'; +import product, { IProductConfiguration } from 'vs/code/node/product'; import { parseArgs } from 'vs/code/node/argv'; export interface IProcessEnvironment { @@ -132,7 +132,7 @@ export class EnvService implements IEnvironmentService { get sharedIPCHandle(): string { return this._sharedIPCHandle; } constructor() { - this._appRoot = path.dirname(uri.parse(require.toUrl('')).fsPath); + this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath); this._currentWorkingDirectory = process.env['VSCODE_CWD'] || process.cwd(); this._version = app.getVersion(); this._appHome = app.getPath('userData'); @@ -239,7 +239,7 @@ export class EnvService implements IEnvironmentService { return '\\\\.\\pipe\\' + handleName; } - return path.join(os.tmpdir(), handleName); + return path.join(tmpdir(), handleName); } private static getUniqueUserId(): string { diff --git a/src/vs/code/electron-main/lifecycle.ts b/src/vs/code/electron-main/lifecycle.ts index a39b01fdfeb..172bb1523ac 100644 --- a/src/vs/code/electron-main/lifecycle.ts +++ b/src/vs/code/electron-main/lifecycle.ts @@ -5,14 +5,13 @@ 'use strict'; -import events = require('events'); -import {ipcMain as ipc, app} from 'electron'; - -import {TPromise, TValueCallback} from 'vs/base/common/winjs.base'; -import {ReadyState, VSCodeWindow} from 'vs/code/electron-main/window'; -import env = require('vs/code/electron-main/env'); -import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/common/instantiation'; -import {ILogService} from './log'; +import { EventEmitter } from 'events'; +import { ipcMain as ipc, app } from 'electron'; +import { TPromise, TValueCallback } from 'vs/base/common/winjs.base'; +import { ReadyState, VSCodeWindow } from 'vs/code/electron-main/window'; +import { IEnvironmentService } from 'vs/code/electron-main/env'; +import { ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/common/instantiation'; +import { ILogService } from './log'; const EventTypes = { BEFORE_QUIT: 'before-quit' @@ -33,7 +32,7 @@ export class LifecycleService implements ILifecycleService { serviceId = ILifecycleService; - private eventEmitter = new events.EventEmitter(); + private eventEmitter = new EventEmitter(); private windowToCloseRequest: { [windowId: string]: boolean }; private quitRequested: boolean; private pendingQuitPromise: TPromise; @@ -41,7 +40,7 @@ export class LifecycleService implements ILifecycleService { private oneTimeListenerTokenGenerator: number; constructor( - @env.IEnvironmentService private envService: env.IEnvironmentService, + @IEnvironmentService private envService: IEnvironmentService, @ILogService private logService: ILogService ) { this.windowToCloseRequest = Object.create(null); diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 24ed520f964..ab1afcbf38c 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -5,31 +5,31 @@ 'use strict'; -import {app, ipcMain as ipc} from 'electron'; -import fs = require('fs'); -import nls = require('vs/nls'); -import {assign} from 'vs/base/common/objects'; -import platform = require('vs/base/common/platform'); +import * as nls from 'vs/nls'; +import * as fs from 'fs'; +import { app, ipcMain as ipc } from 'electron'; +import { assign } from 'vs/base/common/objects'; +import * as platform from 'vs/base/common/platform'; import { IProcessEnvironment, IEnvironmentService, EnvService } from 'vs/code/electron-main/env'; -import windows = require('vs/code/electron-main/windows'); +import { IWindowsService, WindowsManager } from 'vs/code/electron-main/windows'; import { ILifecycleService, LifecycleService } from 'vs/code/electron-main/lifecycle'; import { VSCodeMenu } from 'vs/code/electron-main/menus'; -import {ISettingsService, SettingsManager} from 'vs/code/electron-main/settings'; -import {IUpdateService, UpdateManager} from 'vs/code/electron-main/update-manager'; -import {Server, serve, connect} from 'vs/base/parts/ipc/node/ipc.net'; -import {getUnixUserEnvironment, IEnv} from 'vs/base/node/env'; -import {TPromise} from 'vs/base/common/winjs.base'; -import {AskpassChannel} from 'vs/workbench/parts/git/common/gitIpc'; -import {GitAskpassService} from 'vs/workbench/parts/git/electron-main/askpassService'; -import {spawnSharedProcess} from 'vs/code/electron-main/sharedProcess'; -import {Mutex} from 'windows-mutex'; -import {LaunchService, ILaunchChannel, LaunchChannel, LaunchChannelClient} from './launch'; -import {ServicesAccessor, IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService'; -import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; -import {SyncDescriptor} from 'vs/platform/instantiation/common/descriptors'; -import {ILogService, MainLogService} from './log'; -import {IStorageService, StorageService} from './storage'; +import { ISettingsService, SettingsManager } from 'vs/code/electron-main/settings'; +import { IUpdateService, UpdateManager } from 'vs/code/electron-main/update-manager'; +import { Server, serve, connect } from 'vs/base/parts/ipc/node/ipc.net'; +import { getUnixUserEnvironment, IEnv } from 'vs/base/node/env'; +import { TPromise } from 'vs/base/common/winjs.base'; +import { AskpassChannel } from 'vs/workbench/parts/git/common/gitIpc'; +import { GitAskpassService } from 'vs/workbench/parts/git/electron-main/askpassService'; +import { spawnSharedProcess } from 'vs/code/electron-main/sharedProcess'; +import { Mutex } from 'windows-mutex'; +import { LaunchService, ILaunchChannel, LaunchChannel, LaunchChannelClient } from './launch'; +import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; +import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; +import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; +import { ILogService, MainLogService } from './log'; +import { IStorageService, StorageService } from './storage'; function quit(accessor: ServicesAccessor, error?: Error); function quit(accessor: ServicesAccessor, message?: string); @@ -55,7 +55,7 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn const instantiationService = accessor.get(IInstantiationService); const logService = accessor.get(ILogService); const envService = accessor.get(IEnvironmentService); - const windowManager = accessor.get(windows.IWindowsService); + const windowManager = accessor.get(IWindowsService); const lifecycleService = accessor.get(ILifecycleService); const updateManager = accessor.get(IUpdateService); const settingsManager = accessor.get(ISettingsService); @@ -258,7 +258,7 @@ const services = new ServiceCollection(); services.set(IEnvironmentService, new SyncDescriptor(EnvService)); services.set(ILogService, new SyncDescriptor(MainLogService)); -services.set(windows.IWindowsService, new SyncDescriptor(windows.WindowsManager)); +services.set(IWindowsService, new SyncDescriptor(WindowsManager)); services.set(ILifecycleService, new SyncDescriptor(LifecycleService)); services.set(IStorageService, new SyncDescriptor(StorageService)); services.set(IUpdateService, new SyncDescriptor(UpdateManager)); diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 2924039afe4..74cb9d3e79a 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -5,17 +5,16 @@ 'use strict'; -import {ipcMain as ipc, app, shell, dialog, Menu, MenuItem} from 'electron'; - -import nls = require('vs/nls'); -import platform = require('vs/base/common/platform'); -import arrays = require('vs/base/common/arrays'); +import * as nls from 'vs/nls'; +import * as platform from 'vs/base/common/platform'; +import * as arrays from 'vs/base/common/arrays'; +import * as env from 'vs/code/electron-main/env'; +import { ipcMain as ipc, app, shell, dialog, Menu, MenuItem } from 'electron'; import { IWindowsService, WindowsManager, IOpenedPathsList } from 'vs/code/electron-main/windows'; -import window = require('vs/code/electron-main/window'); -import env = require('vs/code/electron-main/env'); +import { IPath, VSCodeWindow } from 'vs/code/electron-main/window'; import { IStorageService } from 'vs/code/electron-main/storage'; import { IUpdateService, State as UpdateState } from 'vs/code/electron-main/update-manager'; -import {Keybinding} from 'vs/base/common/keyCodes'; +import { Keybinding } from 'vs/base/common/keyCodes'; interface IResolvedKeybinding { id: string; @@ -105,7 +104,7 @@ export class VSCodeMenu { this.updateManager.on('change', () => this.updateMenu()); } - private resolveKeybindings(win: window.VSCodeWindow): void { + private resolveKeybindings(win: VSCodeWindow): void { if (this.keybindingsResolved) { return; // only resolve once } @@ -134,7 +133,7 @@ export class VSCodeMenu { } } - private onOpen(path: window.IPath): void { + private onOpen(path: IPath): void { this.addToOpenedPathsList(path.filePath || path.workspacePath, !!path.filePath); this.updateMenu(); } diff --git a/src/vs/code/electron-main/settings.ts b/src/vs/code/electron-main/settings.ts index ee4a45e676b..19579977e61 100644 --- a/src/vs/code/electron-main/settings.ts +++ b/src/vs/code/electron-main/settings.ts @@ -5,7 +5,7 @@ 'use strict'; -import {app} from 'electron'; +import { app } from 'electron'; import { ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { UserSettings, ISettings } from 'vs/workbench/node/userSettings'; import { IEnvironmentService } from 'vs/code/electron-main/env'; diff --git a/src/vs/code/electron-main/sharedProcess.ts b/src/vs/code/electron-main/sharedProcess.ts index 6dc9ede600f..1b751863c7a 100644 --- a/src/vs/code/electron-main/sharedProcess.ts +++ b/src/vs/code/electron-main/sharedProcess.ts @@ -11,7 +11,7 @@ import { IEnvironment } from 'vs/platform/workspace/common/workspace'; import { IEnvironmentService } from 'vs/code/electron-main/env'; import { ISettingsService } from 'vs/code/electron-main/settings'; import { IUpdateService } from 'vs/code/electron-main/update-manager'; -import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation'; +import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; const boostrapPath = URI.parse(require.toUrl('bootstrap')).fsPath; diff --git a/src/vs/code/electron-main/storage.ts b/src/vs/code/electron-main/storage.ts index f3495643b7e..f0b7316667b 100644 --- a/src/vs/code/electron-main/storage.ts +++ b/src/vs/code/electron-main/storage.ts @@ -3,14 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ - 'use strict'; -import path = require('path'); -import fs = require('fs'); -import events = require('events'); -import env = require('vs/code/electron-main/env'); -import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/common/instantiation'; +import * as path from 'path'; +import * as fs from 'fs'; +import { EventEmitter } from 'events'; +import { IEnvironmentService } from 'vs/code/electron-main/env'; +import { ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/common/instantiation'; const EventTypes = { STORE: 'store' @@ -32,9 +31,9 @@ export class StorageService implements IStorageService { private dbPath: string; private database: any = null; - private eventEmitter = new events.EventEmitter(); + private eventEmitter = new EventEmitter(); - constructor(@env.IEnvironmentService private envService: env.IEnvironmentService) { + constructor(@IEnvironmentService private envService: IEnvironmentService) { this.dbPath = path.join(envService.appHome, 'storage.json'); } diff --git a/src/vs/code/electron-main/update-manager.ts b/src/vs/code/electron-main/update-manager.ts index 782431039d0..b2bdd4366d0 100644 --- a/src/vs/code/electron-main/update-manager.ts +++ b/src/vs/code/electron-main/update-manager.ts @@ -5,11 +5,11 @@ 'use strict'; -import fs = require('fs'); -import path = require('path'); -import events = require('events'); -import electron = require('electron'); -import platform = require('vs/base/common/platform'); +import * as fs from 'fs'; +import * as path from 'path'; +import * as electron from 'electron'; +import * as platform from 'vs/base/common/platform'; +import { EventEmitter } from 'events'; import { IEnvironmentService, getPlatformIdentifier } from 'vs/code/electron-main/env'; import { ISettingsService } from 'vs/code/electron-main/settings'; import { Win32AutoUpdaterImpl } from 'vs/code/electron-main/auto-updater.win32'; @@ -56,7 +56,7 @@ export interface IUpdateService { on(event: string, listener: Function): this; } -export class UpdateManager extends events.EventEmitter implements IUpdateService { +export class UpdateManager extends EventEmitter implements IUpdateService { serviceId = IUpdateService; diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index b3c35534920..2fde7589e29 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -5,13 +5,13 @@ 'use strict'; -import path = require('path'); -import {shell, screen, BrowserWindow} from 'electron'; -import {TPromise, TValueCallback} from 'vs/base/common/winjs.base'; -import platform = require('vs/base/common/platform'); -import objects = require('vs/base/common/objects'); +import * as path from 'path'; +import * as platform from 'vs/base/common/platform'; +import * as objects from 'vs/base/common/objects'; +import { IStorageService } from 'vs/code/electron-main/storage'; +import { shell, screen, BrowserWindow } from 'electron'; +import { TPromise, TValueCallback } from 'vs/base/common/winjs.base'; import { ICommandLineArguments, IEnvironmentService, IProcessEnvironment } from 'vs/code/electron-main/env'; -import storage = require('vs/code/electron-main/storage'); import { ILogService } from './log'; export interface IWindowState { @@ -158,7 +158,7 @@ export class VSCodeWindow { config: IWindowCreationOptions, @ILogService private logService: ILogService, @IEnvironmentService private envService: IEnvironmentService, - @storage.IStorageService private storageService: storage.IStorageService + @IStorageService private storageService: IStorageService ) { this._lastFocusTime = -1; this._readyState = ReadyState.NONE; diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 75d9e541fd8..a8a8fdbe99a 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -3,26 +3,25 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ - 'use strict'; -import events = require('events'); -import path = require('path'); -import fs = require('fs'); -import {ipcMain as ipc, app, screen, crashReporter, BrowserWindow, dialog} from 'electron'; -import platform = require('vs/base/common/platform'); +import * as path from 'path'; +import * as fs from 'fs'; +import * as platform from 'vs/base/common/platform'; +import * as nls from 'vs/nls'; +import * as paths from 'vs/base/common/paths'; +import * as arrays from 'vs/base/common/arrays'; +import * as objects from 'vs/base/common/objects'; +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'; +import { ipcMain as ipc, app, screen, crashReporter, BrowserWindow, dialog } from 'electron'; import { ICommandLineArguments, IProcessEnvironment, IEnvironmentService, IParsedPath, parseLineAndColumnAware } from 'vs/code/electron-main/env'; -import window = require('vs/code/electron-main/window'); import { ILifecycleService } from 'vs/code/electron-main/lifecycle'; -import nls = require('vs/nls'); -import paths = require('vs/base/common/paths'); -import arrays = require('vs/base/common/arrays'); -import objects = require('vs/base/common/objects'); -import storage = require('vs/code/electron-main/storage'); -import {ISettingsService} from 'vs/code/electron-main/settings'; -import {IUpdateService, IUpdate} from 'vs/code/electron-main/update-manager'; +import { ISettingsService } from 'vs/code/electron-main/settings'; +import { IUpdateService, IUpdate } from 'vs/code/electron-main/update-manager'; import { ILogService } from './log'; -import {ServiceIdentifier, createDecorator, IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; +import { ServiceIdentifier, createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; const EventTypes = { OPEN: 'open', @@ -42,13 +41,13 @@ export interface IOpenConfiguration { preferNewWindow?: boolean; forceNewWindow?: boolean; forceEmpty?: boolean; - windowToUse?: window.VSCodeWindow; + windowToUse?: VSCodeWindow; diffMode?: boolean; } interface IWindowState { workspacePath?: string; - uiState: window.IWindowState; + uiState: ISingleWindowState; } interface IWindowsState { @@ -79,27 +78,27 @@ export interface IWindowsService { // TODO make proper events // events - onOpen(clb: (path: window.IPath) => void): () => void; - onReady(clb: (win: window.VSCodeWindow) => void): () => void; + onOpen(clb: (path: IPath) => void): () => void; + onReady(clb: (win: VSCodeWindow) => void): () => void; onClose(clb: (id: number) => void): () => void; // methods ready(initialUserEnv: IProcessEnvironment): void; - reload(win: window.VSCodeWindow, cli?: ICommandLineArguments): void; - open(openConfig: IOpenConfiguration): window.VSCodeWindow[]; + reload(win: VSCodeWindow, cli?: ICommandLineArguments): void; + open(openConfig: IOpenConfiguration): VSCodeWindow[]; openPluginDevelopmentHostWindow(openConfig: IOpenConfiguration): void; openFileFolderPicker(forceNewWindow?: boolean): void; openFilePicker(forceNewWindow?: boolean): void; openFolderPicker(forceNewWindow?: boolean): void; - focusLastActive(cli: ICommandLineArguments): window.VSCodeWindow; - getLastActiveWindow(): window.VSCodeWindow; - findWindow(workspacePath: string, filePath?: string, extensionDevelopmentPath?: string): window.VSCodeWindow; + focusLastActive(cli: ICommandLineArguments): VSCodeWindow; + getLastActiveWindow(): VSCodeWindow; + findWindow(workspacePath: string, filePath?: string, extensionDevelopmentPath?: string): VSCodeWindow; openNewWindow(): void; sendToFocused(channel: string, ...args: any[]): void; sendToAll(channel: string, payload: any, windowIdsToIgnore?: number[]): void; - getFocusedWindow(): window.VSCodeWindow; - getWindowById(windowId: number): window.VSCodeWindow; - getWindows(): window.VSCodeWindow[]; + getFocusedWindow(): VSCodeWindow; + getWindowById(windowId: number): VSCodeWindow; + getWindows(): VSCodeWindow[]; getWindowCount(): number; } @@ -112,29 +111,29 @@ export class WindowsManager implements IWindowsService { private static workingDirPickerStorageKey = 'pickerWorkingDir'; private static windowsStateStorageKey = 'windowsState'; - private static WINDOWS: window.VSCodeWindow[] = []; + private static WINDOWS: VSCodeWindow[] = []; - private eventEmitter = new events.EventEmitter(); + private eventEmitter = new EventEmitter(); private initialUserEnv: IProcessEnvironment; private windowsState: IWindowsState; constructor( @IInstantiationService private instantiationService: IInstantiationService, @ILogService private logService: ILogService, - @storage.IStorageService private storageService: storage.IStorageService, + @IStorageService private storageService: IStorageService, @IEnvironmentService private envService: IEnvironmentService, @ILifecycleService private lifecycleService: ILifecycleService, @IUpdateService private updateManager: IUpdateService, @ISettingsService private settingsManager: ISettingsService ) { } - onOpen(clb: (path: window.IPath) => void): () => void { + onOpen(clb: (path: IPath) => void): () => void { this.eventEmitter.addListener(EventTypes.OPEN, clb); return () => this.eventEmitter.removeListener(EventTypes.OPEN, clb); } - onReady(clb: (win: window.VSCodeWindow) => void): () => void { + onReady(clb: (win: VSCodeWindow) => void): () => void { this.eventEmitter.addListener(EventTypes.READY, clb); return () => this.eventEmitter.removeListener(EventTypes.READY, clb); @@ -350,9 +349,9 @@ export class WindowsManager implements IWindowsService { this.logService.log('IPC#vscode:toggleMenuBar'); // Update in settings - let menuBarHidden = this.storageService.getItem(window.VSCodeWindow.menuBarHiddenKey, false); + let menuBarHidden = this.storageService.getItem(VSCodeWindow.menuBarHiddenKey, false); let newMenuBarHidden = !menuBarHidden; - this.storageService.setItem(window.VSCodeWindow.menuBarHiddenKey, newMenuBarHidden); + this.storageService.setItem(VSCodeWindow.menuBarHiddenKey, newMenuBarHidden); // Update across windows WindowsManager.WINDOWS.forEach(w => w.setMenuBarVisibility(!newMenuBarHidden)); @@ -451,7 +450,7 @@ export class WindowsManager implements IWindowsService { } // 2-N windows open: Keep a list of windows that are opened on a specific folder to restore it in the next session as needed - this.windowsState.openedFolders = WindowsManager.WINDOWS.filter(w => w.readyState === window.ReadyState.READY && !!w.openedWorkspacePath && !w.isPluginDevelopmentHost).map(w => { + this.windowsState.openedFolders = WindowsManager.WINDOWS.filter(w => w.readyState === ReadyState.READY && !!w.openedWorkspacePath && !w.isPluginDevelopmentHost).map(w => { return { workspacePath: w.openedWorkspacePath, uiState: w.serializeWindowState() @@ -479,11 +478,11 @@ export class WindowsManager implements IWindowsService { // Theme changes if (event === 'vscode:changeTheme' && typeof payload === 'string') { - this.storageService.setItem(window.VSCodeWindow.themeStorageKey, payload); + this.storageService.setItem(VSCodeWindow.themeStorageKey, payload); } } - public reload(win: window.VSCodeWindow, cli?: ICommandLineArguments): void { + public reload(win: VSCodeWindow, cli?: ICommandLineArguments): void { // Only reload when the window has not vetoed this this.lifecycleService.unload(win).done((veto) => { @@ -493,9 +492,9 @@ export class WindowsManager implements IWindowsService { }); } - public open(openConfig: IOpenConfiguration): window.VSCodeWindow[] { - let iPathsToOpen: window.IPath[]; - let usedWindows: window.VSCodeWindow[] = []; + public open(openConfig: IOpenConfiguration): VSCodeWindow[] { + let iPathsToOpen: IPath[]; + let usedWindows: VSCodeWindow[] = []; // Find paths from provided paths if any if (openConfig.pathsToOpen && openConfig.pathsToOpen.length > 0) { @@ -543,8 +542,8 @@ export class WindowsManager implements IWindowsService { iPathsToOpen = this.cliToPaths(openConfig.cli, ignoreFileNotFound); } - let filesToOpen: window.IPath[] = []; - let filesToDiff: window.IPath[] = []; + let filesToOpen: IPath[] = []; + let filesToDiff: IPath[] = []; let foldersToOpen = iPathsToOpen.filter((iPath) => iPath.workspacePath && !iPath.filePath && !iPath.installExtensionPath); let emptyToOpen = iPathsToOpen.filter((iPath) => !iPath.workspacePath && !iPath.filePath && !iPath.installExtensionPath); let extensionsToInstall = iPathsToOpen.filter((iPath) => iPath.installExtensionPath).map(ipath => ipath.filePath); @@ -565,7 +564,7 @@ export class WindowsManager implements IWindowsService { filesToOpen = candidates; } - let configuration: window.IWindowConfiguration; + let configuration: IWindowConfiguration; // Handle files to open/diff or to create when we dont open a folder if (!foldersToOpen.length && (filesToOpen.length > 0 || filesToCreate.length > 0 || filesToDiff.length > 0 || extensionsToInstall.length > 0)) { @@ -719,8 +718,8 @@ export class WindowsManager implements IWindowsService { this.open({ cli: openConfig.cli, forceNewWindow: true, forceEmpty: openConfig.cli.pathArguments.length === 0 }); } - private toConfiguration(userEnv: IProcessEnvironment, cli: ICommandLineArguments, workspacePath?: string, filesToOpen?: window.IPath[], filesToCreate?: window.IPath[], filesToDiff?: window.IPath[], extensionsToInstall?: string[]): window.IWindowConfiguration { - let configuration: window.IWindowConfiguration = objects.mixin({}, cli); // inherit all properties from CLI + private toConfiguration(userEnv: IProcessEnvironment, cli: ICommandLineArguments, workspacePath?: string, filesToOpen?: IPath[], filesToCreate?: IPath[], filesToDiff?: IPath[], extensionsToInstall?: string[]): IWindowConfiguration { + let configuration: IWindowConfiguration = objects.mixin({}, cli); // inherit all properties from CLI configuration.execPath = process.execPath; configuration.workspacePath = workspacePath; configuration.filesToOpen = filesToOpen; @@ -761,7 +760,7 @@ export class WindowsManager implements IWindowsService { return configuration; } - private getRecentlyOpenedPaths(workspacePath?: string, filesToOpen?: window.IPath[]): IOpenedPathsList { + private getRecentlyOpenedPaths(workspacePath?: string, filesToOpen?: IPath[]): IOpenedPathsList { let files: string[]; let folders: string[]; @@ -800,7 +799,7 @@ export class WindowsManager implements IWindowsService { return { files, folders }; } - private toIPath(anyPath: string, ignoreFileNotFound?: boolean, gotoLineMode?: boolean): window.IPath { + private toIPath(anyPath: string, ignoreFileNotFound?: boolean, gotoLineMode?: boolean): IPath { if (!anyPath) { return null; } @@ -833,7 +832,7 @@ export class WindowsManager implements IWindowsService { return null; } - private cliToPaths(cli: ICommandLineArguments, ignoreFileNotFound?: boolean): window.IPath[] { + private cliToPaths(cli: ICommandLineArguments, ignoreFileNotFound?: boolean): IPath[] { // Check for pass in candidate or last opened path let candidates: string[] = []; @@ -874,8 +873,8 @@ export class WindowsManager implements IWindowsService { return [Object.create(null)]; } - private openInBrowserWindow(configuration: window.IWindowConfiguration, forceNewWindow?: boolean, windowToUse?: window.VSCodeWindow): window.VSCodeWindow { - let vscodeWindow: window.VSCodeWindow; + private openInBrowserWindow(configuration: IWindowConfiguration, forceNewWindow?: boolean, windowToUse?: VSCodeWindow): VSCodeWindow { + let vscodeWindow: VSCodeWindow; if (!forceNewWindow) { vscodeWindow = windowToUse || this.getLastActiveWindow(); @@ -887,7 +886,7 @@ export class WindowsManager implements IWindowsService { // New window if (!vscodeWindow) { - vscodeWindow = this.instantiationService.createInstance(window.VSCodeWindow, { + vscodeWindow = this.instantiationService.createInstance(VSCodeWindow, { state: this.getNewWindowState(configuration), extensionDevelopmentPath: configuration.extensionDevelopmentPath }); @@ -935,7 +934,7 @@ export class WindowsManager implements IWindowsService { return vscodeWindow; } - private getNewWindowState(configuration: window.IWindowConfiguration): window.IWindowState { + private getNewWindowState(configuration: IWindowConfiguration): ISingleWindowState { // plugin development host Window - load from stored settings if any if (!!configuration.extensionDevelopmentPath && this.windowsState.lastPluginDevelopmentHostWindow) { @@ -989,14 +988,14 @@ export class WindowsManager implements IWindowsService { } } - let defaultState = window.defaultWindowState(); + let defaultState = defaultWindowState(); defaultState.x = displayToUse.bounds.x + (displayToUse.bounds.width / 2) - (defaultState.width / 2); defaultState.y = displayToUse.bounds.y + (displayToUse.bounds.height / 2) - (defaultState.height / 2); return this.ensureNoOverlap(defaultState); } - private ensureNoOverlap(state: window.IWindowState): window.IWindowState { + private ensureNoOverlap(state: ISingleWindowState): ISingleWindowState { if (WindowsManager.WINDOWS.length === 0) { return state; } @@ -1058,7 +1057,7 @@ export class WindowsManager implements IWindowsService { }); } - public focusLastActive(cli: ICommandLineArguments): window.VSCodeWindow { + public focusLastActive(cli: ICommandLineArguments): VSCodeWindow { let lastActive = this.getLastActiveWindow(); if (lastActive) { lastActive.focus(); @@ -1073,7 +1072,7 @@ export class WindowsManager implements IWindowsService { return res && res[0]; } - public getLastActiveWindow(): window.VSCodeWindow { + public getLastActiveWindow(): VSCodeWindow { if (WindowsManager.WINDOWS.length) { let lastFocussedDate = Math.max.apply(Math, WindowsManager.WINDOWS.map((w) => w.lastFocusTime)); let res = WindowsManager.WINDOWS.filter((w) => w.lastFocusTime === lastFocussedDate); @@ -1085,7 +1084,7 @@ export class WindowsManager implements IWindowsService { return null; } - public findWindow(workspacePath: string, filePath?: string, extensionDevelopmentPath?: string): window.VSCodeWindow { + public findWindow(workspacePath: string, filePath?: string, extensionDevelopmentPath?: string): VSCodeWindow { if (WindowsManager.WINDOWS.length) { // Sort the last active window to the front of the array of windows to test @@ -1152,7 +1151,7 @@ export class WindowsManager implements IWindowsService { }); } - public getFocusedWindow(): window.VSCodeWindow { + public getFocusedWindow(): VSCodeWindow { let win = BrowserWindow.getFocusedWindow(); if (win) { return this.getWindowById(win.id); @@ -1161,7 +1160,7 @@ export class WindowsManager implements IWindowsService { return null; } - public getWindowById(windowId: number): window.VSCodeWindow { + public getWindowById(windowId: number): VSCodeWindow { let res = WindowsManager.WINDOWS.filter((w) => w.id === windowId); if (res && res.length === 1) { return res[0]; @@ -1170,7 +1169,7 @@ export class WindowsManager implements IWindowsService { return null; } - public getWindows(): window.VSCodeWindow[] { + public getWindows(): VSCodeWindow[] { return WindowsManager.WINDOWS; } @@ -1178,7 +1177,7 @@ export class WindowsManager implements IWindowsService { return WindowsManager.WINDOWS.length; } - private onWindowError(vscodeWindow: window.VSCodeWindow, error: WindowError): void { + private onWindowError(vscodeWindow: VSCodeWindow, error: WindowError): void { console.error(error === WindowError.CRASHED ? '[VS Code]: render process crashed!' : '[VS Code]: detected unresponsive'); // Unresponsive @@ -1220,8 +1219,8 @@ export class WindowsManager implements IWindowsService { } } - private onBeforeWindowClose(win: window.VSCodeWindow): void { - if (win.readyState !== window.ReadyState.READY) { + private onBeforeWindowClose(win: VSCodeWindow): void { + if (win.readyState !== ReadyState.READY) { return; // only persist windows that are fully loaded } @@ -1240,7 +1239,7 @@ export class WindowsManager implements IWindowsService { } } - private onWindowClosed(win: window.VSCodeWindow): void { + private onWindowClosed(win: VSCodeWindow): void { // Tell window win.dispose();