Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7fadce43
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,发现更多精彩内容 >>
提交
7fadce43
编写于
6月 04, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move completion providers to use register method
上级
75a64cf2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
21 deletion
+37
-21
extensions/typescript-language-features/src/features/completionItemProvider.ts
...-language-features/src/features/completionItemProvider.ts
+14
-1
extensions/typescript-language-features/src/features/directiveCommentCompletionProvider.ts
...atures/src/features/directiveCommentCompletionProvider.ts
+21
-13
extensions/typescript-language-features/src/languageProvider.ts
...ions/typescript-language-features/src/languageProvider.ts
+2
-7
未找到文件。
extensions/typescript-language-features/src/features/completionItemProvider.ts
浏览文件 @
7fadce43
...
...
@@ -244,7 +244,7 @@ namespace CompletionConfiguration {
}
}
export
default
class
TypeScriptCompletionItemProvider
implements
vscode
.
CompletionItemProvider
{
class
TypeScriptCompletionItemProvider
implements
vscode
.
CompletionItemProvider
{
public
static
readonly
triggerCharacters
=
[
'
.
'
,
'
"
'
,
'
\'
'
,
'
/
'
,
'
@
'
,
'
<
'
];
...
...
@@ -581,3 +581,16 @@ export default class TypeScriptCompletionItemProvider implements vscode.Completi
return
snippet
;
}
}
export
function
register
(
selector
:
vscode
.
DocumentSelector
,
client
:
ITypeScriptServiceClient
,
typingsStatus
:
TypingsStatus
,
fileConfigurationManager
:
FileConfigurationManager
,
commandManager
:
CommandManager
,
)
{
return
vscode
.
languages
.
registerCompletionItemProvider
(
selector
,
new
TypeScriptCompletionItemProvider
(
client
,
typingsStatus
,
fileConfigurationManager
,
commandManager
),
...
TypeScriptCompletionItemProvider
.
triggerCharacters
);
}
\ No newline at end of file
extensions/typescript-language-features/src/features/directiveCommentCompletionProvider.ts
浏览文件 @
7fadce43
...
...
@@ -3,11 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Position
,
CompletionItemProvider
,
CompletionItemKind
,
TextDocument
,
CancellationToken
,
CompletionItem
,
Range
}
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
ITypeScriptServiceClient
}
from
'
../typescriptService
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
interface
Directive
{
...
...
@@ -34,16 +33,16 @@ const directives: Directive[] = [
}
];
export
default
class
DirectiveCommentCompletionProvider
implements
CompletionItemProvider
{
class
DirectiveCommentCompletionProvider
implements
vscode
.
CompletionItemProvider
{
constructor
(
private
readonly
client
:
ITypeScriptServiceClient
,
)
{
}
public
provideCompletionItems
(
document
:
TextDocument
,
position
:
Position
,
_token
:
CancellationToken
):
CompletionItem
[]
{
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
,
_token
:
vscode
.
CancellationToken
):
vscode
.
CompletionItem
[]
{
if
(
!
this
.
client
.
apiVersion
.
has230Features
())
{
return
[];
}
...
...
@@ -58,9 +57,9 @@ export default class DirectiveCommentCompletionProvider implements CompletionIte
const
match
=
prefix
.
match
(
/^
\s
*
\/\/
+
\s?(
@
[
a-zA-Z
\-]
*
)?
$/
);
if
(
match
)
{
return
directives
.
map
(
directive
=>
{
const
item
=
new
CompletionItem
(
directive
.
value
,
CompletionItemKind
.
Snippet
);
const
item
=
new
vscode
.
CompletionItem
(
directive
.
value
,
vscode
.
CompletionItemKind
.
Snippet
);
item
.
detail
=
directive
.
description
;
item
.
range
=
new
Range
(
position
.
line
,
Math
.
max
(
0
,
position
.
character
-
(
match
[
1
]
?
match
[
1
].
length
:
0
)),
position
.
line
,
position
.
character
);
item
.
range
=
new
vscode
.
Range
(
position
.
line
,
Math
.
max
(
0
,
position
.
character
-
(
match
[
1
]
?
match
[
1
].
length
:
0
)),
position
.
line
,
position
.
character
);
return
item
;
});
}
...
...
@@ -68,9 +67,18 @@ export default class DirectiveCommentCompletionProvider implements CompletionIte
}
public
resolveCompletionItem
(
item
:
CompletionItem
,
_token
:
CancellationToken
item
:
vscode
.
CompletionItem
,
_token
:
vscode
.
CancellationToken
)
{
return
item
;
}
}
\ No newline at end of file
}
export
function
register
(
selector
:
vscode
.
DocumentSelector
,
client
:
ITypeScriptServiceClient
,
)
{
return
vscode
.
languages
.
registerCompletionItemProvider
(
selector
,
new
DirectiveCommentCompletionProvider
(
client
),
'
@
'
);
}
extensions/typescript-language-features/src/languageProvider.ts
浏览文件 @
7fadce43
...
...
@@ -104,13 +104,6 @@ export default class LanguageProvider {
const
selector
=
this
.
documentSelector
;
const
config
=
vscode
.
workspace
.
getConfiguration
(
this
.
id
);
const
TypeScriptCompletionItemProvider
=
(
await
import
(
'
./features/completionItemProvider
'
)).
default
;
this
.
disposables
.
push
(
vscode
.
languages
.
registerCompletionItemProvider
(
selector
,
new
TypeScriptCompletionItemProvider
(
client
,
typingsStatus
,
this
.
fileConfigurationManager
,
commandManager
),
...
TypeScriptCompletionItemProvider
.
triggerCharacters
));
this
.
disposables
.
push
(
vscode
.
languages
.
registerCompletionItemProvider
(
selector
,
new
(
await
import
(
'
./features/directiveCommentCompletionProvider
'
)).
default
(
client
),
'
@
'
));
const
{
TypeScriptFormattingProvider
,
FormattingProviderManager
}
=
await
import
(
'
./features/formattingProvider
'
);
const
formattingProvider
=
new
TypeScriptFormattingProvider
(
client
,
this
.
fileConfigurationManager
);
formattingProvider
.
updateConfiguration
(
config
);
...
...
@@ -123,6 +116,8 @@ export default class LanguageProvider {
const
cachedResponse
=
new
CachedNavTreeResponse
();
this
.
disposables
.
push
((
await
import
(
'
./features/completionItemProvider
'
)).
register
(
selector
,
client
,
typingsStatus
,
this
.
fileConfigurationManager
,
commandManager
));
this
.
disposables
.
push
((
await
import
(
'
./features/directiveCommentCompletionProvider
'
)).
register
(
selector
,
client
));
this
.
disposables
.
push
((
await
import
(
'
./features/jsDocCompletionProvider
'
)).
register
(
selector
,
client
,
commandManager
));
this
.
disposables
.
push
((
await
import
(
'
./features/hoverProvider
'
)).
register
(
selector
,
client
));
this
.
disposables
.
push
((
await
import
(
'
./features/definitionProvider
'
)).
register
(
selector
,
client
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录