Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move rerun behavior api out of proposed #63511

Merged
merged 3 commits into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5008,6 +5008,16 @@ declare module 'vscode' {
Workspace = 2
}

/**
* Run options for a task.
*/
export interface RunOptions {
/**
* Controls whether task variables are re-evaluated on rerun.
*/
reevaluateOnRerun?: boolean;
}

/**
* A task to execute
*/
Expand Down Expand Up @@ -5091,6 +5101,11 @@ declare module 'vscode' {
* array.
*/
problemMatchers: string[];

/**
* Run options for the task
*/
runOptions: RunOptions;
}

/**
Expand Down
25 changes: 0 additions & 25 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1151,31 +1151,6 @@ declare module 'vscode' {
}
//#endregion

//#region Task
export enum RerunBehavior {
reevaluate = 1,
useEvaluated = 2,
}


export interface RunOptions {
/**
* Controls the behavior of a task when it is rerun.
*/
rerunBehavior?: RerunBehavior;
}

/**
* A task to execute
*/
export class Task2 extends Task {
/**
* Run options for the task. Defaults to an empty literal.
*/
runOptions: RunOptions;
}
//#endregion

//#region Extension Context
export interface ExtensionContext {

Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,6 @@ export function createApiFactory(
QuickInputButtons: extHostTypes.QuickInputButtons,
Range: extHostTypes.Range,
RelativePattern: extHostTypes.RelativePattern,
RerunBehavior: extHostTypes.RerunBehavior,
Selection: extHostTypes.Selection,
ShellExecution: extHostTypes.ShellExecution,
ShellQuoting: extHostTypes.ShellQuoting,
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHostTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ namespace Tasks {
isBackground: !!task.isBackground,
problemMatchers: task.problemMatchers.slice(),
hasDefinedMatchers: (task as types.Task).hasDefinedMatchers,
runOptions: (<vscode.Task2>task).runOptions ? (<vscode.Task2>task).runOptions : { rerunBehavior: tasks.RerunBehavior.reevaluate },
runOptions: (<vscode.Task>task).runOptions ? (<vscode.Task>task).runOptions : { reevaluateOnRerun: true },
};
return result;
}
Expand Down Expand Up @@ -631,7 +631,7 @@ namespace TaskDTO {
presentationOptions: TaskPresentationOptionsDTO.from(value.presentationOptions),
problemMatchers: value.problemMatchers,
hasDefinedMatchers: (value as types.Task).hasDefinedMatchers,
runOptions: (<vscode.Task2>value).runOptions ? (<vscode.Task2>value).runOptions : { rerunBehavior: tasks.RerunBehavior.reevaluate },
runOptions: (<vscode.Task>value).runOptions ? (<vscode.Task>value).runOptions : { reevaluateOnRerun: true },
};
return result;
}
Expand Down
7 changes: 1 addition & 6 deletions src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1591,12 +1591,7 @@ export enum TaskScope {
Workspace = 2
}

export enum RerunBehavior {
reevaluate = 1,
useEvaluated = 2,
}

