diff --git a/src/vs/workbench/electron-browser/actions.ts b/src/vs/workbench/electron-browser/actions.ts index 8abbb2222b1..0d468d05be4 100644 --- a/src/vs/workbench/electron-browser/actions.ts +++ b/src/vs/workbench/electron-browser/actions.ts @@ -44,7 +44,7 @@ export class CloseEditorAction extends Action { } public run(): TPromise { - let activeEditor = this.editorService.getActiveEditor(); + const activeEditor = this.editorService.getActiveEditor(); if (activeEditor) { return this.editorService.closeEditor(activeEditor.position, activeEditor.input); } @@ -270,15 +270,15 @@ export class ShowStartupPerformance extends Action { } private _analyzeLoaderTimes(): any[] { - let stats = (require).getStats(); - let result = []; + const stats = (require).getStats(); + const result = []; let total = 0; for (let i = 0, len = stats.length; i < len; i++) { if (stats[i].type === LoaderEventType.NodeEndNativeRequire) { if (stats[i - 1].type === LoaderEventType.NodeBeginNativeRequire && stats[i - 1].detail === stats[i].detail) { - let entry: any = {}; + const entry: any = {}; entry['Event'] = 'nodeRequire ' + stats[i].detail; entry['Took (ms)'] = (stats[i].timestamp - stats[i - 1].timestamp); total += (stats[i].timestamp - stats[i - 1].timestamp); @@ -290,7 +290,7 @@ export class ShowStartupPerformance extends Action { } if (total > 0) { - let entry: any = {}; + const entry: any = {}; entry['Event'] = '===nodeRequire TOTAL'; entry['Took (ms)'] = total; entry['Start (ms)'] = '**'; @@ -302,18 +302,18 @@ export class ShowStartupPerformance extends Action { } public run(): TPromise { - let table: any[] = []; + const table: any[] = []; table.push(...this._analyzeLoaderTimes()); - let start = Math.round(remote.getGlobal('programStart') || remote.getGlobal('vscodeStart')); - let windowShowTime = Math.round(remote.getGlobal('windowShow')); + const start = Math.round(remote.getGlobal('programStart') || remote.getGlobal('vscodeStart')); + const windowShowTime = Math.round(remote.getGlobal('windowShow')); let lastEvent: timer.ITimerEvent; - let events = timer.getTimeKeeper().getCollectedEvents(); + const events = timer.getTimeKeeper().getCollectedEvents(); events.forEach((e) => { if (e.topic === 'Startup') { lastEvent = e; - let entry: any = {}; + const entry: any = {}; entry['Event'] = e.name; entry['Took (ms)'] = e.stopTime.getTime() - e.startTime.getTime(); @@ -326,12 +326,12 @@ export class ShowStartupPerformance extends Action { table.push({ Event: '---------------------------' }); - let windowShowEvent: any = {}; + const windowShowEvent: any = {}; windowShowEvent['Event'] = 'Show Window at'; windowShowEvent['Start (ms)'] = windowShowTime - start; table.push(windowShowEvent); - let sum: any = {}; + const sum: any = {}; sum['Event'] = 'Total'; sum['Took (ms)'] = lastEvent.stopTime.getTime() - start; table.push(sum); @@ -384,7 +384,7 @@ export class OpenRecentAction extends Action { const recentFolders = this.contextService.getConfiguration().env.recentFolders; const recentFiles = this.contextService.getConfiguration().env.recentFiles; - let folderPicks: IPickOpenEntry[] = recentFolders.map((p, index) => { + const folderPicks: IPickOpenEntry[] = recentFolders.map((p, index) => { return { label: paths.basename(p), description: paths.dirname(p), @@ -394,7 +394,7 @@ export class OpenRecentAction extends Action { }; }); - let filePicks: IPickOpenEntry[] = recentFiles.map((p, index) => { + const filePicks: IPickOpenEntry[] = recentFiles.map((p, index) => { return { label: paths.basename(p), description: paths.dirname(p), @@ -414,7 +414,7 @@ export class OpenRecentAction extends Action { } private runPick(path, context): void { - let newWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; + const newWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; ipc.send('vscode:windowOpen', [path], newWindow); } @@ -460,7 +460,6 @@ CommandsRegistry.registerCommand('_workbench.ipc', function (accessor: ServicesA }); CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string]) { - const editorService = accessor.get(IWorkbenchEditorService); let [left, right, label] = args; @@ -479,9 +478,8 @@ CommandsRegistry.registerCommand('_workbench.diff', function (accessor: Services }); CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, number]) { - const editorService = accessor.get(IWorkbenchEditorService); - let [resource, column] = args; + const [resource, column] = args; return editorService.openEditor({ resource }, column).then(() => { return void 0; diff --git a/src/vs/workbench/electron-browser/crashReporter.ts b/src/vs/workbench/electron-browser/crashReporter.ts index 2092099bd5d..534d7f507e9 100644 --- a/src/vs/workbench/electron-browser/crashReporter.ts +++ b/src/vs/workbench/electron-browser/crashReporter.ts @@ -14,9 +14,9 @@ import {Registry} from 'vs/platform/platform'; import {ipcRenderer as ipc, crashReporter} from 'electron'; -let TELEMETRY_SECTION_ID = 'telemetry'; +const TELEMETRY_SECTION_ID = 'telemetry'; -let configurationRegistry = Registry.as(Extensions.Configuration); +const configurationRegistry = Registry.as(Extensions.Configuration); configurationRegistry.registerConfiguration({ 'id': TELEMETRY_SECTION_ID, 'order': 110.5, @@ -53,7 +53,7 @@ export class CrashReporter { public start(rawConfiguration:Electron.CrashReporterStartOptions): void { if (!this.isStarted) { - let sessionId = !this.sessionId + const sessionId = !this.sessionId ? this.telemetryService.getTelemetryInfo().then(info => this.sessionId = info.sessionId) : TPromise.as(undefined); diff --git a/src/vs/workbench/electron-browser/integration.ts b/src/vs/workbench/electron-browser/integration.ts index c74a9957930..960cb4a4eb4 100644 --- a/src/vs/workbench/electron-browser/integration.ts +++ b/src/vs/workbench/electron-browser/integration.ts @@ -60,7 +60,7 @@ export class ElectronIntegration { public integrate(shellContainer: HTMLElement): void { // Register the active window - let activeWindow = this.instantiationService.createInstance(ElectronWindow, currentWindow, shellContainer); + const activeWindow = this.instantiationService.createInstance(ElectronWindow, currentWindow, shellContainer); this.windowService.registerWindow(activeWindow); // Support runAction event @@ -70,10 +70,10 @@ export class ElectronIntegration { // Support options change ipc.on('vscode:optionsChange', (event, options: string) => { - let optionsData = JSON.parse(options); + const optionsData = JSON.parse(options); for (let key in optionsData) { if (optionsData.hasOwnProperty(key)) { - let value = optionsData[key]; + const value = optionsData[key]; this.contextService.updateOptions(key, value); } } @@ -102,7 +102,7 @@ export class ElectronIntegration { ipc.on('vscode:reportError', (event, error) => { if (error) { - let errorParsed = JSON.parse(error); + const errorParsed = JSON.parse(error); errorParsed.mainProcess = true; errors.onUnexpectedError(errorParsed); } @@ -124,7 +124,7 @@ export class ElectronIntegration { // Configuration changes let previousConfiguredZoomLevel: number; this.configurationService.onDidUpdateConfiguration(e => { - let windowConfig: IWindowConfiguration = e.config; + const windowConfig: IWindowConfiguration = e.config; let newZoomLevel = 0; if (windowConfig.window && typeof windowConfig.window.zoomLevel === 'number') { @@ -172,12 +172,12 @@ export class ElectronIntegration { private resolveKeybindings(actionIds: string[]): TPromise<{ id: string; binding: number; }[]> { return this.partService.joinCreation().then(() => { return arrays.coalesce(actionIds.map((id) => { - let bindings = this.keybindingService.lookupKeybindings(id); + const bindings = this.keybindingService.lookupKeybindings(id); // return the first binding that can be represented by electron for (let i = 0; i < bindings.length; i++) { - let binding = bindings[i]; - let electronAccelerator = this.keybindingService.getElectronAcceleratorFor(binding); + const binding = bindings[i]; + const electronAccelerator = this.keybindingService.getElectronAcceleratorFor(binding); if (electronAccelerator) { return { id: id, diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index cd033322563..19ef3a514e9 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -53,16 +53,17 @@ export interface IMainEnvironment extends IEnvironment { } export function startup(environment: IMainEnvironment, globalSettings: IGlobalSettings): winjs.TPromise { + // Shell Configuration - let shellConfiguration: IConfiguration = { + const shellConfiguration: IConfiguration = { env: environment }; // Shell Options - let filesToOpen = environment.filesToOpen && environment.filesToOpen.length ? toInputs(environment.filesToOpen) : null; - let filesToCreate = environment.filesToCreate && environment.filesToCreate.length ? toInputs(environment.filesToCreate) : null; - let filesToDiff = environment.filesToDiff && environment.filesToDiff.length ? toInputs(environment.filesToDiff) : null; - let shellOptions: IOptions = { + const filesToOpen = environment.filesToOpen && environment.filesToOpen.length ? toInputs(environment.filesToOpen) : null; + const filesToCreate = environment.filesToCreate && environment.filesToCreate.length ? toInputs(environment.filesToCreate) : null; + const filesToDiff = environment.filesToDiff && environment.filesToDiff.length ? toInputs(environment.filesToDiff) : null; + const shellOptions: IOptions = { singleFileMode: !environment.workspacePath, filesToOpen: filesToOpen, filesToCreate: filesToCreate, @@ -81,7 +82,7 @@ export function startup(environment: IMainEnvironment, globalSettings: IGlobalSe function toInputs(paths: IPath[]): IResourceInput[] { return paths.map(p => { - let input = { + const input = { resource: uri.file(p.filePath) }; @@ -112,11 +113,11 @@ function getWorkspace(environment: IMainEnvironment): IWorkspace { realWorkspacePath = strings.rtrim(realWorkspacePath, paths.nativeSep); } - let workspaceResource = uri.file(realWorkspacePath); - let folderName = path.basename(realWorkspacePath) || realWorkspacePath; - let folderStat = fs.statSync(realWorkspacePath); + const workspaceResource = uri.file(realWorkspacePath); + const folderName = path.basename(realWorkspacePath) || realWorkspacePath; + const folderStat = fs.statSync(realWorkspacePath); - let workspace: IWorkspace = { + const workspace: IWorkspace = { 'resource': workspaceResource, 'id': platform.isLinux ? realWorkspacePath : realWorkspacePath.toLowerCase(), 'name': folderName, @@ -128,9 +129,9 @@ function getWorkspace(environment: IMainEnvironment): IWorkspace { } function openWorkbench(workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise { - let eventService = new EventService(); - let contextService = new WorkspaceContextService(eventService, workspace, configuration, options); - let configurationService = new ConfigurationService(contextService, eventService); + const eventService = new EventService(); + const contextService = new WorkspaceContextService(eventService, workspace, configuration, options); + const configurationService = new ConfigurationService(contextService, eventService); // Since the configuration service is one of the core services that is used in so many places, we initialize it // right before startup of the workbench shell to have its data ready for consumers @@ -141,8 +142,8 @@ function openWorkbench(workspace: IWorkspace, configuration: IConfiguration, opt timers.afterReady = new Date(); // Open Shell - let beforeOpen = new Date(); - let shell = new WorkbenchShell(document.body, workspace, { + const beforeOpen = new Date(); + const shell = new WorkbenchShell(document.body, workspace, { configurationService, eventService, contextService @@ -150,7 +151,7 @@ function openWorkbench(workspace: IWorkspace, configuration: IConfiguration, opt shell.open(); shell.joinCreation().then(() => { - timer.start(timer.Topic.STARTUP, 'Open Shell, Viewlet & Editor', beforeOpen, 'Workbench has opened after this event with viewlet and editor restored').stop(); + timer.start(timer.Topic.STARTUP, 'Open Shell, Viewconst & Editor', beforeOpen, 'Workbench has opened after this event with viewconst and editor restored').stop(); }); // Inform user about loading issues from the loader diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index f841148dc26..1f7723e8736 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -65,7 +65,7 @@ export class ElectronWindow { // React to editor input changes (Mac only) if (platform.platform === platform.Platform.Mac) { this.editorGroupService.onEditorsChanged(() => { - let fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true); + const fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true); let representedFilename = ''; if (fileInput) { representedFilename = fileInput.getResource().fsPath; diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index eaf6c1dabf6..a90a36884c4 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -148,7 +148,7 @@ export class Workbench implements IPartService { // If String passed in as container, try to find it in DOM if (types.isString(container)) { - let element = withElementById(container.toString()); + const element = withElementById(container.toString()); this.container = element.getHTMLElement(); } @@ -178,7 +178,7 @@ export class Workbench implements IPartService { // Container assert.ok(container, 'Workbench requires a container to be created with'); if (types.isString(container)) { - let element = withElementById(container.toString()); + const element = withElementById(container.toString()); assert.ok(element, strings.format('Can not find HTMLElement with id \'{0}\'.', container)); } } @@ -224,29 +224,29 @@ export class Workbench implements IPartService { this.registerEmitters(); // Load composits and editors in parallel - let compositeAndEditorPromises: TPromise[] = []; + const compositeAndEditorPromises: TPromise[] = []; // Load Viewlet - let viewletRegistry = (Registry.as(ViewletExtensions.Viewlets)); + const viewletRegistry = (Registry.as(ViewletExtensions.Viewlets)); let viewletId = viewletRegistry.getDefaultViewletId(); if (!this.workbenchParams.configuration.env.isBuilt) { viewletId = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE, viewletRegistry.getDefaultViewletId()); // help developers and restore last view } if (!this.sideBarHidden && !!viewletId) { - let viewletTimerEvent = timer.start(timer.Topic.STARTUP, strings.format('Opening Viewlet: {0}', viewletId)); + const viewletTimerEvent = timer.start(timer.Topic.STARTUP, strings.format('Opening Viewlet: {0}', viewletId)); compositeAndEditorPromises.push(this.sidebarPart.openViewlet(viewletId, false).then(() => viewletTimerEvent.stop())); } // Load Panel - let panelRegistry = (Registry.as(PanelExtensions.Panels)); + const panelRegistry = (Registry.as(PanelExtensions.Panels)); const panelId = this.storageService.get(PanelPart.activePanelSettingsKey, StorageScope.WORKSPACE, panelRegistry.getDefaultPanelId()); if (!this.panelHidden && !!panelId) { compositeAndEditorPromises.push(this.panelPart.openPanel(panelId, false)); } // Load Editors - let editorTimerEvent = timer.start(timer.Topic.STARTUP, strings.format('Restoring Editor(s)')); + const editorTimerEvent = timer.start(timer.Topic.STARTUP, strings.format('Restoring Editor(s)')); compositeAndEditorPromises.push(this.resolveEditorsToOpen().then((inputsWithOptions) => { let editorOpenPromise: TPromise; if (inputsWithOptions.length) { @@ -300,9 +300,9 @@ export class Workbench implements IPartService { // Files to open, diff or create const wbopt = this.workbenchParams.options; if ((wbopt.filesToCreate && wbopt.filesToCreate.length) || (wbopt.filesToOpen && wbopt.filesToOpen.length) || (wbopt.filesToDiff && wbopt.filesToDiff.length)) { - let filesToCreate = wbopt.filesToCreate || []; - let filesToOpen = wbopt.filesToOpen || []; - let filesToDiff = wbopt.filesToDiff; + const filesToCreate = wbopt.filesToCreate || []; + const filesToOpen = wbopt.filesToOpen || []; + const filesToDiff = wbopt.filesToDiff; // Files to diff is exclusive if (filesToDiff && filesToDiff.length) { @@ -313,8 +313,8 @@ export class Workbench implements IPartService { // Otherwise: Open/Create files else { - let inputs: EditorInput[] = []; - let options: EditorOptions[] = []; + const inputs: EditorInput[] = []; + const options: EditorOptions[] = []; // Files to create inputs.push(...filesToCreate.map((resourceInput) => this.untitledEditorService.createOrGet(resourceInput.resource))); @@ -401,7 +401,7 @@ export class Workbench implements IPartService { serviceCollection.set(IQuickOpenService, this.quickOpen); // Contributed services - let contributedServices = getServices(); + const contributedServices = getServices(); for (let contributedService of contributedServices) { serviceCollection.set(contributedService.id, contributedService.descriptor); } @@ -420,20 +420,20 @@ export class Workbench implements IPartService { this.sideBarHidden = true; // we hide sidebar in single-file-mode } - let viewletRegistry = (Registry.as(ViewletExtensions.Viewlets)); + const viewletRegistry = (Registry.as(ViewletExtensions.Viewlets)); if (!viewletRegistry.getDefaultViewletId()) { - this.sideBarHidden = true; // can only hide sidebar if we dont have a default viewlet id + this.sideBarHidden = true; // can only hide sidebar if we dont have a default Viewlet id } // Panel part visibility - let panelRegistry = (Registry.as(PanelExtensions.Panels)); + const panelRegistry = (Registry.as(PanelExtensions.Panels)); this.panelHidden = this.storageService.getBoolean(Workbench.panelHiddenSettingKey, StorageScope.WORKSPACE, true); if (!!this.workbenchParams.options.singleFileMode || !panelRegistry.getDefaultPanelId()) { this.panelHidden = true; // we hide panel part in single-file-mode or if there is no default panel } // Sidebar position - let rawPosition = this.storageService.get(Workbench.sidebarPositionSettingKey, StorageScope.GLOBAL, 'left'); + const rawPosition = this.storageService.get(Workbench.sidebarPositionSettingKey, StorageScope.GLOBAL, 'left'); this.sideBarPosition = (rawPosition === 'left') ? Position.LEFT : Position.RIGHT; // Statusbar visibility @@ -459,7 +459,7 @@ export class Workbench implements IPartService { } public hasFocus(part: Parts): boolean { - let activeElement = document.activeElement; + const activeElement = document.activeElement; if (!activeElement) { return false; } @@ -533,21 +533,21 @@ export class Workbench implements IPartService { this.workbenchLayout.layout(true); } - // If sidebar becomes hidden, also hide the current active viewlet if any + // If sidebar becomes hidden, also hide the current active Viewlet if any if (hidden && this.sidebarPart.getActiveViewlet()) { this.sidebarPart.hideActiveViewlet(); // Pass Focus to Editor if Sidebar is now hidden - let editor = this.editorPart.getActiveEditor(); + const editor = this.editorPart.getActiveEditor(); if (editor) { editor.focus(); } } - // If sidebar becomes visible, show last active viewlet or default viewlet + // If sidebar becomes visible, show last active Viewlet or default viewlet else if (!hidden && !this.sidebarPart.getActiveViewlet()) { - let registry = (Registry.as(ViewletExtensions.Viewlets)); - let viewletToOpen = this.sidebarPart.getLastActiveViewletId() || registry.getDefaultViewletId(); + const registry = (Registry.as(ViewletExtensions.Viewlets)); + const viewletToOpen = this.sidebarPart.getLastActiveViewletId() || registry.getDefaultViewletId(); if (viewletToOpen) { this.sidebarPart.openViewlet(viewletToOpen, true).done(null, errors.onUnexpectedError); } @@ -574,7 +574,7 @@ export class Workbench implements IPartService { this.panelPart.hideActivePanel(); // Pass Focus to Editor if Panel part is now hidden - let editor = this.editorPart.getActiveEditor(); + const editor = this.editorPart.getActiveEditor(); if (editor) { editor.focus(); } @@ -582,8 +582,8 @@ export class Workbench implements IPartService { // If panel part becomes visible, show last active panel or default panel else if (!hidden && !this.panelPart.getActivePanel()) { - let registry = (Registry.as(PanelExtensions.Panels)); - let panelToOpen = this.panelPart.getLastActivePanelId() || registry.getDefaultPanelId(); + const registry = (Registry.as(PanelExtensions.Panels)); + const panelToOpen = this.panelPart.getLastActivePanelId() || registry.getDefaultPanelId(); if (panelToOpen) { this.panelPart.openPanel(panelToOpen, true).done(null, errors.onUnexpectedError); } @@ -602,8 +602,8 @@ export class Workbench implements IPartService { this.setSideBarHidden(false, true /* Skip Layout */); } - let newPositionValue = (position === Position.LEFT) ? 'left' : 'right'; - let oldPositionValue = (this.sideBarPosition === Position.LEFT) ? 'left' : 'right'; + const newPositionValue = (position === Position.LEFT) ? 'left' : 'right'; + const oldPositionValue = (this.sideBarPosition === Position.LEFT) ? 'left' : 'right'; this.sideBarPosition = position; // Adjust CSS @@ -673,7 +673,7 @@ export class Workbench implements IPartService { } private onEditorsChanged(): void { - let visibleEditors = this.editorService.getVisibleEditors().length; + const visibleEditors = this.editorService.getVisibleEditors().length; // We update the editorpart class to indicate if an editor is opened or not // through a delay to accomodate for fast editor switching @@ -689,7 +689,7 @@ export class Workbench implements IPartService { } private createWorkbenchLayout(): void { - let options = new LayoutOptions(); + const options = new LayoutOptions(); options.setMargin(new Box(0, 0, 0, 0)); this.workbenchLayout = this.instantiationService.createInstance(WorkbenchLayout, @@ -740,7 +740,7 @@ export class Workbench implements IPartService { } private createActivityBarPart(): void { - let activitybarPartContainer = $(this.workbench) + const activitybarPartContainer = $(this.workbench) .div({ 'class': ['part', 'activitybar', this.sideBarPosition === Position.LEFT ? 'left' : 'right'], id: Identifiers.ACTIVITYBAR_PART, @@ -751,7 +751,7 @@ export class Workbench implements IPartService { } private createSidebarPart(): void { - let sidebarPartContainer = $(this.workbench) + const sidebarPartContainer = $(this.workbench) .div({ 'class': ['part', 'sidebar', this.sideBarPosition === Position.LEFT ? 'left' : 'right'], id: Identifiers.SIDEBAR_PART, @@ -762,7 +762,7 @@ export class Workbench implements IPartService { } private createPanelPart(): void { - let panelPartContainer = $(this.workbench) + const panelPartContainer = $(this.workbench) .div({ 'class': ['part', 'panel', 'monaco-editor-background'], id: Identifiers.PANEL_PART, @@ -773,7 +773,7 @@ export class Workbench implements IPartService { } private createEditorPart(): void { - let editorContainer = $(this.workbench) + const editorContainer = $(this.workbench) .div({ 'class': ['part', 'editor', 'monaco-editor-background'], id: Identifiers.EDITOR_PART, @@ -784,7 +784,7 @@ export class Workbench implements IPartService { } private createStatusbarPart(): void { - let statusbarContainer = $(this.workbench).div({ + const statusbarContainer = $(this.workbench).div({ 'class': ['part', 'statusbar'], id: Identifiers.STATUSBAR_PART, role: 'contentinfo'