Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
37319680
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
37319680
编写于
5月 15, 2018
作者:
D
Dirk Baeumer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Incooperated API review for tasks
上级
1637f08c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
167 addition
and
93 deletion
+167
-93
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+96
-47
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+27
-0
src/vs/workbench/api/node/extHostTask.ts
src/vs/workbench/api/node/extHostTask.ts
+44
-46
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
37319680
...
...
@@ -334,6 +334,48 @@ declare module 'vscode' {
//#region Tasks
/**
* An object representing an executed Task. It can be used
* to terminate a task.
*
* This interface is not intended to be implemented.
*/
export
interface
TaskExecution
{
/**
* The task that got started.
*/
task
:
Task
;
/**
* Terminates the task execution.
*/
terminate
():
void
;
}
/**
* An event signaling the start of a task execution.
*
* This interface is not intended to be implemented.
*/
interface
TaskStartEvent
{
/**
* The task item representing the task that got started.
*/
execution
:
TaskExecution
;
}
/**
* An event signaling the end of an executed task.
*
* This interface is not intended to be implemented.
*/
interface
TaskEndEvent
{
/**
* The task item representing the task that finished.
*/
execution
:
TaskExecution
;
}
/**
* An event signaling the start of a process execution
* triggered through a task
...
...
@@ -368,76 +410,69 @@ declare module 'vscode' {
exitCode
:
number
;
}
/**
* An object representing an executed Task. It can be used
* to terminate a task.
*
* This interface is not intended to be implemented.
*/
export
interface
TaskExecution
{
export
interface
TaskFilter
{
/**
* The task that got started.
* The task version as used in the tasks.json file.
* The string support the package.json semver notation.
*/
task
:
Task
;
version
?:
string
;
/**
* Fires when the underlying process has been started.
* This event might not fire for tasks that don't
* execute an underlying process.
* The task type to return;
*/
onDidStartProcess
:
Event
<
TaskProcessStartEvent
>
;
type
?:
string
;
}
/**
* Fires when the underlying process has ended.
* This event might not fire for tasks that don't
* execute an underlying process.
*/
onDidEndProcess
:
Event
<
TaskProcessEndEvent
>
;
export
namespace
workspace
{
/**
* Terminates the task execution.
* Fetches all tasks available in the systems. This includes tasks
* from `tasks.json` files as well as tasks from task providers
* contributed through extensions.
*
* @param filter a filter to filter the return tasks.
*/
terminate
():
void
;
}
export
function
fetchTasks
(
filter
?:
TaskFilter
):
Thenable
<
Task
[]
>
;
/**
* An event signaling the start of a task execution.
*
* This interface is not intended to be implemented.
*/
interface
TaskStartEvent
{
/**
* The task item representing the task that got started.
* Executes a task that is managed by VS Code. The returned
* task execution can be used to terminate the task.
*
* @param task the task to execute
*/
execution
:
TaskExecution
;
}
export
function
executeTask
(
task
:
Task
):
Thenable
<
TaskExecution
>
;
/**
* An event signaling the end of an executed task.
*
* This interface is not intended to be implemented.
*/
interface
TaskEndEvent
{
/**
* The task item representing the task that finished.
* The currently active task executions or an empty array.
*
* @readonly
*/
execution
:
TaskExecution
;
}
export
let
taskExecutions
:
ReadonlyArray
<
TaskExecution
>
;
export
interface
TaskFilter
{
/**
* The task version as used in the tasks.json file.
* The string support the package.json semver notation.
* Fires when a task starts.
*/
version
?:
string
;
export
const
onDidStartTask
:
Event
<
TaskStartEvent
>
;
/**
*
The task type to return;
*
Fires when a task ends.
*/
type
?:
string
;
export
const
onDidEndTask
:
Event
<
TaskEndEvent
>
;
}
export
namespace
workspace
{
/**
* Namespace for tasks functionality.
*/
export
namespace
tasks
{
/**
* Register a task provider.
*
* @param type The task kind type this provider is registered for.
* @param provider A task provider.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export
function
registerTaskProvider
(
type
:
string
,
provider
:
TaskProvider
):
Disposable
;
/**
* Fetches all tasks available in the systems. This includes tasks
...
...
@@ -472,6 +507,20 @@ declare module 'vscode' {
* Fires when a task ends.
*/
export
const
onDidEndTask
:
Event
<
TaskEndEvent
>
;
/**
* Fires when the underlying process has been started.
* This event will not fire for tasks that don't
* execute an underlying process.
*/
export
const
onDidStartTaskProcess
:
Event
<
TaskProcessStartEvent
>
;
/**
* Fires when the underlying process has ended.
* This event will not fire for tasks that don't
* execute an underlying process.
*/
export
const
onDidEndTaskProcess
:
Event
<
TaskProcessEndEvent
>
;
}
//#endregion
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
37319680
...
...
@@ -621,6 +621,32 @@ export function createApiFactory(
}
};
const
tasks
:
typeof
vscode
.
tasks
=
{
registerTaskProvider
:
(
type
:
string
,
provider
:
vscode
.
TaskProvider
)
=>
{
return
extHostTask
.
registerTaskProvider
(
extension
,
provider
);
},
fetchTasks
:
proposedApiFunction
(
extension
,
(
filter
?:
vscode
.
TaskFilter
):
Thenable
<
vscode
.
Task
[]
>
=>
{
return
extHostTask
.
fetchTasks
(
filter
);
}),
executeTask
:
proposedApiFunction
(
extension
,
(
task
:
vscode
.
Task
):
Thenable
<
vscode
.
TaskExecution
>
=>
{
return
extHostTask
.
executeTask
(
extension
,
task
);
}),
get
taskExecutions
():
vscode
.
TaskExecution
[]
{
return
extHostTask
.
taskExecutions
;
},
onDidStartTask
:
(
listeners
,
thisArgs
?,
disposables
?)
=>
{
return
extHostTask
.
onDidStartTask
(
listeners
,
thisArgs
,
disposables
);
},
onDidEndTask
:
(
listeners
,
thisArgs
?,
disposables
?)
=>
{
return
extHostTask
.
onDidEndTask
(
listeners
,
thisArgs
,
disposables
);
},
onDidStartTaskProcess
:
(
listeners
,
thisArgs
?,
disposables
?)
=>
{
return
extHostTask
.
onDidStartTaskProcess
(
listeners
,
thisArgs
,
disposables
);
},
onDidEndTaskProcess
:
(
listeners
,
thisArgs
?,
disposables
?)
=>
{
return
extHostTask
.
onDidEndTaskProcess
(
listeners
,
thisArgs
,
disposables
);
}
};
return
<
typeof
vscode
>
{
version
:
pkg
.
version
,
...
...
@@ -633,6 +659,7 @@ export function createApiFactory(
workspace
,
scm
,
debug
,
tasks
,
// types
Breakpoint
:
extHostTypes
.
Breakpoint
,
CancellationTokenSource
:
CancellationTokenSource
,
...
...
src/vs/workbench/api/node/extHostTask.ts
浏览文件 @
37319680
...
...
@@ -690,9 +690,6 @@ namespace TaskFilterDTO {
class
TaskExecutionImpl
implements
vscode
.
TaskExecution
{
private
readonly
_onDidTaskProcessStarted
:
Emitter
<
vscode
.
TaskProcessStartEvent
>
=
new
Emitter
<
vscode
.
TaskProcessStartEvent
>
();
private
readonly
_onDidTaskProcessEnded
:
Emitter
<
vscode
.
TaskProcessEndEvent
>
=
new
Emitter
<
vscode
.
TaskProcessEndEvent
>
();
constructor
(
private
readonly
_tasks
:
ExtHostTask
,
readonly
_id
:
string
,
private
readonly
_task
:
vscode
.
Task
)
{
}
...
...
@@ -704,26 +701,10 @@ class TaskExecutionImpl implements vscode.TaskExecution {
this
.
_tasks
.
terminateTask
(
this
);
}
public
get
onDidStartProcess
():
Event
<
vscode
.
TaskProcessStartEvent
>
{
return
this
.
_onDidTaskProcessStarted
.
event
;
}
public
fireDidStartProcess
(
value
:
TaskProcessStartedDTO
):
void
{
this
.
_onDidTaskProcessStarted
.
fire
({
execution
:
this
,
processId
:
value
.
processId
});
}
public
get
onDidEndProcess
():
Event
<
vscode
.
TaskProcessEndEvent
>
{
return
this
.
_onDidTaskProcessEnded
.
event
;
}
public
fireDidEndProcess
(
value
:
TaskProcessEndedDTO
):
void
{
this
.
_onDidTaskProcessEnded
.
fire
({
execution
:
this
,
exitCode
:
value
.
exitCode
});
}
}
...
...
@@ -755,6 +736,9 @@ export class ExtHostTask implements ExtHostTaskShape {
private
readonly
_onDidExecuteTask
:
Emitter
<
vscode
.
TaskStartEvent
>
=
new
Emitter
<
vscode
.
TaskStartEvent
>
();
private
readonly
_onDidTerminateTask
:
Emitter
<
vscode
.
TaskEndEvent
>
=
new
Emitter
<
vscode
.
TaskEndEvent
>
();
private
readonly
_onDidTaskProcessStarted
:
Emitter
<
vscode
.
TaskProcessStartEvent
>
=
new
Emitter
<
vscode
.
TaskProcessStartEvent
>
();
private
readonly
_onDidTaskProcessEnded
:
Emitter
<
vscode
.
TaskProcessEndEvent
>
=
new
Emitter
<
vscode
.
TaskProcessEndEvent
>
();
constructor
(
mainContext
:
IMainContext
,
extHostWorkspace
:
ExtHostWorkspace
)
{
this
.
_proxy
=
mainContext
.
getProxy
(
MainContext
.
MainThreadTask
);
this
.
_extHostWorkspace
=
extHostWorkspace
;
...
...
@@ -807,36 +791,12 @@ export class ExtHostTask implements ExtHostTaskShape {
}
}
public
$onDidStartTask
(
execution
:
TaskExecutionDTO
):
void
{
this
.
_onDidExecuteTask
.
fire
({
execution
:
this
.
getTaskExecution
(
execution
)
});
}
public
$onDidStartTaskProcess
(
value
:
TaskProcessStartedDTO
):
void
{
const
execution
=
this
.
getTaskExecution
(
value
.
id
);
if
(
execution
)
{
execution
.
fireDidStartProcess
(
value
);
}
}
public
$onDidEndTaskProcess
(
value
:
TaskProcessEndedDTO
):
void
{
const
execution
=
this
.
getTaskExecution
(
value
.
id
);
if
(
execution
)
{
execution
.
fireDidEndProcess
(
value
);
}
}
get
taskExecutions
():
vscode
.
TaskExecution
[]
{
public
get
taskExecutions
():
vscode
.
TaskExecution
[]
{
let
result
:
vscode
.
TaskExecution
[]
=
[];
this
.
_taskExecutions
.
forEach
(
value
=>
result
.
push
(
value
));
return
result
;
}
get
onDidStartTask
():
Event
<
vscode
.
TaskStartEvent
>
{
return
this
.
_onDidExecuteTask
.
event
;
}
public
terminateTask
(
execution
:
vscode
.
TaskExecution
):
TPromise
<
void
>
{
if
(
!
(
execution
instanceof
TaskExecutionImpl
))
{
throw
new
Error
(
'
No valid task execution provided
'
);
...
...
@@ -844,6 +804,20 @@ export class ExtHostTask implements ExtHostTaskShape {
return
this
.
_proxy
.
$terminateTask
((
execution
as
TaskExecutionImpl
).
_id
);
}
public
get
onDidStartTask
():
Event
<
vscode
.
TaskStartEvent
>
{
return
this
.
_onDidExecuteTask
.
event
;
}
public
$onDidStartTask
(
execution
:
TaskExecutionDTO
):
void
{
this
.
_onDidExecuteTask
.
fire
({
execution
:
this
.
getTaskExecution
(
execution
)
});
}
public
get
onDidEndTask
():
Event
<
vscode
.
TaskEndEvent
>
{
return
this
.
_onDidTerminateTask
.
event
;
}
public
$OnDidEndTask
(
execution
:
TaskExecutionDTO
):
void
{
const
_execution
=
this
.
getTaskExecution
(
execution
);
this
.
_taskExecutions
.
delete
(
execution
.
id
);
...
...
@@ -852,8 +826,32 @@ export class ExtHostTask implements ExtHostTaskShape {
});
}
get
onDidEndTask
():
Event
<
vscode
.
TaskEndEvent
>
{
return
this
.
_onDidTerminateTask
.
event
;
public
get
onDidStartTaskProcess
():
Event
<
vscode
.
TaskProcessStartEvent
>
{
return
this
.
_onDidTaskProcessStarted
.
event
;
}
public
$onDidStartTaskProcess
(
value
:
TaskProcessStartedDTO
):
void
{
const
execution
=
this
.
getTaskExecution
(
value
.
id
);
if
(
execution
)
{
this
.
_onDidTaskProcessStarted
.
fire
({
execution
:
execution
,
processId
:
value
.
processId
});
}
}
public
get
onDidEndTaskProcess
():
Event
<
vscode
.
TaskProcessEndEvent
>
{
return
this
.
_onDidTaskProcessEnded
.
event
;
}
public
$onDidEndTaskProcess
(
value
:
TaskProcessEndedDTO
):
void
{
const
execution
=
this
.
getTaskExecution
(
value
.
id
);
if
(
execution
)
{
this
.
_onDidTaskProcessEnded
.
fire
({
execution
:
execution
,
exitCode
:
value
.
exitCode
});
}
}
public
$provideTasks
(
handle
:
number
):
TPromise
<
TaskSystem
.
TaskSet
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录