Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ee3553c5
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,发现更多精彩内容 >>
提交
ee3553c5
编写于
10月 27, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get completion config for resource
上级
99969120
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
28 deletion
+24
-28
extensions/typescript/src/features/completionItemProvider.ts
extensions/typescript/src/features/completionItemProvider.ts
+24
-26
extensions/typescript/src/typescriptMain.ts
extensions/typescript/src/typescriptMain.ts
+0
-2
未找到文件。
extensions/typescript/src/features/completionItemProvider.ts
浏览文件 @
ee3553c5
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
CompletionItem
,
TextDocument
,
Position
,
CompletionItemKind
,
CompletionItemProvider
,
CancellationToken
,
TextEdit
,
Range
,
SnippetString
,
workspace
,
ProviderResult
,
CompletionContext
,
commands
}
from
'
vscode
'
;
import
{
CompletionItem
,
TextDocument
,
Position
,
CompletionItemKind
,
CompletionItemProvider
,
CancellationToken
,
TextEdit
,
Range
,
SnippetString
,
workspace
,
ProviderResult
,
CompletionContext
,
commands
,
Uri
}
from
'
vscode
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
TypingsStatus
from
'
../utils/typingsStatus
'
;
...
...
@@ -21,17 +21,18 @@ let localize = nls.loadMessageBundle();
class
MyCompletionItem
extends
CompletionItem
{
constructor
(
public
position
:
Position
,
public
document
:
TextDocument
,
public
readonly
position
:
Position
,
public
readonly
document
:
TextDocument
,
entry
:
CompletionEntry
,
enableDotCompletions
:
boolean
,
enableCallCompletions
:
boolean
public
readonly
useCodeSnippetsOnMethodSuggest
:
boolean
)
{
super
(
entry
.
name
);
this
.
sortText
=
entry
.
sortText
;
this
.
kind
=
MyCompletionItem
.
convertKind
(
entry
.
kind
);
this
.
position
=
position
;
this
.
commitCharacters
=
MyCompletionItem
.
getCommitCharacters
(
enableDotCompletions
,
enableCallCompletions
,
entry
.
kind
);
this
.
commitCharacters
=
MyCompletionItem
.
getCommitCharacters
(
enableDotCompletions
,
!
useCodeSnippetsOnMethodSuggest
,
entry
.
kind
);
if
(
entry
.
replacementSpan
)
{
let
span
:
protocol
.
TextSpan
=
entry
.
replacementSpan
;
// The indexing for the range returned by the server uses 1-based indexing.
...
...
@@ -137,12 +138,6 @@ namespace Configuration {
export
default
class
TypeScriptCompletionItemProvider
implements
CompletionItemProvider
{
private
readonly
commandId
:
string
;
private
config
:
Configuration
=
{
useCodeSnippetsOnMethodSuggest
:
false
,
nameSuggestions
:
true
,
quickSuggestionsForPaths
:
true
};
constructor
(
private
client
:
ITypescriptServiceClient
,
mode
:
string
,
...
...
@@ -152,16 +147,6 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
commands
.
registerCommand
(
this
.
commandId
,
this
.
applyCompletionCodeAction
,
this
);
}
public
updateConfiguration
():
void
{
// Use shared setting for js and ts
const
typeScriptConfig
=
workspace
.
getConfiguration
(
'
typescript
'
);
this
.
config
.
useCodeSnippetsOnMethodSuggest
=
typeScriptConfig
.
get
<
boolean
>
(
Configuration
.
useCodeSnippetsOnMethodSuggest
,
false
);
this
.
config
.
quickSuggestionsForPaths
=
typeScriptConfig
.
get
<
boolean
>
(
Configuration
.
quickSuggestionsForPaths
,
true
);
this
.
config
.
nameSuggestions
=
workspace
.
getConfiguration
(
'
javascript
'
).
get
(
Configuration
.
nameSuggestions
,
true
);
}
public
async
provideCompletionItems
(
document
:
TextDocument
,
position
:
Position
,
...
...
@@ -184,8 +169,10 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
return
[];
}
const
config
=
this
.
getConfiguration
(
document
.
uri
);
if
(
context
.
triggerCharacter
===
'
"
'
||
context
.
triggerCharacter
===
'
\'
'
)
{
if
(
!
this
.
config
.
quickSuggestionsForPaths
)
{
if
(
!
config
.
quickSuggestionsForPaths
)
{
return
[];
}
...
...
@@ -197,7 +184,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
}
if
(
context
.
triggerCharacter
===
'
/
'
)
{
if
(
!
this
.
config
.
quickSuggestionsForPaths
)
{
if
(
!
config
.
quickSuggestionsForPaths
)
{
return
[];
}
...
...
@@ -252,10 +239,10 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
}
for
(
const
element
of
body
)
{
if
(
element
.
kind
===
PConst
.
Kind
.
warning
&&
!
this
.
config
.
nameSuggestions
)
{
if
(
element
.
kind
===
PConst
.
Kind
.
warning
&&
!
config
.
nameSuggestions
)
{
continue
;
}
const
item
=
new
MyCompletionItem
(
position
,
document
,
element
,
enableDotCompletions
,
!
this
.
config
.
useCodeSnippetsOnMethodSuggest
);
const
item
=
new
MyCompletionItem
(
position
,
document
,
element
,
enableDotCompletions
,
config
.
useCodeSnippetsOnMethodSuggest
);
completionItems
.
push
(
item
);
}
}
...
...
@@ -296,7 +283,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
};
}
if
(
detail
&&
this
.
config
.
useCodeSnippetsOnMethodSuggest
&&
(
item
.
kind
===
CompletionItemKind
.
Function
||
item
.
kind
===
CompletionItemKind
.
Method
))
{
if
(
detail
&&
item
.
useCodeSnippetsOnMethodSuggest
&&
(
item
.
kind
===
CompletionItemKind
.
Function
||
item
.
kind
===
CompletionItemKind
.
Method
))
{
return
this
.
isValidFunctionCompletionContext
(
filepath
,
item
.
position
).
then
(
shouldCompleteFunction
=>
{
if
(
shouldCompleteFunction
)
{
item
.
insertText
=
this
.
snippetForFunctionCall
(
detail
);
...
...
@@ -366,4 +353,15 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
}
return
true
;
}
private
getConfiguration
(
resource
:
Uri
):
Configuration
{
// Use shared setting for js and ts
const
typeScriptConfig
=
workspace
.
getConfiguration
(
'
typescript
'
,
resource
);
return
{
useCodeSnippetsOnMethodSuggest
:
typeScriptConfig
.
get
<
boolean
>
(
Configuration
.
useCodeSnippetsOnMethodSuggest
,
false
),
quickSuggestionsForPaths
:
typeScriptConfig
.
get
<
boolean
>
(
Configuration
.
quickSuggestionsForPaths
,
true
),
nameSuggestions
:
workspace
.
getConfiguration
(
'
javascript
'
,
resource
).
get
(
Configuration
.
nameSuggestions
,
true
)
};
}
}
extensions/typescript/src/typescriptMain.ts
浏览文件 @
ee3553c5
...
...
@@ -236,8 +236,6 @@ class LanguageProvider {
const
config
=
workspace
.
getConfiguration
(
this
.
id
);
const
completionItemProvider
=
new
(
await
import
(
'
./features/completionItemProvider
'
)).
default
(
client
,
this
.
description
.
id
,
this
.
typingsStatus
);
completionItemProvider
.
updateConfiguration
();
this
.
toUpdateOnConfigurationChanged
.
push
(
completionItemProvider
);
this
.
disposables
.
push
(
languages
.
registerCompletionItemProvider
(
selector
,
completionItemProvider
,
'
.
'
,
'
"
'
,
'
\'
'
,
'
/
'
,
'
@
'
));
this
.
disposables
.
push
(
languages
.
registerCompletionItemProvider
(
selector
,
new
(
await
import
(
'
./features/directiveCommentCompletionProvider
'
)).
default
(
client
),
'
@
'
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录