提交 309b492c 编写于 作者: B Benjamin Pasero

debt - a bit more strict init

上级 02eb784a
......@@ -39,7 +39,7 @@ export interface IEditorConfiguration {
export abstract class BaseTextEditor extends BaseEditor implements ITextEditor {
private editorControl: IEditor;
private _editorContainer: HTMLElement;
private hasPendingConfigurationChange: boolean;
private hasPendingConfigurationChange: boolean | undefined;
private lastAppliedEditorOptions?: IEditorOptions;
private editorMemento: IEditorMemento<IEditorViewState>;
......
......@@ -21,7 +21,7 @@ export class NotificationsList extends Themable {
private listContainer: HTMLElement;
private list: WorkbenchList<INotificationViewItem>;
private viewModel: INotificationViewItem[];
private isVisible: boolean;
private isVisible: boolean | undefined;
constructor(
private container: HTMLElement,
......
......@@ -54,7 +54,7 @@ export class NotificationsToasts extends Themable {
private notificationsToastsContainer: HTMLElement;
private workbenchDimensions: Dimension;
private isNotificationsCenterVisible: boolean;
private isNotificationsCenterVisible: boolean | undefined;
private mapNotificationToToast: Map<INotificationViewItem, INotificationToast>;
private notificationsToastsVisibleContextKey: IContextKey<boolean>;
......
......@@ -57,7 +57,7 @@ class StatusbarViewModel extends Disposable {
private readonly _entries: IStatusbarViewModelEntry[] = [];
get entries(): IStatusbarViewModelEntry[] { return this._entries; }
private hidden: Set<string>;
private hidden!: Set<string>;
constructor(private storageService: IStorageService) {
super();
......@@ -334,14 +334,14 @@ export class StatusbarPart extends Part implements IStatusbarService {
//#endregion
private styleElement: HTMLStyleElement;
private styleElement!: HTMLStyleElement;
private pendingEntries: IPendingStatusbarEntry[] = [];
private readonly viewModel: StatusbarViewModel;
private leftItemsContainer: HTMLElement;
private rightItemsContainer: HTMLElement;
private leftItemsContainer!: HTMLElement;
private rightItemsContainer!: HTMLElement;
constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
......@@ -627,10 +627,10 @@ export class StatusbarPart extends Part implements IStatusbarService {
}
class StatusbarEntryItem extends Disposable {
private entry: IStatusbarEntry;
private entry!: IStatusbarEntry;
private labelContainer: HTMLElement;
private label: OcticonLabel;
private labelContainer!: HTMLElement;
private label!: OcticonLabel;
private readonly foregroundListener = this._register(new MutableDisposable());
private readonly backgroundListener = this._register(new MutableDisposable());
......
......@@ -88,7 +88,8 @@ export class EditorGroup extends Disposable {
//#endregion
private _id: GroupIdentifier;
private _id!: GroupIdentifier;
get id(): GroupIdentifier { return this._id; }
private editors: EditorInput[] = [];
private mru: EditorInput[] = [];
......@@ -97,8 +98,8 @@ export class EditorGroup extends Disposable {
private preview: EditorInput | null = null; // editor in preview state
private active: EditorInput | null = null; // editor in active state
private editorOpenPositioning: 'left' | 'right' | 'first' | 'last';
private focusRecentEditorAfterClose: boolean;
private editorOpenPositioning: ('left' | 'right' | 'first' | 'last') | undefined;
private focusRecentEditorAfterClose: boolean | undefined;
constructor(
labelOrSerializedGroup: ISerializedEditorGroup,
......@@ -126,10 +127,6 @@ export class EditorGroup extends Disposable {
this.focusRecentEditorAfterClose = this.configurationService.getValue('workbench.editor.focusRecentEditorAfterClose');
}
get id(): GroupIdentifier {
return this._id;
}
get count(): number {
return this.editors.length;
}
......@@ -689,8 +686,11 @@ export class EditorGroup extends Disposable {
return null;
}));
this.mru = data.mru.map(i => this.editors[i]);
this.active = this.mru[0];
if (typeof data.preview === 'number') {
this.preview = this.editors[data.preview];
}
......
......@@ -14,8 +14,8 @@ import { DiffEditorModel } from 'vs/workbench/common/editor/diffEditorModel';
*/
export class TextDiffEditorModel extends DiffEditorModel {
protected readonly _originalModel: BaseTextEditorModel;
protected readonly _modifiedModel: BaseTextEditorModel;
protected readonly _originalModel: BaseTextEditorModel | null = null;
protected readonly _modifiedModel: BaseTextEditorModel | null = null;
private _textDiffEditorModel: IDiffEditorModel | null = null;
......@@ -25,11 +25,11 @@ export class TextDiffEditorModel extends DiffEditorModel {
this.updateTextDiffEditorModel();
}
get originalModel(): BaseTextEditorModel {
get originalModel(): BaseTextEditorModel | null {
return this._originalModel;
}
get modifiedModel(): BaseTextEditorModel {
get modifiedModel(): BaseTextEditorModel | null {
return this._modifiedModel;
}
......@@ -42,7 +42,7 @@ export class TextDiffEditorModel extends DiffEditorModel {
}
private updateTextDiffEditorModel(): void {
if (this.originalModel.isResolved() && this.modifiedModel.isResolved()) {
if (this.originalModel && this.originalModel.isResolved() && this.modifiedModel && this.modifiedModel.isResolved()) {
// Create new
if (!this._textDiffEditorModel) {
......@@ -69,7 +69,7 @@ export class TextDiffEditorModel extends DiffEditorModel {
}
isReadonly(): boolean {
return this.modifiedModel.isReadonly();
return !!this.modifiedModel && this.modifiedModel.isReadonly();
}
dispose(): void {
......
......@@ -62,7 +62,7 @@ class CommandsHistory extends Disposable {
private static readonly PREF_KEY_CACHE = 'commandPalette.mru.cache';
private static readonly PREF_KEY_COUNTER = 'commandPalette.mru.counter';
private commandHistoryLength: number;
private commandHistoryLength!: number;
constructor(
@IStorageService private readonly storageService: IStorageService,
......
......@@ -41,9 +41,9 @@ export class OpenAnythingHandler extends QuickOpenHandler {
private openSymbolHandler: OpenSymbolHandler;
private openFileHandler: OpenFileHandler;
private searchDelayer: ThrottledDelayer<QuickOpenModel | null>;
private isClosed: boolean;
private isClosed: boolean | undefined;
private scorerCache: ScorerCache;
private includeSymbols: boolean;
private includeSymbols: boolean | undefined;
constructor(
@INotificationService private readonly notificationService: INotificationService,
......
......@@ -153,7 +153,7 @@ export class HideWelcomeOverlayAction extends Action {
class WelcomeOverlay extends Disposable {
private _overlayVisible: IContextKey<boolean>;
private _overlay: HTMLElement;
private _overlay!: HTMLElement;
constructor(
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
......
......@@ -120,9 +120,8 @@ export class HistoryService extends Disposable implements IHistoryService {
private lastEditLocation: IStackEntry | undefined;
private history: Array<IEditorInput | IResourceInput>;
private history: Array<IEditorInput | IResourceInput> | undefined;
private recentlyClosedFiles: IRecentlyClosedFile[];
private loaded: boolean;
private resourceFilter: ResourceGlobMatcher;
private fileInputFactory: IFileInputFactory;
......@@ -155,7 +154,6 @@ export class HistoryService extends Disposable implements IHistoryService {
this.lastIndex = -1;
this.stack = [];
this.recentlyClosedFiles = [];
this.loaded = false;
this.resourceFilter = this._register(instantiationService.createInstance(
ResourceGlobMatcher,
(root?: URI) => this.getExcludes(root),
......@@ -489,17 +487,17 @@ export class HistoryService extends Disposable implements IHistoryService {
return;
}
this.ensureHistoryLoaded();
const history = this.ensureHistoryLoaded();
const historyInput = this.preferResourceInput(input);
// Remove any existing entry and add to the beginning
this.removeFromHistory(input);
this.history.unshift(historyInput);
history.unshift(historyInput);
// Respect max entries setting
if (this.history.length > HistoryService.MAX_HISTORY_ITEMS) {
this.clearOnEditorDispose(this.history.pop()!, this.editorHistoryListeners);
if (history.length > HistoryService.MAX_HISTORY_ITEMS) {
this.clearOnEditorDispose(history.pop()!, this.editorHistoryListeners);
}
// Remove this from the history unless the history input is a resource
......@@ -555,9 +553,9 @@ export class HistoryService extends Disposable implements IHistoryService {
}
private removeExcludedFromHistory(): void {
this.ensureHistoryLoaded();
const history = this.ensureHistoryLoaded();
this.history = this.history.filter(e => {
this.history = history.filter(e => {
const include = this.include(e);
// Cleanup any listeners associated with the input when removing from history
......@@ -570,9 +568,9 @@ export class HistoryService extends Disposable implements IHistoryService {
}
private removeFromHistory(arg1: IEditorInput | IResourceInput | FileChangesEvent): void {
this.ensureHistoryLoaded();
const history = this.ensureHistoryLoaded();
this.history = this.history.filter(e => {
this.history = history.filter(e => {
const matches = this.matches(arg1, e);
// Cleanup any listeners associated with the input when removing from history
......@@ -849,17 +847,17 @@ export class HistoryService extends Disposable implements IHistoryService {
}
getHistory(): Array<IEditorInput | IResourceInput> {
this.ensureHistoryLoaded();
const history = this.ensureHistoryLoaded();
return this.history.slice(0);
return history.slice(0);
}
private ensureHistoryLoaded(): void {
if (!this.loaded) {
this.loadHistory();
private ensureHistoryLoaded(): Array<IEditorInput | IResourceInput> {
if (!this.history) {
this.history = this.loadHistory();
}
this.loaded = true;
return this.history;
}
private saveState(): void {
......@@ -893,7 +891,7 @@ export class HistoryService extends Disposable implements IHistoryService {
this.storageService.store(HistoryService.STORAGE_KEY, JSON.stringify(entries), StorageScope.WORKSPACE);
}
private loadHistory(): void {
private loadHistory(): Array<IEditorInput | IResourceInput> {
let entries: ISerializedEditorHistoryEntry[] = [];
const entriesRaw = this.storageService.get(HistoryService.STORAGE_KEY, StorageScope.WORKSPACE);
......@@ -903,7 +901,7 @@ export class HistoryService extends Disposable implements IHistoryService {
const registry = Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories);
this.history = coalesce(entries.map(entry => {
return coalesce(entries.map(entry => {
try {
return this.safeLoadHistoryEntry(registry, entry);
} catch (error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册