Skip to content

Commit f25a65f

Browse files
authored
Only call resolve() on tasks that have no execution (#15480)
Fixes #15171 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
1 parent fefa45f commit f25a65f

File tree

10 files changed

+23
-20
lines changed

10 files changed

+23
-20
lines changed

packages/plugin-ext/src/common/plugin-api-rpc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ export interface CommandProperties {
16211621
export type TaskGroupKind = 'build' | 'test' | 'rebuild' | 'clean';
16221622
export interface TaskDto {
16231623
type: string;
1624-
taskType?: 'shell' | 'process' | 'customExecution'; // the task execution type
1624+
executionType?: 'shell' | 'process' | 'customExecution'; // the task execution type
16251625
executionId?: string,
16261626
label: string;
16271627
source?: string;

packages/plugin-ext/src/plugin/tasks/task-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class TaskProviderAdapter {
4646
}
4747

4848
const item = Converter.toTask(task);
49-
if (!item) {
49+
if (!item || item.execution) {
5050
return task;
5151
}
5252

packages/plugin-ext/src/plugin/tasks/tasks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class TasksExtImpl implements TasksExt {
163163
if (adapter) {
164164
return adapter.provideTasks(CancellationToken.None).then(tasks => {
165165
for (const task of tasks) {
166-
if (task.taskType === 'customExecution') {
166+
if (task.executionType === 'customExecution') {
167167
this.applyCustomExecution(task);
168168
}
169169
}
@@ -179,8 +179,8 @@ export class TasksExtImpl implements TasksExt {
179179
if (adapter) {
180180
return adapter.resolveTask(task, token).then(resolvedTask => {
181181
// ensure we do not lose task type and execution id during resolution as we need it for custom execution
182-
resolvedTask.taskType = resolvedTask.taskType ?? task.taskType;
183-
if (resolvedTask.taskType === 'customExecution') {
182+
resolvedTask.executionType = resolvedTask.executionType ?? task.executionType;
183+
if (resolvedTask.executionType === 'customExecution') {
184184
this.applyCustomExecution(resolvedTask);
185185
}
186186
return resolvedTask;

packages/plugin-ext/src/plugin/type-converters.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ describe('Type converters:', () => {
188188

189189
const shellTaskDto: TaskDto = {
190190
type: shellType,
191-
taskType: shellType,
191+
executionType: shellType,
192192
label,
193193
source,
194194
scope: 1,
@@ -211,7 +211,7 @@ describe('Type converters:', () => {
211211

212212
const shellTaskDtoWithCommandLine: TaskDto = {
213213
type: shellType,
214-
taskType: shellType,
214+
executionType: shellType,
215215
label,
216216
source,
217217
scope: 2,

packages/plugin-ext/src/plugin/type-converters.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ export function toTask(taskDto: TaskDto): theia.Task {
983983
throw new Error('Task should be provided for converting');
984984
}
985985

986-
const { type, taskType, label, source, scope, problemMatcher, detail, command, args, options, group, presentation, runOptions, ...properties } = taskDto;
986+
const { type, executionType, label, source, scope, problemMatcher, detail, command, args, options, group, presentation, runOptions, ...properties } = taskDto;
987987
const result = {} as theia.Task;
988988
result.name = label;
989989
result.source = source;
@@ -1008,16 +1008,16 @@ export function toTask(taskDto: TaskDto): theia.Task {
10081008

10091009
result.definition = taskDefinition;
10101010

1011-
if (taskType === 'process') {
1011+
if (executionType === 'process') {
10121012
result.execution = getProcessExecution(taskDto);
10131013
}
10141014

10151015
const execution = { command, args, options };
1016-
if (taskType === 'shell' || types.ShellExecution.is(execution)) {
1016+
if (executionType === 'shell' || types.ShellExecution.is(execution)) {
10171017
result.execution = getShellExecution(taskDto);
10181018
}
10191019

1020-
if (taskType === 'customExecution' || types.CustomExecution.is(execution)) {
1020+
if (executionType === 'customExecution' || types.CustomExecution.is(execution)) {
10211021
result.execution = getCustomExecution(taskDto);
10221022
// if taskType is customExecution, we need to put all the information into taskDefinition,
10231023
// because some parameters may be in taskDefinition.
@@ -1053,7 +1053,7 @@ export function toTask(taskDto: TaskDto): theia.Task {
10531053
}
10541054

10551055
export function fromProcessExecution(execution: theia.ProcessExecution, taskDto: TaskDto): TaskDto {
1056-
taskDto.taskType = 'process';
1056+
taskDto.executionType = 'process';
10571057
taskDto.command = execution.process;
10581058
taskDto.args = execution.args;
10591059

@@ -1065,7 +1065,7 @@ export function fromProcessExecution(execution: theia.ProcessExecution, taskDto:
10651065
}
10661066

10671067
export function fromShellExecution(execution: theia.ShellExecution, taskDto: TaskDto): TaskDto {
1068-
taskDto.taskType = 'shell';
1068+
taskDto.executionType = 'shell';
10691069
const options = execution.options;
10701070
if (options) {
10711071
taskDto.options = getShellExecutionOptions(options);
@@ -1087,7 +1087,7 @@ export function fromShellExecution(execution: theia.ShellExecution, taskDto: Tas
10871087
}
10881088

10891089
export function fromCustomExecution(execution: types.CustomExecution, taskDto: TaskDto): TaskDto {
1090-
taskDto.taskType = 'customExecution';
1090+
taskDto.executionType = 'customExecution';
10911091
const callback = execution.callback;
10921092
if (callback) {
10931093
taskDto.callback = callback;

packages/task/src/browser/process/process-task-resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class ProcessTaskResolver implements TaskResolver {
4242
* sane default values. Also, resolve all known variables, e.g. `${workspaceFolder}`.
4343
*/
4444
async resolveTask(taskConfig: TaskConfiguration): Promise<TaskConfiguration> {
45-
const type = taskConfig.taskType || taskConfig.type;
45+
const type = taskConfig.executionType || taskConfig.type;
4646
if (type !== 'process' && type !== 'shell') {
4747
throw new Error('Unsupported task configuration type.');
4848
}

packages/task/src/browser/task-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ export class TaskService implements TaskConfigurationClient {
753753
try {
754754
// resolve problemMatchers
755755
if (!option && task.problemMatcher) {
756-
const customizationObject: TaskCustomization = { type: task.taskType, problemMatcher: task.problemMatcher, runOptions: task.runOptions };
756+
const customizationObject: TaskCustomization = { type: task.type, problemMatcher: task.problemMatcher, runOptions: task.runOptions };
757757
const resolvedMatchers = await this.resolveProblemMatchers(task, customizationObject);
758758
option = {
759759
customization: { ...customizationObject, ...{ problemMatcher: resolvedMatchers } }
@@ -840,7 +840,7 @@ export class TaskService implements TaskConfigurationClient {
840840
try {
841841
const resolver = await this.taskResolverRegistry.getTaskResolver(task.type);
842842
const resolvedTask = resolver ? await resolver.resolveTask(task) : task;
843-
const executionResolver = this.taskResolverRegistry.getExecutionResolver(resolvedTask.taskType || resolvedTask.type);
843+
const executionResolver = this.taskResolverRegistry.getExecutionResolver(resolvedTask.executionType || resolvedTask.type);
844844
overridePropertiesFunction(resolvedTask);
845845
const taskToRun = executionResolver ? await executionResolver.resolveTask(resolvedTask) : resolvedTask;
846846

packages/task/src/common/task-protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export interface TaskConfiguration extends TaskCustomization {
178178
/** A label that uniquely identifies a task configuration per source */
179179
readonly label: string;
180180
readonly _scope: TaskConfigurationScope;
181+
readonly executionType?: 'shell' | 'process' | 'customExecution';
181182
}
182183

183184
export interface ContributedTaskConfiguration extends TaskConfiguration {

packages/task/src/node/process/process-task-runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class ProcessTaskRunner implements TaskRunner {
9595
});
9696
});
9797

98-
const processType = (taskConfig.taskType || taskConfig.type) as 'process' | 'shell';
98+
const processType = (taskConfig.executionType || taskConfig.type) as 'process' | 'shell';
9999
return this.taskFactory({
100100
label: taskConfig.label,
101101
process: terminal,
@@ -135,7 +135,7 @@ export class ProcessTaskRunner implements TaskRunner {
135135
*/
136136
let commandLine: string | undefined;
137137

138-
if ((taskConfig.taskType || taskConfig.type) === 'shell') {
138+
if ((taskConfig.executionType || taskConfig.type) === 'shell') {
139139
// When running a shell task, we have to spawn a shell process somehow,
140140
// and tell it to run the command the user wants to run inside of it.
141141
//

packages/task/src/node/task-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export class TaskServerImpl implements TaskServer, Disposable {
9090
}
9191

9292
async run(taskConfiguration: TaskConfiguration, ctx?: string, option?: RunTaskOption): Promise<TaskInfo> {
93-
const runner = this.runnerRegistry.getRunner(taskConfiguration.type, taskConfiguration.taskType);
93+
const runner = taskConfiguration.executionType ?
94+
this.runnerRegistry.getRunner(taskConfiguration.type, taskConfiguration.executionType) :
95+
this.runnerRegistry.getRunner(taskConfiguration.type);
9496
const task = await runner.run(taskConfiguration, ctx);
9597

9698
if (!this.toDispose.has(task.id)) {

0 commit comments

Comments
 (0)