Skip to content

Commit

Permalink
strict init, #78168
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Aug 5, 2019
1 parent e428bed commit 629ef6a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 35 deletions.
10 changes: 5 additions & 5 deletions src/vs/base/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export class Action extends Disposable implements IAction {

protected readonly _id: string;
protected _label: string;
protected _tooltip: string;
protected _tooltip: string | undefined;
protected _cssClass: string | undefined;
protected _enabled: boolean;
protected _checked: boolean;
protected _radio: boolean;
protected _enabled: boolean = true;
protected _checked: boolean = false;
protected _radio: boolean = false;
protected readonly _actionCallback?: (event?: any) => Promise<any>;

constructor(id: string, label: string = '', cssClass: string = '', enabled: boolean = true, actionCallback?: (event?: any) => Promise<any>) {
Expand Down Expand Up @@ -100,7 +100,7 @@ export class Action extends Disposable implements IAction {
}

get tooltip(): string {
return this._tooltip;
return this._tooltip || '';
}

set tooltip(value: string) {
Expand Down
10 changes: 5 additions & 5 deletions src/vs/editor/contrib/snippet/snippetParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export abstract class Marker {

readonly _markerBrand: any;

public parent: Marker;
public parent!: Marker;
protected _children: Marker[] = [];

appendChild(child: Marker): this {
Expand Down Expand Up @@ -215,7 +215,7 @@ export class Text extends Marker {
}

export abstract class TransformableMarker extends Marker {
public transform: Transform;
public transform?: Transform;
}

export class Placeholder extends TransformableMarker {
Expand Down Expand Up @@ -310,7 +310,7 @@ export class Choice extends Marker {

export class Transform extends Marker {

regexp: RegExp;
regexp: RegExp = new RegExp('');

resolve(value: string): string {
const _this = this;
Expand Down Expand Up @@ -586,8 +586,8 @@ export class SnippetParser {
return value.replace(/\$|}|\\/g, '\\$&');
}

private _scanner = new Scanner();
private _token: Token;
private _scanner: Scanner = new Scanner();
private _token: Token = { type: TokenType.EOF, pos: 0, len: 0 };

text(value: string): string {
return this.parse(value).toString();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/snippet/test/snippetParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ suite('SnippetParser', () => {
assert.ok(children[3] instanceof Placeholder);
assert.equal(children[3].children.length, 0);
assert.notEqual((<Placeholder>children[3]).transform, undefined);
let transform = (<Placeholder>children[3]).transform;
let transform = (<Placeholder>children[3]).transform!;
assert.equal(transform.regexp, '/\\s:=(.*)/');
assert.equal(transform.children.length, 2);
assert.ok(transform.children[0] instanceof FormatString);
Expand Down
20 changes: 11 additions & 9 deletions src/vs/editor/contrib/suggest/completionModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export interface ICompletionStats {
}

export class LineContext {
leadingLineContent: string;
characterCountDelta: number;
constructor(
readonly leadingLineContent: string,
readonly characterCountDelta: number,
) { }
}

const enum Refilter {
Expand All @@ -49,9 +51,9 @@ export class CompletionModel {

private _lineContext: LineContext;
private _refilterKind: Refilter;
private _filteredItems: StrictCompletionItem[];
private _isIncomplete: Set<CompletionItemProvider>;
private _stats: ICompletionStats;
private _filteredItems?: StrictCompletionItem[];
private _isIncomplete?: Set<CompletionItemProvider>;
private _stats?: ICompletionStats;

constructor(
items: CompletionItem[],
Expand Down Expand Up @@ -89,12 +91,12 @@ export class CompletionModel {

get items(): CompletionItem[] {
this._ensureCachedState();
return this._filteredItems;
return this._filteredItems!;
}

get incomplete(): Set<CompletionItemProvider> {
this._ensureCachedState();
return this._isIncomplete;
return this._isIncomplete!;
}

adopt(except: Set<CompletionItemProvider>): CompletionItem[] {
Expand All @@ -117,7 +119,7 @@ export class CompletionModel {

get stats(): ICompletionStats {
this._ensureCachedState();
return this._stats;
return this._stats!;
}

private _ensureCachedState(): void {
Expand All @@ -136,7 +138,7 @@ export class CompletionModel {
let wordLow = '';

// incrementally filter less
const source = this._refilterKind === Refilter.All ? this._items : this._filteredItems;
const source = this._refilterKind === Refilter.All ? this._items : this._filteredItems!;
const target: StrictCompletionItem[] = [];

// picks a score function based on the number of
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/api/common/extHostApiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,11 @@ export class ExtHostApiCommands {
return res;
}

detail: string;
range: vscode.Range;
selectionRange: vscode.Range;
children: vscode.DocumentSymbol[];
containerName: string;
detail!: string;
range!: vscode.Range;
selectionRange!: vscode.Range;
children!: vscode.DocumentSymbol[];
containerName!: string;
}
return value.map(MergedInfo.to);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ class LayoutInfo {

export class CallHierarchyTreePeekWidget extends PeekViewWidget {

private _changeDirectionAction: ChangeHierarchyDirectionAction;
private _parent: HTMLElement;
private _message: HTMLElement;
private _splitView: SplitView;
private _tree: WorkbenchAsyncDataTree<CallHierarchyItem, callHTree.Call, FuzzyScore>;
private _changeDirectionAction?: ChangeHierarchyDirectionAction;
private _parent!: HTMLElement;
private _message!: HTMLElement;
private _splitView!: SplitView;
private _tree!: WorkbenchAsyncDataTree<CallHierarchyItem, callHTree.Call, FuzzyScore>;
private _treeViewStates = new Map<CallHierarchyDirection, IAsyncDataTreeViewState>();
private _editor: EmbeddedCodeEditorWidget;
private _dim: Dimension;
private _layoutInfo: LayoutInfo;
private _editor!: EmbeddedCodeEditorWidget;
private _dim!: Dimension;
private _layoutInfo!: LayoutInfo;

constructor(
editor: ICodeEditor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export class IdentityProvider implements IIdentityProvider<Call> {
}

class CallRenderingTemplate {
readonly iconLabel: IconLabel;
constructor(
readonly iconLabel: IconLabel
) { }
}

export class CallRenderer implements ITreeRenderer<Call, FuzzyScore, CallRenderingTemplate> {
Expand All @@ -69,7 +71,7 @@ export class CallRenderer implements ITreeRenderer<Call, FuzzyScore, CallRenderi

renderTemplate(container: HTMLElement): CallRenderingTemplate {
const iconLabel = new IconLabel(container, { supportHighlights: true });
return { iconLabel };
return new CallRenderingTemplate(iconLabel);
}

renderElement(node: ITreeNode<Call, FuzzyScore>, _index: number, template: CallRenderingTemplate): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
this._terminating = false;

this._namedPipeServer = null;
this._inspectPort = null;
this._extensionHostProcess = null;
this._extensionHostConnection = null;
this._messageProtocol = null;
Expand Down

0 comments on commit 629ef6a

Please sign in to comment.