提交 50d49c8c 编写于 作者: G Gabriel DeBacker

Move to proposed API and rename things for consistency

上级 1faf0981
...@@ -5074,21 +5074,6 @@ declare module 'vscode' { ...@@ -5074,21 +5074,6 @@ declare module 'vscode' {
options?: ShellExecutionOptions; options?: ShellExecutionOptions;
} }
/**
* Class used to execute an extension callback as a task.
*/
export class ExtensionCallbackExecution {
/**
* @param callback The callback that will be called when the extension callback task is executed.
*/
constructor(callback: (terminalRenderer: TerminalRenderer, cancellationToken: CancellationToken, thisArg?: any) => Thenable<void>);
/**
* The callback used to execute the task.
*/
callback: (terminalRenderer: TerminalRenderer, cancellationToken: CancellationToken, thisArg?: any) => Thenable<void>;
}
/** /**
* The scope of a task. * The scope of a task.
*/ */
...@@ -5118,7 +5103,6 @@ declare module 'vscode' { ...@@ -5118,7 +5103,6 @@ declare module 'vscode' {
* A task to execute * A task to execute
*/ */
export class Task { export class Task {
/** /**
* Creates a new task. * Creates a new task.
* *
...@@ -5131,7 +5115,7 @@ declare module 'vscode' { ...@@ -5131,7 +5115,7 @@ declare module 'vscode' {
* or '$eslint'. Problem matchers can be contributed by an extension using * or '$eslint'. Problem matchers can be contributed by an extension using
* the `problemMatchers` extension point. * the `problemMatchers` extension point.
*/ */
constructor(taskDefinition: TaskDefinition, scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace, name: string, source: string, execution?: ProcessExecution | ShellExecution | ExtensionCallbackExecution, problemMatchers?: string | string[]); constructor(taskDefinition: TaskDefinition, scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
/** /**
* ~~Creates a new task.~~ * ~~Creates a new task.~~
...@@ -5146,7 +5130,7 @@ declare module 'vscode' { ...@@ -5146,7 +5130,7 @@ declare module 'vscode' {
* or '$eslint'. Problem matchers can be contributed by an extension using * or '$eslint'. Problem matchers can be contributed by an extension using
* the `problemMatchers` extension point. * the `problemMatchers` extension point.
*/ */
constructor(taskDefinition: TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution | ExtensionCallbackExecution, problemMatchers?: string | string[]); constructor(taskDefinition: TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
/** /**
* The task's definition. * The task's definition.
...@@ -5166,7 +5150,7 @@ declare module 'vscode' { ...@@ -5166,7 +5150,7 @@ declare module 'vscode' {
/** /**
* The task's execution engine * The task's execution engine
*/ */
execution?: ProcessExecution | ShellExecution | ExtensionCallbackExecution; execution?: ProcessExecution | ShellExecution;
/** /**
* Whether the task is a background task or not. * Whether the task is a background task or not.
......
...@@ -1098,4 +1098,43 @@ declare module 'vscode' { ...@@ -1098,4 +1098,43 @@ declare module 'vscode' {
readonly activeSignatureHelp?: SignatureHelp; readonly activeSignatureHelp?: SignatureHelp;
} }
//#endregion //#endregion
/**
* Class used to execute an extension callback as a task.
*/
export class ExtensionCallbackExecution {
/**
* @param callback The callback that will be called when the extension callback task is executed.
*/
constructor(callback: (terminalRenderer: TerminalRenderer, cancellationToken: CancellationToken, thisArg?: any) => Thenable<void>);
/**
* The callback used to execute the task.
*/
callback: (terminalRenderer: TerminalRenderer, cancellationToken: CancellationToken, thisArg?: any) => Thenable<void>;
}
/**
* A task to execute
*/
export class TaskWithExtensionCallback extends Task {
/**
* Creates a new task.
*
* @param definition The task definition as defined in the taskDefinitions extension point.
* @param scope Specifies the task's scope. It is either a global or a workspace task or a task for a specific workspace folder.
* @param name The task's name. Is presented in the user interface.
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
* @param execution The process or shell execution.
* @param problemMatchers the names of problem matchers to use, like '$tsc'
* or '$eslint'. Problem matchers can be contributed by an extension using
* the `problemMatchers` extension point.
*/
constructor(taskDefinition: TaskDefinition, scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace, name: string, source: string, execution?: ProcessExecution | ShellExecution | ExtensionCallbackExecution, problemMatchers?: string | string[]);
/**
* The task's execution engine
*/
executionWithExtensionCallback?: ProcessExecution | ShellExecution | ExtensionCallbackExecution;
}
} }
...@@ -32,7 +32,7 @@ import { ...@@ -32,7 +32,7 @@ import {
TaskDefinitionDTO, TaskExecutionDTO, ProcessExecutionOptionsDTO, TaskPresentationOptionsDTO, TaskDefinitionDTO, TaskExecutionDTO, ProcessExecutionOptionsDTO, TaskPresentationOptionsDTO,
ProcessExecutionDTO, ShellExecutionDTO, ShellExecutionOptionsDTO, TaskDTO, TaskSourceDTO, TaskHandleDTO, TaskFilterDTO, TaskProcessStartedDTO, TaskProcessEndedDTO, TaskSystemInfoDTO, ProcessExecutionDTO, ShellExecutionDTO, ShellExecutionOptionsDTO, TaskDTO, TaskSourceDTO, TaskHandleDTO, TaskFilterDTO, TaskProcessStartedDTO, TaskProcessEndedDTO, TaskSystemInfoDTO,
RunOptionsDTO, RunOptionsDTO,
CallbackExecutionDTO ExtensionCallbackExecutionDTO
} from 'vs/workbench/api/shared/tasks'; } from 'vs/workbench/api/shared/tasks';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
...@@ -139,7 +139,7 @@ namespace ProcessExecutionOptionsDTO { ...@@ -139,7 +139,7 @@ namespace ProcessExecutionOptionsDTO {
} }
namespace ProcessExecutionDTO { namespace ProcessExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CallbackExecutionDTO): value is ProcessExecutionDTO { export function is(value: ShellExecutionDTO | ProcessExecutionDTO | ExtensionCallbackExecutionDTO): value is ProcessExecutionDTO {
let candidate = value as ProcessExecutionDTO; let candidate = value as ProcessExecutionDTO;
return candidate && !!candidate.process; return candidate && !!candidate.process;
} }
...@@ -207,7 +207,7 @@ namespace ShellExecutionOptionsDTO { ...@@ -207,7 +207,7 @@ namespace ShellExecutionOptionsDTO {
} }
namespace ShellExecutionDTO { namespace ShellExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CallbackExecutionDTO): value is ShellExecutionDTO { export function is(value: ShellExecutionDTO | ProcessExecutionDTO | ExtensionCallbackExecutionDTO): value is ShellExecutionDTO {
let candidate = value as ShellExecutionDTO; let candidate = value as ShellExecutionDTO;
return candidate && (!!candidate.commandLine || !!candidate.command); return candidate && (!!candidate.commandLine || !!candidate.command);
} }
...@@ -239,18 +239,18 @@ namespace ShellExecutionDTO { ...@@ -239,18 +239,18 @@ namespace ShellExecutionDTO {
} }
namespace CallbackExecutionDTO { namespace CallbackExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CallbackExecutionDTO): value is CallbackExecutionDTO { export function is(value: ShellExecutionDTO | ProcessExecutionDTO | ExtensionCallbackExecutionDTO): value is ExtensionCallbackExecutionDTO {
let candidate = value as CallbackExecutionDTO; let candidate = value as ExtensionCallbackExecutionDTO;
return candidate && candidate.extensionCallback === 'extensionCallback'; return candidate && candidate.extensionCallback === 'extensionCallback';
} }
export function from(value: CommandConfiguration): CallbackExecutionDTO { export function from(value: CommandConfiguration): ExtensionCallbackExecutionDTO {
return { return {
extensionCallback: 'extensionCallback' extensionCallback: 'extensionCallback'
}; };
} }
export function to(value: CallbackExecutionDTO): CommandConfiguration { export function to(value: ExtensionCallbackExecutionDTO): CommandConfiguration {
return { return {
runtime: RuntimeType.ExtensionCallback, runtime: RuntimeType.ExtensionCallback,
presentation: undefined presentation: undefined
......
...@@ -800,7 +800,7 @@ export function createApiFactory( ...@@ -800,7 +800,7 @@ export function createApiFactory(
SymbolInformation: extHostTypes.SymbolInformation, SymbolInformation: extHostTypes.SymbolInformation,
SymbolKind: extHostTypes.SymbolKind, SymbolKind: extHostTypes.SymbolKind,
Task: extHostTypes.Task, Task: extHostTypes.Task,
Task2: extHostTypes.Task, TaskWithExtensionCallback: extHostTypes.Task,
TaskGroup: extHostTypes.TaskGroup, TaskGroup: extHostTypes.TaskGroup,
TaskPanelKind: extHostTypes.TaskPanelKind, TaskPanelKind: extHostTypes.TaskPanelKind,
TaskRevealKind: extHostTypes.TaskRevealKind, TaskRevealKind: extHostTypes.TaskRevealKind,
......
...@@ -22,7 +22,7 @@ import { ...@@ -22,7 +22,7 @@ import {
TaskDefinitionDTO, TaskExecutionDTO, TaskPresentationOptionsDTO, TaskDefinitionDTO, TaskExecutionDTO, TaskPresentationOptionsDTO,
ProcessExecutionOptionsDTO, ProcessExecutionDTO, ProcessExecutionOptionsDTO, ProcessExecutionDTO,
ShellExecutionOptionsDTO, ShellExecutionDTO, ShellExecutionOptionsDTO, ShellExecutionDTO,
CallbackExecutionDTO, ExtensionCallbackExecutionDTO,
TaskDTO, TaskHandleDTO, TaskFilterDTO, TaskProcessStartedDTO, TaskProcessEndedDTO, TaskSystemInfoDTO, TaskSetDTO TaskDTO, TaskHandleDTO, TaskFilterDTO, TaskProcessStartedDTO, TaskProcessEndedDTO, TaskSystemInfoDTO, TaskSetDTO
} from '../shared/tasks'; } from '../shared/tasks';
import { ExtHostVariableResolverService } from 'vs/workbench/api/node/extHostDebugService'; import { ExtHostVariableResolverService } from 'vs/workbench/api/node/extHostDebugService';
...@@ -79,7 +79,7 @@ namespace ProcessExecutionOptionsDTO { ...@@ -79,7 +79,7 @@ namespace ProcessExecutionOptionsDTO {
} }
namespace ProcessExecutionDTO { namespace ProcessExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CallbackExecutionDTO): value is ProcessExecutionDTO { export function is(value: ShellExecutionDTO | ProcessExecutionDTO | ExtensionCallbackExecutionDTO): value is ProcessExecutionDTO {
let candidate = value as ProcessExecutionDTO; let candidate = value as ProcessExecutionDTO;
return candidate && !!candidate.process; return candidate && !!candidate.process;
} }
...@@ -120,7 +120,7 @@ namespace ShellExecutionOptionsDTO { ...@@ -120,7 +120,7 @@ namespace ShellExecutionOptionsDTO {
} }
namespace ShellExecutionDTO { namespace ShellExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CallbackExecutionDTO): value is ShellExecutionDTO { export function is(value: ShellExecutionDTO | ProcessExecutionDTO | ExtensionCallbackExecutionDTO): value is ShellExecutionDTO {
let candidate = value as ShellExecutionDTO; let candidate = value as ShellExecutionDTO;
return candidate && (!!candidate.commandLine || !!candidate.command); return candidate && (!!candidate.commandLine || !!candidate.command);
} }
...@@ -153,13 +153,13 @@ namespace ShellExecutionDTO { ...@@ -153,13 +153,13 @@ namespace ShellExecutionDTO {
} }
} }
namespace CallbackExecutionDTO { namespace ExtensionCallbackExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CallbackExecutionDTO): value is CallbackExecutionDTO { export function is(value: ShellExecutionDTO | ProcessExecutionDTO | ExtensionCallbackExecutionDTO): value is ExtensionCallbackExecutionDTO {
let candidate = value as CallbackExecutionDTO; let candidate = value as ExtensionCallbackExecutionDTO;
return candidate && candidate.extensionCallback === 'extensionCallback'; return candidate && candidate.extensionCallback === 'extensionCallback';
} }
export function from(value: vscode.ExtensionCallbackExecution): CallbackExecutionDTO { export function from(value: vscode.ExtensionCallbackExecution): ExtensionCallbackExecutionDTO {
return { return {
extensionCallback: 'extensionCallback' extensionCallback: 'extensionCallback'
}; };
...@@ -199,13 +199,13 @@ namespace TaskDTO { ...@@ -199,13 +199,13 @@ namespace TaskDTO {
if (value === undefined || value === null) { if (value === undefined || value === null) {
return undefined; return undefined;
} }
let execution: ShellExecutionDTO | ProcessExecutionDTO | CallbackExecutionDTO; let execution: ShellExecutionDTO | ProcessExecutionDTO | ExtensionCallbackExecutionDTO;
if (value.execution instanceof types.ProcessExecution) { if (value.execution instanceof types.ProcessExecution) {
execution = ProcessExecutionDTO.from(value.execution); execution = ProcessExecutionDTO.from(value.execution);
} else if (value.execution instanceof types.ShellExecution) { } else if (value.execution instanceof types.ShellExecution) {
execution = ShellExecutionDTO.from(value.execution); execution = ShellExecutionDTO.from(value.execution);
} else if (value.execution instanceof types.ExtensionCallbackExecution) { } else if ((<vscode.TaskWithExtensionCallback>value).executionWithExtensionCallback && (<vscode.TaskWithExtensionCallback>value).executionWithExtensionCallback instanceof types.ExtensionCallbackExecution) {
execution = CallbackExecutionDTO.from(value.execution); execution = ExtensionCallbackExecutionDTO.from(<types.ExtensionCallbackExecution>(<vscode.TaskWithExtensionCallback>value).executionWithExtensionCallback);
} }
let definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition); let definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition);
...@@ -387,8 +387,13 @@ class ExtensionCallbackExecutionData implements IDisposable { ...@@ -387,8 +387,13 @@ class ExtensionCallbackExecutionData implements IDisposable {
// Regardless of how the task completes, we are done with this extension callback task execution. // Regardless of how the task completes, we are done with this extension callback task execution.
return this.callbackData.callback(terminalRenderer, this._cancellationSource.token).then( return this.callbackData.callback(terminalRenderer, this._cancellationSource.token).then(
() => this._onTaskExecutionComplete.fire(this), (success) => {
() => this._onTaskExecutionComplete.fire(this)); this._onTaskExecutionComplete.fire(this);
terminalRenderer.terminal.dispose();
}, (rejected) => {
this._onTaskExecutionComplete.fire(this);
terminalRenderer.terminal.dispose();
});
} }
return undefined; return undefined;
...@@ -617,11 +622,11 @@ export class ExtHostTask implements ExtHostTaskShape { ...@@ -617,11 +622,11 @@ export class ExtHostTask implements ExtHostTaskShape {
const taskDTO: TaskDTO = TaskDTO.from(task, handler.extension); const taskDTO: TaskDTO = TaskDTO.from(task, handler.extension);
taskDTOs.push(taskDTO); taskDTOs.push(taskDTO);
if (CallbackExecutionDTO.is(taskDTO.execution)) { if (ExtensionCallbackExecutionDTO.is(taskDTO.execution)) {
taskIdPromises.push(new Promise((resolve) => { taskIdPromises.push(new Promise((resolve) => {
// The ID is calculated on the main thread task side, so, let's call into it here. // The ID is calculated on the main thread task side, so, let's call into it here.
this._proxy.$createTaskId(taskDTO).then((taskId) => { this._proxy.$createTaskId(taskDTO).then((taskId) => {
this._providedExtensionCallbacks.set(taskId, new ExtensionCallbackExecutionData(<vscode.ExtensionCallbackExecution>task.execution, this._terminalService)); this._providedExtensionCallbacks.set(taskId, new ExtensionCallbackExecutionData(<vscode.ExtensionCallbackExecution>(<vscode.TaskWithExtensionCallback>task).executionWithExtensionCallback, this._terminalService));
resolve(); resolve();
}); });
})); }));
......
...@@ -1646,7 +1646,7 @@ export class ExtensionCallbackExecution implements vscode.ExtensionCallbackExecu ...@@ -1646,7 +1646,7 @@ export class ExtensionCallbackExecution implements vscode.ExtensionCallbackExecu
} }
} }
export class Task implements vscode.Task { export class Task implements vscode.TaskWithExtensionCallback {
private static ExtensionCallbackType: string = 'extensionCallback'; private static ExtensionCallbackType: string = 'extensionCallback';
private static ProcessType: string = 'process'; private static ProcessType: string = 'process';
...@@ -1733,7 +1733,7 @@ export class Task implements vscode.Task { ...@@ -1733,7 +1733,7 @@ export class Task implements vscode.Task {
type: Task.ShellType, type: Task.ShellType,
id: this._execution.computeId() id: this._execution.computeId()
}; };
} else if (this._execution instanceof ExtensionScriptApis) { } else if (this._execution instanceof ExtensionCallbackExecution) {
this._definition = { this._definition = {
type: Task.ExtensionCallbackType, type: Task.ExtensionCallbackType,
id: this._execution.computeId() id: this._execution.computeId()
...@@ -1779,18 +1779,34 @@ export class Task implements vscode.Task { ...@@ -1779,18 +1779,34 @@ export class Task implements vscode.Task {
this._name = value; this._name = value;
} }
get execution(): ProcessExecution | ShellExecution | ExtensionCallbackExecution | undefined { get execution(): ProcessExecution | ShellExecution | undefined {
return (this._execution instanceof ExtensionCallbackExecution) ? undefined : this._execution;
}
set execution(value: ProcessExecution | ShellExecution | undefined) {
this.executionInternal = value;
}
get executionWithExtensionCallback(): ProcessExecution | ShellExecution | ExtensionCallbackExecution | undefined {
return this.executionInternal;
}
set executionWithExtensionCallback(value: ProcessExecution | ShellExecution | ExtensionCallbackExecution | undefined) {
this.executionInternal = value;
}
private get executionInternal(): ProcessExecution | ShellExecution | ExtensionCallbackExecution | undefined {
return this._execution; return this._execution;
} }
set execution(value: ProcessExecution | ShellExecution | ExtensionCallbackExecution | undefined) { private set executionInternal(value: ProcessExecution | ShellExecution | ExtensionCallbackExecution | undefined) {
if (value === null) { if (value === null) {
value = undefined; value = undefined;
} }
this.clear(); this.clear();
this._execution = value; this._execution = value;
let type = this._definition.type; let type = this._definition.type;
if (Task.EmptyType === type || Task.ProcessType === type || Task.ShellType === type) { if (Task.EmptyType === type || Task.ProcessType === type || Task.ShellType === type || Task.ExtensionCallbackType === type) {
this.computeDefinitionBasedOnExecution(); this.computeDefinitionBasedOnExecution();
} }
} }
......
...@@ -65,7 +65,7 @@ export interface ShellExecutionDTO { ...@@ -65,7 +65,7 @@ export interface ShellExecutionDTO {
options?: ShellExecutionOptionsDTO; options?: ShellExecutionOptionsDTO;
} }
export interface CallbackExecutionDTO { export interface ExtensionCallbackExecutionDTO {
extensionCallback: 'extensionCallback'; extensionCallback: 'extensionCallback';
} }
...@@ -83,7 +83,7 @@ export interface TaskHandleDTO { ...@@ -83,7 +83,7 @@ export interface TaskHandleDTO {
export interface TaskDTO { export interface TaskDTO {
_id: string; _id: string;
name: string; name: string;
execution: ProcessExecutionDTO | ShellExecutionDTO | CallbackExecutionDTO; execution: ProcessExecutionDTO | ShellExecutionDTO | ExtensionCallbackExecutionDTO;
definition: TaskDefinitionDTO; definition: TaskDefinitionDTO;
isBackground: boolean; isBackground: boolean;
source: TaskSourceDTO; source: TaskSourceDTO;
......
...@@ -514,7 +514,9 @@ export class TerminalTaskSystem implements ITaskSystem { ...@@ -514,7 +514,9 @@ export class TerminalTaskSystem implements ITaskSystem {
let processStartedSignaled = false; let processStartedSignaled = false;
terminal.processReady.then(() => { terminal.processReady.then(() => {
if (!processStartedSignaled) { if (!processStartedSignaled) {
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.ProcessStarted, task, terminal!.processId!)); if (task.command.runtime !== RuntimeType.ExtensionCallback) {
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.ProcessStarted, task, terminal!.processId!));
}
processStartedSignaled = true; processStartedSignaled = true;
} }
}, (_error) => { }, (_error) => {
...@@ -581,7 +583,9 @@ export class TerminalTaskSystem implements ITaskSystem { ...@@ -581,7 +583,9 @@ export class TerminalTaskSystem implements ITaskSystem {
let processStartedSignaled = false; let processStartedSignaled = false;
terminal.processReady.then(() => { terminal.processReady.then(() => {
if (!processStartedSignaled) { if (!processStartedSignaled) {
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.ProcessStarted, task, terminal!.processId!)); if (task.command.runtime !== RuntimeType.ExtensionCallback) {
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.ProcessStarted, task, terminal!.processId!));
}
processStartedSignaled = true; processStartedSignaled = true;
} }
}, (_error) => { }, (_error) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册