less context serivce use

This commit is contained in:
Benjamin Pasero 2016-08-17 15:59:01 +02:00
parent e7a371a1dc
commit e824cb7735
5 changed files with 21 additions and 29 deletions

View file

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

View file

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

View file

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

View file

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

View file

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