Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
adf0be09
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,发现更多精彩内容 >>
提交
adf0be09
编写于
2月 03, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parameter Hints Model uses equal instead of hashing for equality check
上级
65b9e937
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
23 deletion
+43
-23
src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts
...tor/contrib/parameterHints/browser/parameterHintsModel.ts
+43
-23
未找到文件。
src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts
浏览文件 @
adf0be09
...
...
@@ -6,7 +6,6 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
import
hash
=
require
(
'
vs/base/common/bits/hash
'
);
import
async
=
require
(
'
vs/base/common/async
'
);
import
events
=
require
(
'
vs/base/common/eventEmitter
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
...
...
@@ -14,26 +13,45 @@ import Modes = require('vs/editor/common/modes');
import
{
ParameterHintsRegistry
,
getParameterHints
}
from
'
../common/parameterHints
'
;
import
{
sequence
}
from
'
vs/base/common/async
'
;
function
hashParameterHints
(
hints
:
Modes
.
IParameterHints
):
string
{
if
(
!
hints
)
{
return
null
;
function
equalsArr
<
T
>
(
a
:
T
[],
b
:
T
[],
equalsFn
:(
a
:
T
,
b
:
T
)
=>
boolean
):
boolean
{
if
(
a
.
length
!==
b
.
length
)
{
return
false
;
}
for
(
let
i
=
0
,
len
=
a
.
length
;
i
<
len
;
i
++
)
{
if
(
!
equalsFn
(
a
[
i
],
b
[
i
]))
{
return
false
;
}
}
return
true
;
}
var
result
=
new
hash
.
SHA1
();
hints
.
signatures
.
forEach
(
s
=>
{
result
.
update
(
s
.
documentation
||
''
);
result
.
update
(
s
.
label
||
''
);
function
equalsParameter
(
a
:
Modes
.
IParameter
,
b
:
Modes
.
IParameter
):
boolean
{
return
(
a
.
documentation
===
b
.
documentation
&&
a
.
label
===
b
.
label
&&
a
.
signatureLabelEnd
===
b
.
signatureLabelEnd
&&
a
.
signatureLabelOffset
===
b
.
signatureLabelOffset
);
}
s
.
parameters
.
forEach
(
p
=>
{
result
.
update
(
p
.
documentation
||
''
);
result
.
update
(
p
.
label
||
''
);
result
.
update
(
p
.
signatureLabelEnd
.
toString
());
result
.
update
(
p
.
signatureLabelOffset
.
toString
());
}
);
});
function
equalsSignature
(
a
:
Modes
.
ISignature
,
b
:
Modes
.
ISignature
):
boolean
{
return
(
a
.
documentation
===
b
.
documentation
&&
a
.
label
===
b
.
label
&&
equalsArr
(
a
.
parameters
,
b
.
parameters
,
equalsParameter
)
);
}
return
result
.
digest
();
function
equalsParameterHints
(
a
:
Modes
.
IParameterHints
,
b
:
Modes
.
IParameterHints
):
boolean
{
if
(
!
a
&&
!
b
)
{
return
true
;
}
if
(
!
a
||
!
b
)
{
return
false
;
}
return
(
equalsArr
(
a
.
signatures
,
b
.
signatures
,
equalsSignature
)
);
}
export
interface
IHintEvent
{
...
...
@@ -49,7 +67,7 @@ export class ParameterHintsModel extends events.EventEmitter {
private
triggerCharactersListeners
:
lifecycle
.
IDisposable
[];
private
active
:
boolean
;
private
hash
:
string
;
private
prevResult
:
Modes
.
IParameterHints
;
private
throttledDelayer
:
async
.
ThrottledDelayer
<
boolean
>
;
constructor
(
editor
:
EditorCommon
.
ICommonCodeEditor
)
{
...
...
@@ -62,7 +80,7 @@ export class ParameterHintsModel extends events.EventEmitter {
this
.
throttledDelayer
=
new
async
.
ThrottledDelayer
<
boolean
>
(
ParameterHintsModel
.
DELAY
);
this
.
active
=
false
;
this
.
hash
=
null
;
this
.
prevResult
=
null
;
this
.
event
(
this
.
editor
,
EditorCommon
.
EventType
.
ModelChanged
,
e
=>
this
.
onModelChanged
());
this
.
event
(
this
.
editor
,
EditorCommon
.
EventType
.
ModelModeChanged
,
encodeURI
=>
this
.
onModelChanged
());
...
...
@@ -76,7 +94,7 @@ export class ParameterHintsModel extends events.EventEmitter {
this
.
active
=
false
;
if
(
!
refresh
)
{
this
.
hash
=
null
;
this
.
prevResult
=
null
;
}
this
.
throttledDelayer
.
cancel
();
...
...
@@ -97,15 +115,17 @@ export class ParameterHintsModel extends events.EventEmitter {
public
doTrigger
(
triggerCharacter
:
string
):
TPromise
<
boolean
>
{
return
getParameterHints
(
this
.
editor
.
getModel
(),
this
.
editor
.
getPosition
(),
triggerCharacter
).
then
(
result
=>
{
var
hash
=
hashParameterHints
(
result
);
if
(
!
result
||
result
.
signatures
.
length
===
0
||
(
this
.
hash
&&
hash
!==
this
.
hash
))
{
let
equalsPrevResult
=
equalsParameterHints
(
this
.
prevResult
,
result
);
if
(
!
result
||
result
.
signatures
.
length
===
0
||
(
this
.
prevResult
&&
!
equalsPrevResult
))
{
this
.
cancel
();
this
.
emit
(
'
cancel
'
);
return
false
;
}
this
.
active
=
true
;
this
.
hash
=
hash
;
this
.
prevResult
=
result
;
var
event
:
IHintEvent
=
{
hints
:
result
};
this
.
emit
(
'
hint
'
,
event
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录