Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
0e17c435
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0e17c435
编写于
11月 22, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
replViewer: renaming and polishing
上级
8efb9e68
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
49 addition
and
53 deletion
+49
-53
src/vs/workbench/parts/debug/common/debug.ts
src/vs/workbench/parts/debug/common/debug.ts
+1
-1
src/vs/workbench/parts/debug/common/debugModel.ts
src/vs/workbench/parts/debug/common/debugModel.ts
+14
-14
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
+1
-1
src/vs/workbench/parts/debug/electron-browser/repl.ts
src/vs/workbench/parts/debug/electron-browser/repl.ts
+1
-1
src/vs/workbench/parts/debug/electron-browser/replViewer.ts
src/vs/workbench/parts/debug/electron-browser/replViewer.ts
+29
-33
src/vs/workbench/parts/debug/test/node/debugModel.test.ts
src/vs/workbench/parts/debug/test/node/debugModel.test.ts
+3
-3
未找到文件。
src/vs/workbench/parts/debug/common/debug.ts
浏览文件 @
0e17c435
...
...
@@ -59,7 +59,7 @@ export interface ITreeElement {
export
interface
IExpressionContainer
extends
ITreeElement
{
stackFrame
:
IStackFrame
;
hasChildren
:
boolean
;
getChildren
(
debugService
:
IDebugService
):
TPromise
<
IExpression
[]
>
;
getChildren
():
TPromise
<
IExpression
[]
>
;
}
export
interface
IExpression
extends
ITreeElement
,
IExpressionContainer
{
...
...
src/vs/workbench/parts/debug/common/debugModel.ts
浏览文件 @
0e17c435
...
...
@@ -24,10 +24,10 @@ import { Source } from 'vs/workbench/parts/debug/common/debugSource';
const
MAX_REPL_LENGTH
=
10000
;
const
UNKNOWN_SOURCE_LABEL
=
nls
.
localize
(
'
unknownSource
'
,
"
Unknown Source
"
);
export
class
OutputElement
implements
debug
.
ITreeElement
{
export
abstract
class
Abstract
OutputElement
implements
debug
.
ITreeElement
{
private
static
ID_COUNTER
=
0
;
constructor
(
private
id
=
OutputElement
.
ID_COUNTER
++
)
{
constructor
(
private
id
=
Abstract
OutputElement
.
ID_COUNTER
++
)
{
// noop
}
...
...
@@ -36,7 +36,7 @@ export class OutputElement implements debug.ITreeElement {
}
}
export
class
ValueOutputElement
extends
OutputElement
{
export
class
ValueOutputElement
extends
Abstract
OutputElement
{
constructor
(
public
value
:
string
,
...
...
@@ -47,11 +47,11 @@ export class ValueOutputElement extends OutputElement {
}
}
export
class
KeyValueOutputElement
extends
OutputElement
{
export
class
NameValueOutputElement
extends
Abstract
OutputElement
{
private
static
MAX_CHILDREN
=
1000
;
// upper bound of children per value
constructor
(
public
key
:
string
,
public
valueObj
:
any
,
public
annotation
?:
string
)
{
constructor
(
public
name
:
string
,
public
valueObj
:
any
,
public
annotation
?:
string
)
{
super
();
}
...
...
@@ -71,11 +71,11 @@ export class KeyValueOutputElement extends OutputElement {
public
getChildren
():
debug
.
ITreeElement
[]
{
if
(
Array
.
isArray
(
this
.
valueObj
))
{
return
(
<
any
[]
>
this
.
valueObj
).
slice
(
0
,
Key
ValueOutputElement
.
MAX_CHILDREN
)
.
map
((
v
,
index
)
=>
new
Key
ValueOutputElement
(
String
(
index
),
v
));
return
(
<
any
[]
>
this
.
valueObj
).
slice
(
0
,
Name
ValueOutputElement
.
MAX_CHILDREN
)
.
map
((
v
,
index
)
=>
new
Name
ValueOutputElement
(
String
(
index
),
v
));
}
else
if
(
isObject
(
this
.
valueObj
))
{
return
Object
.
getOwnPropertyNames
(
this
.
valueObj
).
slice
(
0
,
Key
ValueOutputElement
.
MAX_CHILDREN
)
.
map
(
key
=>
new
Key
ValueOutputElement
(
key
,
this
.
valueObj
[
key
]));
return
Object
.
getOwnPropertyNames
(
this
.
valueObj
).
slice
(
0
,
Name
ValueOutputElement
.
MAX_CHILDREN
)
.
map
(
key
=>
new
Name
ValueOutputElement
(
key
,
this
.
valueObj
[
key
]));
}
return
[];
...
...
@@ -95,14 +95,13 @@ export abstract class ExpressionContainer implements debug.IExpressionContainer
public
stackFrame
:
debug
.
IStackFrame
,
public
reference
:
number
,
private
id
:
string
,
public
namedVariables
:
number
,
public
indexedVariables
:
number
,
public
namedVariables
=
0
,
public
indexedVariables
=
0
,
private
startOfVariables
=
0
)
{
}
public
getChildren
():
TPromise
<
debug
.
IExpression
[]
>
{
// only variables with reference > 0 have children.
if
(
this
.
reference
<=
0
)
{
if
(
!
this
.
hasChildren
)
{
return
TPromise
.
as
([]);
}
...
...
@@ -144,6 +143,7 @@ export abstract class ExpressionContainer implements debug.IExpressionContainer
}
public
get
hasChildren
():
boolean
{
// only variables with reference > 0 have children.
return
this
.
reference
>
0
;
}
...
...
@@ -180,7 +180,7 @@ export class Expression extends ExpressionContainer implements debug.IExpression
public
type
:
string
;
constructor
(
public
name
:
string
,
id
=
generateUuid
())
{
super
(
null
,
0
,
id
,
0
,
0
);
super
(
null
,
0
,
id
);
this
.
available
=
false
;
// name is not set if the expression is just being added
// in that case do not set default value to prevent flashing #14499
...
...
src/vs/workbench/parts/debug/electron-browser/debugHover.ts
浏览文件 @
0e17c435
...
...
@@ -190,7 +190,7 @@ export class DebugHoverWidget implements IContentWidget {
}
private
doFindExpression
(
container
:
IExpressionContainer
,
namesToFind
:
string
[]):
TPromise
<
IExpression
>
{
return
container
.
getChildren
(
this
.
debugService
).
then
(
children
=>
{
return
container
.
getChildren
().
then
(
children
=>
{
// look for our variable in the list. First find the parents of the hovered variable if there are any.
// some languages pass the type as part of the name, so need to check if the last word of the name matches.
const
filtered
=
children
.
filter
(
v
=>
typeof
v
.
name
===
'
string
'
&&
(
namesToFind
[
0
]
===
v
.
name
||
namesToFind
[
0
]
===
v
.
name
.
substr
(
v
.
name
.
lastIndexOf
(
'
'
)
+
1
)));
...
...
src/vs/workbench/parts/debug/electron-browser/repl.ts
浏览文件 @
0e17c435
...
...
@@ -140,7 +140,7 @@ export class Repl extends Panel implements IPrivateReplService {
this
.
renderer
=
this
.
instantiationService
.
createInstance
(
ReplExpressionsRenderer
);
this
.
tree
=
new
Tree
(
this
.
treeContainer
,
{
dataSource
:
new
ReplExpressionsDataSource
(
this
.
debugService
),
dataSource
:
new
ReplExpressionsDataSource
(),
renderer
:
this
.
renderer
,
accessibilityProvider
:
new
ReplExpressionsAccessibilityProvider
(),
controller
:
new
ReplExpressionsController
(
this
.
debugService
,
this
.
contextMenuService
,
new
ReplExpressionsActionProvider
(
this
.
instantiationService
),
this
.
replInput
,
false
)
...
...
src/vs/workbench/parts/debug/electron-browser/replViewer.ts
浏览文件 @
0e17c435
...
...
@@ -19,8 +19,8 @@ import { ITree, IAccessibilityProvider, IDataSource, IRenderer } from 'vs/base/p
import
{
IActionProvider
}
from
'
vs/base/parts/tree/browser/actionsRenderer
'
;
import
{
ICancelableEvent
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
*
as
debug
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Model
,
Key
ValueOutputElement
,
Expression
,
ValueOutputElement
,
Variable
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
IExpressionContainer
,
IExpression
,
IDebugService
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
Model
,
Name
ValueOutputElement
,
Expression
,
ValueOutputElement
,
Variable
}
from
'
vs/workbench/parts/debug/common/debugModel
'
;
import
{
renderVariable
,
renderExpressionValue
,
IVariableTemplateData
,
BaseDebugController
}
from
'
vs/workbench/parts/debug/electron-browser/debugViewer
'
;
import
{
AddToWatchExpressionsAction
,
ClearReplAction
}
from
'
vs/workbench/parts/debug/browser/debugActions
'
;
import
{
CopyAction
}
from
'
vs/workbench/parts/debug/electron-browser/electronDebugActions
'
;
...
...
@@ -33,30 +33,26 @@ const $ = dom.$;
export
class
ReplExpressionsDataSource
implements
IDataSource
{
constructor
(
private
debugService
:
debug
.
IDebugService
)
{
// noop
}
public
getId
(
tree
:
ITree
,
element
:
any
):
string
{
return
element
.
getId
();
}
public
hasChildren
(
tree
:
ITree
,
element
:
any
):
boolean
{
return
element
instanceof
Model
||
element
.
reference
>
0
||
(
element
instanceof
KeyValueOutputElement
&&
element
.
getChildren
().
length
>
0
)
;
return
element
instanceof
Model
||
(
<
IExpressionContainer
>
element
).
hasChildren
||
element
instanceof
NameValueOutputElement
;
}
public
getChildren
(
tree
:
ITree
,
element
:
any
):
TPromise
<
any
>
{
if
(
element
instanceof
Model
)
{
return
TPromise
.
as
(
element
.
getReplElements
());
}
if
(
element
instanceof
Key
ValueOutputElement
)
{
if
(
element
instanceof
Name
ValueOutputElement
)
{
return
TPromise
.
as
(
element
.
getChildren
());
}
if
(
element
instanceof
ValueOutputElement
)
{
return
TPromise
.
as
(
null
);
}
return
(
<
debug
.
IExpression
>
element
).
getChildren
(
this
.
debugService
);
return
(
<
IExpression
>
element
).
getChildren
(
);
}
public
getParent
(
tree
:
ITree
,
element
:
any
):
TPromise
<
any
>
{
...
...
@@ -64,7 +60,7 @@ export class ReplExpressionsDataSource implements IDataSource {
}
}
interface
I
InputOutputPair
TemplateData
{
interface
I
Expression
TemplateData
{
input
:
HTMLElement
;
output
:
HTMLElement
;
value
:
HTMLElement
;
...
...
@@ -80,7 +76,7 @@ interface IValueOutputTemplateData {
interface
IKeyValueOutputTemplateData
{
container
:
HTMLElement
;
expression
:
HTMLElement
;
key
:
HTMLElement
;
name
:
HTMLElement
;
value
:
HTMLElement
;
annotation
:
HTMLElement
;
}
...
...
@@ -88,9 +84,9 @@ interface IKeyValueOutputTemplateData {
export
class
ReplExpressionsRenderer
implements
IRenderer
{
private
static
VARIABLE_TEMPLATE_ID
=
'
variable
'
;
private
static
INPUT_OUTPUT_PAIR
_TEMPLATE_ID
=
'
inputOutputPair
'
;
private
static
EXPRESSION
_TEMPLATE_ID
=
'
inputOutputPair
'
;
private
static
VALUE_OUTPUT_TEMPLATE_ID
=
'
outputValue
'
;
private
static
KEY
_VALUE_OUTPUT_TEMPLATE_ID
=
'
outputKeyValue
'
;
private
static
NAME
_VALUE_OUTPUT_TEMPLATE_ID
=
'
outputKeyValue
'
;
private
static
FILE_LOCATION_PATTERNS
:
RegExp
[]
=
[
// group 0: the full thing :)
...
...
@@ -145,13 +141,13 @@ export class ReplExpressionsRenderer implements IRenderer {
return
ReplExpressionsRenderer
.
VARIABLE_TEMPLATE_ID
;
}
if
(
element
instanceof
Expression
)
{
return
ReplExpressionsRenderer
.
INPUT_OUTPUT_PAIR
_TEMPLATE_ID
;
return
ReplExpressionsRenderer
.
EXPRESSION
_TEMPLATE_ID
;
}
if
(
element
instanceof
ValueOutputElement
)
{
return
ReplExpressionsRenderer
.
VALUE_OUTPUT_TEMPLATE_ID
;
}
if
(
element
instanceof
Key
ValueOutputElement
)
{
return
ReplExpressionsRenderer
.
KEY
_VALUE_OUTPUT_TEMPLATE_ID
;
if
(
element
instanceof
Name
ValueOutputElement
)
{
return
ReplExpressionsRenderer
.
NAME
_VALUE_OUTPUT_TEMPLATE_ID
;
}
return
null
;
...
...
@@ -167,8 +163,8 @@ export class ReplExpressionsRenderer implements IRenderer {
return
data
;
}
if
(
templateId
===
ReplExpressionsRenderer
.
INPUT_OUTPUT_PAIR
_TEMPLATE_ID
)
{
let
data
:
I
InputOutputPair
TemplateData
=
Object
.
create
(
null
);
if
(
templateId
===
ReplExpressionsRenderer
.
EXPRESSION
_TEMPLATE_ID
)
{
let
data
:
I
Expression
TemplateData
=
Object
.
create
(
null
);
dom
.
addClass
(
container
,
'
input-output-pair
'
);
data
.
input
=
dom
.
append
(
container
,
$
(
'
.input.expression
'
));
data
.
output
=
dom
.
append
(
container
,
$
(
'
.output.expression
'
));
...
...
@@ -190,13 +186,13 @@ export class ReplExpressionsRenderer implements IRenderer {
return
data
;
}
if
(
templateId
===
ReplExpressionsRenderer
.
KEY
_VALUE_OUTPUT_TEMPLATE_ID
)
{
if
(
templateId
===
ReplExpressionsRenderer
.
NAME
_VALUE_OUTPUT_TEMPLATE_ID
)
{
let
data
:
IKeyValueOutputTemplateData
=
Object
.
create
(
null
);
dom
.
addClass
(
container
,
'
output
'
);
data
.
container
=
container
;
data
.
expression
=
dom
.
append
(
container
,
$
(
'
.output.expression
'
));
data
.
key
=
dom
.
append
(
data
.
expression
,
$
(
'
span.name
'
));
data
.
name
=
dom
.
append
(
data
.
expression
,
$
(
'
span.name
'
));
data
.
value
=
dom
.
append
(
data
.
expression
,
$
(
'
span.value
'
));
data
.
annotation
=
dom
.
append
(
data
.
expression
,
$
(
'
span
'
));
...
...
@@ -207,16 +203,16 @@ export class ReplExpressionsRenderer implements IRenderer {
public
renderElement
(
tree
:
ITree
,
element
:
any
,
templateId
:
string
,
templateData
:
any
):
void
{
if
(
templateId
===
ReplExpressionsRenderer
.
VARIABLE_TEMPLATE_ID
)
{
renderVariable
(
tree
,
element
,
templateData
,
false
);
}
else
if
(
templateId
===
ReplExpressionsRenderer
.
INPUT_OUTPUT_PAIR
_TEMPLATE_ID
)
{
this
.
render
InputOutputPair
(
tree
,
element
,
templateData
);
}
else
if
(
templateId
===
ReplExpressionsRenderer
.
EXPRESSION
_TEMPLATE_ID
)
{
this
.
render
Expression
(
tree
,
element
,
templateData
);
}
else
if
(
templateId
===
ReplExpressionsRenderer
.
VALUE_OUTPUT_TEMPLATE_ID
)
{
this
.
renderOutputValue
(
element
,
templateData
);
}
else
if
(
templateId
===
ReplExpressionsRenderer
.
KEY
_VALUE_OUTPUT_TEMPLATE_ID
)
{
this
.
renderOutput
Key
Value
(
tree
,
element
,
templateData
);
}
else
if
(
templateId
===
ReplExpressionsRenderer
.
NAME
_VALUE_OUTPUT_TEMPLATE_ID
)
{
this
.
renderOutput
Name
Value
(
tree
,
element
,
templateData
);
}
}
private
render
InputOutputPair
(
tree
:
ITree
,
expression
:
debug
.
IExpression
,
templateData
:
IInputOutputPair
TemplateData
):
void
{
private
render
Expression
(
tree
:
ITree
,
expression
:
IExpression
,
templateData
:
IExpression
TemplateData
):
void
{
templateData
.
input
.
textContent
=
expression
.
name
;
renderExpressionValue
(
expression
,
templateData
.
value
,
{
showChanged
:
false
,
...
...
@@ -401,13 +397,13 @@ export class ReplExpressionsRenderer implements IRenderer {
},
event
.
ctrlKey
||
event
.
metaKey
).
done
(
null
,
errors
.
onUnexpectedError
);
}
private
renderOutput
KeyValue
(
tree
:
ITree
,
output
:
Key
ValueOutputElement
,
templateData
:
IKeyValueOutputTemplateData
):
void
{
private
renderOutput
NameValue
(
tree
:
ITree
,
output
:
Name
ValueOutputElement
,
templateData
:
IKeyValueOutputTemplateData
):
void
{
// key
if
(
output
.
key
)
{
templateData
.
key
.
textContent
=
`
${
output
.
key
}
:`
;
if
(
output
.
name
)
{
templateData
.
name
.
textContent
=
`
${
output
.
name
}
:`
;
}
else
{
templateData
.
key
.
textContent
=
''
;
templateData
.
name
.
textContent
=
''
;
}
// value
...
...
@@ -443,8 +439,8 @@ export class ReplExpressionsAccessibilityProvider implements IAccessibilityProvi
if
(
element
instanceof
ValueOutputElement
)
{
return
nls
.
localize
(
'
replValueOutputAriaLabel
'
,
"
{0}, read eval print loop, debug
"
,
(
<
ValueOutputElement
>
element
).
value
);
}
if
(
element
instanceof
Key
ValueOutputElement
)
{
return
nls
.
localize
(
'
replKeyValueOutputAriaLabel
'
,
"
Output variable {0} has value {1}, read eval print loop, debug
"
,
(
<
KeyValueOutputElement
>
element
).
key
,
(
<
Key
ValueOutputElement
>
element
).
value
);
if
(
element
instanceof
Name
ValueOutputElement
)
{
return
nls
.
localize
(
'
replKeyValueOutputAriaLabel
'
,
"
Output variable {0} has value {1}, read eval print loop, debug
"
,
(
<
NameValueOutputElement
>
element
).
name
,
(
<
Name
ValueOutputElement
>
element
).
value
);
}
return
null
;
...
...
@@ -491,7 +487,7 @@ export class ReplExpressionsController extends BaseDebugController {
private
lastSelectedString
:
string
=
null
;
constructor
(
debugService
:
debug
.
IDebugService
,
debugService
:
IDebugService
,
contextMenuService
:
IContextMenuService
,
actionProvider
:
IActionProvider
,
private
replInput
:
ICodeEditor
,
...
...
@@ -503,7 +499,7 @@ export class ReplExpressionsController extends BaseDebugController {
protected
onLeftClick
(
tree
:
ITree
,
element
:
any
,
eventish
:
ICancelableEvent
,
origin
:
string
=
'
mouse
'
):
boolean
{
const
mouseEvent
=
<
IMouseEvent
>
eventish
;
// input and output are one element in the tree => we only expand if the user clicked on the output.
if
((
element
.
reference
>
0
||
(
element
instanceof
Key
ValueOutputElement
&&
element
.
getChildren
().
length
>
0
))
&&
mouseEvent
.
target
.
className
.
indexOf
(
'
input expression
'
)
===
-
1
)
{
if
((
element
.
reference
>
0
||
(
element
instanceof
Name
ValueOutputElement
&&
element
.
getChildren
().
length
>
0
))
&&
mouseEvent
.
target
.
className
.
indexOf
(
'
input expression
'
)
===
-
1
)
{
super
.
onLeftClick
(
tree
,
element
,
eventish
,
origin
);
tree
.
clearFocus
();
tree
.
deselect
(
element
);
...
...
src/vs/workbench/parts/debug/test/node/debugModel.test.ts
浏览文件 @
0e17c435
...
...
@@ -354,13 +354,13 @@ suite('Debug - Model', () => {
assert
.
equal
(
elements
[
3
].
severity
,
severity
.
Warning
);
const
keyValueObject
=
{
'
key1
'
:
2
,
'
key2
'
:
'
value
'
};
model
.
appendReplOutput
(
keyValueObject
);
const
element
=
<
debugmodel
.
Key
ValueOutputElement
>
model
.
getReplElements
()[
4
];
model
.
appendReplOutput
(
keyValueObject
,
severity
.
Info
);
const
element
=
<
debugmodel
.
Name
ValueOutputElement
>
model
.
getReplElements
()[
4
];
assert
.
equal
(
element
.
value
,
'
Object
'
);
assert
.
deepEqual
(
element
.
valueObj
,
keyValueObject
);
const
multiLineContent
=
'
multi line
\n
string
\n
last line
'
;
model
.
appendReplOutput
(
multiLineContent
);
model
.
appendReplOutput
(
multiLineContent
,
severity
.
Info
);
const
multiLineElement
=
<
debugmodel
.
ValueOutputElement
>
model
.
getReplElements
()[
5
];
assert
.
equal
(
multiLineElement
.
value
,
multiLineContent
);
assert
.
equal
(
model
.
getReplElements
().
length
,
6
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录