Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
04292e83
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,体验更适合开发者的 AI 搜索 >>
提交
04292e83
编写于
3月 29, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
parameter hints
上级
2118c084
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
4 deletion
+72
-4
src/vs/languages/typescript/common/languageFeatures.ts
src/vs/languages/typescript/common/languageFeatures.ts
+64
-4
src/vs/languages/typescript/common/worker/worker.ts
src/vs/languages/typescript/common/worker/worker.ts
+4
-0
src/vs/languages/typescript/common/worker/workerImpl.ts
src/vs/languages/typescript/common/worker/workerImpl.ts
+4
-0
未找到文件。
src/vs/languages/typescript/common/languageFeatures.ts
浏览文件 @
04292e83
...
...
@@ -13,6 +13,7 @@ import * as ts from 'vs/languages/typescript/common/lib/typescriptServices';
import
AbstractWorker
from
'
./worker/worker
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
SuggestRegistry
}
from
'
vs/editor/contrib/suggest/common/suggest
'
;
import
{
ParameterHintsRegistry
}
from
'
vs/editor/contrib/parameterHints/common/parameterHints
'
;
import
{
OccurrencesRegistry
}
from
'
vs/editor/contrib/wordHighlighter/common/wordHighlighter
'
;
import
{
ExtraInfoRegistry
}
from
'
vs/editor/contrib/hover/common/hover
'
;
import
{
ReferenceRegistry
}
from
'
vs/editor/contrib/referenceSearch/common/referenceSearch
'
;
...
...
@@ -21,6 +22,7 @@ import {DeclarationRegistry} from 'vs/editor/contrib/goToDeclaration/common/goTo
export
default
function
registerLanguageFeatures
(
selector
:
string
,
modelService
:
IModelService
,
worker
:
()
=>
TPromise
<
AbstractWorker
>
):
lifecycle
.
IDisposable
{
const
disposables
:
lifecycle
.
IDisposable
[]
=
[];
disposables
.
push
(
SuggestRegistry
.
register
(
selector
,
new
SuggestAdapter
(
modelService
,
worker
)));
disposables
.
push
(
ParameterHintsRegistry
.
register
(
selector
,
new
ParameterHintsAdapter
(
modelService
,
worker
)));
disposables
.
push
(
ExtraInfoRegistry
.
register
(
selector
,
new
QuickInfoAdapter
(
modelService
,
worker
)));
disposables
.
push
(
OccurrencesRegistry
.
register
(
selector
,
new
OccurrencesAdapter
(
modelService
,
worker
)));
disposables
.
push
(
DeclarationRegistry
.
register
(
selector
,
new
DeclarationAdapter
(
modelService
,
worker
)));
...
...
@@ -79,7 +81,9 @@ class SuggestAdapter extends Adapter implements modes.ISuggestSupport {
return
this
.
_worker
().
then
(
worker
=>
{
return
worker
.
getCompletionsAtPosition
(
resource
.
toString
(),
offset
);
}).
then
(
info
=>
{
if
(
!
info
)
{
return
;
}
let
suggestions
=
info
.
entries
.
map
(
entry
=>
{
return
<
modes
.
ISuggestion
>
{
label
:
entry
.
name
,
...
...
@@ -103,6 +107,9 @@ class SuggestAdapter extends Adapter implements modes.ISuggestSupport {
suggestion
.
label
);
}).
then
(
details
=>
{
if
(
!
details
)
{
return
suggestion
;
}
return
<
modes
.
ISuggestion
>
{
label
:
details
.
name
,
codeSnippet
:
details
.
name
,
...
...
@@ -130,6 +137,59 @@ class SuggestAdapter extends Adapter implements modes.ISuggestSupport {
}
}
class
ParameterHintsAdapter
extends
Adapter
implements
modes
.
IParameterHintsSupport
{
getParameterHintsTriggerCharacters
():
string
[]
{
return
[
'
(
'
,
'
,
'
];
}
shouldTriggerParameterHints
(
context
:
modes
.
ILineContext
,
offset
:
number
):
boolean
{
return
true
;
}
getParameterHints
(
resource
:
URI
,
position
:
editor
.
IPosition
,
triggerCharacter
?:
string
):
TPromise
<
modes
.
IParameterHints
>
{
return
this
.
_worker
().
then
(
worker
=>
worker
.
getSignatureHelpItems
(
resource
.
toString
(),
this
.
_positionToOffset
(
resource
,
position
))).
then
(
info
=>
{
if
(
!
info
)
{
return
;
}
let
ret
=
<
modes
.
IParameterHints
>
{
currentSignature
:
info
.
selectedItemIndex
,
currentParameter
:
info
.
argumentIndex
,
signatures
:
[]
};
info
.
items
.
forEach
(
item
=>
{
let
signature
=
<
modes
.
ISignature
>
{
label
:
''
,
documentation
:
null
,
parameters
:
[]
};
signature
.
label
+=
ts
.
displayPartsToString
(
item
.
prefixDisplayParts
);
item
.
parameters
.
forEach
((
p
,
i
,
a
)
=>
{
let
label
=
ts
.
displayPartsToString
(
p
.
displayParts
);
let
parameter
=
<
modes
.
IParameter
>
{
label
:
label
,
documentation
:
ts
.
displayPartsToString
(
p
.
documentation
),
signatureLabelOffset
:
signature
.
label
.
length
,
signatureLabelEnd
:
signature
.
label
.
length
+
label
.
length
};
signature
.
label
+=
label
;
signature
.
parameters
.
push
(
parameter
);
if
(
i
<
a
.
length
-
1
)
{
signature
.
label
+=
ts
.
displayPartsToString
(
item
.
separatorDisplayParts
);
}
});
signature
.
label
+=
ts
.
displayPartsToString
(
item
.
suffixDisplayParts
);
ret
.
signatures
.
push
(
signature
);
});
return
ret
;
});
}
}
// --- hover ------
class
QuickInfoAdapter
extends
Adapter
implements
modes
.
IExtraInfoSupport
{
...
...
@@ -153,7 +213,7 @@ class QuickInfoAdapter extends Adapter implements modes.IExtraInfoSupport {
class
OccurrencesAdapter
extends
Adapter
implements
modes
.
IOccurrencesSupport
{
findOccurrences
(
resource
:
URI
,
position
:
editor
.
IPosition
,
strict
?:
boolean
):
TPromise
<
modes
.
IOccurence
[]
>
{
findOccurrences
(
resource
:
URI
,
position
:
editor
.
IPosition
,
strict
?:
boolean
):
TPromise
<
modes
.
IOccurence
[]
>
{
return
this
.
_worker
().
then
(
worker
=>
{
return
worker
.
getOccurrencesAtPosition
(
resource
.
toString
(),
this
.
_positionToOffset
(
resource
,
position
));
}).
then
(
entries
=>
{
...
...
@@ -174,7 +234,7 @@ class OccurrencesAdapter extends Adapter implements modes.IOccurrencesSupport {
class
DeclarationAdapter
extends
Adapter
implements
modes
.
IDeclarationSupport
{
canFindDeclaration
(
context
:
modes
.
ILineContext
,
offset
:
number
):
boolean
{
canFindDeclaration
(
context
:
modes
.
ILineContext
,
offset
:
number
):
boolean
{
return
true
;
}
...
...
@@ -212,7 +272,7 @@ class ReferenceAdapter extends Adapter implements modes.IReferenceSupport {
* @returns a list of reference of the symbol at the position in the
* given resource.
*/
findReferences
(
resource
:
URI
,
position
:
editor
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
IReference
[]
>
{
findReferences
(
resource
:
URI
,
position
:
editor
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
IReference
[]
>
{
return
this
.
_worker
().
then
(
worker
=>
{
return
worker
.
getReferencesAtPosition
(
resource
.
toString
(),
this
.
_positionToOffset
(
resource
,
position
));
}).
then
(
entries
=>
{
...
...
src/vs/languages/typescript/common/worker/worker.ts
浏览文件 @
04292e83
...
...
@@ -45,6 +45,10 @@ abstract class AbstractWorker implements IRequestHandler {
throw
notImplemented
();
}
getSignatureHelpItems
(
fileName
:
string
,
position
:
number
):
TPromise
<
ts
.
SignatureHelpItems
>
{
throw
notImplemented
();
}
getQuickInfoAtPosition
(
fileName
:
string
,
position
:
number
):
TPromise
<
ts
.
QuickInfo
>
{
throw
notImplemented
();
}
...
...
src/vs/languages/typescript/common/worker/workerImpl.ts
浏览文件 @
04292e83
...
...
@@ -85,6 +85,10 @@ class TypeScriptWorker extends AbstractWorker implements ts.LanguageServiceHost
return
TPromise
.
as
(
this
.
_languageService
.
getCompletionEntryDetails
(
fileName
,
position
,
entry
));
}
getSignatureHelpItems
(
fileName
:
string
,
position
:
number
):
TPromise
<
ts
.
SignatureHelpItems
>
{
return
TPromise
.
as
(
this
.
_languageService
.
getSignatureHelpItems
(
fileName
,
position
));
}
getQuickInfoAtPosition
(
fileName
:
string
,
position
:
number
):
TPromise
<
ts
.
QuickInfo
>
{
return
TPromise
.
as
(
this
.
_languageService
.
getQuickInfoAtPosition
(
fileName
,
position
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录