Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
52e38713
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,发现更多精彩内容 >>
提交
52e38713
编写于
8月 12, 2020
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow workspace tasks to be executed through API
Fixes #104408
上级
a1b65534
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
12 deletion
+32
-12
src/vs/workbench/api/browser/mainThreadTask.ts
src/vs/workbench/api/browser/mainThreadTask.ts
+24
-8
src/vs/workbench/api/common/extHostTask.ts
src/vs/workbench/api/common/extHostTask.ts
+6
-2
src/vs/workbench/api/node/extHostTask.ts
src/vs/workbench/api/node/extHostTask.ts
+2
-2
未找到文件。
src/vs/workbench/api/browser/mainThreadTask.ts
浏览文件 @
52e38713
...
...
@@ -5,14 +5,14 @@
import
*
as
nls
from
'
vs/nls
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
*
as
Types
from
'
vs/base/common/types
'
;
import
*
as
Platform
from
'
vs/base/common/platform
'
;
import
{
IStringDictionary
,
forEach
}
from
'
vs/base/common/collections
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkspaceContextService
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspace
,
IWorkspace
ContextService
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ContributedTask
,
ConfiguringTask
,
KeyedTaskIdentifier
,
TaskExecution
,
Task
,
TaskEvent
,
TaskEventKind
,
...
...
@@ -509,11 +509,27 @@ export class MainThreadTask implements MainThreadTaskShape {
});
}
private
getWorkspace
(
value
:
UriComponents
|
string
):
string
|
IWorkspace
|
IWorkspaceFolder
|
null
{
let
workspace
;
if
(
typeof
value
===
'
string
'
)
{
workspace
=
value
;
}
else
{
const
workspaceObject
=
this
.
_workspaceContextServer
.
getWorkspace
();
const
uri
=
URI
.
revive
(
value
);
if
(
workspaceObject
.
configuration
?.
toString
()
===
uri
.
toString
())
{
workspace
=
workspaceObject
;
}
else
{
workspace
=
this
.
_workspaceContextServer
.
getWorkspaceFolder
(
uri
);
}
}
return
workspace
;
}
public
async
$getTaskExecution
(
value
:
TaskHandleDTO
|
TaskDTO
):
Promise
<
TaskExecutionDTO
>
{
if
(
TaskHandleDTO
.
is
(
value
))
{
const
workspace
Folder
=
typeof
value
.
workspaceFolder
===
'
string
'
?
value
.
workspaceFolder
:
this
.
_workspaceContextServer
.
getWorkspaceFolder
(
URI
.
revive
(
value
.
workspaceFolder
)
);
if
(
workspace
Folder
)
{
const
task
=
await
this
.
_taskService
.
getTask
(
workspace
Folder
,
value
.
id
,
true
);
const
workspace
=
this
.
getWorkspace
(
value
.
workspaceFolder
);
if
(
workspace
)
{
const
task
=
await
this
.
_taskService
.
getTask
(
workspace
,
value
.
id
,
true
);
if
(
task
)
{
return
{
id
:
task
.
_id
,
...
...
@@ -538,9 +554,9 @@ export class MainThreadTask implements MainThreadTaskShape {
public
$executeTask
(
value
:
TaskHandleDTO
|
TaskDTO
):
Promise
<
TaskExecutionDTO
>
{
return
new
Promise
<
TaskExecutionDTO
>
((
resolve
,
reject
)
=>
{
if
(
TaskHandleDTO
.
is
(
value
))
{
const
workspace
Folder
=
typeof
value
.
workspaceFolder
===
'
string
'
?
value
.
workspaceFolder
:
this
.
_workspaceContextServer
.
getWorkspaceFolder
(
URI
.
revive
(
value
.
workspaceFolder
)
);
if
(
workspace
Folder
)
{
this
.
_taskService
.
getTask
(
workspace
Folder
,
value
.
id
,
true
).
then
((
task
:
Task
|
undefined
)
=>
{
const
workspace
=
this
.
getWorkspace
(
value
.
workspaceFolder
);
if
(
workspace
)
{
this
.
_taskService
.
getTask
(
workspace
,
value
.
id
,
true
).
then
((
task
:
Task
|
undefined
)
=>
{
if
(
!
task
)
{
reject
(
new
Error
(
'
Task not found
'
));
}
else
{
...
...
src/vs/workbench/api/common/extHostTask.ts
浏览文件 @
52e38713
...
...
@@ -192,12 +192,16 @@ export namespace CustomExecutionDTO {
export
namespace
TaskHandleDTO
{
export
function
from
(
value
:
types
.
Task
):
tasks
.
TaskHandleDTO
{
export
function
from
(
value
:
types
.
Task
,
workspaceService
?:
IExtHostWorkspace
):
tasks
.
TaskHandleDTO
{
let
folder
:
UriComponents
|
string
;
if
(
value
.
scope
!==
undefined
&&
typeof
value
.
scope
!==
'
number
'
)
{
folder
=
value
.
scope
.
uri
;
}
else
if
(
value
.
scope
!==
undefined
&&
typeof
value
.
scope
===
'
number
'
)
{
folder
=
USER_TASKS_GROUP_KEY
;
if
((
value
.
scope
===
types
.
TaskScope
.
Workspace
)
&&
workspaceService
&&
workspaceService
.
workspaceFile
)
{
folder
=
workspaceService
.
workspaceFile
;
}
else
{
folder
=
USER_TASKS_GROUP_KEY
;
}
}
return
{
id
:
value
.
_id
!
,
...
...
src/vs/workbench/api/node/extHostTask.ts
浏览文件 @
52e38713
...
...
@@ -32,7 +32,7 @@ export class ExtHostTask extends ExtHostTaskBase {
constructor
(
@
IExtHostRpcService
extHostRpc
:
IExtHostRpcService
,
@
IExtHostInitDataService
initData
:
IExtHostInitDataService
,
@
IExtHostWorkspace
workspaceService
:
IExtHostWorkspace
,
@
IExtHostWorkspace
private
readonly
workspaceService
:
IExtHostWorkspace
,
@
IExtHostDocumentsAndEditors
editorService
:
IExtHostDocumentsAndEditors
,
@
IExtHostConfiguration
configurationService
:
IExtHostConfiguration
,
@
IExtHostTerminalService
extHostTerminalService
:
IExtHostTerminalService
,
...
...
@@ -55,7 +55,7 @@ export class ExtHostTask extends ExtHostTaskBase {
// We have a preserved ID. So the task didn't change.
if
(
tTask
.
_id
!==
undefined
)
{
// Always get the task execution first to prevent timing issues when retrieving it later
const
handleDto
=
TaskHandleDTO
.
from
(
tTask
);
const
handleDto
=
TaskHandleDTO
.
from
(
tTask
,
this
.
workspaceService
);
const
executionDTO
=
await
this
.
_proxy
.
$getTaskExecution
(
handleDto
);
if
(
executionDTO
.
task
===
undefined
)
{
throw
new
Error
(
'
Task from execution DTO is undefined
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录