Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6577bde5
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,发现更多精彩内容 >>
提交
6577bde5
编写于
3月 26, 2018
作者:
D
Dirk Baeumer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Task query and execution polish
上级
e45a276a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
121 addition
and
36 deletion
+121
-36
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+15
-7
src/vs/workbench/api/electron-browser/mainThreadTask.ts
src/vs/workbench/api/electron-browser/mainThreadTask.ts
+11
-6
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+10
-7
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-1
src/vs/workbench/api/node/extHostTask.ts
src/vs/workbench/api/node/extHostTask.ts
+28
-10
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+48
-0
src/vs/workbench/api/shared/tasks.ts
src/vs/workbench/api/shared/tasks.ts
+5
-4
src/vs/workbench/parts/tasks/common/tasks.ts
src/vs/workbench/parts/tasks/common/tasks.ts
+3
-1
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
6577bde5
...
...
@@ -688,12 +688,25 @@ declare module 'vscode' {
/**
* 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
{
/**
...
...
@@ -704,6 +717,8 @@ declare module 'vscode' {
/**
* An event signaling the end of an executed task.
*
* This interface is not intended to be implemented.
*/
interface
TaskEndEvent
{
/**
...
...
@@ -734,13 +749,6 @@ declare module 'vscode' {
*/
export
const
onDidStartTask
:
Event
<
TaskStartEvent
>
;
/**
* Terminates a task that was previously started using `executeTask`
*
* @param task the task to terminate
*/
export
function
terminateTask
(
task
:
TaskExecution
):
void
;
/**
* Fires when a task ends.
*/
...
...
src/vs/workbench/api/electron-browser/mainThreadTask.ts
浏览文件 @
6577bde5
...
...
@@ -17,7 +17,7 @@ import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspac
import
{
ContributedTask
,
ExtensionTaskSourceTransfer
,
TaskIdentifier
,
TaskExecution
,
Task
,
TaskEvent
,
TaskEventKind
,
PresentationOptions
,
CommandOptions
,
CommandConfiguration
,
RuntimeType
,
CustomTask
,
TaskScope
,
TaskSource
,
TaskSourceKind
,
ExtensionTaskSource
PresentationOptions
,
CommandOptions
,
CommandConfiguration
,
RuntimeType
,
CustomTask
,
TaskScope
,
TaskSource
,
TaskSourceKind
,
ExtensionTaskSource
,
RevealKind
,
PanelKind
}
from
'
vs/workbench/parts/tasks/common/tasks
'
;
import
{
ITaskService
}
from
'
vs/workbench/parts/tasks/common/taskService
'
;
...
...
@@ -35,11 +35,13 @@ namespace TaskExecutionDTO {
export
function
from
(
value
:
TaskExecution
):
TaskExecutionDTO
{
return
{
id
:
value
.
id
,
task
:
TaskDTO
.
from
(
value
.
task
)
};
}
export
function
to
(
value
:
TaskExecutionDTO
,
workspace
:
IWorkspaceContextService
):
TaskExecution
{
return
{
id
:
value
.
id
,
task
:
TaskDTO
.
to
(
value
.
task
,
workspace
)
};
}
}
...
...
@@ -303,6 +305,8 @@ namespace TaskDTO {
return
undefined
;
}
command
.
presentation
=
TaskPresentationOptionsDTO
.
to
(
task
.
presentationOptions
);
command
.
presentation
=
Objects
.
assign
(
command
.
presentation
||
{},
{
echo
:
true
,
reveal
:
RevealKind
.
Always
,
focus
:
false
,
panel
:
PanelKind
.
Shared
});
let
source
=
TaskSourceDTO
.
to
(
task
.
source
,
workspace
);
let
label
=
nls
.
localize
(
'
task.label
'
,
'
{0}: {1}
'
,
source
.
label
,
task
.
name
);
...
...
@@ -403,7 +407,8 @@ export class MainThreadTask implements MainThreadTaskShape {
this
.
_taskService
.
getTask
(
workspaceFolder
,
value
.
id
,
true
).
then
((
task
:
Task
)
=>
{
this
.
_taskService
.
run
(
task
);
let
result
:
TaskExecutionDTO
=
{
id
:
value
.
id
id
:
value
.
id
,
task
:
TaskDTO
.
from
(
task
)
};
resolve
(
result
);
},
(
error
)
=>
{
...
...
@@ -413,19 +418,19 @@ export class MainThreadTask implements MainThreadTaskShape {
let
task
=
TaskDTO
.
to
(
value
,
this
.
_workspaceContextServer
);
this
.
_taskService
.
run
(
task
);
let
result
:
TaskExecutionDTO
=
{
id
:
task
.
_id
id
:
task
.
_id
,
task
:
TaskDTO
.
from
(
task
)
};
resolve
(
result
);
}
});
}
public
$terminateTask
(
value
:
TaskExecutionDTO
):
TPromise
<
void
>
{
let
execution
:
TaskExecution
=
TaskExecutionDTO
.
to
(
value
,
this
.
_workspaceContextServer
);
public
$terminateTask
(
id
:
string
):
TPromise
<
void
>
{
return
new
TPromise
<
void
>
((
resolve
,
reject
)
=>
{
this
.
_taskService
.
getActiveTasks
().
then
((
tasks
)
=>
{
for
(
let
task
of
tasks
)
{
if
(
execution
.
id
===
task
.
_id
)
{
if
(
id
===
task
.
_id
)
{
this
.
_taskService
.
terminate
(
task
).
then
((
value
)
=>
{
resolve
(
undefined
);
},
(
error
)
=>
{
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
6577bde5
...
...
@@ -517,18 +517,21 @@ export function createApiFactory(
registerTaskProvider
:
(
type
:
string
,
provider
:
vscode
.
TaskProvider
)
=>
{
return
extHostTask
.
registerTaskProvider
(
extension
,
provider
);
},
fetchTasks
:
proposedApiFunction
(
extension
,
():
Thenable
<
vscode
.
Task
[]
>
=>
{
// fetchTasks: proposedApiFunction(extension, (): Thenable<vscode.Task[]> => {
// return extHostTask.executeTaskProvider();
// }),
// executeTask: proposedApiFunction(extension, (task: vscode.Task): Thenable<vscode.TaskExecution> => {
// return extHostTask.executeTask(extension, task);
// }),
fetchTasks
:
():
Thenable
<
vscode
.
Task
[]
>
=>
{
return
extHostTask
.
executeTaskProvider
();
}
)
,
executeTask
:
proposedApiFunction
(
extension
,
(
task
:
vscode
.
Task
):
Thenable
<
vscode
.
TaskExecution
>
=>
{
},
executeTask
:
(
task
:
vscode
.
Task
):
Thenable
<
vscode
.
TaskExecution
>
=>
{
return
extHostTask
.
executeTask
(
extension
,
task
);
}
)
,
},
onDidStartTask
:
(
listeners
,
thisArgs
?,
disposables
?)
=>
{
return
extHostTask
.
onDidStartTask
(
listeners
,
thisArgs
,
disposables
);
},
terminateTask
:
proposedApiFunction
(
extension
,
(
task
:
vscode
.
TaskExecution
):
void
=>
{
extHostTask
.
terminateTask
(
task
);
}),
onDidEndTask
:
(
listeners
,
thisArgs
?,
disposables
?)
=>
{
return
extHostTask
.
onDidEndTask
(
listeners
,
thisArgs
,
disposables
);
},
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
6577bde5
...
...
@@ -391,7 +391,7 @@ export interface MainThreadTaskShape extends IDisposable {
$registerTaskProvider
(
handle
:
number
):
TPromise
<
void
>
;
$executeTaskProvider
():
TPromise
<
TaskDTO
[]
>
;
$executeTask
(
task
:
TaskHandleDTO
|
TaskDTO
):
TPromise
<
TaskExecutionDTO
>
;
$terminateTask
(
task
:
TaskExecutionDTO
):
TPromise
<
void
>
;
$terminateTask
(
id
:
string
):
TPromise
<
void
>
;
$unregisterTaskProvider
(
handle
:
number
):
TPromise
<
void
>
;
}
...
...
src/vs/workbench/api/node/extHostTask.ts
浏览文件 @
6577bde5
...
...
@@ -613,6 +613,7 @@ namespace TaskDTO {
if
(
!
execution
||
!
definition
||
!
scope
)
{
return
undefined
;
}
let
group
=
(
value
.
group
as
types
.
TaskGroup
)
?
(
value
.
group
as
types
.
TaskGroup
).
id
:
undefined
;
let
result
:
TaskDTO
=
{
_id
:
(
value
as
types
.
Task
).
_id
,
definition
,
...
...
@@ -624,7 +625,7 @@ namespace TaskDTO {
},
execution
,
isBackground
:
value
.
isBackground
,
group
:
(
value
.
group
as
types
.
TaskGroup
).
id
,
group
:
group
,
presentationOptions
:
TaskPresentationOptionsDTO
.
from
(
value
.
presentationOptions
),
problemMatchers
:
value
.
problemMatchers
,
hasDefinedMatchers
:
(
value
as
types
.
Task
).
hasDefinedMatchers
...
...
@@ -675,17 +676,26 @@ namespace TaskDTO {
}
class
TaskExecutionImpl
implements
vscode
.
TaskExecution
{
constructor
(
readonly
_id
:
string
)
{
constructor
(
readonly
_id
:
string
,
private
readonly
_task
:
vscode
.
Task
,
private
readonly
_tasks
:
ExtHostTask
)
{
}
get
task
():
vscode
.
Task
{
return
this
.
_task
;
}
public
terminate
():
void
{
this
.
_tasks
.
terminateTask
(
this
);
}
}
namespace
TaskExecutionDTO
{
export
function
to
(
value
:
TaskExecutionDTO
):
vscode
.
TaskExecution
{
return
new
TaskExecutionImpl
(
value
.
id
);
export
function
to
(
value
:
TaskExecutionDTO
,
tasks
:
ExtHostTask
):
vscode
.
TaskExecution
{
return
new
TaskExecutionImpl
(
value
.
id
,
TaskDTO
.
to
(
value
.
task
,
tasks
.
extHostWorkspace
),
tasks
);
}
export
function
from
(
value
:
vscode
.
TaskExecution
):
TaskExecutionDTO
{
return
{
id
:
(
value
as
TaskExecutionImpl
).
_id
id
:
(
value
as
TaskExecutionImpl
).
_id
,
task
:
undefined
};
}
}
...
...
@@ -712,6 +722,10 @@ export class ExtHostTask implements ExtHostTaskShape {
this
.
_handlers
=
new
Map
<
number
,
HandlerData
>
();
}
public
get
extHostWorkspace
():
ExtHostWorkspace
{
return
this
.
_extHostWorkspace
;
}
public
registerTaskProvider
(
extension
:
IExtensionDescription
,
provider
:
vscode
.
TaskProvider
):
vscode
.
Disposable
{
if
(
!
provider
)
{
return
new
types
.
Disposable
(()
=>
{
});
...
...
@@ -742,15 +756,19 @@ export class ExtHostTask implements ExtHostTaskShape {
let
tTask
=
(
task
as
types
.
Task
);
// We have a preserved ID. So the task didn't change.
if
(
tTask
.
_id
!==
void
0
)
{
return
this
.
_proxy
.
$executeTask
(
TaskHandleDTO
.
from
(
tTask
)).
then
(
value
=>
TaskExecutionDTO
.
to
(
value
));
return
this
.
_proxy
.
$executeTask
(
TaskHandleDTO
.
from
(
tTask
)).
then
(
value
=>
new
TaskExecutionImpl
(
value
.
id
,
task
,
this
));
}
else
{
return
this
.
_proxy
.
$executeTask
(
TaskDTO
.
from
(
task
,
extension
)).
then
(
value
=>
TaskExecutionDTO
.
to
(
value
));
let
dto
=
TaskDTO
.
from
(
task
,
extension
);
if
(
dto
===
void
0
)
{
return
Promise
.
reject
(
new
Error
(
'
Task is not valid
'
));
}
return
this
.
_proxy
.
$executeTask
(
dto
).
then
(
value
=>
new
TaskExecutionImpl
(
value
.
id
,
task
,
this
));
}
}
public
$taskStarted
(
execution
:
TaskExecutionDTO
):
void
{
this
.
_onDidExecuteTask
.
fire
({
execution
:
TaskExecutionDTO
.
to
(
execution
)
execution
:
TaskExecutionDTO
.
to
(
execution
,
this
)
});
}
...
...
@@ -762,12 +780,12 @@ export class ExtHostTask implements ExtHostTaskShape {
if
(
!
(
execution
instanceof
TaskExecutionImpl
))
{
throw
new
Error
(
'
No valid task execution provided
'
);
}
return
this
.
_proxy
.
$terminateTask
(
TaskExecutionDTO
.
from
(
execution
)
);
return
this
.
_proxy
.
$terminateTask
(
(
execution
as
TaskExecutionImpl
).
_id
);
}
public
$taskEnded
(
execution
:
TaskExecutionDTO
):
void
{
this
.
_onDidTerminateTask
.
fire
({
execution
:
TaskExecutionDTO
.
to
(
execution
)
execution
:
TaskExecutionDTO
.
to
(
execution
,
this
)
});
}
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
6577bde5
...
...
@@ -1343,6 +1343,20 @@ export class ProcessExecution implements vscode.ProcessExecution {
set
options
(
value
:
vscode
.
ProcessExecutionOptions
)
{
this
.
_options
=
value
;
}
public
computeId
():
string
{
const
hash
=
crypto
.
createHash
(
'
md5
'
);
hash
.
update
(
'
process
'
);
if
(
this
.
_process
!==
void
0
)
{
hash
.
update
(
this
.
_process
);
}
if
(
this
.
_args
&&
this
.
_args
.
length
>
0
)
{
for
(
let
arg
of
this
.
_args
)
{
hash
.
update
(
arg
);
}
}
return
hash
.
digest
(
'
hex
'
);
}
}
export
class
ShellExecution
implements
vscode
.
ShellExecution
{
...
...
@@ -1411,6 +1425,23 @@ export class ShellExecution implements vscode.ShellExecution {
set
options
(
value
:
vscode
.
ShellExecutionOptions
)
{
this
.
_options
=
value
;
}
public
computeId
():
string
{
const
hash
=
crypto
.
createHash
(
'
md5
'
);
hash
.
update
(
'
shell
'
);
if
(
this
.
_commandLine
!==
void
0
)
{
hash
.
update
(
this
.
_commandLine
);
}
if
(
this
.
_command
!==
void
0
)
{
hash
.
update
(
typeof
this
.
_command
===
'
string
'
?
this
.
_command
:
this
.
_command
.
value
);
}
if
(
this
.
_args
&&
this
.
_args
.
length
>
0
)
{
for
(
let
arg
of
this
.
_args
)
{
hash
.
update
(
typeof
arg
===
'
string
'
?
arg
:
arg
.
value
);
}
}
return
hash
.
digest
(
'
hex
'
);
}
}
export
enum
ShellQuoting
{
...
...
@@ -1485,7 +1516,24 @@ export class Task implements vscode.Task {
}
private
clear
():
void
{
if
(
this
.
__id
===
void
0
)
{
return
;
}
this
.
__id
=
undefined
;
this
.
_scope
=
undefined
;
this
.
_definitionKey
=
undefined
;
this
.
_definition
=
undefined
;
if
(
this
.
_execution
instanceof
ProcessExecution
)
{
this
.
_definition
=
{
type
:
'
process
'
,
id
:
this
.
_execution
.
computeId
()
};
}
else
if
(
this
.
_execution
instanceof
ShellExecution
)
{
this
.
_definition
=
{
type
:
'
shell
'
,
id
:
this
.
_execution
.
computeId
()
};
}
}
get
definition
():
vscode
.
TaskDefinition
{
...
...
src/vs/workbench/api/shared/tasks.ts
浏览文件 @
6577bde5
...
...
@@ -11,10 +11,6 @@ export interface TaskDefinitionDTO {
[
name
:
string
]:
any
;
}
export
interface
TaskExecutionDTO
{
id
:
string
;
}
export
interface
TaskPresentationOptionsDTO
{
reveal
?:
number
;
echo
?:
boolean
;
...
...
@@ -85,4 +81,9 @@ export interface TaskDTO {
presentationOptions
:
TaskPresentationOptionsDTO
;
problemMatchers
:
string
[];
hasDefinedMatchers
:
boolean
;
}
export
interface
TaskExecutionDTO
{
id
:
string
;
task
:
TaskDTO
;
}
\ No newline at end of file
src/vs/workbench/parts/tasks/common/tasks.ts
浏览文件 @
6577bde5
...
...
@@ -642,7 +642,8 @@ export namespace Task {
export
function
getTaskExecution
(
task
:
Task
):
TaskExecution
{
let
result
:
TaskExecution
=
{
id
:
task
.
_id
id
:
task
.
_id
,
task
:
task
};
return
result
;
}
...
...
@@ -657,6 +658,7 @@ export interface TaskItem {
export
interface
TaskExecution
{
id
:
string
;
task
:
Task
;
}
export
enum
ExecutionEngine
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录