未验证 提交 9afa70a7 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #78265 from microsoft/joh/strict

eng - strict field initialisations
......@@ -77,8 +77,8 @@ export class BreadcrumbsWidget {
private _focusedItemIdx: number = -1;
private _selectedItemIdx: number = -1;
private _pendingLayout: IDisposable;
private _dimension: dom.Dimension;
private _pendingLayout: IDisposable | undefined;
private _dimension: dom.Dimension | undefined;
constructor(
container: HTMLElement
......
......@@ -645,7 +645,7 @@ export interface IWaitUntil {
export class AsyncEmitter<T extends IWaitUntil> extends Emitter<T> {
private _asyncDeliveryQueue: [Listener<T>, T, Promise<any>[]][];
private _asyncDeliveryQueue?: [Listener<T>, T, Promise<any>[]][];
async fireAsync(eventFn: (thenables: Promise<any>[], listener: Function) => T): Promise<void> {
if (!this._listeners) {
......
......@@ -60,7 +60,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
private readonly _editor: editorBrowser.ICodeEditor;
private readonly _commands = new Map<string, Command>();
private _widgetPosition: editorBrowser.IContentWidgetPosition;
private _widgetPosition?: editorBrowser.IContentWidgetPosition;
constructor(
editor: editorBrowser.ICodeEditor,
......@@ -147,8 +147,8 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
};
}
getPosition(): editorBrowser.IContentWidgetPosition {
return this._widgetPosition;
getPosition(): editorBrowser.IContentWidgetPosition | null {
return this._widgetPosition || null;
}
isVisible(): boolean {
......
......@@ -45,16 +45,19 @@ export class OutlineIdentityProvider implements IIdentityProvider<OutlineItem> {
export class OutlineGroupTemplate {
static id = 'OutlineGroupTemplate';
labelContainer: HTMLElement;
label: HighlightedLabel;
constructor(
readonly labelContainer: HTMLElement,
readonly label: HighlightedLabel,
) { }
}
export class OutlineElementTemplate {
static id = 'OutlineElementTemplate';
container: HTMLElement;
iconLabel: IconLabel;
decoration: HTMLElement;
constructor(
readonly container: HTMLElement,
readonly iconLabel: IconLabel,
readonly decoration: HTMLElement,
) { }
}
export class OutlineVirtualDelegate implements IListVirtualDelegate<OutlineItem> {
......@@ -80,7 +83,7 @@ export class OutlineGroupRenderer implements ITreeRenderer<OutlineGroup, FuzzySc
const labelContainer = dom.$('.outline-element-label');
dom.addClass(container, 'outline-element');
dom.append(container, labelContainer);
return { labelContainer, label: new HighlightedLabel(labelContainer, true) };
return new OutlineGroupTemplate(labelContainer, new HighlightedLabel(labelContainer, true));
}
renderElement(node: ITreeNode<OutlineGroup, FuzzyScore>, index: number, template: OutlineGroupTemplate): void {
......@@ -109,7 +112,7 @@ export class OutlineElementRenderer implements ITreeRenderer<OutlineElement, Fuz
const iconLabel = new IconLabel(container, { supportHighlights: true });
const decoration = dom.$('.outline-element-decoration');
container.appendChild(decoration);
return { container, iconLabel, decoration };
return new OutlineElementTemplate(container, iconLabel, decoration);
}
renderElement(node: ITreeNode<OutlineElement, FuzzyScore>, index: number, template: OutlineElementTemplate): void {
......
......@@ -34,18 +34,16 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
private readonly editor: ICodeEditor;
private readonly toUnhook = new DisposableStore();
private decorations: string[];
private currentWordUnderMouse: IWordAtPosition | null;
private previousPromise: CancelablePromise<LocationLink[] | null> | null;
private decorations: string[] = [];
private currentWordUnderMouse: IWordAtPosition | null = null;
private previousPromise: CancelablePromise<LocationLink[] | null> | null = null;
constructor(
editor: ICodeEditor,
@ITextModelService private readonly textModelResolverService: ITextModelService,
@IModeService private readonly modeService: IModeService
) {
this.decorations = [];
this.editor = editor;
this.previousPromise = null;
let linkGesture = new ClickLinkGesture(editor);
this.toUnhook.add(linkGesture);
......
......@@ -89,7 +89,7 @@ export class FileReferences implements IDisposable {
private _children: OneReference[];
private _preview?: FilePreview;
private _resolved: boolean;
private _resolved?: boolean;
private _loadFailure: any;
constructor(private readonly _parent: ReferencesModel, private readonly _uri: URI) {
......
......@@ -56,12 +56,8 @@ export class Scanner {
|| (ch >= CharCode.A && ch <= CharCode.Z);
}
value: string;
pos: number;
constructor() {
this.text('');
}
value: string = '';
pos: number = 0;
text(value: string) {
this.value = value;
......
......@@ -15,7 +15,7 @@ export class SuggestAlternatives {
private readonly _ckOtherSuggestions: IContextKey<boolean>;
private _index: number;
private _index: number = 0;
private _model: CompletionModel | undefined;
private _acceptNext: ((selected: ISelectedSuggestion) => any) | undefined;
private _listener: IDisposable | undefined;
......
......@@ -13,7 +13,7 @@ export class WordContextKey extends Disposable {
private readonly _ckAtEnd: IContextKey<boolean>;
private _enabled: boolean;
private _enabled: boolean = false;
private _selectionListener?: IDisposable;
constructor(
......
......@@ -21,7 +21,7 @@ class EditorWebviewZone implements IViewZone {
readonly afterColumn: number;
readonly heightInLines: number;
private _id: number;
private _id?: number;
// suppressMouseDown?: boolean | undefined;
// heightInPx?: number | undefined;
// minWidthInPx?: number | undefined;
......@@ -46,7 +46,7 @@ class EditorWebviewZone implements IViewZone {
}
dispose(): void {
this.editor.changeViewZones(accessor => accessor.removeZone(this._id));
this.editor.changeViewZones(accessor => this._id && accessor.removeZone(this._id));
}
}
......
......@@ -109,7 +109,7 @@ class DocumentAndEditorStateDelta {
class DocumentAndEditorState {
static compute(before: DocumentAndEditorState, after: DocumentAndEditorState): DocumentAndEditorStateDelta {
static compute(before: DocumentAndEditorState | undefined, after: DocumentAndEditorState): DocumentAndEditorStateDelta {
if (!before) {
return new DocumentAndEditorStateDelta(
[], values(after.documents),
......@@ -146,7 +146,7 @@ class MainThreadDocumentAndEditorStateComputer {
private readonly _toDispose = new DisposableStore();
private _toDisposeOnEditorRemove = new Map<string, IDisposable>();
private _currentState: DocumentAndEditorState;
private _currentState?: DocumentAndEditorState;
private _activeEditorOrder: ActiveEditorOrder = ActiveEditorOrder.Editor;
constructor(
......
......@@ -63,7 +63,7 @@ export class ExtHostEditorInsets implements ExtHostEditorInsetsShape {
private readonly _uuid = generateUuid();
private _html: string = '';
private _options: vscode.WebviewOptions;
private _options: vscode.WebviewOptions = Object.create(null);
toWebviewResource(resource: vscode.Uri): vscode.Uri {
return toWebviewResource(that._initData, this._uuid, resource);
......
......@@ -26,7 +26,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
private _proxy: MainThreadDocumentsShape;
private _languageId: string;
private _isDirty: boolean;
private _document: vscode.TextDocument;
private _document?: vscode.TextDocument;
private _textLines: vscode.TextLine[] = [];
private _isDisposed: boolean = false;
......
......@@ -17,7 +17,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
private _disposables: Disposable[] = [];
private _activeEditorId: string | null;
private _activeEditorId: string | null = null;
private readonly _editors = new Map<string, ExtHostTextEditor>();
private readonly _documents = new Map<string, ExtHostDocumentData>();
......
......@@ -155,7 +155,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
private readonly _usedSchemes = new Set<string>();
private readonly _watches = new Map<number, IDisposable>();
private _linkProviderRegistration: IDisposable;
private _linkProviderRegistration?: IDisposable;
private _handlePool: number = 0;
readonly fileSystem: vscode.FileSystem;
......
......@@ -14,7 +14,7 @@ export class ExtensionMemento implements IExtensionMemento {
private readonly _storage: ExtHostStorage;
private readonly _init: Promise<ExtensionMemento>;
private _value: { [n: string]: any; };
private _value?: { [n: string]: any; };
private readonly _storageListener: IDisposable;
constructor(id: string, global: boolean, storage: ExtHostStorage) {
......@@ -41,7 +41,7 @@ export class ExtensionMemento implements IExtensionMemento {
get<T>(key: string): T | undefined;
get<T>(key: string, defaultValue: T): T;
get<T>(key: string, defaultValue?: T): T {
let value = this._value[key];
let value = this._value![key];
if (typeof value === 'undefined') {
value = defaultValue;
}
......@@ -49,8 +49,8 @@ export class ExtensionMemento implements IExtensionMemento {
}
update(key: string, value: any): Promise<void> {
this._value[key] = value;
return this._storage.setValue(this._shared, this._id, this._value);
this._value![key] = value;
return this._storage.setValue(this._shared, this._id, this._value!);
}
dispose(): void {
......
......@@ -27,6 +27,7 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
this._name = name;
this._proxy = proxy;
this._id = proxy.$register(this.name, log, file);
this._disposed = false;
this._offset = 0;
}
......@@ -121,7 +122,7 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
private readonly _logsLocation: URI;
private readonly _proxy: MainThreadOutputServiceShape;
private readonly _channels: Map<string, AbstractExtHostOutputChannel> = new Map<string, AbstractExtHostOutputChannel>();
private _visibleChannelDisposable: IDisposable;
private _visibleChannelDisposable?: IDisposable;
constructor(factory: IOutputChannelFactory, logsLocation: URI, mainContext: IMainContext) {
this._factory = factory;
......
......@@ -29,7 +29,7 @@ export interface IBreadcrumbsService {
export class BreadcrumbsService implements IBreadcrumbsService {
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand: any;
private readonly _map = new Map<number, BreadcrumbsWidget>();
......@@ -55,8 +55,8 @@ registerSingleton(IBreadcrumbsService, BreadcrumbsService, true);
export abstract class BreadcrumbsConfig<T> {
name: string;
onDidChange: Event<void>;
abstract get name(): string;
abstract get onDidChange(): Event<void>;
abstract getValue(overrides?: IConfigurationOverrides): T;
abstract updateValue(value: T, overrides?: IConfigurationOverrides): Promise<void>;
......
......@@ -5,7 +5,7 @@
import * as nls from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionHostProfile, ProfileSession, IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { Disposable, toDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { onUnexpectedError } from 'vs/base/common/errors';
......@@ -23,7 +23,7 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
export class ExtensionHostProfileService extends Disposable implements IExtensionHostProfileService {
_serviceBrand: ServiceIdentifier<IExtensionHostProfileService>;
_serviceBrand: any;
private readonly _onDidChangeState: Emitter<void> = this._register(new Emitter<void>());
public readonly onDidChangeState: Event<void> = this._onDidChangeState.event;
......@@ -34,7 +34,7 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio
private readonly _unresponsiveProfiles = new Map<string, IExtensionHostProfile>();
private _profile: IExtensionHostProfile | null;
private _profileSession: ProfileSession | null;
private _state: ProfileSessionState;
private _state: ProfileSessionState = ProfileSessionState.None;
private profilingStatusBarIndicator: IStatusbarEntryAccessor | undefined;
private readonly profilingStatusBarIndicatorLabelUpdater = this._register(new MutableDisposable());
......
......@@ -19,9 +19,9 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import Severity from 'vs/base/common/severity';
abstract class RepoInfo {
readonly base: string;
readonly owner: string;
readonly repo: string;
abstract get base(): string;
abstract get owner(): string;
abstract get repo(): string;
static fromExtension(desc: IExtensionDescription): RepoInfo | undefined {
......
......@@ -56,8 +56,8 @@ class MarkersDecorationsProvider implements IDecorationsProvider {
class MarkersFileDecorations implements IWorkbenchContribution {
private readonly _disposables: IDisposable[];
private _provider: IDisposable;
private _enabled: boolean;
private _provider?: IDisposable;
private _enabled?: boolean;
constructor(
@IMarkerService private readonly _markerService: IMarkerService,
......
......@@ -262,11 +262,11 @@ class PerfModelContentProvider implements ITextModelContentProvider {
}
abstract class LoaderStats {
readonly amdLoad: (string | number)[][];
readonly amdInvoke: (string | number)[][];
readonly nodeRequire: (string | number)[][];
readonly nodeEval: (string | number)[][];
readonly nodeRequireTotal: number;
abstract get amdLoad(): (string | number)[][];
abstract get amdInvoke(): (string | number)[][];
abstract get nodeRequire(): (string | number)[][];
abstract get nodeEval(): (string | number)[][];
abstract get nodeRequireTotal(): number;
static get(): LoaderStats {
......
......@@ -21,7 +21,7 @@ export class SnippetCompletion implements CompletionItem {
label: string;
detail: string;
insertText: string;
documentation: MarkdownString;
documentation?: MarkdownString;
range: IRange;
sortText: string;
kind: CompletionItemKind;
......
......@@ -31,8 +31,8 @@ export class TabCompletionController implements editorCommon.IEditorContribution
private _hasSnippets: IContextKey<boolean>;
private _activeSnippets: Snippet[] = [];
private _enabled: boolean;
private _selectionListener: IDisposable;
private _enabled?: boolean;
private _selectionListener?: IDisposable;
private readonly _configListener: IDisposable;
constructor(
......
......@@ -32,8 +32,8 @@ class PartsSplash {
private readonly _disposables = new DisposableStore();
private _didChangeTitleBarStyle: boolean;
private _lastBaseTheme: string;
private _didChangeTitleBarStyle?: boolean;
private _lastBaseTheme?: string;
private _lastBackground?: string;
constructor(
......
......@@ -51,7 +51,7 @@ class ModelEditTask implements IDisposable {
protected _edits: IIdentifiedSingleEditOperation[];
private _expectedModelVersionId: number | undefined;
protected _newEol: EndOfLineSequence;
protected _newEol: EndOfLineSequence | undefined;
constructor(private readonly _modelReference: IReference<IResolvedTextEditorModel>) {
this._model = this._modelReference.object.textEditorModel;
......@@ -142,7 +142,7 @@ class BulkEditModel implements IDisposable {
private _textModelResolverService: ITextModelService;
private _edits = new Map<string, ResourceTextEdit[]>();
private _editor: ICodeEditor | undefined;
private _tasks: ModelEditTask[];
private _tasks: ModelEditTask[] | undefined;
private _progress: IProgress<void>;
constructor(
......@@ -159,7 +159,7 @@ class BulkEditModel implements IDisposable {
}
dispose(): void {
this._tasks = dispose(this._tasks);
this._tasks = dispose(this._tasks!);
}
addEdit(edit: ResourceTextEdit): void {
......@@ -196,7 +196,7 @@ class BulkEditModel implements IDisposable {
}
value.forEach(edit => task.addEdit(edit));
this._tasks.push(task);
this._tasks!.push(task);
this._progress.report(undefined);
});
promises.push(promise);
......@@ -208,7 +208,7 @@ class BulkEditModel implements IDisposable {
}
validate(): ValidationResult {
for (const task of this._tasks) {
for (const task of this._tasks!) {
const result = task.validate();
if (!result.canApply) {
return result;
......@@ -218,7 +218,7 @@ class BulkEditModel implements IDisposable {
}
apply(): void {
for (const task of this._tasks) {
for (const task of this._tasks!) {
task.apply();
this._progress.report(undefined);
}
......
......@@ -305,7 +305,7 @@ class TimerService implements ITimerService {
_serviceBrand: any;
private _startupMetrics: Promise<IStartupMetrics>;
private _startupMetrics?: Promise<IStartupMetrics>;
constructor(
@IWindowsService private readonly _windowsService: IWindowsService,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册