mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Strict null checks for Task in extHostTypes
This commit is contained in:
@@ -1427,7 +1427,7 @@ export class ProcessExecution implements vscode.ProcessExecution {
|
||||
|
||||
private _process: string;
|
||||
private _args: string[];
|
||||
private _options: vscode.ProcessExecutionOptions;
|
||||
private _options: vscode.ProcessExecutionOptions | undefined;
|
||||
|
||||
constructor(process: string, options?: vscode.ProcessExecutionOptions);
|
||||
constructor(process: string, args: string[], options?: vscode.ProcessExecutionOptions);
|
||||
@@ -1472,11 +1472,11 @@ export class ProcessExecution implements vscode.ProcessExecution {
|
||||
this._args = value;
|
||||
}
|
||||
|
||||
get options(): vscode.ProcessExecutionOptions {
|
||||
get options(): vscode.ProcessExecutionOptions | undefined {
|
||||
return this._options;
|
||||
}
|
||||
|
||||
set options(value: vscode.ProcessExecutionOptions) {
|
||||
set options(value: vscode.ProcessExecutionOptions | undefined) {
|
||||
this._options = value;
|
||||
}
|
||||
|
||||
@@ -1500,7 +1500,7 @@ export class ShellExecution implements vscode.ShellExecution {
|
||||
private _commandLine: string;
|
||||
private _command: string | vscode.ShellQuotedString;
|
||||
private _args: (string | vscode.ShellQuotedString)[];
|
||||
private _options: vscode.ShellExecutionOptions;
|
||||
private _options: vscode.ShellExecutionOptions | undefined;
|
||||
|
||||
constructor(commandLine: string, options?: vscode.ShellExecutionOptions);
|
||||
constructor(command: string | vscode.ShellQuotedString, args: (string | vscode.ShellQuotedString)[], options?: vscode.ShellExecutionOptions);
|
||||
@@ -1554,11 +1554,11 @@ export class ShellExecution implements vscode.ShellExecution {
|
||||
this._args = value || [];
|
||||
}
|
||||
|
||||
get options(): vscode.ShellExecutionOptions {
|
||||
get options(): vscode.ShellExecutionOptions | undefined {
|
||||
return this._options;
|
||||
}
|
||||
|
||||
set options(value: vscode.ShellExecutionOptions) {
|
||||
set options(value: vscode.ShellExecutionOptions | undefined) {
|
||||
this._options = value;
|
||||
}
|
||||
|
||||
@@ -1598,17 +1598,21 @@ export enum RerunBehavior {
|
||||
|
||||
export class Task implements vscode.Task2 {
|
||||
|
||||
private __id: string;
|
||||
private static ProcessType: string = 'process';
|
||||
private static ShellType: string = 'shell';
|
||||
private static EmptyType: string = '$empty';
|
||||
|
||||
private __id: string | undefined;
|
||||
|
||||
private _definition: vscode.TaskDefinition;
|
||||
private _scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder;
|
||||
private _scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined;
|
||||
private _name: string;
|
||||
private _execution: ProcessExecution | ShellExecution;
|
||||
private _execution: ProcessExecution | ShellExecution | undefined;
|
||||
private _problemMatchers: string[];
|
||||
private _hasDefinedMatchers: boolean;
|
||||
private _isBackground: boolean;
|
||||
private _source: string;
|
||||
private _group: TaskGroup;
|
||||
private _group: TaskGroup | undefined;
|
||||
private _presentationOptions: vscode.TaskPresentationOptions;
|
||||
private _runOptions: vscode.RunOptions;
|
||||
|
||||
@@ -1646,13 +1650,15 @@ export class Task implements vscode.Task2 {
|
||||
this._hasDefinedMatchers = false;
|
||||
}
|
||||
this._isBackground = false;
|
||||
this._presentationOptions = Object.create(null);
|
||||
this._runOptions = Object.create(null);
|
||||
}
|
||||
|
||||
get _id(): string {
|
||||
get _id(): string | undefined {
|
||||
return this.__id;
|
||||
}
|
||||
|
||||
set _id(value: string) {
|
||||
set _id(value: string | undefined) {
|
||||
this.__id = value;
|
||||
}
|
||||
|
||||
@@ -1662,17 +1668,25 @@ export class Task implements vscode.Task2 {
|
||||
}
|
||||
this.__id = undefined;
|
||||
this._scope = undefined;
|
||||
this._definition = undefined;
|
||||
this.computeDefinitionBasedOnExecution();
|
||||
}
|
||||
|
||||
private computeDefinitionBasedOnExecution(): void {
|
||||
if (this._execution instanceof ProcessExecution) {
|
||||
this._definition = {
|
||||
type: 'process',
|
||||
type: Task.ProcessType,
|
||||
id: this._execution.computeId()
|
||||
};
|
||||
} else if (this._execution instanceof ShellExecution) {
|
||||
this._definition = {
|
||||
type: 'shell',
|
||||
type: Task.ShellType,
|
||||
id: this._execution.computeId()
|
||||
};
|
||||
} else {
|
||||
this._definition = {
|
||||
type: Task.EmptyType,
|
||||
id: generateUuid()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1688,7 +1702,7 @@ export class Task implements vscode.Task2 {
|
||||
this._definition = value;
|
||||
}
|
||||
|
||||
get scope(): vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder {
|
||||
get scope(): vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined {
|
||||
return this._scope;
|
||||
}
|
||||
|
||||
@@ -1709,16 +1723,20 @@ export class Task implements vscode.Task2 {
|
||||
this._name = value;
|
||||
}
|
||||
|
||||
get execution(): ProcessExecution | ShellExecution {
|
||||
get execution(): ProcessExecution | ShellExecution | undefined {
|
||||
return this._execution;
|
||||
}
|
||||
|
||||
set execution(value: ProcessExecution | ShellExecution) {
|
||||
set execution(value: ProcessExecution | ShellExecution | undefined) {
|
||||
if (value === null) {
|
||||
value = undefined;
|
||||
}
|
||||
this.clear();
|
||||
this._execution = value;
|
||||
let type = this._definition.type;
|
||||
if (Task.EmptyType === type || Task.ProcessType === type || Task.ShellType === type) {
|
||||
this.computeDefinitionBasedOnExecution();
|
||||
}
|
||||
}
|
||||
|
||||
get problemMatchers(): string[] {
|
||||
@@ -1727,13 +1745,15 @@ export class Task implements vscode.Task2 {
|
||||
|
||||
set problemMatchers(value: string[]) {
|
||||
if (!Array.isArray(value)) {
|
||||
this.clear();
|
||||
this._problemMatchers = [];
|
||||
this._hasDefinedMatchers = false;
|
||||
return;
|
||||
} else {
|
||||
this.clear();
|
||||
this._problemMatchers = value;
|
||||
this._hasDefinedMatchers = true;
|
||||
}
|
||||
this.clear();
|
||||
this._problemMatchers = value;
|
||||
this._hasDefinedMatchers = true;
|
||||
}
|
||||
|
||||
get hasDefinedMatchers(): boolean {
|
||||
@@ -1764,14 +1784,13 @@ export class Task implements vscode.Task2 {
|
||||
this._source = value;
|
||||
}
|
||||
|
||||
get group(): TaskGroup {
|
||||
get group(): TaskGroup | undefined {
|
||||
return this._group;
|
||||
}
|
||||
|
||||
set group(value: TaskGroup) {
|
||||
if (value === void 0 || value === null) {
|
||||
this._group = undefined;
|
||||
return;
|
||||
set group(value: TaskGroup | undefined) {
|
||||
if (value === null) {
|
||||
value = undefined;
|
||||
}
|
||||
this.clear();
|
||||
this._group = value;
|
||||
@@ -1782,8 +1801,8 @@ export class Task implements vscode.Task2 {
|
||||
}
|
||||
|
||||
set presentationOptions(value: vscode.TaskPresentationOptions) {
|
||||
if (value === null) {
|
||||
value = undefined;
|
||||
if (value === null || value === undefined) {
|
||||
value = Object.create(null);
|
||||
}
|
||||
this.clear();
|
||||
this._presentationOptions = value;
|
||||
@@ -1794,8 +1813,8 @@ export class Task implements vscode.Task2 {
|
||||
}
|
||||
|
||||
set runOptions(value: vscode.RunOptions) {
|
||||
if (value === null) {
|
||||
value = undefined;
|
||||
if (value === null || value === undefined) {
|
||||
value = Object.create(null);
|
||||
}
|
||||
this.clear();
|
||||
this._runOptions = value;
|
||||
|
||||
Reference in New Issue
Block a user