Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
76563841
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,发现更多精彩内容 >>
提交
76563841
编写于
2月 09, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#19733 Implement intellisense for language specific editor settings in configuration defaults
上级
b5485273
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
101 addition
and
0 deletion
+101
-0
extensions/extension-editing/package.json
extensions/extension-editing/package.json
+5
-0
extensions/extension-editing/src/extension.ts
extensions/extension-editing/src/extension.ts
+12
-0
extensions/extension-editing/src/packageDocumentHelper.ts
extensions/extension-editing/src/packageDocumentHelper.ts
+84
-0
未找到文件。
extensions/extension-editing/package.json
浏览文件 @
76563841
...
...
@@ -10,6 +10,7 @@
"Other"
],
"activationEvents"
:
[
"onLanguage:json"
,
"onLanguage:typescript"
],
"main"
:
"./out/extension"
,
...
...
@@ -17,6 +18,10 @@
"compile"
:
"gulp compile-extension:extension-editing"
,
"watch"
:
"gulp watch-extension:extension-editing"
},
"dependencies"
:
{
"jsonc-parser"
:
"^0.3.1"
,
"vscode-nls"
:
"^2.0.1"
},
"contributes"
:
{
"jsonValidation"
:
[
{
...
...
extensions/extension-editing/src/extension.ts
浏览文件 @
76563841
...
...
@@ -7,10 +7,14 @@
import
*
as
vscode
from
'
vscode
'
;
import
*
as
ts
from
'
typescript
'
;
import
{
PackageDocument
}
from
'
./packageDocumentHelper
'
;
export
function
activate
(
context
:
vscode
.
ExtensionContext
)
{
const
registration
=
vscode
.
languages
.
registerDocumentLinkProvider
({
language
:
'
typescript
'
,
pattern
:
'
**/vscode.d.ts
'
},
_linkProvider
);
context
.
subscriptions
.
push
(
registration
);
//package.json suggestions
context
.
subscriptions
.
push
(
registerPackageDocumentCompletions
());
}
const
_linkProvider
=
new
class
implements
vscode
.
DocumentLinkProvider
{
...
...
@@ -101,3 +105,11 @@ namespace ast {
};
}
}
function
registerPackageDocumentCompletions
():
vscode
.
Disposable
{
return
vscode
.
languages
.
registerCompletionItemProvider
({
language
:
'
json
'
,
pattern
:
'
**/**/package.json
'
},
{
provideCompletionItems
(
document
,
position
,
token
)
{
return
new
PackageDocument
(
document
).
provideCompletionItems
(
position
,
token
);
}
});
}
\ No newline at end of file
extensions/extension-editing/src/packageDocumentHelper.ts
0 → 100644
浏览文件 @
76563841
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
vscode
from
'
vscode
'
;
import
{
getLocation
,
Location
}
from
'
jsonc-parser
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
export
class
PackageDocument
{
constructor
(
private
document
:
vscode
.
TextDocument
)
{
}
public
provideCompletionItems
(
position
:
vscode
.
Position
,
token
:
vscode
.
CancellationToken
):
vscode
.
ProviderResult
<
vscode
.
CompletionItem
[]
>
{
const
location
=
getLocation
(
this
.
document
.
getText
(),
this
.
document
.
offsetAt
(
position
));
if
(
location
.
path
.
length
>=
2
&&
location
.
path
[
1
]
===
'
configurationDefaults
'
)
{
return
this
.
provideLanguageOverridesCompletionItems
(
location
,
position
);
}
}
private
provideLanguageOverridesCompletionItems
(
location
:
Location
,
position
:
vscode
.
Position
):
vscode
.
ProviderResult
<
vscode
.
CompletionItem
[]
>
{
let
range
=
this
.
document
.
getWordRangeAtPosition
(
position
)
||
new
vscode
.
Range
(
position
,
position
);
const
text
=
this
.
document
.
getText
(
range
);
if
(
location
.
path
.
length
===
2
)
{
let
snippet
=
'
"[${1:language}]": {
\n\t
"$0"
\n
}
'
;
// Suggestion model word matching includes quotes,
// hence exclude the starting quote from the snippet and the range
// ending quote gets replaced
if
(
text
.
startsWith
(
'
"
'
))
{
range
=
new
vscode
.
Range
(
new
vscode
.
Position
(
range
.
start
.
line
,
range
.
start
.
character
+
1
),
range
.
end
);
snippet
=
snippet
.
substring
(
1
);
}
return
Promise
.
resolve
([
this
.
newSnippetCompletionItem
({
label
:
localize
(
'
languageSpecificEditorSettings
'
,
"
Language specific editor settings
"
),
documentation
:
localize
(
'
languageSpecificEditorSettingsDescription
'
,
"
Override editor settings for language
"
),
snippet
,
range
})]);
}
if
(
location
.
path
.
length
===
3
&&
location
.
previousNode
&&
location
.
previousNode
.
value
.
startsWith
(
'
[
'
))
{
// Suggestion model word matching includes starting quote and open sqaure bracket
// Hence exclude them from the proposal range
range
=
new
vscode
.
Range
(
new
vscode
.
Position
(
range
.
start
.
line
,
range
.
start
.
character
+
2
),
range
.
end
);
return
vscode
.
languages
.
getLanguages
().
then
(
languages
=>
{
return
languages
.
map
(
l
=>
{
// Suggestion model word matching includes closed sqaure bracket and ending quote
// Hence include them in the proposal to replace
return
this
.
newSimpleCompletionItem
(
l
,
range
,
''
,
l
+
'
]"
'
);
});
});
}
return
Promise
.
resolve
([]);
}
private
newSimpleCompletionItem
(
text
:
string
,
range
:
vscode
.
Range
,
description
?:
string
,
insertText
?:
string
):
vscode
.
CompletionItem
{
const
item
=
new
vscode
.
CompletionItem
(
text
);
item
.
kind
=
vscode
.
CompletionItemKind
.
Value
;
item
.
detail
=
description
;
item
.
insertText
=
insertText
?
insertText
:
text
;
item
.
range
=
range
;
return
item
;
}
private
newSnippetCompletionItem
(
o
:
{
label
:
string
;
documentation
?:
string
;
snippet
:
string
;
range
:
vscode
.
Range
;
}):
vscode
.
CompletionItem
{
const
item
=
new
vscode
.
CompletionItem
(
o
.
label
);
item
.
kind
=
vscode
.
CompletionItemKind
.
Value
;
item
.
documentation
=
o
.
documentation
;
item
.
insertText
=
new
vscode
.
SnippetString
(
o
.
snippet
);
item
.
range
=
o
.
range
;
return
item
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录