Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
6eb4cd9d
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
6eb4cd9d
编写于
10月 08, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tsfmt - extensions/javascript
上级
1ea46436
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
64 addition
and
62 deletion
+64
-62
extensions/javascript/src/features/bowerJSONContribution.ts
extensions/javascript/src/features/bowerJSONContribution.ts
+21
-21
extensions/javascript/src/features/jsonContributions.ts
extensions/javascript/src/features/jsonContributions.ts
+21
-19
extensions/javascript/src/features/markedTextUtil.ts
extensions/javascript/src/features/markedTextUtil.ts
+2
-2
extensions/javascript/src/features/packageJSONContribution.ts
...nsions/javascript/src/features/packageJSONContribution.ts
+17
-17
extensions/javascript/src/javascriptMain.ts
extensions/javascript/src/javascriptMain.ts
+3
-3
未找到文件。
extensions/javascript/src/features/bowerJSONContribution.ts
浏览文件 @
6eb4cd9d
...
...
@@ -4,37 +4,37 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
,
DocumentSelector
}
from
'
vscode
'
;
import
{
IJSONContribution
,
ISuggestionsCollector
}
from
'
./jsonContributions
'
;
import
{
XHRRequest
}
from
'
request-light
'
;
import
{
Location
}
from
'
jsonc-parser
'
;
import
{
textToMarkedString
}
from
'
./markedTextUtil
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
,
DocumentSelector
}
from
'
vscode
'
;
import
{
IJSONContribution
,
ISuggestionsCollector
}
from
'
./jsonContributions
'
;
import
{
XHRRequest
}
from
'
request-light
'
;
import
{
Location
}
from
'
jsonc-parser
'
;
import
{
textToMarkedString
}
from
'
./markedTextUtil
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
export
class
BowerJSONContribution
implements
IJSONContribution
{
private
topRanked
=
[
'
twitter
'
,
'
bootstrap
'
,
'
angular-1.1.6
'
,
'
angular-latest
'
,
'
angulerjs
'
,
'
d3
'
,
'
myjquery
'
,
'
jq
'
,
'
abcdef1234567890
'
,
'
jQuery
'
,
'
jquery-1.11.1
'
,
'
jquery
'
,
'
sushi-vanilla-x-data
'
,
'
font-awsome
'
,
'
Font-Awesome
'
,
'
font-awesome
'
,
'
fontawesome
'
,
'
html5-boilerplate
'
,
'
impress.js
'
,
'
homebrew
'
,
'
backbone
'
,
'
moment1
'
,
'
momentjs
'
,
'
moment
'
,
'
linux
'
,
'
animate.css
'
,
'
animate-css
'
,
'
reveal.js
'
,
'
jquery-file-upload
'
,
'
blueimp-file-upload
'
,
'
threejs
'
,
'
express
'
,
'
chosen
'
,
'
normalize-css
'
,
'
normalize.css
'
,
'
semantic
'
,
'
semantic-ui
'
,
'
Semantic-UI
'
,
'
modernizr
'
,
'
underscore
'
,
'
underscore1
'
,
'
material-design-icons
'
,
'
ionic
'
,
'
chartjs
'
,
'
Chart.js
'
,
'
nnnick-chartjs
'
,
'
select2-ng
'
,
'
select2-dist
'
,
'
phantom
'
,
'
skrollr
'
,
'
scrollr
'
,
'
less.js
'
,
'
leancss
'
,
'
parser-lib
'
,
'
hui
'
,
'
bootstrap-languages
'
,
'
async
'
,
'
gulp
'
,
'
jquery-pjax
'
,
'
coffeescript
'
,
'
hammer.js
'
,
'
ace
'
,
'
leaflet
'
,
'
jquery-mobile
'
,
'
sweetalert
'
,
'
typeahead.js
'
,
'
soup
'
,
'
typehead.js
'
,
'
sails
'
,
'
codeigniter2
'
];
private
topRanked
=
[
'
twitter
'
,
'
bootstrap
'
,
'
angular-1.1.6
'
,
'
angular-latest
'
,
'
angulerjs
'
,
'
d3
'
,
'
myjquery
'
,
'
jq
'
,
'
abcdef1234567890
'
,
'
jQuery
'
,
'
jquery-1.11.1
'
,
'
jquery
'
,
'
sushi-vanilla-x-data
'
,
'
font-awsome
'
,
'
Font-Awesome
'
,
'
font-awesome
'
,
'
fontawesome
'
,
'
html5-boilerplate
'
,
'
impress.js
'
,
'
homebrew
'
,
'
backbone
'
,
'
moment1
'
,
'
momentjs
'
,
'
moment
'
,
'
linux
'
,
'
animate.css
'
,
'
animate-css
'
,
'
reveal.js
'
,
'
jquery-file-upload
'
,
'
blueimp-file-upload
'
,
'
threejs
'
,
'
express
'
,
'
chosen
'
,
'
normalize-css
'
,
'
normalize.css
'
,
'
semantic
'
,
'
semantic-ui
'
,
'
Semantic-UI
'
,
'
modernizr
'
,
'
underscore
'
,
'
underscore1
'
,
'
material-design-icons
'
,
'
ionic
'
,
'
chartjs
'
,
'
Chart.js
'
,
'
nnnick-chartjs
'
,
'
select2-ng
'
,
'
select2-dist
'
,
'
phantom
'
,
'
skrollr
'
,
'
scrollr
'
,
'
less.js
'
,
'
leancss
'
,
'
parser-lib
'
,
'
hui
'
,
'
bootstrap-languages
'
,
'
async
'
,
'
gulp
'
,
'
jquery-pjax
'
,
'
coffeescript
'
,
'
hammer.js
'
,
'
ace
'
,
'
leaflet
'
,
'
jquery-mobile
'
,
'
sweetalert
'
,
'
typeahead.js
'
,
'
soup
'
,
'
typehead.js
'
,
'
sails
'
,
'
codeigniter2
'
];
public
constructor
(
private
xhr
:
XHRRequest
)
{
}
public
getDocumentSelector
():
DocumentSelector
{
return
[{
language
:
'
json
'
,
pattern
:
'
**/bower.json
'
},
{
language
:
'
json
'
,
pattern
:
'
**/.bower.json
'
}];
return
[{
language
:
'
json
'
,
pattern
:
'
**/bower.json
'
},
{
language
:
'
json
'
,
pattern
:
'
**/.bower.json
'
}];
}
public
collectDefaultSuggestions
(
resource
:
string
,
collector
:
ISuggestionsCollector
):
Thenable
<
any
>
{
let
defaultValue
=
{
'
name
'
:
'
{{name}}
'
,
'
description
'
:
'
{{description}}
'
,
'
authors
'
:
[
'
{{author}}
'
],
'
authors
'
:
[
'
{{author}}
'
],
'
version
'
:
'
{{1.0.0}}
'
,
'
main
'
:
'
{{pathToMain}}
'
,
'
dependencies
'
:
{}
...
...
@@ -46,19 +46,19 @@ 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
>
{
if
((
location
.
matches
([
'
dependencies
'
])
||
location
.
matches
([
'
devDependencies
'
])))
{
if
(
currentWord
.
length
>
0
)
{
let
queryUrl
=
'
https://bower.herokuapp.com/packages/search/
'
+
encodeURIComponent
(
currentWord
);
return
this
.
xhr
({
url
:
queryUrl
url
:
queryUrl
}).
then
((
success
)
=>
{
if
(
success
.
status
===
200
)
{
try
{
let
obj
=
JSON
.
parse
(
success
.
responseText
);
if
(
Array
.
isArray
(
obj
))
{
let
results
=
<
{
name
:
string
;
description
:
string
;}[]
>
obj
;
let
results
=
<
{
name
:
string
;
description
:
string
;
}[]
>
obj
;
for
(
let
i
=
0
;
i
<
results
.
length
;
i
++
)
{
let
name
=
results
[
i
].
name
;
let
description
=
results
[
i
].
description
||
''
;
...
...
@@ -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
>
{
if
(
item
.
kind
===
CompletionItemKind
.
Property
&&
item
.
documentation
===
''
)
{
return
this
.
getInfo
(
item
.
label
).
then
(
documentation
=>
{
if
(
documentation
)
{
...
...
@@ -143,12 +143,12 @@ export class BowerJSONContribution implements IJSONContribution {
let
queryUrl
=
'
https://bower.herokuapp.com/packages/
'
+
encodeURIComponent
(
pack
);
return
this
.
xhr
({
url
:
queryUrl
url
:
queryUrl
}).
then
((
success
)
=>
{
try
{
let
obj
=
JSON
.
parse
(
success
.
responseText
);
if
(
obj
&&
obj
.
url
)
{
let
url
:
string
=
obj
.
url
;
let
url
:
string
=
obj
.
url
;
if
(
url
.
indexOf
(
'
git://
'
)
===
0
)
{
url
=
url
.
substring
(
6
);
}
...
...
@@ -170,7 +170,7 @@ export class BowerJSONContribution implements IJSONContribution {
if
((
location
.
matches
([
'
dependencies
'
,
'
*
'
])
||
location
.
matches
([
'
devDependencies
'
,
'
*
'
])))
{
let
pack
=
location
.
path
[
location
.
path
.
length
-
1
];
if
(
typeof
pack
===
'
string
'
)
{
let
htmlContent
:
MarkedString
[]
=
[];
let
htmlContent
:
MarkedString
[]
=
[];
htmlContent
.
push
(
localize
(
'
json.bower.package.hover
'
,
'
{0}
'
,
pack
));
return
this
.
getInfo
(
pack
).
then
(
documentation
=>
{
if
(
documentation
)
{
...
...
extensions/javascript/src/features/jsonContributions.ts
浏览文件 @
6eb4cd9d
...
...
@@ -4,34 +4,36 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Location
,
getLocation
,
createScanner
,
SyntaxKind
,
ScanError
}
from
'
jsonc-parser
'
;
import
{
basename
}
from
'
path
'
;
import
{
BowerJSONContribution
}
from
'
./bowerJSONContribution
'
;
import
{
PackageJSONContribution
}
from
'
./packageJSONContribution
'
;
import
{
XHRRequest
}
from
'
request-light
'
;
import
{
Location
,
getLocation
,
createScanner
,
SyntaxKind
,
ScanError
}
from
'
jsonc-parser
'
;
import
{
basename
}
from
'
path
'
;
import
{
BowerJSONContribution
}
from
'
./bowerJSONContribution
'
;
import
{
PackageJSONContribution
}
from
'
./packageJSONContribution
'
;
import
{
XHRRequest
}
from
'
request-light
'
;
import
{
CompletionItem
,
CompletionItemProvider
,
CompletionList
,
TextDocument
,
Position
,
Hover
,
HoverProvider
,
CancellationToken
,
Range
,
TextEdit
,
MarkedString
,
DocumentSelector
,
languages
,
Disposable
}
from
'
vscode
'
;
import
{
CompletionItem
,
CompletionItemProvider
,
CompletionList
,
TextDocument
,
Position
,
Hover
,
HoverProvider
,
CancellationToken
,
Range
,
TextEdit
,
MarkedString
,
DocumentSelector
,
languages
,
Disposable
}
from
'
vscode
'
;
export
interface
ISuggestionsCollector
{
add
(
suggestion
:
CompletionItem
):
void
;
error
(
message
:
string
):
void
;
log
(
message
:
string
):
void
;
error
(
message
:
string
):
void
;
log
(
message
:
string
):
void
;
setAsIncomplete
():
void
;
}
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
>
;
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
>
;
collectDefaultSuggestions
(
fileName
:
string
,
result
:
ISuggestionsCollector
):
Thenable
<
any
>
;
resolveSuggestion
?(
item
:
CompletionItem
):
Thenable
<
CompletionItem
>
;
}
export
function
addJSONProviders
(
xhr
:
XHRRequest
)
:
Disposable
{
export
function
addJSONProviders
(
xhr
:
XHRRequest
):
Disposable
{
let
contributions
=
[
new
PackageJSONContribution
(
xhr
),
new
BowerJSONContribution
(
xhr
)];
let
subscriptions
:
Disposable
[]
=
[];
let
subscriptions
:
Disposable
[]
=
[];
contributions
.
forEach
(
contribution
=>
{
let
selector
=
contribution
.
getDocumentSelector
();
subscriptions
.
push
(
languages
.
registerCompletionItemProvider
(
selector
,
new
JSONCompletionItemProvider
(
contribution
),
'
.
'
,
'
$
'
));
...
...
@@ -72,7 +74,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
>
{
if
(
this
.
jsonContribution
.
resolveSuggestion
)
{
let
resolver
=
this
.
jsonContribution
.
resolveSuggestion
(
item
);
if
(
resolver
)
{
...
...
@@ -87,7 +89,7 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
let
fileName
=
basename
(
document
.
fileName
);
let
currentWord
=
this
.
getCurrentWord
(
document
,
position
);
let
overwriteRange
:
Range
;
let
overwriteRange
:
Range
;
let
items
:
CompletionItem
[]
=
[];
let
isIncomplete
=
false
;
...
...
@@ -116,7 +118,7 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
log
:
(
message
:
string
)
=>
console
.
log
(
message
)
};
let
collectPromise
:
Thenable
<
any
>
=
null
;
let
collectPromise
:
Thenable
<
any
>
=
null
;
if
(
location
.
isAtPropertyKey
)
{
let
addValue
=
!
location
.
previousNode
||
!
location
.
previousNode
.
columnOffset
;
...
...
@@ -146,15 +148,15 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
while
(
i
>=
0
&&
'
\t\n\r\
v":{[,
'
.
indexOf
(
text
.
charAt
(
i
))
===
-
1
)
{
i
--
;
}
return
text
.
substring
(
i
+
1
,
position
.
character
);
return
text
.
substring
(
i
+
1
,
position
.
character
);
}
private
isLast
(
document
:
TextDocument
,
position
:
Position
):
boolean
{
private
isLast
(
document
:
TextDocument
,
position
:
Position
):
boolean
{
let
scanner
=
createScanner
(
document
.
getText
(),
true
);
scanner
.
setPosition
(
document
.
offsetAt
(
position
));
let
nextToken
=
scanner
.
scan
();
if
(
nextToken
===
SyntaxKind
.
StringLiteral
&&
scanner
.
getTokenError
()
===
ScanError
.
UnexpectedEndOfString
)
{
nextToken
=
scanner
.
scan
();
nextToken
=
scanner
.
scan
();
}
return
nextToken
===
SyntaxKind
.
CloseBraceToken
||
nextToken
===
SyntaxKind
.
EOF
;
}
...
...
extensions/javascript/src/features/markedTextUtil.ts
浏览文件 @
6eb4cd9d
...
...
@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
MarkedString
}
from
'
vscode
'
;
import
{
MarkedString
}
from
'
vscode
'
;
export
function
textToMarkedString
(
text
:
string
)
:
MarkedString
{
export
function
textToMarkedString
(
text
:
string
):
MarkedString
{
return
text
.
replace
(
/
[\\
`*_{}[
\]
()#+
\-
.!
]
/g
,
'
\\
$&
'
);
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
}
\ No newline at end of file
extensions/javascript/src/features/packageJSONContribution.ts
浏览文件 @
6eb4cd9d
...
...
@@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
,
DocumentSelector
}
from
'
vscode
'
;
import
{
IJSONContribution
,
ISuggestionsCollector
}
from
'
./jsonContributions
'
;
import
{
XHRRequest
}
from
'
request-light
'
;
import
{
Location
}
from
'
jsonc-parser
'
;
import
{
textToMarkedString
}
from
'
./markedTextUtil
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
,
DocumentSelector
}
from
'
vscode
'
;
import
{
IJSONContribution
,
ISuggestionsCollector
}
from
'
./jsonContributions
'
;
import
{
XHRRequest
}
from
'
request-light
'
;
import
{
Location
}
from
'
jsonc-parser
'
;
import
{
textToMarkedString
}
from
'
./markedTextUtil
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -17,7 +17,7 @@ let LIMIT = 40;
export
class
PackageJSONContribution
implements
IJSONContribution
{
private
mostDependedOn
=
[
'
lodash
'
,
'
async
'
,
'
underscore
'
,
'
request
'
,
'
commander
'
,
'
express
'
,
'
debug
'
,
'
chalk
'
,
'
colors
'
,
'
q
'
,
'
coffee-script
'
,
private
mostDependedOn
=
[
'
lodash
'
,
'
async
'
,
'
underscore
'
,
'
request
'
,
'
commander
'
,
'
express
'
,
'
debug
'
,
'
chalk
'
,
'
colors
'
,
'
q
'
,
'
coffee-script
'
,
'
mkdirp
'
,
'
optimist
'
,
'
through2
'
,
'
yeoman-generator
'
,
'
moment
'
,
'
bluebird
'
,
'
glob
'
,
'
gulp-util
'
,
'
minimist
'
,
'
cheerio
'
,
'
jade
'
,
'
redis
'
,
'
node-uuid
'
,
'
socket
'
,
'
io
'
,
'
uglify-js
'
,
'
winston
'
,
'
through
'
,
'
fs-extra
'
,
'
handlebars
'
,
'
body-parser
'
,
'
rimraf
'
,
'
mime
'
,
'
semver
'
,
'
mongodb
'
,
'
jquery
'
,
'
grunt
'
,
'
connect
'
,
'
yosay
'
,
'
underscore
'
,
'
string
'
,
'
xml2js
'
,
'
ejs
'
,
'
mongoose
'
,
'
marked
'
,
'
extend
'
,
'
mocha
'
,
'
superagent
'
,
'
js-yaml
'
,
'
xtend
'
,
...
...
@@ -25,7 +25,7 @@ export class PackageJSONContribution implements IJSONContribution {
'
jsdom
'
,
'
stylus
'
,
'
when
'
,
'
readable-stream
'
,
'
aws-sdk
'
,
'
concat-stream
'
,
'
chai
'
,
'
Thenable
'
,
'
wrench
'
];
public
getDocumentSelector
():
DocumentSelector
{
return
[{
language
:
'
json
'
,
pattern
:
'
**/package.json
'
}];
return
[{
language
:
'
json
'
,
pattern
:
'
**/package.json
'
}];
}
public
constructor
(
private
xhr
:
XHRRequest
)
{
...
...
@@ -47,20 +47,20 @@ export class PackageJSONContribution 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
>
{
if
((
location
.
matches
([
'
dependencies
'
])
||
location
.
matches
([
'
devDependencies
'
])
||
location
.
matches
([
'
optionalDependencies
'
])
||
location
.
matches
([
'
peerDependencies
'
])))
{
let
queryUrl
:
string
;
let
queryUrl
:
string
;
if
(
currentWord
.
length
>
0
)
{
queryUrl
=
'
https://skimdb.npmjs.com/registry/_design/app/_view/browseAll?group_level=1&limit=
'
+
LIMIT
+
'
&start_key=%5B%22
'
+
encodeURIComponent
(
currentWord
)
+
'
%22%5D&end_key=%5B%22
'
+
encodeURIComponent
(
currentWord
+
'
z
'
)
+
'
%22,%7B%7D%5D
'
;
queryUrl
=
'
https://skimdb.npmjs.com/registry/_design/app/_view/browseAll?group_level=1&limit=
'
+
LIMIT
+
'
&start_key=%5B%22
'
+
encodeURIComponent
(
currentWord
)
+
'
%22%5D&end_key=%5B%22
'
+
encodeURIComponent
(
currentWord
+
'
z
'
)
+
'
%22,%7B%7D%5D
'
;
return
this
.
xhr
({
url
:
queryUrl
url
:
queryUrl
}).
then
((
success
)
=>
{
if
(
success
.
status
===
200
)
{
try
{
let
obj
=
JSON
.
parse
(
success
.
responseText
);
if
(
obj
&&
Array
.
isArray
(
obj
.
rows
))
{
let
results
=
<
{
key
:
string
[];
}[]
>
obj
.
rows
;
let
results
=
<
{
key
:
string
[];
}[]
>
obj
.
rows
;
for
(
let
i
=
0
;
i
<
results
.
length
;
i
++
)
{
let
keys
=
results
[
i
].
key
;
if
(
Array
.
isArray
(
keys
)
&&
keys
.
length
>
0
)
{
...
...
@@ -124,7 +124,7 @@ export class PackageJSONContribution implements IJSONContribution {
if
(
typeof
currentKey
===
'
string
'
)
{
let
queryUrl
=
'
http://registry.npmjs.org/
'
+
encodeURIComponent
(
currentKey
).
replace
(
'
%40
'
,
'
@
'
);
return
this
.
xhr
({
url
:
queryUrl
url
:
queryUrl
}).
then
((
success
)
=>
{
try
{
let
obj
=
JSON
.
parse
(
success
.
responseText
);
...
...
@@ -163,7 +163,7 @@ export class PackageJSONContribution implements IJSONContribution {
return
null
;
}
public
resolveSuggestion
(
item
:
CompletionItem
)
:
Thenable
<
CompletionItem
>
{
public
resolveSuggestion
(
item
:
CompletionItem
):
Thenable
<
CompletionItem
>
{
if
(
item
.
kind
===
CompletionItemKind
.
Property
&&
item
.
documentation
===
''
)
{
return
this
.
getInfo
(
item
.
label
).
then
(
infos
=>
{
if
(
infos
.
length
>
0
)
{
...
...
@@ -183,12 +183,12 @@ export class PackageJSONContribution implements IJSONContribution {
let
queryUrl
=
'
http://registry.npmjs.org/
'
+
encodeURIComponent
(
pack
).
replace
(
'
%40
'
,
'
@
'
);
return
this
.
xhr
({
url
:
queryUrl
url
:
queryUrl
}).
then
((
success
)
=>
{
try
{
let
obj
=
JSON
.
parse
(
success
.
responseText
);
if
(
obj
)
{
let
result
:
string
[]
=
[];
let
result
:
string
[]
=
[];
if
(
obj
.
description
)
{
result
.
push
(
obj
.
description
);
}
...
...
@@ -211,7 +211,7 @@ export class PackageJSONContribution implements IJSONContribution {
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
'
)
{
let
htmlContent
:
MarkedString
[]
=
[];
let
htmlContent
:
MarkedString
[]
=
[];
htmlContent
.
push
(
localize
(
'
json.npm.package.hover
'
,
'
{0}
'
,
pack
));
return
this
.
getInfo
(
pack
).
then
(
infos
=>
{
infos
.
forEach
(
info
=>
{
...
...
extensions/javascript/src/javascriptMain.ts
浏览文件 @
6eb4cd9d
...
...
@@ -5,15 +5,15 @@
'
use strict
'
;
import
{
addJSONProviders
}
from
'
./features/jsonContributions
'
;
import
{
addJSONProviders
}
from
'
./features/jsonContributions
'
;
import
*
as
httpRequest
from
'
request-light
'
;
import
{
ExtensionContext
,
env
,
workspace
}
from
'
vscode
'
;
import
{
ExtensionContext
,
env
,
workspace
}
from
'
vscode
'
;
import
*
as
nls
from
'
vscode-nls
'
;
export
function
activate
(
context
:
ExtensionContext
):
any
{
nls
.
config
({
locale
:
env
.
language
});
nls
.
config
({
locale
:
env
.
language
});
configureHttpRequest
();
workspace
.
onDidChangeConfiguration
(
e
=>
configureHttpRequest
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录