Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
adc58ddb
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,发现更多精彩内容 >>
提交
adc58ddb
编写于
9月 24, 2019
作者:
D
Dmitry Gozman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Process debug adapter messages in separate tasks
上级
4e293af1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
130 addition
and
21 deletion
+130
-21
src/vs/workbench/contrib/debug/browser/debugSession.ts
src/vs/workbench/contrib/debug/browser/debugSession.ts
+5
-0
src/vs/workbench/contrib/debug/common/abstractDebugAdapter.ts
...vs/workbench/contrib/debug/common/abstractDebugAdapter.ts
+34
-19
src/vs/workbench/contrib/debug/test/browser/debugModel.test.ts
...s/workbench/contrib/debug/test/browser/debugModel.test.ts
+26
-2
src/vs/workbench/contrib/debug/test/common/mockDebug.ts
src/vs/workbench/contrib/debug/test/common/mockDebug.ts
+65
-0
未找到文件。
src/vs/workbench/contrib/debug/browser/debugSession.ts
浏览文件 @
adc58ddb
...
...
@@ -685,6 +685,11 @@ export class DebugSession implements IDebugSession {
})
:
Promise
.
resolve
(
undefined
);
}
initializeForTest
(
raw
:
RawDebugSession
):
void
{
this
.
raw
=
raw
;
this
.
registerListeners
();
}
//---- private
private
registerListeners
():
void
{
...
...
src/vs/workbench/contrib/debug/common/abstractDebugAdapter.ts
浏览文件 @
adc58ddb
...
...
@@ -20,6 +20,7 @@ export abstract class AbstractDebugAdapter implements IDebugAdapter {
private
messageCallback
:
((
message
:
DebugProtocol
.
ProtocolMessage
)
=>
void
)
|
undefined
;
protected
readonly
_onError
:
Emitter
<
Error
>
;
protected
readonly
_onExit
:
Emitter
<
number
|
null
>
;
private
queue
:
DebugProtocol
.
ProtocolMessage
[]
=
[];
constructor
()
{
this
.
sequence
=
1
;
...
...
@@ -110,29 +111,43 @@ export abstract class AbstractDebugAdapter implements IDebugAdapter {
this
.
messageCallback
(
message
);
}
else
{
switch
(
message
.
type
)
{
case
'
event
'
:
if
(
this
.
eventCallback
)
{
this
.
eventCallback
(
<
DebugProtocol
.
Event
>
message
);
}
break
;
case
'
request
'
:
if
(
this
.
requestCallback
)
{
this
.
requestCallback
(
<
DebugProtocol
.
Request
>
message
);
}
break
;
case
'
response
'
:
const
response
=
<
DebugProtocol
.
Response
>
message
;
const
clb
=
this
.
pendingRequests
.
get
(
response
.
request_seq
);
if
(
clb
)
{
this
.
pendingRequests
.
delete
(
response
.
request_seq
);
clb
(
response
);
}
break
;
// Artificially queueing protocol messages guarantees that any microtasks for
// previous message finish before next message is processed. This is essential
// to guarantee ordering when using promises anywhere along the call path.
this
.
queue
.
push
(
message
);
if
(
this
.
queue
.
length
===
1
)
{
setTimeout
(()
=>
this
.
processQueue
(),
0
);
}
}
}
private
processQueue
():
void
{
const
message
=
this
.
queue
!
.
shift
()
!
;
switch
(
message
.
type
)
{
case
'
event
'
:
if
(
this
.
eventCallback
)
{
this
.
eventCallback
(
<
DebugProtocol
.
Event
>
message
);
}
break
;
case
'
request
'
:
if
(
this
.
requestCallback
)
{
this
.
requestCallback
(
<
DebugProtocol
.
Request
>
message
);
}
break
;
case
'
response
'
:
const
response
=
<
DebugProtocol
.
Response
>
message
;
const
clb
=
this
.
pendingRequests
.
get
(
response
.
request_seq
);
if
(
clb
)
{
this
.
pendingRequests
.
delete
(
response
.
request_seq
);
clb
(
response
);
}
break
;
}
if
(
this
.
queue
!
.
length
)
{
setTimeout
(()
=>
this
.
processQueue
(),
0
);
}
}
private
internalSend
(
typ
:
'
request
'
|
'
response
'
|
'
event
'
,
message
:
DebugProtocol
.
ProtocolMessage
):
void
{
message
.
type
=
typ
;
message
.
seq
=
this
.
sequence
++
;
...
...
src/vs/workbench/contrib/debug/test/browser/debugModel.test.ts
浏览文件 @
adc58ddb
...
...
@@ -8,12 +8,14 @@ import { URI as uri } from 'vs/base/common/uri';
import
severity
from
'
vs/base/common/severity
'
;
import
{
DebugModel
,
Expression
,
StackFrame
,
Thread
}
from
'
vs/workbench/contrib/debug/common/debugModel
'
;
import
*
as
sinon
from
'
sinon
'
;
import
{
MockRawSession
}
from
'
vs/workbench/contrib/debug/test/common/mockDebug
'
;
import
{
MockRawSession
,
MockDebugAdapter
}
from
'
vs/workbench/contrib/debug/test/common/mockDebug
'
;
import
{
Source
}
from
'
vs/workbench/contrib/debug/common/debugSource
'
;
import
{
DebugSession
}
from
'
vs/workbench/contrib/debug/browser/debugSession
'
;
import
{
SimpleReplElement
,
RawObjectReplElement
,
ReplEvaluationInput
,
ReplModel
}
from
'
vs/workbench/contrib/debug/common/replModel
'
;
import
{
SimpleReplElement
,
RawObjectReplElement
,
ReplEvaluationInput
,
ReplModel
,
ReplEvaluationResult
}
from
'
vs/workbench/contrib/debug/common/replModel
'
;
import
{
IBreakpointUpdateData
,
IDebugSessionOptions
}
from
'
vs/workbench/contrib/debug/common/debug
'
;
import
{
NullOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
RawDebugSession
}
from
'
vs/workbench/contrib/debug/browser/rawDebugSession
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
function
createMockSession
(
model
:
DebugModel
,
name
=
'
mockSession
'
,
options
?:
IDebugSessionOptions
):
DebugSession
{
return
new
DebugSession
({
resolved
:
{
name
,
type
:
'
node
'
,
request
:
'
launch
'
},
unresolved
:
undefined
},
undefined
!
,
model
,
options
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
,
NullOpenerService
);
...
...
@@ -540,4 +542,26 @@ suite('Debug - Model', () => {
assert
.
equal
(
grandChild
.
getReplElements
().
length
,
2
);
assert
.
equal
(
child3
.
getReplElements
().
length
,
1
);
});
test
(
'
repl ordering
'
,
async
()
=>
{
const
session
=
createMockSession
(
model
);
model
.
addSession
(
session
);
const
adapter
=
new
MockDebugAdapter
();
const
raw
=
new
RawDebugSession
(
adapter
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
,
undefined
!
);
session
.
initializeForTest
(
raw
);
await
session
.
addReplExpression
(
undefined
,
'
before.1
'
);
assert
.
equal
(
session
.
getReplElements
().
length
,
3
);
assert
.
equal
((
<
ReplEvaluationInput
>
session
.
getReplElements
()[
0
]).
value
,
'
before.1
'
);
assert
.
equal
((
<
SimpleReplElement
>
session
.
getReplElements
()[
1
]).
value
,
'
before.1
'
);
assert
.
equal
((
<
ReplEvaluationResult
>
session
.
getReplElements
()[
2
]).
value
,
'
=before.1
'
);
await
session
.
addReplExpression
(
undefined
,
'
after.2
'
);
await
timeout
(
0
);
assert
.
equal
(
session
.
getReplElements
().
length
,
6
);
assert
.
equal
((
<
ReplEvaluationInput
>
session
.
getReplElements
()[
3
]).
value
,
'
after.2
'
);
assert
.
equal
((
<
ReplEvaluationResult
>
session
.
getReplElements
()[
4
]).
value
,
'
=after.2
'
);
assert
.
equal
((
<
SimpleReplElement
>
session
.
getReplElements
()[
5
]).
value
,
'
after.2
'
);
});
});
src/vs/workbench/contrib/debug/test/common/mockDebug.ts
浏览文件 @
adc58ddb
...
...
@@ -11,6 +11,7 @@ import { ILaunch, IDebugService, State, IDebugSession, IConfigurationManager, IS
import
{
Source
}
from
'
vs/workbench/contrib/debug/common/debugSource
'
;
import
{
CompletionItem
}
from
'
vs/editor/common/modes
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
AbstractDebugAdapter
}
from
'
vs/workbench/contrib/debug/common/abstractDebugAdapter
'
;
export
class
MockDebugService
implements
IDebugService
{
...
...
@@ -463,3 +464,67 @@ export class MockRawSession {
public
readonly
onDidStop
:
Event
<
DebugProtocol
.
StoppedEvent
>
=
null
!
;
}
export
class
MockDebugAdapter
extends
AbstractDebugAdapter
{
private
seq
=
0
;
startSession
():
Promise
<
void
>
{
return
Promise
.
resolve
();
}
stopSession
():
Promise
<
void
>
{
return
Promise
.
resolve
();
}
sendMessage
(
message
:
DebugProtocol
.
ProtocolMessage
):
void
{
setTimeout
(()
=>
{
if
(
message
.
type
===
'
request
'
)
{
const
request
=
message
as
DebugProtocol
.
Request
;
switch
(
request
.
command
)
{
case
'
evaluate
'
:
this
.
evaluate
(
request
,
request
.
arguments
);
return
;
}
this
.
sendResponseBody
(
request
,
{});
return
;
}
},
0
);
}
sendResponseBody
(
request
:
DebugProtocol
.
Request
,
body
:
any
)
{
const
response
:
DebugProtocol
.
Response
=
{
seq
:
++
this
.
seq
,
type
:
'
response
'
,
request_seq
:
request
.
seq
,
command
:
request
.
command
,
success
:
true
,
body
};
this
.
acceptMessage
(
response
);
}
sendEventBody
(
event
:
string
,
body
:
any
)
{
const
response
:
DebugProtocol
.
Event
=
{
seq
:
++
this
.
seq
,
type
:
'
event
'
,
event
,
body
};
this
.
acceptMessage
(
response
);
}
evaluate
(
request
:
DebugProtocol
.
Request
,
args
:
DebugProtocol
.
EvaluateArguments
)
{
if
(
args
.
expression
.
indexOf
(
'
before.
'
)
===
0
)
{
this
.
sendEventBody
(
'
output
'
,
{
output
:
args
.
expression
});
}
this
.
sendResponseBody
(
request
,
{
result
:
'
=
'
+
args
.
expression
,
variablesReference
:
0
});
if
(
args
.
expression
.
indexOf
(
'
after.
'
)
===
0
)
{
this
.
sendEventBody
(
'
output
'
,
{
output
:
args
.
expression
});
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录