export class Task implements vscode.Task2 {
export class Task implements vscode.Task {

private static ProcessType: string = 'process';
private static ShellType: string = 'shell';
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/api/shared/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/

import { UriComponents } from 'vs/base/common/uri';
import { RerunBehavior } from 'vs/workbench/parts/tasks/common/tasks';

export interface TaskDefinitionDTO {
type: string;
Expand All @@ -21,7 +20,7 @@ export interface TaskPresentationOptionsDTO {
}

export interface RunOptionsDTO {
rerunBehavior?: RerunBehavior;
reevaluateOnRerun?: boolean;
}

export interface ExecutionOptionsDTO {
Expand Down
7 changes: 1 addition & 6 deletions src/vs/workbench/parts/tasks/common/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,13 @@ export interface ConfigurationProperties {
problemMatchers?: (string | ProblemMatcher)[];
}

export enum RerunBehavior {
reevaluate = 1,
useEvaluated = 2,
}

export enum RunOnOptions {
default = 1,
folderOpen = 2
}

export interface RunOptions {
rerunBehavior?: RerunBehavior;
reevaluateOnRerun?: boolean;
runOn?: RunOnOptions;
}
export interface CommonTask {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ const identifier: IJSONSchema = {
const runOptions: IJSONSchema = {
type: 'object',
properties: {
rerunBehavior: {
type: 'string',
enum: ['reevauate', 'useEvaluated'],
description: nls.localize('JsonSchema.tasks.rerunBehavior', 'The task\'s behavior on rerun')
reevaluateOnRerun: {
type: 'boolean',
description: nls.localize('JsonSchema.tasks.reevaluateOnRerun', 'Whether to reevaluate task variables on rerun.'),
default: true
},
runOn: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import { ITaskSystem, ITaskResolver, ITaskSummary, TaskExecuteKind, TaskError, T
import {
Task, CustomTask, ConfiguringTask, ContributedTask, InMemoryTask, TaskEvent,
TaskEventKind, TaskSet, TaskGroup, GroupType, ExecutionEngine, JsonSchemaVersion, TaskSourceKind,
TaskSorter, TaskIdentifier, KeyedTaskIdentifier, TASK_RUNNING_STATE, RerunBehavior
TaskSorter, TaskIdentifier, KeyedTaskIdentifier, TASK_RUNNING_STATE
} from 'vs/workbench/parts/tasks/common/tasks';
import { ITaskService, ITaskProvider, ProblemMatcherRunOptions, CustomizationProperties, TaskFilter, WorkspaceFolderTaskResult } from 'vs/workbench/parts/tasks/common/taskService';
import { getTemplates as getTaskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates';
Expand Down Expand Up @@ -1172,7 +1172,7 @@ class TaskService extends Disposable implements ITaskService {
name: id,
identifier: id,
dependsOn: extensionTasks.map((task) => { return { workspaceFolder: Task.getWorkspaceFolder(task), task: task._id }; }),
runOptions: { rerunBehavior: RerunBehavior.reevaluate },
runOptions: { reevaluateOnRerun: true },
};
return { task, resolver };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { IOutputService, IOutputChannel } from 'vs/workbench/parts/output/common
import { StartStopProblemCollector, WatchingProblemCollector, ProblemCollectorEventKind } from 'vs/workbench/parts/tasks/common/problemCollectors';
import {
Task, CustomTask, ContributedTask, RevealKind, CommandOptions, ShellConfiguration, RuntimeType, PanelKind,
TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, RerunBehavior, ExtensionTaskSource, TaskScope
TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, ExtensionTaskSource, TaskScope
} from 'vs/workbench/parts/tasks/common/tasks';
import {
ITaskSystem, ITaskSummary, ITaskExecuteResult, TaskExecuteKind, TaskError, TaskErrors, ITaskResolver,
Expand Down Expand Up @@ -201,7 +201,9 @@ export class TerminalTaskSystem implements ITaskSystem {

try {
const executeResult = { kind: TaskExecuteKind.Started, task, started: {}, promise: this.executeTask(task, resolver, trigger) };
this.lastTask = this.currentTask;
executeResult.promise.then(summary => {
this.lastTask = this.currentTask;
});
return executeResult;
} catch (error) {
if (error instanceof TaskError) {
Expand All @@ -218,11 +220,13 @@ export class TerminalTaskSystem implements ITaskSystem {

public rerun(): ITaskExecuteResult | undefined {
if (this.lastTask && this.lastTask.verify()) {
if (this.lastTask.task.runOptions.rerunBehavior === RerunBehavior.useEvaluated) {
if ((this.lastTask.task.runOptions.reevaluateOnRerun !== void 0) && !this.lastTask.task.runOptions.reevaluateOnRerun) {
this.isRerun = true;
}
const result = this.run(this.lastTask.task, this.lastTask.resolver);
this.isRerun = false;
result.promise.then(summary => {
this.isRerun = false;
});
return result;
} else {
return undefined;
Expand Down
21 changes: 3 additions & 18 deletions src/vs/workbench/parts/tasks/node/taskConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export interface PresentationOptionsConfig {
}

export interface RunOptionsConfig {
rerunBehavior?: string;
reevaluateOnRerun?: boolean;
runOn?: string;
}

Expand Down Expand Up @@ -634,21 +634,6 @@ function _freeze<T>(this: void, target: T, properties: MetaData<T, any>[]): Read
return target;
}

export namespace RerunBehavior {
export function fromString(value: string | undefined): Tasks.RerunBehavior {
if (!value) {
return Tasks.RerunBehavior.reevaluate;
}
switch (value.toLowerCase()) {
case 'useevaluated':
return Tasks.RerunBehavior.useEvaluated;
case 'reevaulate':
default:
return Tasks.RerunBehavior.reevaluate;
}
}
}

export namespace RunOnOptions {
export function fromString(value: string | undefined): Tasks.RunOnOptions {
if (!value) {
Expand All @@ -667,7 +652,7 @@ export namespace RunOnOptions {
export namespace RunOptions {
export function fromConfiguration(value: RunOptionsConfig | undefined): Tasks.RunOptions {
return {
rerunBehavior: value ? RerunBehavior.fromString(value.rerunBehavior) : Tasks.RerunBehavior.reevaluate,
reevaluateOnRerun: value ? value.reevaluateOnRerun : true,
runOn: value ? RunOnOptions.fromString(value.runOn) : Tasks.RunOnOptions.default
};
}
Expand Down Expand Up @@ -1904,7 +1889,7 @@ class ConfigurationParser {
isBackground: isBackground,
problemMatchers: matchers,
hasDefinedMatchers: false,
runOptions: { rerunBehavior: Tasks.RerunBehavior.reevaluate },
runOptions: { reevaluateOnRerun: true },
};
let value = GroupKind.from(fileConfig.group);
if (value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class CustomTaskBuilder {
promptOnClose: true,
problemMatchers: [],
hasDefinedMatchers: false,
runOptions: { rerunBehavior: Tasks.RerunBehavior.reevaluate },
runOptions: { reevaluateOnRerun: true },
};
}

Expand Down