Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a7ddb97e
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,发现更多精彩内容 >>
提交
a7ddb97e
编写于
10月 04, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix strict property init in parameterHintWidget
For #78168
上级
92514c46
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
39 deletion
+65
-39
src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts
src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts
+65
-39
未找到文件。
src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts
浏览文件 @
a7ddb97e
...
...
@@ -34,13 +34,17 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
private
readonly
model
=
this
.
_register
(
new
MutableDisposable
<
ParameterHintsModel
>
());
private
readonly
keyVisible
:
IContextKey
<
boolean
>
;
private
readonly
keyMultipleSignatures
:
IContextKey
<
boolean
>
;
private
element
:
HTMLElement
;
private
signature
:
HTMLElement
;
private
docs
:
HTMLElement
;
private
overloads
:
HTMLElement
;
private
visible
:
boolean
;
private
announcedLabel
:
string
|
null
;
private
scrollbar
:
DomScrollableElement
;
private
domNodes
?:
{
readonly
element
:
HTMLElement
;
readonly
signature
:
HTMLElement
;
readonly
docs
:
HTMLElement
;
readonly
overloads
:
HTMLElement
;
readonly
scrollbar
:
DomScrollableElement
;
};
private
visible
:
boolean
=
false
;
private
announcedLabel
:
string
|
null
=
null
;
// Editor.IContentWidget.allowEditorOverflow
allowEditorOverflow
=
true
;
...
...
@@ -56,7 +60,6 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
this
.
model
.
value
=
new
ParameterHintsModel
(
editor
);
this
.
keyVisible
=
Context
.
Visible
.
bindTo
(
contextKeyService
);
this
.
keyMultipleSignatures
=
Context
.
MultipleSignatures
.
bindTo
(
contextKeyService
);
this
.
visible
=
false
;
this
.
_register
(
this
.
model
.
value
.
onChangedHints
(
newParameterHints
=>
{
if
(
newParameterHints
)
{
...
...
@@ -69,8 +72,8 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
}
private
createParamaterHintDOMNodes
()
{
this
.
element
=
$
(
'
.editor-widget.parameter-hints-widget
'
);
const
wrapper
=
dom
.
append
(
this
.
element
,
$
(
'
.wrapper
'
));
const
element
=
$
(
'
.editor-widget.parameter-hints-widget
'
);
const
wrapper
=
dom
.
append
(
element
,
$
(
'
.wrapper
'
));
wrapper
.
tabIndex
=
-
1
;
const
buttons
=
dom
.
append
(
wrapper
,
$
(
'
.buttons
'
));
...
...
@@ -83,21 +86,29 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
const
onNextClick
=
stop
(
domEvent
(
next
,
'
click
'
));
this
.
_register
(
onNextClick
(
this
.
next
,
this
));
this
.
overloads
=
dom
.
append
(
wrapper
,
$
(
'
.overloads
'
));
const
overloads
=
dom
.
append
(
wrapper
,
$
(
'
.overloads
'
));
const
body
=
$
(
'
.body
'
);
this
.
scrollbar
=
new
DomScrollableElement
(
body
,
{});
this
.
_register
(
this
.
scrollbar
);
wrapper
.
appendChild
(
this
.
scrollbar
.
getDomNode
());
const
scrollbar
=
new
DomScrollableElement
(
body
,
{});
this
.
_register
(
scrollbar
);
wrapper
.
appendChild
(
scrollbar
.
getDomNode
());
this
.
signature
=
dom
.
append
(
body
,
$
(
'
.signature
'
));
const
signature
=
dom
.
append
(
body
,
$
(
'
.signature
'
));
const
docs
=
dom
.
append
(
body
,
$
(
'
.docs
'
));
this
.
docs
=
dom
.
append
(
body
,
$
(
'
.docs
'
));
element
.
style
.
userSelect
=
'
text
'
;
this
.
domNodes
=
{
element
,
signature
,
overloads
,
docs
,
scrollbar
,
};
this
.
editor
.
addContentWidget
(
this
);
this
.
hide
();
this
.
element
.
style
.
userSelect
=
'
text
'
;
this
.
_register
(
this
.
editor
.
onDidChangeCursorSelection
(
e
=>
{
if
(
this
.
visible
)
{
this
.
editor
.
layoutContentWidget
(
this
);
...
...
@@ -105,8 +116,11 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
}));
const
updateFont
=
()
=>
{
if
(
!
this
.
domNodes
)
{
return
;
}
const
fontInfo
=
this
.
editor
.
getOption
(
EditorOption
.
fontInfo
);
this
.
element
.
style
.
fontSize
=
`
${
fontInfo
.
fontSize
}
px`
;
this
.
domNodes
.
element
.
style
.
fontSize
=
`
${
fontInfo
.
fontSize
}
px`
;
};
updateFont
();
...
...
@@ -124,13 +138,17 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
return
;
}
if
(
!
this
.
element
)
{
if
(
!
this
.
domNodes
)
{
this
.
createParamaterHintDOMNodes
();
}
this
.
keyVisible
.
set
(
true
);
this
.
visible
=
true
;
setTimeout
(()
=>
dom
.
addClass
(
this
.
element
,
'
visible
'
),
100
);
setTimeout
(()
=>
{
if
(
this
.
domNodes
)
{
dom
.
addClass
(
this
.
domNodes
.
element
,
'
visible
'
);
}
},
100
);
this
.
editor
.
layoutContentWidget
(
this
);
}
...
...
@@ -139,14 +157,12 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
return
;
}
if
(
!
this
.
element
)
{
this
.
createParamaterHintDOMNodes
();
}
this
.
keyVisible
.
reset
();
this
.
visible
=
false
;
this
.
announcedLabel
=
null
;
dom
.
removeClass
(
this
.
element
,
'
visible
'
);
if
(
this
.
domNodes
)
{
dom
.
removeClass
(
this
.
domNodes
.
element
,
'
visible
'
);
}
this
.
editor
.
layoutContentWidget
(
this
);
}
...
...
@@ -161,12 +177,16 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
}
private
render
(
hints
:
modes
.
SignatureHelp
):
void
{
if
(
!
this
.
domNodes
)
{
return
;
}
const
multiple
=
hints
.
signatures
.
length
>
1
;
dom
.
toggleClass
(
this
.
element
,
'
multiple
'
,
multiple
);
dom
.
toggleClass
(
this
.
domNodes
.
element
,
'
multiple
'
,
multiple
);
this
.
keyMultipleSignatures
.
set
(
multiple
);
this
.
signature
.
innerHTML
=
''
;
this
.
docs
.
innerHTML
=
''
;
this
.
domNodes
.
signature
.
innerHTML
=
''
;
this
.
do
mNodes
.
do
cs
.
innerHTML
=
''
;
const
signature
=
hints
.
signatures
[
hints
.
activeSignature
];
...
...
@@ -174,7 +194,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
return
;
}
const
code
=
dom
.
append
(
this
.
signature
,
$
(
'
.code
'
));
const
code
=
dom
.
append
(
this
.
domNodes
.
signature
,
$
(
'
.code
'
));
const
hasParameters
=
signature
.
parameters
.
length
>
0
;
const
fontInfo
=
this
.
editor
.
getOption
(
EditorOption
.
fontInfo
);
...
...
@@ -203,17 +223,17 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
this
.
renderDisposeables
.
add
(
renderedContents
);
documentation
.
appendChild
(
renderedContents
.
element
);
}
dom
.
append
(
this
.
docs
,
$
(
'
p
'
,
{},
documentation
));
dom
.
append
(
this
.
do
mNodes
.
do
cs
,
$
(
'
p
'
,
{},
documentation
));
}
if
(
signature
.
documentation
===
undefined
)
{
/** no op */
}
else
if
(
typeof
signature
.
documentation
===
'
string
'
)
{
dom
.
append
(
this
.
docs
,
$
(
'
p
'
,
{},
signature
.
documentation
));
dom
.
append
(
this
.
do
mNodes
.
do
cs
,
$
(
'
p
'
,
{},
signature
.
documentation
));
}
else
{
const
renderedContents
=
this
.
markdownRenderer
.
render
(
signature
.
documentation
);
dom
.
addClass
(
renderedContents
.
element
,
'
markdown-docs
'
);
this
.
renderDisposeables
.
add
(
renderedContents
);
dom
.
append
(
this
.
docs
,
renderedContents
.
element
);
dom
.
append
(
this
.
do
mNodes
.
do
cs
,
renderedContents
.
element
);
}
let
hasDocs
=
false
;
...
...
@@ -230,8 +250,8 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
hasDocs
=
true
;
}
dom
.
toggleClass
(
this
.
signature
,
'
has-docs
'
,
hasDocs
);
dom
.
toggleClass
(
this
.
docs
,
'
empty
'
,
!
hasDocs
);
dom
.
toggleClass
(
this
.
domNodes
.
signature
,
'
has-docs
'
,
hasDocs
);
dom
.
toggleClass
(
this
.
do
mNodes
.
do
cs
,
'
empty
'
,
!
hasDocs
);
let
currentOverload
=
String
(
hints
.
activeSignature
+
1
);
...
...
@@ -239,7 +259,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
currentOverload
+=
`/
${
hints
.
signatures
.
length
}
`
;
}
this
.
overloads
.
textContent
=
currentOverload
;
this
.
domNodes
.
overloads
.
textContent
=
currentOverload
;
if
(
activeParameter
)
{
const
labelToAnnounce
=
this
.
getParameterLabel
(
signature
,
hints
.
activeParameter
);
...
...
@@ -253,7 +273,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
}
this
.
editor
.
layoutContentWidget
(
this
);
this
.
scrollbar
.
scanDomNode
();
this
.
domNodes
.
scrollbar
.
scanDomNode
();
}
private
renderParameters
(
parent
:
HTMLElement
,
signature
:
modes
.
SignatureInformation
,
currentParameter
:
number
):
void
{
...
...
@@ -317,7 +337,10 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
}
getDomNode
():
HTMLElement
{
return
this
.
element
;
if
(
!
this
.
domNodes
)
{
this
.
createParamaterHintDOMNodes
();
}
return
this
.
domNodes
!
.
element
;
}
getId
():
string
{
...
...
@@ -331,10 +354,13 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget,
}
private
updateMaxHeight
():
void
{
if
(
!
this
.
domNodes
)
{
return
;
}
const
height
=
Math
.
max
(
this
.
editor
.
getLayoutInfo
().
height
/
4
,
250
);
const
maxHeight
=
`
${
height
}
px`
;
this
.
element
.
style
.
maxHeight
=
maxHeight
;
const
wrapper
=
this
.
element
.
getElementsByClassName
(
'
wrapper
'
)
as
HTMLCollectionOf
<
HTMLElement
>
;
this
.
domNodes
.
element
.
style
.
maxHeight
=
maxHeight
;
const
wrapper
=
this
.
domNodes
.
element
.
getElementsByClassName
(
'
wrapper
'
)
as
HTMLCollectionOf
<
HTMLElement
>
;
if
(
wrapper
.
length
)
{
wrapper
[
0
].
style
.
maxHeight
=
maxHeight
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录