Skip to content

Commit

Permalink
More work strict null checking quick open related files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Feb 5, 2019
1 parent 815a3cb commit 6e2995e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@
"./vs/workbench/parts/stats/test/workspaceStats.test.ts",
"./vs/workbench/parts/surveys/electron-browser/languageSurveys.contribution.ts",
"./vs/workbench/parts/surveys/electron-browser/nps.contribution.ts",
"./vs/workbench/parts/tasks/browser/quickOpen.ts",
"./vs/workbench/parts/tasks/browser/taskQuickOpen.ts",
"./vs/workbench/parts/tasks/common/problemCollectors.ts",
"./vs/workbench/parts/tasks/common/problemMatcher.ts",
"./vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/quickinput/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class QuickInput implements IQuickInput {
this.onDidHideEmitter,
];

private busyDelay: TimeoutTimer;
private busyDelay: TimeoutTimer | null;

constructor(protected ui: QuickInputUI) {
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class OutlineModel extends QuickOpenModel {
this.entries.forEach((entry: SymbolEntry) => {

// Clear all state first
entry.setGroupLabel(null);
entry.setGroupLabel(undefined);
entry.setShowBorder(false);
entry.setHighlights(null);
entry.setHighlights([]);
entry.setHidden(false);

// Filter by search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class OpenAnythingHandler extends QuickOpenHandler {
}

// Combine results.
const mergedResults: QuickOpenEntry[] = [].concat(...results.map(r => r.entries));
const mergedResults: QuickOpenEntry[] = ([] as QuickOpenEntry[]).concat(...results.map(r => r.entries));

// Sort
const compare = (elementA: QuickOpenEntry, elementB: QuickOpenEntry) => compareItemsByScore(elementA, elementB, query, true, QuickOpenItemAccessor, this.scorerCache);
Expand Down
15 changes: 9 additions & 6 deletions src/vs/workbench/parts/tasks/browser/quickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class TaskEntry extends Model.QuickOpenEntry {
return this.task._label;
}

public getDescription(): string {
public getDescription(): string | null {
if (!this.taskService.needsFolderQualification()) {
return null;
}
Expand All @@ -51,7 +51,7 @@ export class TaskEntry extends Model.QuickOpenEntry {
this.taskService.run(task, options).then(undefined, reason => {
// eat the error, it has already been surfaced to the user and we don't care about it here
});
if (!task.command || task.command.presentation.focus) {
if (!task.command || (task.command.presentation && task.command.presentation.focus)) {
this.quickOpenService.close();
return false;
}
Expand All @@ -67,7 +67,7 @@ export class TaskGroupEntry extends Model.QuickOpenEntryGroup {

export abstract class QuickOpenHandler extends Quickopen.QuickOpenHandler {

private tasks: Promise<Array<CustomTask | ContributedTask>>;
private tasks?: Promise<Array<CustomTask | ContributedTask>>;

constructor(
protected quickOpenService: IQuickOpenService,
Expand All @@ -87,7 +87,10 @@ export abstract class QuickOpenHandler extends Quickopen.QuickOpenHandler {
this.tasks = undefined;
}

public getResults(input: string, token: CancellationToken): Promise<Model.QuickOpenModel> {
public getResults(input: string, token: CancellationToken): Promise<Model.QuickOpenModel | null> {
if (!this.tasks) {
return Promise.resolve(null);
}
return this.tasks.then((tasks) => {
let entries: Model.QuickOpenEntry[] = [];
if (tasks.length === 0 || token.isCancellationRequested) {
Expand Down Expand Up @@ -186,7 +189,7 @@ class CustomizeTaskAction extends Action {
}
}

private getTask(element: any): CustomTask | ContributedTask {
private getTask(element: any): CustomTask | ContributedTask | undefined {
if (element instanceof TaskEntry) {
return element.task;
} else if (element instanceof TaskGroupEntry) {
Expand Down Expand Up @@ -220,7 +223,7 @@ export class QuickOpenActionContributor extends ActionBarContributor {
return actions;
}

private getTask(context: any): CustomTask | ContributedTask {
private getTask(context: any): CustomTask | ContributedTask | undefined {
if (!context) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/tasks/browser/taskQuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TaskEntry extends base.TaskEntry {
super(quickOpenService, taskService, task, highlights);
}

public run(mode: QuickOpen.Mode, context: Model.IContext): boolean {
public run(mode: QuickOpen.Mode, context: QuickOpen.IEntryRunContext): boolean {
if (mode === QuickOpen.Mode.PREVIEW) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const IConfigurationResolverService = createDecorator<IConfigurationResol
export interface IConfigurationResolverService {
_serviceBrand: any;

resolve(folder: IWorkspaceFolder, value: string): string;
resolve(folder: IWorkspaceFolder, value: string[]): string[];
resolve(folder: IWorkspaceFolder, value: IStringDictionary<string>): IStringDictionary<string>;
resolve(folder: IWorkspaceFolder | undefined, value: string): string;
resolve(folder: IWorkspaceFolder | undefined, value: string[]): string[];
resolve(folder: IWorkspaceFolder | undefined, value: IStringDictionary<string>): IStringDictionary<string>;

/**
* Recursively resolves all variables in the given config and returns a copy of it with substituted values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
}
}

public resolve(root: IWorkspaceFolder, value: string): string;
public resolve(root: IWorkspaceFolder, value: string[]): string[];
public resolve(root: IWorkspaceFolder, value: IStringDictionary<string>): IStringDictionary<string>;
public resolve(root: IWorkspaceFolder, value: any): any {
public resolve(root: IWorkspaceFolder | undefined, value: string): string;
public resolve(root: IWorkspaceFolder | undefined, value: string[]): string[];
public resolve(root: IWorkspaceFolder | undefined, value: IStringDictionary<string>): IStringDictionary<string>;
public resolve(root: IWorkspaceFolder | undefined, value: any): any {
return this.recursiveResolve(root ? root.uri : undefined, value);
}

Expand Down

0 comments on commit 6e2995e

Please sign in to comment.