Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eb4a91f7
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,发现更多精彩内容 >>
提交
eb4a91f7
编写于
7月 15, 2020
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add when property to tasks definition
Part of #102477
上级
ffd12de5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
138 addition
and
28 deletion
+138
-28
extensions/npm/package.json
extensions/npm/package.json
+2
-1
src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
...vs/workbench/contrib/tasks/browser/abstractTaskService.ts
+65
-17
src/vs/workbench/contrib/tasks/common/taskConfiguration.ts
src/vs/workbench/contrib/tasks/common/taskConfiguration.ts
+34
-6
src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.ts
.../workbench/contrib/tasks/common/taskDefinitionRegistry.ts
+12
-1
src/vs/workbench/contrib/tasks/common/taskService.ts
src/vs/workbench/contrib/tasks/common/taskService.ts
+5
-0
src/vs/workbench/contrib/tasks/common/tasks.ts
src/vs/workbench/contrib/tasks/common/tasks.ts
+2
-1
src/vs/workbench/contrib/tasks/electron-browser/taskService.ts
...s/workbench/contrib/tasks/electron-browser/taskService.ts
+4
-0
src/vs/workbench/contrib/tasks/test/common/configuration.test.ts
...workbench/contrib/tasks/test/common/configuration.test.ts
+14
-2
未找到文件。
extensions/npm/package.json
浏览文件 @
eb4a91f7
...
@@ -290,7 +290,8 @@
...
@@ -290,7 +290,8 @@
"type"
:
"string"
,
"type"
:
"string"
,
"description"
:
"%taskdef.path%"
"description"
:
"%taskdef.path%"
}
}
}
},
"when"
:
"shellExecutionSupported"
}
}
]
]
}
}
...
...
src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
浏览文件 @
eb4a91f7
...
@@ -56,7 +56,7 @@ import {
...
@@ -56,7 +56,7 @@ import {
TaskSorter
,
TaskIdentifier
,
KeyedTaskIdentifier
,
TASK_RUNNING_STATE
,
TaskRunSource
,
TaskSorter
,
TaskIdentifier
,
KeyedTaskIdentifier
,
TASK_RUNNING_STATE
,
TaskRunSource
,
KeyedTaskIdentifier
as
NKeyedTaskIdentifier
,
TaskDefinition
KeyedTaskIdentifier
as
NKeyedTaskIdentifier
,
TaskDefinition
}
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
}
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
{
ITaskService
,
ITaskProvider
,
ProblemMatcherRunOptions
,
CustomizationProperties
,
TaskFilter
,
WorkspaceFolderTaskResult
,
USER_TASKS_GROUP_KEY
}
from
'
vs/workbench/contrib/tasks/common/taskService
'
;
import
{
ITaskService
,
ITaskProvider
,
ProblemMatcherRunOptions
,
CustomizationProperties
,
TaskFilter
,
WorkspaceFolderTaskResult
,
USER_TASKS_GROUP_KEY
,
CustomExecutionSupportedContext
,
ShellExecutionSupportedContext
,
ProcessExecutionSupportedContext
}
from
'
vs/workbench/contrib/tasks/common/taskService
'
;
import
{
getTemplates
as
getTaskTemplates
}
from
'
vs/workbench/contrib/tasks/common/taskTemplates
'
;
import
{
getTemplates
as
getTaskTemplates
}
from
'
vs/workbench/contrib/tasks/common/taskTemplates
'
;
import
*
as
TaskConfig
from
'
../common/taskConfiguration
'
;
import
*
as
TaskConfig
from
'
../common/taskConfiguration
'
;
...
@@ -248,7 +248,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -248,7 +248,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
@
IHostService
private
readonly
_hostService
:
IHostService
,
@
IHostService
private
readonly
_hostService
:
IHostService
,
@
IDialogService
private
readonly
dialogService
:
IDialogService
,
@
IDialogService
private
readonly
dialogService
:
IDialogService
,
@
INotificationService
private
readonly
notificationService
:
INotificationService
,
@
INotificationService
private
readonly
notificationService
:
INotificationService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IContextKeyService
protected
readonly
contextKeyService
:
IContextKeyService
,
@
IWorkbenchEnvironmentService
private
readonly
environmentService
:
IWorkbenchEnvironmentService
,
@
IWorkbenchEnvironmentService
private
readonly
environmentService
:
IWorkbenchEnvironmentService
,
@
ITerminalInstanceService
private
readonly
terminalInstanceService
:
ITerminalInstanceService
,
@
ITerminalInstanceService
private
readonly
terminalInstanceService
:
ITerminalInstanceService
,
@
IPathService
private
readonly
pathService
:
IPathService
,
@
IPathService
private
readonly
pathService
:
IPathService
,
...
@@ -331,6 +331,16 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -331,6 +331,16 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
}
return
task
.
_label
;
return
task
.
_label
;
});
});
this
.
setExecutionContexts
();
}
protected
setExecutionContexts
(
custom
:
boolean
=
true
,
shell
:
boolean
=
false
,
process
:
boolean
=
false
):
void
{
const
customContext
=
CustomExecutionSupportedContext
.
bindTo
(
this
.
contextKeyService
);
customContext
.
set
(
custom
);
const
shellContext
=
ShellExecutionSupportedContext
.
bindTo
(
this
.
contextKeyService
);
shellContext
.
set
(
shell
);
const
processContext
=
ProcessExecutionSupportedContext
.
bindTo
(
this
.
contextKeyService
);
processContext
.
set
(
process
);
}
}
public
get
onDidStateChange
():
Event
<
TaskEvent
>
{
public
get
onDidStateChange
():
Event
<
TaskEvent
>
{
...
@@ -556,14 +566,27 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -556,14 +566,27 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
public
async
tryResolveTask
(
configuringTask
:
ConfiguringTask
):
Promise
<
Task
|
undefined
>
{
public
async
tryResolveTask
(
configuringTask
:
ConfiguringTask
):
Promise
<
Task
|
undefined
>
{
await
Promise
.
all
([
this
.
extensionService
.
activateByEvent
(
'
onCommand:workbench.action.tasks.runTask
'
),
this
.
extensionService
.
whenInstalledExtensionsRegistered
()]);
await
Promise
.
all
([
this
.
extensionService
.
activateByEvent
(
'
onCommand:workbench.action.tasks.runTask
'
),
this
.
extensionService
.
whenInstalledExtensionsRegistered
()]);
let
matchingProvider
:
ITaskProvider
|
undefined
;
let
matchingProvider
:
ITaskProvider
|
undefined
;
let
matchingProviderUnavailable
:
boolean
=
false
;
for
(
const
[
handle
,
provider
]
of
this
.
_providers
)
{
for
(
const
[
handle
,
provider
]
of
this
.
_providers
)
{
if
(
configuringTask
.
type
===
this
.
_providerTypes
.
get
(
handle
))
{
const
providerType
=
this
.
_providerTypes
.
get
(
handle
);
if
(
configuringTask
.
type
===
providerType
)
{
if
(
providerType
&&
!
this
.
isTaskProviderEnabled
(
providerType
))
{
matchingProviderUnavailable
=
true
;
continue
;
}
matchingProvider
=
provider
;
matchingProvider
=
provider
;
break
;
break
;
}
}
}
}
if
(
!
matchingProvider
)
{
if
(
!
matchingProvider
)
{
if
(
matchingProviderUnavailable
)
{
this
.
_outputChannel
.
append
(
nls
.
localize
(
'
TaskService.providerUnavailable
'
,
'
Warning: {0} tasks are unavailable in the current environment.
\n
'
,
configuringTask
.
configures
.
type
));
}
return
;
return
;
}
}
...
@@ -624,7 +647,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -624,7 +647,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
if
(
this
.
isProvideTasksEnabled
())
{
if
(
this
.
isProvideTasksEnabled
())
{
for
(
const
[
handle
]
of
this
.
_providers
)
{
for
(
const
[
handle
]
of
this
.
_providers
)
{
const
type
=
this
.
_providerTypes
.
get
(
handle
);
const
type
=
this
.
_providerTypes
.
get
(
handle
);
if
(
type
)
{
if
(
type
&&
this
.
isTaskProviderEnabled
(
type
)
)
{
types
.
push
(
type
);
types
.
push
(
type
);
}
}
}
}
...
@@ -1559,6 +1582,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -1559,6 +1582,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
protected
abstract
getTaskSystem
():
ITaskSystem
;
protected
abstract
getTaskSystem
():
ITaskSystem
;
private
isTaskProviderEnabled
(
type
:
string
)
{
const
definition
=
TaskDefinitionRegistry
.
get
(
type
);
return
!
definition
.
when
||
this
.
contextKeyService
.
contextMatchesRules
(
definition
.
when
);
}
private
getGroupedTasks
(
type
?:
string
):
Promise
<
TaskMap
>
{
private
getGroupedTasks
(
type
?:
string
):
Promise
<
TaskMap
>
{
const
needsRecentTasksMigration
=
this
.
needsRecentTasksMigration
();
const
needsRecentTasksMigration
=
this
.
needsRecentTasksMigration
();
return
Promise
.
all
([
this
.
extensionService
.
activateByEvent
(
'
onCommand:workbench.action.tasks.runTask
'
),
this
.
extensionService
.
whenInstalledExtensionsRegistered
()]).
then
(()
=>
{
return
Promise
.
all
([
this
.
extensionService
.
activateByEvent
(
'
onCommand:workbench.action.tasks.runTask
'
),
this
.
extensionService
.
whenInstalledExtensionsRegistered
()]).
then
(()
=>
{
...
@@ -1596,7 +1624,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -1596,7 +1624,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
};
};
if
(
this
.
isProvideTasksEnabled
()
&&
(
this
.
schemaVersion
===
JsonSchemaVersion
.
V2_0_0
)
&&
(
this
.
_providers
.
size
>
0
))
{
if
(
this
.
isProvideTasksEnabled
()
&&
(
this
.
schemaVersion
===
JsonSchemaVersion
.
V2_0_0
)
&&
(
this
.
_providers
.
size
>
0
))
{
for
(
const
[
handle
,
provider
]
of
this
.
_providers
)
{
for
(
const
[
handle
,
provider
]
of
this
.
_providers
)
{
if
((
type
===
undefined
)
||
(
type
===
this
.
_providerTypes
.
get
(
handle
)))
{
const
providerType
=
this
.
_providerTypes
.
get
(
handle
);
if
((
type
===
undefined
)
||
(
type
===
providerType
))
{
if
(
providerType
&&
!
this
.
isTaskProviderEnabled
(
providerType
))
{
continue
;
}
counter
++
;
counter
++
;
provider
.
provideTasks
(
validTypes
).
then
((
taskSet
:
TaskSet
)
=>
{
provider
.
provideTasks
(
validTypes
).
then
((
taskSet
:
TaskSet
)
=>
{
// Check that the tasks provided are of the correct type
// Check that the tasks provided are of the correct type
...
@@ -1699,8 +1731,16 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -1699,8 +1731,16 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
return
;
return
;
}
}
let
requiredTaskProviderUnavailable
:
boolean
=
false
;
for
(
const
[
handle
,
provider
]
of
this
.
_providers
)
{
for
(
const
[
handle
,
provider
]
of
this
.
_providers
)
{
if
(
configuringTask
.
type
===
this
.
_providerTypes
.
get
(
handle
))
{
const
providerType
=
this
.
_providerTypes
.
get
(
handle
);
if
(
configuringTask
.
type
===
providerType
)
{
if
(
providerType
&&
!
this
.
isTaskProviderEnabled
(
providerType
))
{
requiredTaskProviderUnavailable
=
true
;
continue
;
}
try
{
try
{
const
resolvedTask
=
await
provider
.
resolveTask
(
configuringTask
);
const
resolvedTask
=
await
provider
.
resolveTask
(
configuringTask
);
if
(
resolvedTask
&&
(
resolvedTask
.
_id
===
configuringTask
.
_id
))
{
if
(
resolvedTask
&&
(
resolvedTask
.
_id
===
configuringTask
.
_id
))
{
...
@@ -1713,13 +1753,21 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -1713,13 +1753,21 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
}
}
}
this
.
_outputChannel
.
append
(
nls
.
localize
(
if
(
requiredTaskProviderUnavailable
)
{
'
TaskService.noConfiguration
'
,
this
.
_outputChannel
.
append
(
nls
.
localize
(
'
Error: The {0} task detection didn
\'
t contribute a task for the following configuration:
\n
{1}
\n
The task will be ignored.
\n
'
,
'
TaskService.providerUnavailable
'
,
configuringTask
.
configures
.
type
,
'
Warning: {0} tasks are unavailable in the current environment.
\n
'
,
JSON
.
stringify
(
configuringTask
.
_source
.
config
.
element
,
undefined
,
4
)
configuringTask
.
configures
.
type
));
));
this
.
showOutput
();
}
else
{
this
.
_outputChannel
.
append
(
nls
.
localize
(
'
TaskService.noConfiguration
'
,
'
Error: The {0} task detection didn
\'
t contribute a task for the following configuration:
\n
{1}
\n
The task will be ignored.
\n
'
,
configuringTask
.
configures
.
type
,
JSON
.
stringify
(
configuringTask
.
_source
.
config
.
element
,
undefined
,
4
)
));
this
.
showOutput
();
}
});
});
await
Promise
.
all
(
unUsedConfigurationPromises
);
await
Promise
.
all
(
unUsedConfigurationPromises
);
...
@@ -1831,9 +1879,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -1831,9 +1879,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
return
ProblemMatcherRegistry
.
onReady
().
then
(
async
():
Promise
<
WorkspaceFolderTaskResult
>
=>
{
return
ProblemMatcherRegistry
.
onReady
().
then
(
async
():
Promise
<
WorkspaceFolderTaskResult
>
=>
{
let
taskSystemInfo
:
TaskSystemInfo
|
undefined
=
this
.
_taskSystemInfos
.
get
(
workspaceFolder
.
uri
.
scheme
);
let
taskSystemInfo
:
TaskSystemInfo
|
undefined
=
this
.
_taskSystemInfos
.
get
(
workspaceFolder
.
uri
.
scheme
);
let
problemReporter
=
new
ProblemReporter
(
this
.
_outputChannel
);
let
problemReporter
=
new
ProblemReporter
(
this
.
_outputChannel
);
let
parseResult
=
TaskConfig
.
parse
(
workspaceFolder
,
undefined
,
taskSystemInfo
?
taskSystemInfo
.
platform
:
Platform
.
platform
,
workspaceFolderConfiguration
.
config
!
,
problemReporter
,
TaskConfig
.
TaskConfigSource
.
TasksJson
);
let
parseResult
=
TaskConfig
.
parse
(
workspaceFolder
,
undefined
,
taskSystemInfo
?
taskSystemInfo
.
platform
:
Platform
.
platform
,
workspaceFolderConfiguration
.
config
!
,
problemReporter
,
TaskConfig
.
TaskConfigSource
.
TasksJson
,
this
.
contextKeyService
);
let
hasErrors
=
false
;
let
hasErrors
=
false
;
if
(
!
parseResult
.
validationStatus
.
isOK
())
{
if
(
!
parseResult
.
validationStatus
.
isOK
()
&&
(
parseResult
.
validationStatus
.
state
!==
ValidationState
.
Info
)
)
{
hasErrors
=
true
;
hasErrors
=
true
;
this
.
showOutput
(
runSource
);
this
.
showOutput
(
runSource
);
}
}
...
@@ -1928,9 +1976,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
...
@@ -1928,9 +1976,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
}
let
taskSystemInfo
:
TaskSystemInfo
|
undefined
=
workspaceFolder
?
this
.
_taskSystemInfos
.
get
(
workspaceFolder
.
uri
.
scheme
)
:
undefined
;
let
taskSystemInfo
:
TaskSystemInfo
|
undefined
=
workspaceFolder
?
this
.
_taskSystemInfos
.
get
(
workspaceFolder
.
uri
.
scheme
)
:
undefined
;
let
problemReporter
=
new
ProblemReporter
(
this
.
_outputChannel
);
let
problemReporter
=
new
ProblemReporter
(
this
.
_outputChannel
);
let
parseResult
=
TaskConfig
.
parse
(
workspaceFolder
,
this
.
_workspace
,
taskSystemInfo
?
taskSystemInfo
.
platform
:
Platform
.
platform
,
config
,
problemReporter
,
source
,
isRecentTask
);
let
parseResult
=
TaskConfig
.
parse
(
workspaceFolder
,
this
.
_workspace
,
taskSystemInfo
?
taskSystemInfo
.
platform
:
Platform
.
platform
,
config
,
problemReporter
,
source
,
this
.
contextKeyService
,
isRecentTask
);
let
hasErrors
=
false
;
let
hasErrors
=
false
;
if
(
!
parseResult
.
validationStatus
.
isOK
())
{
if
(
!
parseResult
.
validationStatus
.
isOK
()
&&
(
parseResult
.
validationStatus
.
state
!==
ValidationState
.
Info
)
)
{
this
.
showOutput
(
runSource
);
this
.
showOutput
(
runSource
);
hasErrors
=
true
;
hasErrors
=
true
;
}
}
...
...
src/vs/workbench/contrib/tasks/common/taskConfiguration.ts
浏览文件 @
eb4a91f7
...
@@ -23,8 +23,8 @@ import * as Tasks from './tasks';
...
@@ -23,8 +23,8 @@ import * as Tasks from './tasks';
import
{
TaskDefinitionRegistry
}
from
'
./taskDefinitionRegistry
'
;
import
{
TaskDefinitionRegistry
}
from
'
./taskDefinitionRegistry
'
;
import
{
ConfiguredInput
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
import
{
ConfiguredInput
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
USER_TASKS_GROUP_KEY
}
from
'
vs/workbench/contrib/tasks/common/taskService
'
;
import
{
USER_TASKS_GROUP_KEY
,
ShellExecutionSupportedContext
,
ProcessExecutionSupportedContext
}
from
'
vs/workbench/contrib/tasks/common/taskService
'
;
import
{
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
export
const
enum
ShellQuoting
{
export
const
enum
ShellQuoting
{
/**
/**
...
@@ -709,6 +709,7 @@ interface ParseContext {
...
@@ -709,6 +709,7 @@ interface ParseContext {
schemaVersion
:
Tasks
.
JsonSchemaVersion
;
schemaVersion
:
Tasks
.
JsonSchemaVersion
;
platform
:
Platform
;
platform
:
Platform
;
taskLoadIssues
:
string
[];
taskLoadIssues
:
string
[];
contextKeyService
:
IContextKeyService
;
}
}
...
@@ -1656,6 +1657,11 @@ namespace TaskParser {
...
@@ -1656,6 +1657,11 @@ namespace TaskParser {
return
customize
===
undefined
&&
(
type
===
undefined
||
type
===
null
||
type
===
Tasks
.
CUSTOMIZED_TASK_TYPE
||
type
===
'
shell
'
||
type
===
'
process
'
);
return
customize
===
undefined
&&
(
type
===
undefined
||
type
===
null
||
type
===
Tasks
.
CUSTOMIZED_TASK_TYPE
||
type
===
'
shell
'
||
type
===
'
process
'
);
}
}
const
builtinTypeContextMap
:
IStringDictionary
<
RawContextKey
<
boolean
>>
=
{
shell
:
ShellExecutionSupportedContext
,
process
:
ProcessExecutionSupportedContext
};
export
function
from
(
this
:
void
,
externals
:
Array
<
CustomTask
|
ConfiguringTask
>
|
undefined
,
globals
:
Globals
,
context
:
ParseContext
,
source
:
TaskConfigSource
):
TaskParseResult
{
export
function
from
(
this
:
void
,
externals
:
Array
<
CustomTask
|
ConfiguringTask
>
|
undefined
,
globals
:
Globals
,
context
:
ParseContext
,
source
:
TaskConfigSource
):
TaskParseResult
{
let
result
:
TaskParseResult
=
{
custom
:
[],
configured
:
[]
};
let
result
:
TaskParseResult
=
{
custom
:
[],
configured
:
[]
};
if
(
!
externals
)
{
if
(
!
externals
)
{
...
@@ -1667,6 +1673,27 @@ namespace TaskParser {
...
@@ -1667,6 +1673,27 @@ namespace TaskParser {
const
baseLoadIssues
=
Objects
.
deepClone
(
context
.
taskLoadIssues
);
const
baseLoadIssues
=
Objects
.
deepClone
(
context
.
taskLoadIssues
);
for
(
let
index
=
0
;
index
<
externals
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
externals
.
length
;
index
++
)
{
let
external
=
externals
[
index
];
let
external
=
externals
[
index
];
const
definition
=
external
.
type
?
TaskDefinitionRegistry
.
get
(
external
.
type
)
:
undefined
;
let
typeNotSupported
:
boolean
=
false
;
if
(
definition
&&
definition
.
when
&&
!
context
.
contextKeyService
.
contextMatchesRules
(
definition
.
when
))
{
typeNotSupported
=
true
;
}
else
if
(
!
definition
&&
external
.
type
)
{
for
(
const
key
of
Object
.
keys
(
builtinTypeContextMap
))
{
if
(
external
.
type
===
key
)
{
typeNotSupported
=
!
ShellExecutionSupportedContext
.
evaluate
(
context
.
contextKeyService
.
getContext
(
null
));
break
;
}
}
}
if
(
typeNotSupported
)
{
context
.
problemReporter
.
info
(
nls
.
localize
(
'
taskConfiguration.providerUnavailable
'
,
'
Warning: {0} tasks are unavailable in the current environment.
\n
'
,
external
.
type
));
continue
;
}
if
(
isCustomTask
(
external
))
{
if
(
isCustomTask
(
external
))
{
let
customTask
=
CustomTask
.
from
(
external
,
context
,
index
,
source
);
let
customTask
=
CustomTask
.
from
(
external
,
context
,
index
,
source
);
if
(
customTask
)
{
if
(
customTask
)
{
...
@@ -1976,7 +2003,7 @@ class ConfigurationParser {
...
@@ -1976,7 +2003,7 @@ class ConfigurationParser {
this
.
uuidMap
=
uuidMap
;
this
.
uuidMap
=
uuidMap
;
}
}
public
run
(
fileConfig
:
ExternalTaskRunnerConfiguration
,
source
:
TaskConfigSource
):
ParseResult
{
public
run
(
fileConfig
:
ExternalTaskRunnerConfiguration
,
source
:
TaskConfigSource
,
contextKeyService
:
IContextKeyService
):
ParseResult
{
let
engine
=
ExecutionEngine
.
from
(
fileConfig
);
let
engine
=
ExecutionEngine
.
from
(
fileConfig
);
let
schemaVersion
=
JsonSchemaVersion
.
from
(
fileConfig
);
let
schemaVersion
=
JsonSchemaVersion
.
from
(
fileConfig
);
let
context
:
ParseContext
=
{
let
context
:
ParseContext
=
{
...
@@ -1988,7 +2015,8 @@ class ConfigurationParser {
...
@@ -1988,7 +2015,8 @@ class ConfigurationParser {
engine
,
engine
,
schemaVersion
,
schemaVersion
,
platform
:
this
.
platform
,
platform
:
this
.
platform
,
taskLoadIssues
:
[]
taskLoadIssues
:
[],
contextKeyService
};
};
let
taskParseResult
=
this
.
createTaskRunnerConfiguration
(
fileConfig
,
context
,
source
);
let
taskParseResult
=
this
.
createTaskRunnerConfiguration
(
fileConfig
,
context
,
source
);
return
{
return
{
...
@@ -2081,7 +2109,7 @@ class ConfigurationParser {
...
@@ -2081,7 +2109,7 @@ class ConfigurationParser {
let
uuidMaps
:
Map
<
TaskConfigSource
,
Map
<
string
,
UUIDMap
>>
=
new
Map
();
let
uuidMaps
:
Map
<
TaskConfigSource
,
Map
<
string
,
UUIDMap
>>
=
new
Map
();
let
recentUuidMaps
:
Map
<
TaskConfigSource
,
Map
<
string
,
UUIDMap
>>
=
new
Map
();
let
recentUuidMaps
:
Map
<
TaskConfigSource
,
Map
<
string
,
UUIDMap
>>
=
new
Map
();
export
function
parse
(
workspaceFolder
:
IWorkspaceFolder
,
workspace
:
IWorkspace
|
undefined
,
platform
:
Platform
,
configuration
:
ExternalTaskRunnerConfiguration
,
logger
:
IProblemReporter
,
source
:
TaskConfigSource
,
isRecents
:
boolean
=
false
):
ParseResult
{
export
function
parse
(
workspaceFolder
:
IWorkspaceFolder
,
workspace
:
IWorkspace
|
undefined
,
platform
:
Platform
,
configuration
:
ExternalTaskRunnerConfiguration
,
logger
:
IProblemReporter
,
source
:
TaskConfigSource
,
contextKeyService
:
IContextKeyService
,
isRecents
:
boolean
=
false
):
ParseResult
{
let
recentOrOtherMaps
=
isRecents
?
recentUuidMaps
:
uuidMaps
;
let
recentOrOtherMaps
=
isRecents
?
recentUuidMaps
:
uuidMaps
;
let
selectedUuidMaps
=
recentOrOtherMaps
.
get
(
source
);
let
selectedUuidMaps
=
recentOrOtherMaps
.
get
(
source
);
if
(
!
selectedUuidMaps
)
{
if
(
!
selectedUuidMaps
)
{
...
@@ -2095,7 +2123,7 @@ export function parse(workspaceFolder: IWorkspaceFolder, workspace: IWorkspace |
...
@@ -2095,7 +2123,7 @@ export function parse(workspaceFolder: IWorkspaceFolder, workspace: IWorkspace |
}
}
try
{
try
{
uuidMap
.
start
();
uuidMap
.
start
();
return
(
new
ConfigurationParser
(
workspaceFolder
,
workspace
,
platform
,
logger
,
uuidMap
)).
run
(
configuration
,
source
);
return
(
new
ConfigurationParser
(
workspaceFolder
,
workspace
,
platform
,
logger
,
uuidMap
)).
run
(
configuration
,
source
,
contextKeyService
);
}
finally
{
}
finally
{
uuidMap
.
finish
();
uuidMap
.
finish
();
}
}
...
...
src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.ts
浏览文件 @
eb4a91f7
...
@@ -13,6 +13,7 @@ import { ExtensionsRegistry, ExtensionMessageCollector } from 'vs/workbench/serv
...
@@ -13,6 +13,7 @@ import { ExtensionsRegistry, ExtensionMessageCollector } from 'vs/workbench/serv
import
*
as
Tasks
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
*
as
Tasks
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
const
taskDefinitionSchema
:
IJSONSchema
=
{
const
taskDefinitionSchema
:
IJSONSchema
=
{
...
@@ -35,6 +36,10 @@ const taskDefinitionSchema: IJSONSchema = {
...
@@ -35,6 +36,10 @@ const taskDefinitionSchema: IJSONSchema = {
additionalProperties
:
{
additionalProperties
:
{
$ref
:
'
http://json-schema.org/draft-07/schema#
'
$ref
:
'
http://json-schema.org/draft-07/schema#
'
}
}
},
when
:
{
type
:
'
string
'
,
markdownDescription
:
nls
.
localize
(
'
TaskDefinition.when
'
,
'
Condition when the task definition is valid. Consider using `shellExecutionSupported`, `processExecutionSupported`, and `customExecutionSupported` as appropriate for this task definition.
'
)
}
}
}
}
};
};
...
@@ -44,6 +49,7 @@ namespace Configuration {
...
@@ -44,6 +49,7 @@ namespace Configuration {
type
?:
string
;
type
?:
string
;
required
?:
string
[];
required
?:
string
[];
properties
?:
IJSONSchemaMap
;
properties
?:
IJSONSchemaMap
;
when
?:
string
;
}
}
export
function
from
(
value
:
TaskDefinition
,
extensionId
:
ExtensionIdentifier
,
messageCollector
:
ExtensionMessageCollector
):
Tasks
.
TaskDefinition
|
undefined
{
export
function
from
(
value
:
TaskDefinition
,
extensionId
:
ExtensionIdentifier
,
messageCollector
:
ExtensionMessageCollector
):
Tasks
.
TaskDefinition
|
undefined
{
...
@@ -63,7 +69,12 @@ namespace Configuration {
...
@@ -63,7 +69,12 @@ namespace Configuration {
}
}
}
}
}
}
return
{
extensionId
:
extensionId
.
value
,
taskType
,
required
:
required
,
properties
:
value
.
properties
?
Objects
.
deepClone
(
value
.
properties
)
:
{}
};
return
{
extensionId
:
extensionId
.
value
,
taskType
,
required
:
required
,
properties
:
value
.
properties
?
Objects
.
deepClone
(
value
.
properties
)
:
{},
when
:
value
.
when
?
ContextKeyExpr
.
deserialize
(
value
.
when
)
:
undefined
};
}
}
}
}
...
...
src/vs/workbench/contrib/tasks/common/taskService.ts
浏览文件 @
eb4a91f7
...
@@ -13,9 +13,14 @@ import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/works
...
@@ -13,9 +13,14 @@ import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/works
import
{
Task
,
ContributedTask
,
CustomTask
,
TaskSet
,
TaskSorter
,
TaskEvent
,
TaskIdentifier
,
ConfiguringTask
,
TaskRunSource
}
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
{
Task
,
ContributedTask
,
CustomTask
,
TaskSet
,
TaskSorter
,
TaskEvent
,
TaskIdentifier
,
ConfiguringTask
,
TaskRunSource
}
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
{
ITaskSummary
,
TaskTerminateResponse
,
TaskSystemInfo
}
from
'
vs/workbench/contrib/tasks/common/taskSystem
'
;
import
{
ITaskSummary
,
TaskTerminateResponse
,
TaskSystemInfo
}
from
'
vs/workbench/contrib/tasks/common/taskSystem
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
export
{
ITaskSummary
,
Task
,
TaskTerminateResponse
};
export
{
ITaskSummary
,
Task
,
TaskTerminateResponse
};
export
const
CustomExecutionSupportedContext
=
new
RawContextKey
<
boolean
>
(
'
customExecutionSupported
'
,
true
);
export
const
ShellExecutionSupportedContext
=
new
RawContextKey
<
boolean
>
(
'
shellExecutionSupported
'
,
false
);
export
const
ProcessExecutionSupportedContext
=
new
RawContextKey
<
boolean
>
(
'
processExecutionSupported
'
,
false
);
export
const
ITaskService
=
createDecorator
<
ITaskService
>
(
'
taskService
'
);
export
const
ITaskService
=
createDecorator
<
ITaskService
>
(
'
taskService
'
);
export
interface
ITaskProvider
{
export
interface
ITaskProvider
{
...
...
src/vs/workbench/contrib/tasks/common/tasks.ts
浏览文件 @
eb4a91f7
...
@@ -12,7 +12,7 @@ import { UriComponents, URI } from 'vs/base/common/uri';
...
@@ -12,7 +12,7 @@ import { UriComponents, URI } from 'vs/base/common/uri';
import
{
ProblemMatcher
}
from
'
vs/workbench/contrib/tasks/common/problemMatcher
'
;
import
{
ProblemMatcher
}
from
'
vs/workbench/contrib/tasks/common/problemMatcher
'
;
import
{
IWorkspaceFolder
,
IWorkspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceFolder
,
IWorkspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
RawContextKey
,
ContextKeyExpression
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
TaskDefinitionRegistry
}
from
'
vs/workbench/contrib/tasks/common/taskDefinitionRegistry
'
;
import
{
TaskDefinitionRegistry
}
from
'
vs/workbench/contrib/tasks/common/taskDefinitionRegistry
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
...
@@ -1002,6 +1002,7 @@ export interface TaskDefinition {
...
@@ -1002,6 +1002,7 @@ export interface TaskDefinition {
taskType
:
string
;
taskType
:
string
;
required
:
string
[];
required
:
string
[];
properties
:
IJSONSchemaMap
;
properties
:
IJSONSchemaMap
;
when
?:
ContextKeyExpression
;
}
}
export
class
TaskSorter
{
export
class
TaskSorter
{
...
...
src/vs/workbench/contrib/tasks/electron-browser/taskService.ts
浏览文件 @
eb4a91f7
...
@@ -25,6 +25,10 @@ interface WorkspaceFolderConfigurationResult {
...
@@ -25,6 +25,10 @@ interface WorkspaceFolderConfigurationResult {
export
class
TaskService
extends
AbstractTaskService
{
export
class
TaskService
extends
AbstractTaskService
{
private
_configHasErrors
:
boolean
=
false
;
private
_configHasErrors
:
boolean
=
false
;
protected
setExecutionContexts
():
void
{
super
.
setExecutionContexts
(
true
,
true
,
true
);
}
protected
getTaskSystem
():
ITaskSystem
{
protected
getTaskSystem
():
ITaskSystem
{
if
(
this
.
_taskSystem
)
{
if
(
this
.
_taskSystem
)
{
return
this
.
_taskSystem
;
return
this
.
_taskSystem
;
...
...
src/vs/workbench/contrib/tasks/test/common/configuration.test.ts
浏览文件 @
eb4a91f7
...
@@ -14,6 +14,8 @@ import { WorkspaceFolder, Workspace, IWorkspace } from 'vs/platform/workspace/co
...
@@ -14,6 +14,8 @@ import { WorkspaceFolder, Workspace, IWorkspace } from 'vs/platform/workspace/co
import
*
as
Tasks
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
*
as
Tasks
from
'
vs/workbench/contrib/tasks/common/tasks
'
;
import
{
parse
,
ParseResult
,
IProblemReporter
,
ExternalTaskRunnerConfiguration
,
CustomTask
,
TaskConfigSource
}
from
'
vs/workbench/contrib/tasks/common/taskConfiguration
'
;
import
{
parse
,
ParseResult
,
IProblemReporter
,
ExternalTaskRunnerConfiguration
,
CustomTask
,
TaskConfigSource
}
from
'
vs/workbench/contrib/tasks/common/taskConfiguration
'
;
import
{
MockContextKeyService
}
from
'
vs/platform/keybinding/test/common/mockKeybindingService
'
;
import
{
IContext
}
from
'
vs/platform/contextkey/common/contextkey
'
;
const
workspaceFolder
:
WorkspaceFolder
=
new
WorkspaceFolder
({
const
workspaceFolder
:
WorkspaceFolder
=
new
WorkspaceFolder
({
uri
:
URI
.
file
(
'
/workspace/folderOne
'
),
uri
:
URI
.
file
(
'
/workspace/folderOne
'
),
...
@@ -357,9 +359,19 @@ class PatternBuilder {
...
@@ -357,9 +359,19 @@ class PatternBuilder {
}
}
}
}
class
TasksMockContextKeyService
extends
MockContextKeyService
{
public
getContext
(
domNode
:
HTMLElement
):
IContext
{
return
{
getValue
:
<
T
>
(
_key
:
string
)
=>
{
return
<
T
><
unknown
>
true
;
}
};
}
}
function
testDefaultProblemMatcher
(
external
:
ExternalTaskRunnerConfiguration
,
resolved
:
number
)
{
function
testDefaultProblemMatcher
(
external
:
ExternalTaskRunnerConfiguration
,
resolved
:
number
)
{
let
reporter
=
new
ProblemReporter
();
let
reporter
=
new
ProblemReporter
();
let
result
=
parse
(
workspaceFolder
,
workspace
,
Platform
.
platform
,
external
,
reporter
,
TaskConfigSource
.
TasksJson
);
let
result
=
parse
(
workspaceFolder
,
workspace
,
Platform
.
platform
,
external
,
reporter
,
TaskConfigSource
.
TasksJson
,
new
TasksMockContextKeyService
()
);
assert
.
ok
(
!
reporter
.
receivedMessage
);
assert
.
ok
(
!
reporter
.
receivedMessage
);
assert
.
strictEqual
(
result
.
custom
.
length
,
1
);
assert
.
strictEqual
(
result
.
custom
.
length
,
1
);
let
task
=
result
.
custom
[
0
];
let
task
=
result
.
custom
[
0
];
...
@@ -370,7 +382,7 @@ function testDefaultProblemMatcher(external: ExternalTaskRunnerConfiguration, re
...
@@ -370,7 +382,7 @@ function testDefaultProblemMatcher(external: ExternalTaskRunnerConfiguration, re
function
testConfiguration
(
external
:
ExternalTaskRunnerConfiguration
,
builder
:
ConfiguationBuilder
):
void
{
function
testConfiguration
(
external
:
ExternalTaskRunnerConfiguration
,
builder
:
ConfiguationBuilder
):
void
{
builder
.
done
();
builder
.
done
();
let
reporter
=
new
ProblemReporter
();
let
reporter
=
new
ProblemReporter
();
let
result
=
parse
(
workspaceFolder
,
workspace
,
Platform
.
platform
,
external
,
reporter
,
TaskConfigSource
.
TasksJson
);
let
result
=
parse
(
workspaceFolder
,
workspace
,
Platform
.
platform
,
external
,
reporter
,
TaskConfigSource
.
TasksJson
,
new
TasksMockContextKeyService
()
);
if
(
reporter
.
receivedMessage
)
{
if
(
reporter
.
receivedMessage
)
{
assert
.
ok
(
false
,
reporter
.
lastMessage
);
assert
.
ok
(
false
,
reporter
.
lastMessage
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录