Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
111b4dcc
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,发现更多精彩内容 >>
提交
111b4dcc
编写于
10月 07, 2019
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debug: more async / await
上级
0634ecc2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
95 addition
and
84 deletion
+95
-84
src/vs/workbench/contrib/debug/browser/debugService.ts
src/vs/workbench/contrib/debug/browser/debugService.ts
+95
-84
未找到文件。
src/vs/workbench/contrib/debug/browser/debugService.ts
浏览文件 @
111b4dcc
...
...
@@ -424,7 +424,7 @@ export class DebugService implements IDebugService {
/**
* instantiates the new session, initializes the session, registers session listeners and reports telemetry
*/
private
doCreateSession
(
root
:
IWorkspaceFolder
|
undefined
,
configuration
:
{
resolved
:
IConfig
,
unresolved
:
IConfig
|
undefined
},
options
?:
IDebugSessionOptions
):
Promise
<
boolean
>
{
private
async
doCreateSession
(
root
:
IWorkspaceFolder
|
undefined
,
configuration
:
{
resolved
:
IConfig
,
unresolved
:
IConfig
|
undefined
},
options
?:
IDebugSessionOptions
):
Promise
<
boolean
>
{
const
session
=
this
.
instantiationService
.
createInstance
(
DebugSession
,
configuration
,
root
,
this
.
model
,
options
);
this
.
model
.
addSession
(
session
);
...
...
@@ -438,10 +438,11 @@ export class DebugService implements IDebugService {
const
openDebug
=
this
.
configurationService
.
getValue
<
IDebugConfiguration
>
(
'
debug
'
).
openDebug
;
// Open debug viewlet based on the visibility of the side bar and openDebug setting. Do not open for 'run without debug'
if
(
!
configuration
.
resolved
.
noDebug
&&
(
openDebug
===
'
openOnSessionStart
'
||
(
openDebug
===
'
openOnFirstSessionStart
'
&&
this
.
viewModel
.
firstSessionStart
)))
{
this
.
viewletService
.
openViewlet
(
VIEWLET_ID
).
then
(
undefined
,
errors
.
onUnexpectedError
);
await
this
.
viewletService
.
openViewlet
(
VIEWLET_ID
);
}
return
this
.
launchOrAttachToSession
(
session
).
then
(()
=>
{
try
{
await
this
.
launchOrAttachToSession
(
session
);
const
internalConsoleOptions
=
session
.
configuration
.
internalConsoleOptions
||
this
.
configurationService
.
getValue
<
IDebugConfiguration
>
(
'
debug
'
).
internalConsoleOptions
;
if
(
internalConsoleOptions
===
'
openOnSessionStart
'
||
(
this
.
viewModel
.
firstSessionStart
&&
internalConsoleOptions
===
'
openOnFirstSessionStart
'
))
{
...
...
@@ -459,12 +460,14 @@ export class DebugService implements IDebugService {
// since the initialized response has arrived announce the new Session (including extensions)
this
.
_onDidNewSession
.
fire
(
session
);
return
this
.
telemetryDebugSessionStart
(
root
,
session
.
configuration
.
type
);
}).
then
(()
=>
true
,
(
error
:
Error
|
string
)
=>
{
await
this
.
telemetryDebugSessionStart
(
root
,
session
.
configuration
.
type
);
return
true
;
}
catch
(
error
)
{
if
(
errors
.
isPromiseCanceledError
(
error
))
{
// don't show 'canceled' error messages to the user #7906
return
Promise
.
resolve
(
false
)
;
return
false
;
}
// Show the repl if some error got logged there #5870
...
...
@@ -474,13 +477,15 @@ export class DebugService implements IDebugService {
if
(
session
.
configuration
&&
session
.
configuration
.
request
===
'
attach
'
&&
session
.
configuration
.
__autoAttach
)
{
// ignore attach timeouts in auto attach mode
return
Promise
.
resolve
(
false
)
;
return
false
;
}
const
errorMessage
=
error
instanceof
Error
?
error
.
message
:
error
;
this
.
telemetryDebugMisconfiguration
(
session
.
configuration
?
session
.
configuration
.
type
:
undefined
,
errorMessage
);
return
this
.
showError
(
errorMessage
,
isErrorWithActions
(
error
)
?
error
.
actions
:
[]).
then
(()
=>
false
);
});
await
this
.
showError
(
errorMessage
,
isErrorWithActions
(
error
)
?
error
.
actions
:
[]);
return
false
;
}
}
private
async
launchOrAttachToSession
(
session
:
IDebugSession
,
forceFocus
=
false
):
Promise
<
void
>
{
...
...
@@ -557,87 +562,93 @@ export class DebugService implements IDebugService {
}));
}
restartSession
(
session
:
IDebugSession
,
restartData
?:
any
):
Promise
<
any
>
{
return
this
.
textFileService
.
saveAll
().
then
(()
=>
{
const
isAutoRestart
=
!!
restartData
;
const
runTasks
:
()
=>
Promise
<
TaskRunResult
>
=
()
=>
{
if
(
isAutoRestart
)
{
// Do not run preLaunch and postDebug tasks for automatic restarts
return
Promise
.
resolve
(
TaskRunResult
.
Success
);
}
async
restartSession
(
session
:
IDebugSession
,
restartData
?:
any
):
Promise
<
any
>
{
await
this
.
textFileService
.
saveAll
();
const
isAutoRestart
=
!!
restartData
;
return
this
.
runTask
(
session
.
root
,
session
.
configuration
.
postDebugTask
)
.
then
(()
=>
this
.
runTaskAndCheckErrors
(
session
.
root
,
session
.
configuration
.
preLaunchTask
));
};
const
runTasks
:
()
=>
Promise
<
TaskRunResult
>
=
async
()
=>
{
if
(
isAutoRestart
)
{
// Do not run preLaunch and postDebug tasks for automatic restarts
return
Promise
.
resolve
(
TaskRunResult
.
Success
);
}
if
(
session
.
capabilities
.
supportsRestartRequest
)
{
return
runTasks
().
then
(
taskResult
=>
taskResult
===
TaskRunResult
.
Success
?
session
.
restart
()
:
undefined
);
await
this
.
runTask
(
session
.
root
,
session
.
configuration
.
postDebugTask
);
return
this
.
runTaskAndCheckErrors
(
session
.
root
,
session
.
configuration
.
preLaunchTask
);
};
if
(
session
.
capabilities
.
supportsRestartRequest
)
{
const
taskResult
=
await
runTasks
();
if
(
taskResult
===
TaskRunResult
.
Success
)
{
await
session
.
restart
();
}
if
(
isExtensionHostDebugging
(
session
.
configuration
))
{
return
runTasks
().
then
(
taskResult
=>
taskResult
===
TaskRunResult
.
Success
?
this
.
extensionHostDebugService
.
reload
(
session
.
getId
())
:
undefined
);
return
;
}
if
(
isExtensionHostDebugging
(
session
.
configuration
))
{
const
taskResult
=
await
runTasks
();
if
(
taskResult
===
TaskRunResult
.
Success
)
{
this
.
extensionHostDebugService
.
reload
(
session
.
getId
());
}
const
shouldFocus
=
!!
this
.
viewModel
.
focusedSession
&&
session
.
getId
()
===
this
.
viewModel
.
focusedSession
.
getId
();
// If the restart is automatic -> disconnect, otherwise -> terminate #55064
return
(
isAutoRestart
?
session
.
disconnect
(
true
)
:
session
.
terminate
(
true
)).
then
(()
=>
{
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
setTimeout
(()
=>
{
runTasks
().
then
(
taskResult
=>
{
if
(
taskResult
!==
TaskRunResult
.
Success
)
{
return
;
}
// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let
needsToSubstitute
=
false
;
let
unresolved
:
IConfig
|
undefined
;
const
launch
=
session
.
root
?
this
.
configurationManager
.
getLaunch
(
session
.
root
.
uri
)
:
undefined
;
if
(
launch
)
{
unresolved
=
launch
.
getConfiguration
(
session
.
configuration
.
name
);
if
(
unresolved
&&
!
equals
(
unresolved
,
session
.
unresolvedConfiguration
))
{
// Take the type from the session since the debug extension might overwrite it #21316
unresolved
.
type
=
session
.
configuration
.
type
;
unresolved
.
noDebug
=
session
.
configuration
.
noDebug
;
needsToSubstitute
=
true
;
}
}
let
substitutionThenable
:
Promise
<
IConfig
|
null
|
undefined
>
=
Promise
.
resolve
(
session
.
configuration
);
if
(
launch
&&
needsToSubstitute
&&
unresolved
)
{
this
.
initCancellationToken
=
new
CancellationTokenSource
();
substitutionThenable
=
this
.
configurationManager
.
resolveConfigurationByProviders
(
launch
.
workspace
?
launch
.
workspace
.
uri
:
undefined
,
unresolved
.
type
,
unresolved
,
this
.
initCancellationToken
.
token
)
.
then
(
resolved
=>
{
if
(
resolved
)
{
// start debugging
return
this
.
substituteVariables
(
launch
,
resolved
);
}
else
if
(
resolved
===
null
)
{
// abort debugging silently and open launch.json
return
Promise
.
resolve
(
null
);
}
else
{
// abort debugging silently
return
Promise
.
resolve
(
undefined
);
}
});
}
substitutionThenable
.
then
(
resolved
=>
{
if
(
!
resolved
)
{
return
c
(
undefined
);
}
session
.
setConfiguration
({
resolved
,
unresolved
});
session
.
configuration
.
__restart
=
restartData
;
this
.
launchOrAttachToSession
(
session
,
shouldFocus
).
then
(()
=>
{
this
.
_onDidNewSession
.
fire
(
session
);
c
(
undefined
);
},
err
=>
e
(
err
));
});
});
},
300
);
});
});
return
;
}
const
shouldFocus
=
!!
this
.
viewModel
.
focusedSession
&&
session
.
getId
()
===
this
.
viewModel
.
focusedSession
.
getId
();
// If the restart is automatic -> disconnect, otherwise -> terminate #55064
if
(
isAutoRestart
)
{
await
session
.
disconnect
(
true
);
}
else
{
await
session
.
terminate
(
true
);
}
return
new
Promise
<
void
>
((
c
,
e
)
=>
{
setTimeout
(
async
()
=>
{
const
taskResult
=
await
runTasks
();
if
(
taskResult
!==
TaskRunResult
.
Success
)
{
return
;
}
// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let
needsToSubstitute
=
false
;
let
unresolved
:
IConfig
|
undefined
;
const
launch
=
session
.
root
?
this
.
configurationManager
.
getLaunch
(
session
.
root
.
uri
)
:
undefined
;
if
(
launch
)
{
unresolved
=
launch
.
getConfiguration
(
session
.
configuration
.
name
);
if
(
unresolved
&&
!
equals
(
unresolved
,
session
.
unresolvedConfiguration
))
{
// Take the type from the session since the debug extension might overwrite it #21316
unresolved
.
type
=
session
.
configuration
.
type
;
unresolved
.
noDebug
=
session
.
configuration
.
noDebug
;
needsToSubstitute
=
true
;
}
}
let
resolved
:
IConfig
|
undefined
|
null
=
session
.
configuration
;
if
(
launch
&&
needsToSubstitute
&&
unresolved
)
{
this
.
initCancellationToken
=
new
CancellationTokenSource
();
const
resolvedByProviders
=
await
this
.
configurationManager
.
resolveConfigurationByProviders
(
launch
.
workspace
?
launch
.
workspace
.
uri
:
undefined
,
unresolved
.
type
,
unresolved
,
this
.
initCancellationToken
.
token
);
if
(
resolvedByProviders
)
{
resolved
=
await
this
.
substituteVariables
(
launch
,
resolvedByProviders
);
}
else
{
resolved
=
resolvedByProviders
;
}
}
if
(
!
resolved
)
{
return
c
(
undefined
);
}
session
.
setConfiguration
({
resolved
,
unresolved
});
session
.
configuration
.
__restart
=
restartData
;
try
{
await
this
.
launchOrAttachToSession
(
session
,
shouldFocus
);
this
.
_onDidNewSession
.
fire
(
session
);
c
(
undefined
);
}
catch
(
error
)
{
e
(
error
);
}
},
300
);
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录