Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
04ccc517
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,发现更多精彩内容 >>
提交
04ccc517
编写于
11月 06, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable strict mode in JS extension
上级
d28123cb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
19 deletion
+23
-19
extensions/javascript/src/features/bowerJSONContribution.ts
extensions/javascript/src/features/bowerJSONContribution.ts
+4
-4
extensions/javascript/src/features/jsonContributions.ts
extensions/javascript/src/features/jsonContributions.ts
+13
-10
extensions/javascript/src/features/packageJSONContribution.ts
...nsions/javascript/src/features/packageJSONContribution.ts
+4
-4
extensions/javascript/tsconfig.json
extensions/javascript/tsconfig.json
+2
-1
未找到文件。
extensions/javascript/src/features/bowerJSONContribution.ts
浏览文件 @
04ccc517
...
...
@@ -46,7 +46,7 @@ export class BowerJSONContribution implements IJSONContribution {
return
Promise
.
resolve
(
null
);
}
public
collectPropertySuggestions
(
resource
:
string
,
location
:
Location
,
currentWord
:
string
,
addValue
:
boolean
,
isLast
:
boolean
,
collector
:
ISuggestionsCollector
):
Thenable
<
any
>
{
public
collectPropertySuggestions
(
resource
:
string
,
location
:
Location
,
currentWord
:
string
,
addValue
:
boolean
,
isLast
:
boolean
,
collector
:
ISuggestionsCollector
):
Thenable
<
any
>
|
null
{
if
((
location
.
matches
([
'
dependencies
'
])
||
location
.
matches
([
'
devDependencies
'
])))
{
if
(
currentWord
.
length
>
0
)
{
let
queryUrl
=
'
https://bower.herokuapp.com/packages/search/
'
+
encodeURIComponent
(
currentWord
);
...
...
@@ -126,7 +126,7 @@ export class BowerJSONContribution implements IJSONContribution {
return
Promise
.
resolve
(
null
);
}
public
resolveSuggestion
(
item
:
CompletionItem
):
Thenable
<
CompletionItem
>
{
public
resolveSuggestion
(
item
:
CompletionItem
):
Thenable
<
CompletionItem
|
null
>
|
null
{
if
(
item
.
kind
===
CompletionItemKind
.
Property
&&
item
.
documentation
===
''
)
{
return
this
.
getInfo
(
item
.
label
).
then
(
documentation
=>
{
if
(
documentation
)
{
...
...
@@ -139,7 +139,7 @@ export class BowerJSONContribution implements IJSONContribution {
return
null
;
}
private
getInfo
(
pack
:
string
):
Thenable
<
string
>
{
private
getInfo
(
pack
:
string
):
Thenable
<
string
|
undefined
>
{
let
queryUrl
=
'
https://bower.herokuapp.com/packages/
'
+
encodeURIComponent
(
pack
);
return
this
.
xhr
({
...
...
@@ -166,7 +166,7 @@ export class BowerJSONContribution implements IJSONContribution {
});
}
public
getInfoContribution
(
resource
:
string
,
location
:
Location
):
Thenable
<
MarkedString
[]
>
{
public
getInfoContribution
(
resource
:
string
,
location
:
Location
):
Thenable
<
MarkedString
[]
|
null
>
|
null
{
if
((
location
.
matches
([
'
dependencies
'
,
'
*
'
])
||
location
.
matches
([
'
devDependencies
'
,
'
*
'
])))
{
let
pack
=
location
.
path
[
location
.
path
.
length
-
1
];
if
(
typeof
pack
===
'
string
'
)
{
...
...
extensions/javascript/src/features/jsonContributions.ts
浏览文件 @
04ccc517
...
...
@@ -24,11 +24,11 @@ export interface ISuggestionsCollector {
export
interface
IJSONContribution
{
getDocumentSelector
():
DocumentSelector
;
getInfoContribution
(
fileName
:
string
,
location
:
Location
):
Thenable
<
MarkedString
[]
>
;
collectPropertySuggestions
(
fileName
:
string
,
location
:
Location
,
currentWord
:
string
,
addValue
:
boolean
,
isLast
:
boolean
,
result
:
ISuggestionsCollector
):
Thenable
<
any
>
;
collectValueSuggestions
(
fileName
:
string
,
location
:
Location
,
result
:
ISuggestionsCollector
):
Thenable
<
any
>
;
getInfoContribution
(
fileName
:
string
,
location
:
Location
):
Thenable
<
MarkedString
[]
|
null
>
|
null
;
collectPropertySuggestions
(
fileName
:
string
,
location
:
Location
,
currentWord
:
string
,
addValue
:
boolean
,
isLast
:
boolean
,
result
:
ISuggestionsCollector
):
Thenable
<
any
>
|
null
;
collectValueSuggestions
(
fileName
:
string
,
location
:
Location
,
result
:
ISuggestionsCollector
):
Thenable
<
any
>
|
null
;
collectDefaultSuggestions
(
fileName
:
string
,
result
:
ISuggestionsCollector
):
Thenable
<
any
>
;
resolveSuggestion
?(
item
:
CompletionItem
):
Thenable
<
CompletionItem
>
;
resolveSuggestion
?(
item
:
CompletionItem
):
Thenable
<
CompletionItem
|
null
>
|
null
;
}
export
function
addJSONProviders
(
xhr
:
XHRRequest
):
Disposable
{
...
...
@@ -47,18 +47,21 @@ export class JSONHoverProvider implements HoverProvider {
constructor
(
private
jsonContribution
:
IJSONContribution
)
{
}
public
provideHover
(
document
:
TextDocument
,
position
:
Position
,
token
:
CancellationToken
):
Thenable
<
Hover
>
{
public
provideHover
(
document
:
TextDocument
,
position
:
Position
,
token
:
CancellationToken
):
Thenable
<
Hover
>
|
null
{
let
fileName
=
basename
(
document
.
fileName
);
let
offset
=
document
.
offsetAt
(
position
);
let
location
=
getLocation
(
document
.
getText
(),
offset
);
let
node
=
location
.
previousNode
;
if
(
!
location
.
previousNode
)
{
return
null
;
}
const
node
=
location
.
previousNode
;
if
(
node
&&
node
.
offset
<=
offset
&&
offset
<=
node
.
offset
+
node
.
length
)
{
let
promise
=
this
.
jsonContribution
.
getInfoContribution
(
fileName
,
location
);
if
(
promise
)
{
return
promise
.
then
(
htmlContent
=>
{
let
range
=
new
Range
(
document
.
positionAt
(
node
.
offset
),
document
.
positionAt
(
node
.
offset
+
node
.
length
));
let
result
:
Hover
=
{
contents
:
htmlContent
,
contents
:
htmlContent
||
[]
,
range
:
range
};
return
result
;
...
...
@@ -74,7 +77,7 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
constructor
(
private
jsonContribution
:
IJSONContribution
)
{
}
public
resolveCompletionItem
(
item
:
CompletionItem
,
token
:
CancellationToken
):
Thenable
<
CompletionItem
>
{
public
resolveCompletionItem
(
item
:
CompletionItem
,
token
:
CancellationToken
):
Thenable
<
CompletionItem
|
null
>
{
if
(
this
.
jsonContribution
.
resolveSuggestion
)
{
let
resolver
=
this
.
jsonContribution
.
resolveSuggestion
(
item
);
if
(
resolver
)
{
...
...
@@ -84,7 +87,7 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
return
Promise
.
resolve
(
item
);
}
public
provideCompletionItems
(
document
:
TextDocument
,
position
:
Position
,
token
:
CancellationToken
):
Thenable
<
CompletionList
>
{
public
provideCompletionItems
(
document
:
TextDocument
,
position
:
Position
,
token
:
CancellationToken
):
Thenable
<
CompletionList
|
null
>
|
null
{
let
fileName
=
basename
(
document
.
fileName
);
...
...
@@ -118,7 +121,7 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
log
:
(
message
:
string
)
=>
console
.
log
(
message
)
};
let
collectPromise
:
Thenable
<
any
>
=
null
;
let
collectPromise
:
Thenable
<
any
>
|
null
=
null
;
if
(
location
.
isAtPropertyKey
)
{
let
addValue
=
!
location
.
previousNode
||
!
location
.
previousNode
.
columnOffset
;
...
...
extensions/javascript/src/features/packageJSONContribution.ts
浏览文件 @
04ccc517
...
...
@@ -54,7 +54,7 @@ export class PackageJSONContribution implements IJSONContribution {
addValue
:
boolean
,
isLast
:
boolean
,
collector
:
ISuggestionsCollector
):
Thenable
<
any
>
{
):
Thenable
<
any
>
|
null
{
if
((
location
.
matches
([
'
dependencies
'
])
||
location
.
matches
([
'
devDependencies
'
])
||
location
.
matches
([
'
optionalDependencies
'
])
||
location
.
matches
([
'
peerDependencies
'
])))
{
let
queryUrl
:
string
;
if
(
currentWord
.
length
>
0
)
{
...
...
@@ -129,7 +129,7 @@ export class PackageJSONContribution implements IJSONContribution {
fileName
:
string
,
location
:
Location
,
result
:
ISuggestionsCollector
):
Thenable
<
any
>
{
):
Thenable
<
any
>
|
null
{
if
((
location
.
matches
([
'
dependencies
'
,
'
*
'
])
||
location
.
matches
([
'
devDependencies
'
,
'
*
'
])
||
location
.
matches
([
'
optionalDependencies
'
,
'
*
'
])
||
location
.
matches
([
'
peerDependencies
'
,
'
*
'
])))
{
let
currentKey
=
location
.
path
[
location
.
path
.
length
-
1
];
if
(
typeof
currentKey
===
'
string
'
)
{
...
...
@@ -174,7 +174,7 @@ export class PackageJSONContribution implements IJSONContribution {
return
null
;
}
public
resolveSuggestion
(
item
:
CompletionItem
):
Thenable
<
CompletionItem
>
{
public
resolveSuggestion
(
item
:
CompletionItem
):
Thenable
<
CompletionItem
|
null
>
|
null
{
if
(
item
.
kind
===
CompletionItemKind
.
Property
&&
item
.
documentation
===
''
)
{
return
this
.
getInfo
(
item
.
label
).
then
(
infos
=>
{
if
(
infos
.
length
>
0
)
{
...
...
@@ -218,7 +218,7 @@ export class PackageJSONContribution implements IJSONContribution {
});
}
public
getInfoContribution
(
fileName
:
string
,
location
:
Location
):
Thenable
<
MarkedString
[]
>
{
public
getInfoContribution
(
fileName
:
string
,
location
:
Location
):
Thenable
<
MarkedString
[]
|
null
>
|
null
{
if
((
location
.
matches
([
'
dependencies
'
,
'
*
'
])
||
location
.
matches
([
'
devDependencies
'
,
'
*
'
])
||
location
.
matches
([
'
optionalDependencies
'
,
'
*
'
])
||
location
.
matches
([
'
peerDependencies
'
,
'
*
'
])))
{
let
pack
=
location
.
path
[
location
.
path
.
length
-
1
];
if
(
typeof
pack
===
'
string
'
)
{
...
...
extensions/javascript/tsconfig.json
浏览文件 @
04ccc517
...
...
@@ -5,7 +5,8 @@
"outDir"
:
"./out"
,
"lib"
:
[
"es2015"
]
],
"strict"
:
true
},
"include"
:
[
"src/**/*"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录