Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f178d6c3
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,发现更多精彩内容 >>
提交
f178d6c3
编写于
10月 27, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debug: support evalaution when no stack frame exist
fixes #14571
上级
f4923178
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
60 deletion
+63
-60
src/vs/workbench/parts/debug/common/debugModel.ts
src/vs/workbench/parts/debug/common/debugModel.ts
+42
-42
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
+10
-7
src/vs/workbench/parts/debug/electron-browser/debugService.ts
...vs/workbench/parts/debug/electron-browser/debugService.ts
+4
-4
src/vs/workbench/parts/debug/test/node/debugModel.test.ts
src/vs/workbench/parts/debug/test/node/debugModel.test.ts
+7
-7
未找到文件。
src/vs/workbench/parts/debug/common/debugModel.ts
浏览文件 @
f178d6c3
...
...
@@ -24,39 +24,6 @@ function massageValue(value: string): string {
return
value
?
value
.
replace
(
/
\n
/g
,
'
\\
n
'
).
replace
(
/
\r
/g
,
'
\\
r
'
).
replace
(
/
\t
/g
,
'
\\
t
'
)
:
value
;
}
export
function
evaluateExpression
(
stackFrame
:
debug
.
IStackFrame
,
expression
:
Expression
,
context
:
string
):
TPromise
<
Expression
>
{
if
(
!
stackFrame
||
!
stackFrame
.
thread
.
process
)
{
expression
.
value
=
context
===
'
repl
'
?
nls
.
localize
(
'
startDebugFirst
'
,
"
Please start a debug session to evaluate
"
)
:
Expression
.
DEFAULT_VALUE
;
expression
.
available
=
false
;
expression
.
reference
=
0
;
return
TPromise
.
as
(
expression
);
}
expression
.
stackFrame
=
stackFrame
;
return
stackFrame
.
thread
.
process
.
session
.
evaluate
({
expression
:
expression
.
name
,
frameId
:
stackFrame
?
stackFrame
.
frameId
:
undefined
,
context
}).
then
(
response
=>
{
expression
.
available
=
!!
(
response
&&
response
.
body
);
if
(
response
&&
response
.
body
)
{
expression
.
value
=
response
.
body
.
result
;
expression
.
reference
=
response
.
body
.
variablesReference
;
expression
.
namedVariables
=
response
.
body
.
namedVariables
;
expression
.
indexedVariables
=
response
.
body
.
indexedVariables
;
expression
.
type
=
response
.
body
.
type
;
}
return
expression
;
},
err
=>
{
expression
.
value
=
err
.
message
;
expression
.
available
=
false
;
expression
.
reference
=
0
;
return
expression
;
});
}
export
class
OutputElement
implements
debug
.
ITreeElement
{
private
static
ID_COUNTER
=
0
;
...
...
@@ -238,6 +205,39 @@ export class Expression extends ExpressionContainer implements debug.IExpression
this
.
value
=
Expression
.
DEFAULT_VALUE
;
this
.
available
=
false
;
}
public
evaluate
(
process
:
debug
.
IProcess
,
stackFrame
:
debug
.
IStackFrame
,
context
:
string
):
TPromise
<
void
>
{
if
(
!
process
)
{
this
.
value
=
context
===
'
repl
'
?
nls
.
localize
(
'
startDebugFirst
'
,
"
Please start a debug session to evaluate
"
)
:
Expression
.
DEFAULT_VALUE
;
this
.
available
=
false
;
this
.
reference
=
0
;
return
TPromise
.
as
(
null
);
}
// Create a fake stack frame which is just used as a container for the process.
// TODO@Isidor revisit if variables should have a reference to the StackFrame or a process after all
this
.
stackFrame
=
stackFrame
||
new
StackFrame
(
new
Thread
(
process
,
undefined
,
undefined
),
undefined
,
undefined
,
undefined
,
undefined
,
undefined
);
return
process
.
session
.
evaluate
({
expression
:
this
.
name
,
frameId
:
stackFrame
?
stackFrame
.
frameId
:
undefined
,
context
}).
then
(
response
=>
{
this
.
available
=
!!
(
response
&&
response
.
body
);
if
(
response
&&
response
.
body
)
{
this
.
value
=
response
.
body
.
result
;
this
.
reference
=
response
.
body
.
variablesReference
;
this
.
namedVariables
=
response
.
body
.
namedVariables
;
this
.
indexedVariables
=
response
.
body
.
indexedVariables
;
this
.
type
=
response
.
body
.
type
;
}
},
err
=>
{
this
.
value
=
err
.
message
;
this
.
available
=
false
;
this
.
reference
=
0
;
});
}
}
export
class
Variable
extends
ExpressionContainer
implements
debug
.
IExpression
{
...
...
@@ -800,10 +800,10 @@ export class Model implements debug.IModel {
return
this
.
replElements
;
}
public
addReplExpression
(
stackFrame
:
debug
.
IStackFrame
,
name
:
string
):
TPromise
<
void
>
{
public
addReplExpression
(
process
:
debug
.
IProcess
,
stackFrame
:
debug
.
IStackFrame
,
name
:
string
):
TPromise
<
void
>
{
const
expression
=
new
Expression
(
name
,
true
);
this
.
addReplElements
([
expression
]);
return
e
valuateExpression
(
stackFrame
,
expression
,
'
repl
'
)
return
e
xpression
.
evaluate
(
process
,
stackFrame
,
'
repl
'
)
.
then
(()
=>
this
.
_onDidChangeREPLElements
.
fire
());
}
...
...
@@ -875,7 +875,7 @@ export class Model implements debug.IModel {
return
this
.
watchExpressions
;
}
public
addWatchExpression
(
stackFrame
:
debug
.
IStackFrame
,
name
:
string
):
TPromise
<
void
>
{
public
addWatchExpression
(
process
:
debug
.
IProcess
,
stackFrame
:
debug
.
IStackFrame
,
name
:
string
):
TPromise
<
void
>
{
const
we
=
new
Expression
(
name
,
false
);
this
.
watchExpressions
.
push
(
we
);
if
(
!
name
)
{
...
...
@@ -883,14 +883,14 @@ export class Model implements debug.IModel {
return
TPromise
.
as
(
null
);
}
return
this
.
evaluateWatchExpressions
(
stackFrame
,
we
.
getId
());
return
this
.
evaluateWatchExpressions
(
process
,
stackFrame
,
we
.
getId
());
}
public
renameWatchExpression
(
stackFrame
:
debug
.
IStackFrame
,
id
:
string
,
newName
:
string
):
TPromise
<
void
>
{
public
renameWatchExpression
(
process
:
debug
.
IProcess
,
stackFrame
:
debug
.
IStackFrame
,
id
:
string
,
newName
:
string
):
TPromise
<
void
>
{
const
filtered
=
this
.
watchExpressions
.
filter
(
we
=>
we
.
getId
()
===
id
);
if
(
filtered
.
length
===
1
)
{
filtered
[
0
].
name
=
newName
;
return
evaluateExpression
(
stackFrame
,
filtered
[
0
]
,
'
watch
'
).
then
(()
=>
{
return
filtered
[
0
].
evaluate
(
process
,
stackFrame
,
'
watch
'
).
then
(()
=>
{
this
.
_onDidChangeWatchExpressions
.
fire
(
filtered
[
0
]);
});
}
...
...
@@ -898,19 +898,19 @@ export class Model implements debug.IModel {
return
TPromise
.
as
(
null
);
}
public
evaluateWatchExpressions
(
stackFrame
:
debug
.
IStackFrame
,
id
:
string
=
null
):
TPromise
<
void
>
{
public
evaluateWatchExpressions
(
process
:
debug
.
IProcess
,
stackFrame
:
debug
.
IStackFrame
,
id
:
string
=
null
):
TPromise
<
void
>
{
if
(
id
)
{
const
filtered
=
this
.
watchExpressions
.
filter
(
we
=>
we
.
getId
()
===
id
);
if
(
filtered
.
length
!==
1
)
{
return
TPromise
.
as
(
null
);
}
return
evaluateExpression
(
stackFrame
,
filtered
[
0
]
,
'
watch
'
).
then
(()
=>
{
return
filtered
[
0
].
evaluate
(
process
,
stackFrame
,
'
watch
'
).
then
(()
=>
{
this
.
_onDidChangeWatchExpressions
.
fire
(
filtered
[
0
]);
});
}
return
TPromise
.
join
(
this
.
watchExpressions
.
map
(
we
=>
evaluateExpression
(
stackFrame
,
w
e
,
'
watch
'
))).
then
(()
=>
{
return
TPromise
.
join
(
this
.
watchExpressions
.
map
(
we
=>
we
.
evaluate
(
process
,
stackFram
e
,
'
watch
'
))).
then
(()
=>
{
this
.
_onDidChangeWatchExpressions
.
fire
();
});
}
...
...
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
浏览文件 @
f178d6c3
...
...
@@ -15,7 +15,7 @@ import { IConfigurationChangedEvent } from 'vs/editor/common/editorCommon';
import
editorbrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
debug
=
require
(
'
vs/workbench/parts/debug/common/debug
'
);
import
{
evaluateExpression
,
Expression
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
Expression
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
viewer
=
require
(
'
vs/workbench/parts/debug/electron-browser/debugViewer
'
);
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
...
...
@@ -158,13 +158,16 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget {
const
expressionRange
=
this
.
getExactExpressionRange
(
lineContent
,
range
);
// use regex to extract the sub-expression #9821
const
matchingExpression
=
lineContent
.
substring
(
expressionRange
.
startColumn
-
1
,
expressionRange
.
endColumn
);
let
promise
:
TPromise
<
debug
.
IExpression
>
;
if
(
process
.
session
.
configuration
.
capabilities
.
supportsEvaluateForHovers
)
{
const
result
=
new
Expression
(
matchingExpression
,
true
);
promise
=
result
.
evaluate
(
process
,
focusedStackFrame
,
'
hover
'
).
then
(()
=>
result
);
}
else
{
promise
=
this
.
findExpressionInStackFrame
(
matchingExpression
.
split
(
'
.
'
).
map
(
word
=>
word
.
trim
()).
filter
(
word
=>
!!
word
));
}
const
evaluatedExpression
=
process
.
session
.
configuration
.
capabilities
.
supportsEvaluateForHovers
?
evaluateExpression
(
focusedStackFrame
,
new
Expression
(
matchingExpression
,
true
),
'
hover
'
)
:
this
.
findExpressionInStackFrame
(
matchingExpression
.
split
(
'
.
'
).
map
(
word
=>
word
.
trim
()).
filter
(
word
=>
!!
word
));
return
evaluatedExpression
.
then
(
expression
=>
{
if
(
!
expression
||
!
expression
.
available
)
{
return
promise
.
then
(
expression
=>
{
if
(
!
expression
||
(
expression
instanceof
Expression
&&
!
expression
.
available
))
{
this
.
hide
();
return
;
}
...
...
src/vs/workbench/parts/debug/electron-browser/debugService.ts
浏览文件 @
f178d6c3
...
...
@@ -451,7 +451,7 @@ export class DebugService implements debug.IDebugService {
this
.
viewModel
.
setFocusedStackFrame
(
focusedStackFrame
,
process
);
this
.
_onDidChangeState
.
fire
();
if
(
focusedStackFrame
)
{
return
this
.
model
.
evaluateWatchExpressions
(
focusedStackFrame
);
return
this
.
model
.
evaluateWatchExpressions
(
process
,
focusedStackFrame
);
}
else
{
this
.
model
.
clearWatchExpressionValues
();
return
TPromise
.
as
(
null
);
...
...
@@ -512,7 +512,7 @@ export class DebugService implements debug.IDebugService {
public
addReplExpression
(
name
:
string
):
TPromise
<
void
>
{
this
.
telemetryService
.
publicLog
(
'
debugService/addReplExpression
'
);
return
this
.
model
.
addReplExpression
(
this
.
viewModel
.
focusedStackFrame
,
name
)
return
this
.
model
.
addReplExpression
(
this
.
viewModel
.
focused
Process
,
this
.
viewModel
.
focused
StackFrame
,
name
)
// Evaluate all watch expressions again since repl evaluation might have changed some.
.
then
(()
=>
this
.
setFocusedStackFrameAndEvaluate
(
this
.
viewModel
.
focusedStackFrame
));
}
...
...
@@ -530,11 +530,11 @@ export class DebugService implements debug.IDebugService {
}
public
addWatchExpression
(
name
:
string
):
TPromise
<
void
>
{
return
this
.
model
.
addWatchExpression
(
this
.
viewModel
.
focusedStackFrame
,
name
);
return
this
.
model
.
addWatchExpression
(
this
.
viewModel
.
focused
Process
,
this
.
viewModel
.
focused
StackFrame
,
name
);
}
public
renameWatchExpression
(
id
:
string
,
newName
:
string
):
TPromise
<
void
>
{
return
this
.
model
.
renameWatchExpression
(
this
.
viewModel
.
focusedStackFrame
,
id
,
newName
);
return
this
.
model
.
renameWatchExpression
(
this
.
viewModel
.
focused
Process
,
this
.
viewModel
.
focused
StackFrame
,
id
,
newName
);
}
public
removeWatchExpressions
(
id
?:
string
):
void
{
...
...
src/vs/workbench/parts/debug/test/node/debugModel.test.ts
浏览文件 @
f178d6c3
...
...
@@ -294,13 +294,13 @@ suite('Debug - Model', () => {
const
process
=
new
debugmodel
.
Process
(
'
mockProcess
'
,
rawSession
);
const
thread
=
new
debugmodel
.
Thread
(
process
,
'
mockthread
'
,
1
);
const
stackFrame
=
new
debugmodel
.
StackFrame
(
thread
,
1
,
null
,
'
app.js
'
,
1
,
1
);
model
.
addWatchExpression
(
stackFrame
,
'
console
'
).
done
();
model
.
addWatchExpression
(
stackFrame
,
'
console
'
).
done
();
model
.
addWatchExpression
(
process
,
stackFrame
,
'
console
'
).
done
();
model
.
addWatchExpression
(
process
,
stackFrame
,
'
console
'
).
done
();
const
watchExpressions
=
model
.
getWatchExpressions
();
assertWatchExpressions
(
watchExpressions
,
'
console
'
);
model
.
renameWatchExpression
(
stackFrame
,
watchExpressions
[
0
].
getId
(),
'
new_name
'
).
done
();
model
.
renameWatchExpression
(
stackFrame
,
watchExpressions
[
1
].
getId
(),
'
new_name
'
).
done
();
model
.
renameWatchExpression
(
process
,
stackFrame
,
watchExpressions
[
0
].
getId
(),
'
new_name
'
).
done
();
model
.
renameWatchExpression
(
process
,
stackFrame
,
watchExpressions
[
1
].
getId
(),
'
new_name
'
).
done
();
assertWatchExpressions
(
model
.
getWatchExpressions
(),
'
new_name
'
);
model
.
clearWatchExpressionValues
();
...
...
@@ -315,9 +315,9 @@ suite('Debug - Model', () => {
const
process
=
new
debugmodel
.
Process
(
'
mockProcess
'
,
rawSession
);
const
thread
=
new
debugmodel
.
Thread
(
process
,
'
mockthread
'
,
1
);
const
stackFrame
=
new
debugmodel
.
StackFrame
(
thread
,
1
,
null
,
'
app.js
'
,
1
,
1
);
model
.
addReplExpression
(
stackFrame
,
'
myVariable
'
).
done
();
model
.
addReplExpression
(
stackFrame
,
'
myVariable
'
).
done
();
model
.
addReplExpression
(
stackFrame
,
'
myVariable
'
).
done
();
model
.
addReplExpression
(
process
,
stackFrame
,
'
myVariable
'
).
done
();
model
.
addReplExpression
(
process
,
stackFrame
,
'
myVariable
'
).
done
();
model
.
addReplExpression
(
process
,
stackFrame
,
'
myVariable
'
).
done
();
assert
.
equal
(
model
.
getReplElements
().
length
,
3
);
model
.
getReplElements
().
forEach
(
re
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录