Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
60d58566
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,发现更多精彩内容 >>
提交
60d58566
编写于
12月 19, 2019
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move repl renderer related stuff to the replViewer
上级
046ae379
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
370 addition
and
354 deletion
+370
-354
src/vs/workbench/contrib/debug/browser/repl.ts
src/vs/workbench/contrib/debug/browser/repl.ts
+18
-354
src/vs/workbench/contrib/debug/browser/replViewer.ts
src/vs/workbench/contrib/debug/browser/replViewer.ts
+352
-0
未找到文件。
src/vs/workbench/contrib/debug/browser/repl.ts
浏览文件 @
60d58566
此差异已折叠。
点击以展开。
src/vs/workbench/contrib/debug/browser/replViewer.ts
0 → 100644
浏览文件 @
60d58566
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
severity
from
'
vs/base/common/severity
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
IAccessibilityProvider
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
Variable
}
from
'
vs/workbench/contrib/debug/common/debugModel
'
;
import
{
SimpleReplElement
,
RawObjectReplElement
,
ReplEvaluationInput
,
ReplEvaluationResult
}
from
'
vs/workbench/contrib/debug/common/replModel
'
;
import
{
CachedListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
ITreeRenderer
,
ITreeNode
,
IAsyncDataSource
}
from
'
vs/base/browser/ui/tree/tree
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
renderExpressionValue
,
AbstractExpressionsRenderer
,
IExpressionTemplateData
,
renderVariable
,
IInputBoxOptions
}
from
'
vs/workbench/contrib/debug/browser/baseDebugView
'
;
import
{
handleANSIOutput
}
from
'
vs/workbench/contrib/debug/browser/debugANSIHandling
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
LinkDetector
}
from
'
vs/workbench/contrib/debug/browser/linkDetector
'
;
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
FuzzyScore
,
createMatches
}
from
'
vs/base/common/filters
'
;
import
{
HighlightedLabel
,
IHighlight
}
from
'
vs/base/browser/ui/highlightedlabel/highlightedLabel
'
;
import
{
IReplElementSource
,
IDebugService
,
IExpression
,
IReplElement
,
IDebugConfiguration
,
IDebugSession
,
IExpressionContainer
}
from
'
vs/workbench/contrib/debug/common/debug
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
localize
}
from
'
vs/nls
'
;
const
$
=
dom
.
$
;
interface
IReplEvaluationInputTemplateData
{
label
:
HighlightedLabel
;
}
interface
IReplEvaluationResultTemplateData
{
value
:
HTMLElement
;
annotation
:
HTMLElement
;
}
interface
ISimpleReplElementTemplateData
{
container
:
HTMLElement
;
value
:
HTMLElement
;
source
:
HTMLElement
;
getReplElementSource
():
IReplElementSource
|
undefined
;
toDispose
:
IDisposable
[];
}
interface
IRawObjectReplTemplateData
{
container
:
HTMLElement
;
expression
:
HTMLElement
;
name
:
HTMLElement
;
value
:
HTMLElement
;
annotation
:
HTMLElement
;
label
:
HighlightedLabel
;
}
export
class
ReplEvaluationInputsRenderer
implements
ITreeRenderer
<
ReplEvaluationInput
,
FuzzyScore
,
IReplEvaluationInputTemplateData
>
{
static
readonly
ID
=
'
replEvaluationInput
'
;
get
templateId
():
string
{
return
ReplEvaluationInputsRenderer
.
ID
;
}
renderTemplate
(
container
:
HTMLElement
):
IReplEvaluationInputTemplateData
{
dom
.
append
(
container
,
$
(
'
span.arrow.codicon.codicon-chevron-right
'
));
const
input
=
dom
.
append
(
container
,
$
(
'
.expression
'
));
const
label
=
new
HighlightedLabel
(
input
,
false
);
return
{
label
};
}
renderElement
(
element
:
ITreeNode
<
ReplEvaluationInput
,
FuzzyScore
>
,
index
:
number
,
templateData
:
IReplEvaluationInputTemplateData
):
void
{
const
evaluation
=
element
.
element
;
templateData
.
label
.
set
(
evaluation
.
value
,
createMatches
(
element
.
filterData
));
}
disposeTemplate
(
templateData
:
IReplEvaluationInputTemplateData
):
void
{
// noop
}
}
export
class
ReplEvaluationResultsRenderer
implements
ITreeRenderer
<
ReplEvaluationResult
,
FuzzyScore
,
IReplEvaluationResultTemplateData
>
{
static
readonly
ID
=
'
replEvaluationResult
'
;
get
templateId
():
string
{
return
ReplEvaluationResultsRenderer
.
ID
;
}
constructor
(
private
readonly
linkDetector
:
LinkDetector
)
{
}
renderTemplate
(
container
:
HTMLElement
):
IReplEvaluationResultTemplateData
{
dom
.
append
(
container
,
$
(
'
span.arrow.codicon.codicon-chevron-left
'
));
const
output
=
dom
.
append
(
container
,
$
(
'
.evaluation-result.expression
'
));
const
value
=
dom
.
append
(
output
,
$
(
'
span.value
'
));
const
annotation
=
dom
.
append
(
output
,
$
(
'
span
'
));
return
{
value
,
annotation
};
}
renderElement
(
element
:
ITreeNode
<
ReplEvaluationResult
,
FuzzyScore
>
,
index
:
number
,
templateData
:
IReplEvaluationResultTemplateData
):
void
{
const
expression
=
element
.
element
;
renderExpressionValue
(
expression
,
templateData
.
value
,
{
preserveWhitespace
:
!
expression
.
hasChildren
,
showHover
:
false
,
colorize
:
true
,
linkDetector
:
this
.
linkDetector
});
if
(
expression
.
hasChildren
)
{
templateData
.
annotation
.
className
=
'
annotation codicon codicon-info
'
;
templateData
.
annotation
.
title
=
localize
(
'
stateCapture
'
,
"
Object state is captured from first evaluation
"
);
}
}
disposeTemplate
(
templateData
:
IReplEvaluationResultTemplateData
):
void
{
// noop
}
}
export
class
ReplSimpleElementsRenderer
implements
ITreeRenderer
<
SimpleReplElement
,
FuzzyScore
,
ISimpleReplElementTemplateData
>
{
static
readonly
ID
=
'
simpleReplElement
'
;
constructor
(
private
readonly
linkDetector
:
LinkDetector
,
@
IEditorService
private
readonly
editorService
:
IEditorService
,
@
ILabelService
private
readonly
labelService
:
ILabelService
,
@
IThemeService
private
readonly
themeService
:
IThemeService
)
{
}
get
templateId
():
string
{
return
ReplSimpleElementsRenderer
.
ID
;
}
renderTemplate
(
container
:
HTMLElement
):
ISimpleReplElementTemplateData
{
const
data
:
ISimpleReplElementTemplateData
=
Object
.
create
(
null
);
dom
.
addClass
(
container
,
'
output
'
);
const
expression
=
dom
.
append
(
container
,
$
(
'
.output.expression.value-and-source
'
));
data
.
container
=
container
;
data
.
value
=
dom
.
append
(
expression
,
$
(
'
span.value
'
));
data
.
source
=
dom
.
append
(
expression
,
$
(
'
.source
'
));
data
.
toDispose
=
[];
data
.
toDispose
.
push
(
dom
.
addDisposableListener
(
data
.
source
,
'
click
'
,
e
=>
{
e
.
preventDefault
();
e
.
stopPropagation
();
const
source
=
data
.
getReplElementSource
();
if
(
source
)
{
source
.
source
.
openInEditor
(
this
.
editorService
,
{
startLineNumber
:
source
.
lineNumber
,
startColumn
:
source
.
column
,
endLineNumber
:
source
.
lineNumber
,
endColumn
:
source
.
column
});
}
}));
return
data
;
}
renderElement
({
element
}:
ITreeNode
<
SimpleReplElement
,
FuzzyScore
>
,
index
:
number
,
templateData
:
ISimpleReplElementTemplateData
):
void
{
// value
dom
.
clearNode
(
templateData
.
value
);
// Reset classes to clear ansi decorations since templates are reused
templateData
.
value
.
className
=
'
value
'
;
const
result
=
handleANSIOutput
(
element
.
value
,
this
.
linkDetector
,
this
.
themeService
,
element
.
session
);
templateData
.
value
.
appendChild
(
result
);
dom
.
addClass
(
templateData
.
value
,
(
element
.
severity
===
severity
.
Warning
)
?
'
warn
'
:
(
element
.
severity
===
severity
.
Error
)
?
'
error
'
:
(
element
.
severity
===
severity
.
Ignore
)
?
'
ignore
'
:
'
info
'
);
templateData
.
source
.
textContent
=
element
.
sourceData
?
`
${
element
.
sourceData
.
source
.
name
}
:
${
element
.
sourceData
.
lineNumber
}
`
:
''
;
templateData
.
source
.
title
=
element
.
sourceData
?
this
.
labelService
.
getUriLabel
(
element
.
sourceData
.
source
.
uri
)
:
''
;
templateData
.
getReplElementSource
=
()
=>
element
.
sourceData
;
}
disposeTemplate
(
templateData
:
ISimpleReplElementTemplateData
):
void
{
dispose
(
templateData
.
toDispose
);
}
}
export
class
ReplVariablesRenderer
extends
AbstractExpressionsRenderer
{
static
readonly
ID
=
'
replVariable
'
;
get
templateId
():
string
{
return
ReplVariablesRenderer
.
ID
;
}
constructor
(
private
readonly
linkDetector
:
LinkDetector
,
@
IDebugService
debugService
:
IDebugService
,
@
IContextViewService
contextViewService
:
IContextViewService
,
@
IThemeService
themeService
:
IThemeService
,
)
{
super
(
debugService
,
contextViewService
,
themeService
);
}
protected
renderExpression
(
expression
:
IExpression
,
data
:
IExpressionTemplateData
,
highlights
:
IHighlight
[]):
void
{
renderVariable
(
expression
as
Variable
,
data
,
true
,
highlights
,
this
.
linkDetector
);
}
protected
getInputBoxOptions
(
expression
:
IExpression
):
IInputBoxOptions
|
undefined
{
return
undefined
;
}
}
export
class
ReplRawObjectsRenderer
implements
ITreeRenderer
<
RawObjectReplElement
,
FuzzyScore
,
IRawObjectReplTemplateData
>
{
static
readonly
ID
=
'
rawObject
'
;
constructor
(
private
readonly
linkDetector
:
LinkDetector
)
{
}
get
templateId
():
string
{
return
ReplRawObjectsRenderer
.
ID
;
}
renderTemplate
(
container
:
HTMLElement
):
IRawObjectReplTemplateData
{
dom
.
addClass
(
container
,
'
output
'
);
const
expression
=
dom
.
append
(
container
,
$
(
'
.output.expression
'
));
const
name
=
dom
.
append
(
expression
,
$
(
'
span.name
'
));
const
label
=
new
HighlightedLabel
(
name
,
false
);
const
value
=
dom
.
append
(
expression
,
$
(
'
span.value
'
));
const
annotation
=
dom
.
append
(
expression
,
$
(
'
span
'
));
return
{
container
,
expression
,
name
,
label
,
value
,
annotation
};
}
renderElement
(
node
:
ITreeNode
<
RawObjectReplElement
,
FuzzyScore
>
,
index
:
number
,
templateData
:
IRawObjectReplTemplateData
):
void
{
// key
const
element
=
node
.
element
;
templateData
.
label
.
set
(
element
.
name
?
`
${
element
.
name
}
:`
:
''
,
createMatches
(
node
.
filterData
));
if
(
element
.
name
)
{
templateData
.
name
.
textContent
=
`
${
element
.
name
}
:`
;
}
else
{
templateData
.
name
.
textContent
=
''
;
}
// value
renderExpressionValue
(
element
.
value
,
templateData
.
value
,
{
preserveWhitespace
:
true
,
showHover
:
false
,
linkDetector
:
this
.
linkDetector
});
// annotation if any
if
(
element
.
annotation
)
{
templateData
.
annotation
.
className
=
'
annotation codicon codicon-info
'
;
templateData
.
annotation
.
title
=
element
.
annotation
;
}
else
{
templateData
.
annotation
.
className
=
''
;
templateData
.
annotation
.
title
=
''
;
}
}
disposeTemplate
(
templateData
:
IRawObjectReplTemplateData
):
void
{
// noop
}
}
export
class
ReplDelegate
extends
CachedListVirtualDelegate
<
IReplElement
>
{
constructor
(
private
configurationService
:
IConfigurationService
)
{
super
();
}
getHeight
(
element
:
IReplElement
):
number
{
const
config
=
this
.
configurationService
.
getValue
<
IDebugConfiguration
>
(
'
debug
'
);
if
(
!
config
.
console
.
wordWrap
)
{
return
this
.
estimateHeight
(
element
,
true
);
}
return
super
.
getHeight
(
element
);
}
protected
estimateHeight
(
element
:
IReplElement
,
ignoreValueLength
=
false
):
number
{
const
config
=
this
.
configurationService
.
getValue
<
IDebugConfiguration
>
(
'
debug
'
);
const
rowHeight
=
Math
.
ceil
(
1.4
*
config
.
console
.
fontSize
);
const
countNumberOfLines
=
(
str
:
string
)
=>
Math
.
max
(
1
,
(
str
&&
str
.
match
(
/
\r\n
|
\n
/g
)
||
[]).
length
);
const
hasValue
=
(
e
:
any
):
e
is
{
value
:
string
}
=>
typeof
e
.
value
===
'
string
'
;
// Calculate a rough overestimation for the height
// For every 30 characters increase the number of lines needed
if
(
hasValue
(
element
))
{
let
value
=
element
.
value
;
let
valueRows
=
countNumberOfLines
(
value
)
+
(
ignoreValueLength
?
0
:
Math
.
floor
(
value
.
length
/
30
));
return
valueRows
*
rowHeight
;
}
return
rowHeight
;
}
getTemplateId
(
element
:
IReplElement
):
string
{
if
(
element
instanceof
Variable
&&
element
.
name
)
{
return
ReplVariablesRenderer
.
ID
;
}
if
(
element
instanceof
ReplEvaluationResult
)
{
return
ReplEvaluationResultsRenderer
.
ID
;
}
if
(
element
instanceof
ReplEvaluationInput
)
{
return
ReplEvaluationInputsRenderer
.
ID
;
}
if
(
element
instanceof
SimpleReplElement
||
(
element
instanceof
Variable
&&
!
element
.
name
))
{
// Variable with no name is a top level variable which should be rendered like a repl element #17404
return
ReplSimpleElementsRenderer
.
ID
;
}
return
ReplRawObjectsRenderer
.
ID
;
}
hasDynamicHeight
(
element
:
IReplElement
):
boolean
{
// Empty elements should not have dynamic height since they will be invisible
return
element
.
toString
().
length
>
0
;
}
}
function
isDebugSession
(
obj
:
any
):
obj
is
IDebugSession
{
return
typeof
obj
.
getReplElements
===
'
function
'
;
}
export
class
ReplDataSource
implements
IAsyncDataSource
<
IDebugSession
,
IReplElement
>
{
hasChildren
(
element
:
IReplElement
|
IDebugSession
):
boolean
{
if
(
isDebugSession
(
element
))
{
return
true
;
}
return
!!
(
<
IExpressionContainer
>
element
).
hasChildren
;
}
getChildren
(
element
:
IReplElement
|
IDebugSession
):
Promise
<
IReplElement
[]
>
{
if
(
isDebugSession
(
element
))
{
return
Promise
.
resolve
(
element
.
getReplElements
());
}
if
(
element
instanceof
RawObjectReplElement
)
{
return
element
.
getChildren
();
}
return
(
<
IExpression
>
element
).
getChildren
();
}
}
export
class
ReplAccessibilityProvider
implements
IAccessibilityProvider
<
IReplElement
>
{
getAriaLabel
(
element
:
IReplElement
):
string
{
if
(
element
instanceof
Variable
)
{
return
localize
(
'
replVariableAriaLabel
'
,
"
Variable {0} has value {1}, read eval print loop, debug
"
,
element
.
name
,
element
.
value
);
}
if
(
element
instanceof
SimpleReplElement
||
element
instanceof
ReplEvaluationInput
||
element
instanceof
ReplEvaluationResult
)
{
return
localize
(
'
replValueOutputAriaLabel
'
,
"
{0}, read eval print loop, debug
"
,
element
.
value
);
}
if
(
element
instanceof
RawObjectReplElement
)
{
return
localize
(
'
replRawObjectAriaLabel
'
,
"
Repl variable {0} has value {1}, read eval print loop, debug
"
,
element
.
name
,
element
.
value
);
}
return
''
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录