Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
507b5514
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,发现更多精彩内容 >>
提交
507b5514
编写于
10月 08, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tsfmt - extensions/json/server
上级
7b5a8283
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
63 addition
and
63 deletion
+63
-63
extensions/json/server/src/jsonServerMain.ts
extensions/json/server/src/jsonServerMain.ts
+9
-9
extensions/json/server/src/jsoncontributions/fileAssociationContribution.ts
...rver/src/jsoncontributions/fileAssociationContribution.ts
+4
-4
extensions/json/server/src/jsoncontributions/globPatternContribution.ts
...n/server/src/jsoncontributions/globPatternContribution.ts
+2
-2
extensions/json/server/src/jsoncontributions/projectJSONContribution.ts
...n/server/src/jsoncontributions/projectJSONContribution.ts
+29
-29
extensions/json/server/src/languageModelCache.ts
extensions/json/server/src/languageModelCache.ts
+5
-5
extensions/json/server/src/typings/promise.d.ts
extensions/json/server/src/typings/promise.d.ts
+12
-12
extensions/json/server/src/utils/uri.ts
extensions/json/server/src/utils/uri.ts
+2
-2
未找到文件。
extensions/json/server/src/jsonServerMain.ts
浏览文件 @
507b5514
...
...
@@ -9,17 +9,17 @@ import {
TextDocuments
,
TextDocument
,
InitializeParams
,
InitializeResult
,
NotificationType
,
RequestType
}
from
'
vscode-languageserver
'
;
import
{
xhr
,
XHRResponse
,
configure
as
configureHttpRequests
,
getErrorStatusDescription
}
from
'
request-light
'
;
import
{
xhr
,
XHRResponse
,
configure
as
configureHttpRequests
,
getErrorStatusDescription
}
from
'
request-light
'
;
import
path
=
require
(
'
path
'
);
import
fs
=
require
(
'
fs
'
);
import
URI
from
'
./utils/uri
'
;
import
*
as
URL
from
'
url
'
;
import
Strings
=
require
(
'
./utils/strings
'
);
import
{
JSONDocument
,
JSONSchema
,
LanguageSettings
,
getLanguageService
}
from
'
vscode-json-languageservice
'
;
import
{
ProjectJSONContribution
}
from
'
./jsoncontributions/projectJSONContribution
'
;
import
{
GlobPatternContribution
}
from
'
./jsoncontributions/globPatternContribution
'
;
import
{
FileAssociationContribution
}
from
'
./jsoncontributions/fileAssociationContribution
'
;
import
{
getLanguageModelCache
}
from
'
./languageModelCache
'
;
import
{
JSONDocument
,
JSONSchema
,
LanguageSettings
,
getLanguageService
}
from
'
vscode-json-languageservice
'
;
import
{
ProjectJSONContribution
}
from
'
./jsoncontributions/projectJSONContribution
'
;
import
{
GlobPatternContribution
}
from
'
./jsoncontributions/globPatternContribution
'
;
import
{
FileAssociationContribution
}
from
'
./jsoncontributions/fileAssociationContribution
'
;
import
{
getLanguageModelCache
}
from
'
./languageModelCache
'
;
import
*
as
nls
from
'
vscode-nls
'
;
nls
.
config
(
process
.
env
[
'
VSCODE_NLS_CONFIG
'
]);
...
...
@@ -76,7 +76,7 @@ let workspaceContext = {
}
};
let
schemaRequestService
=
(
uri
:
string
):
Thenable
<
string
>
=>
{
let
schemaRequestService
=
(
uri
:
string
):
Thenable
<
string
>
=>
{
if
(
Strings
.
startsWith
(
uri
,
'
file://
'
))
{
let
fsPath
=
URI
.
parse
(
uri
).
fsPath
;
return
new
Promise
<
string
>
((
c
,
e
)
=>
{
...
...
@@ -153,7 +153,7 @@ connection.onNotification(SchemaAssociationNotification.type, associations => {
});
function
updateConfiguration
()
{
let
languageSettings
:
LanguageSettings
=
{
let
languageSettings
:
LanguageSettings
=
{
validate
:
true
,
allowComments
:
true
,
schemas
:
[]
...
...
@@ -204,7 +204,7 @@ documents.onDidClose(event => {
connection
.
sendDiagnostics
({
uri
:
event
.
document
.
uri
,
diagnostics
:
[]
});
});
let
pendingValidationRequests
:
{
[
uri
:
string
]:
NodeJS
.
Timer
;
}
=
{};
let
pendingValidationRequests
:
{
[
uri
:
string
]:
NodeJS
.
Timer
;
}
=
{};
const
validationDelayMs
=
200
;
function
cleanPendingValidation
(
textDocument
:
TextDocument
):
void
{
...
...
extensions/json/server/src/jsoncontributions/fileAssociationContribution.ts
浏览文件 @
507b5514
...
...
@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
}
from
'
vscode-languageserver
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
}
from
'
vscode-languageserver
'
;
import
Strings
=
require
(
'
../utils/strings
'
);
import
{
JSONWorkerContribution
,
JSONPath
,
CompletionsCollector
}
from
'
vscode-json-languageservice
'
;
import
{
JSONWorkerContribution
,
JSONPath
,
CompletionsCollector
}
from
'
vscode-json-languageservice
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -17,12 +17,12 @@ let globProperties: CompletionItem[] = [
];
export
class
FileAssociationContribution
implements
JSONWorkerContribution
{
private
languageIds
:
string
[];
private
languageIds
:
string
[];
constructor
()
{
}
public
setLanguageIds
(
ids
:
string
[]):
void
{
public
setLanguageIds
(
ids
:
string
[]):
void
{
this
.
languageIds
=
ids
;
}
...
...
extensions/json/server/src/jsoncontributions/globPatternContribution.ts
浏览文件 @
507b5514
...
...
@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
}
from
'
vscode-languageserver
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
}
from
'
vscode-languageserver
'
;
import
Strings
=
require
(
'
../utils/strings
'
);
import
{
JSONWorkerContribution
,
JSONPath
,
CompletionsCollector
}
from
'
vscode-json-languageservice
'
;
import
{
JSONWorkerContribution
,
JSONPath
,
CompletionsCollector
}
from
'
vscode-json-languageservice
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
extensions/json/server/src/jsoncontributions/projectJSONContribution.ts
浏览文件 @
507b5514
...
...
@@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
}
from
'
vscode-languageserver
'
;
import
{
MarkedString
,
CompletionItemKind
,
CompletionItem
}
from
'
vscode-languageserver
'
;
import
Strings
=
require
(
'
../utils/strings
'
);
import
{
XHRResponse
,
getErrorStatusDescription
}
from
'
request-light
'
;
import
{
JSONWorkerContribution
,
JSONPath
,
CompletionsCollector
}
from
'
vscode-json-languageservice
'
;
import
{
xhr
}
from
'
request-light
'
;
import
{
XHRResponse
,
getErrorStatusDescription
}
from
'
request-light
'
;
import
{
JSONWorkerContribution
,
JSONPath
,
CompletionsCollector
}
from
'
vscode-json-languageservice
'
;
import
{
xhr
}
from
'
request-light
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -29,7 +29,7 @@ interface NugetServices {
export
class
ProjectJSONContribution
implements
JSONWorkerContribution
{
private
cachedProjects
:
{
[
id
:
string
]:
{
version
:
string
,
description
:
string
,
time
:
number
}}
=
{};
private
cachedProjects
:
{
[
id
:
string
]:
{
version
:
string
,
description
:
string
,
time
:
number
}
}
=
{};
private
cacheSize
:
number
=
0
;
private
nugetIndexPromise
:
Thenable
<
NugetServices
>
;
...
...
@@ -40,7 +40,7 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
return
Strings
.
endsWith
(
resource
,
'
/project.json
'
);
}
private
completeWithCache
(
id
:
string
,
item
:
CompletionItem
)
:
boolean
{
private
completeWithCache
(
id
:
string
,
item
:
CompletionItem
):
boolean
{
let
entry
=
this
.
cachedProjects
[
id
];
if
(
entry
)
{
if
(
new
Date
().
getTime
()
-
entry
.
time
>
CACHE_EXPIRY
)
{
...
...
@@ -57,10 +57,10 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
}
private
addCached
(
id
:
string
,
version
:
string
,
description
:
string
)
{
this
.
cachedProjects
[
id
]
=
{
version
,
description
,
time
:
new
Date
().
getTime
()};
this
.
cachedProjects
[
id
]
=
{
version
,
description
,
time
:
new
Date
().
getTime
()
};
this
.
cacheSize
++
;
if
(
this
.
cacheSize
>
50
)
{
let
currentTime
=
new
Date
().
getTime
()
;
let
currentTime
=
new
Date
().
getTime
();
for
(
let
id
in
this
.
cachedProjects
)
{
let
entry
=
this
.
cachedProjects
[
id
];
if
(
currentTime
-
entry
.
time
>
CACHE_EXPIRY
)
{
...
...
@@ -71,12 +71,12 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
}
}
private
getNugetIndex
()
:
Thenable
<
NugetServices
>
{
private
getNugetIndex
():
Thenable
<
NugetServices
>
{
if
(
!
this
.
nugetIndexPromise
)
{
this
.
nugetIndexPromise
=
this
.
makeJSONRequest
<
any
>
(
FEED_INDEX_URL
).
then
(
indexContent
=>
{
let
services
:
NugetServices
=
{};
let
services
:
NugetServices
=
{};
if
(
indexContent
&&
Array
.
isArray
(
indexContent
.
resources
))
{
let
resources
=
<
any
[]
>
indexContent
.
resources
;
let
resources
=
<
any
[]
>
indexContent
.
resources
;
for
(
let
i
=
resources
.
length
-
1
;
i
>=
0
;
i
--
)
{
let
type
=
resources
[
i
][
'
@type
'
];
let
id
=
resources
[
i
][
'
@id
'
];
...
...
@@ -91,7 +91,7 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
return
this
.
nugetIndexPromise
;
}
private
getNugetService
(
serviceType
:
string
)
:
Thenable
<
string
>
{
private
getNugetService
(
serviceType
:
string
):
Thenable
<
string
>
{
return
this
.
getNugetIndex
().
then
(
services
=>
{
let
serviceURL
=
services
[
serviceType
];
if
(
!
serviceURL
)
{
...
...
@@ -116,13 +116,13 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
return
null
;
}
private
makeJSONRequest
<
T
>
(
url
:
string
)
:
Thenable
<
T
>
{
private
makeJSONRequest
<
T
>
(
url
:
string
):
Thenable
<
T
>
{
return
xhr
({
url
:
url
url
:
url
}).
then
(
success
=>
{
if
(
success
.
status
===
200
)
{
try
{
return
<
T
>
JSON
.
parse
(
success
.
responseText
);
return
<
T
>
JSON
.
parse
(
success
.
responseText
);
}
catch
(
e
)
{
return
Promise
.
reject
<
T
>
(
localize
(
'
json.nugget.error.invalidformat
'
,
'
{0} is not a valid JSON document
'
,
url
));
}
...
...
@@ -133,19 +133,19 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
});
}
public
collectPropertyCompletions
(
resource
:
string
,
location
:
JSONPath
,
currentWord
:
string
,
addValue
:
boolean
,
isLast
:
boolean
,
result
:
CompletionsCollector
)
:
Thenable
<
any
>
{
public
collectPropertyCompletions
(
resource
:
string
,
location
:
JSONPath
,
currentWord
:
string
,
addValue
:
boolean
,
isLast
:
boolean
,
result
:
CompletionsCollector
)
:
Thenable
<
any
>
{
if
(
this
.
isProjectJSONFile
(
resource
)
&&
(
matches
(
location
,
[
'
dependencies
'
])
||
matches
(
location
,
[
'
frameworks
'
,
'
*
'
,
'
dependencies
'
])
||
matches
(
location
,
[
'
frameworks
'
,
'
*
'
,
'
frameworkAssemblies
'
])))
{
return
this
.
getNugetService
(
'
SearchAutocompleteService
'
).
then
(
service
=>
{
let
queryUrl
:
string
;
let
queryUrl
:
string
;
if
(
currentWord
.
length
>
0
)
{
queryUrl
=
service
+
'
?q=
'
+
encodeURIComponent
(
currentWord
)
+
'
&take=
'
+
LIMIT
;
queryUrl
=
service
+
'
?q=
'
+
encodeURIComponent
(
currentWord
)
+
'
&take=
'
+
LIMIT
;
}
else
{
queryUrl
=
service
+
'
?take=
'
+
LIMIT
;
}
return
this
.
makeJSONRequest
<
any
>
(
queryUrl
).
then
(
resultObj
=>
{
if
(
Array
.
isArray
(
resultObj
.
data
))
{
let
results
=
<
any
[]
>
resultObj
.
data
;
let
results
=
<
any
[]
>
resultObj
.
data
;
for
(
let
i
=
0
;
i
<
results
.
length
;
i
++
)
{
let
name
=
results
[
i
];
let
insertText
=
JSON
.
stringify
(
name
);
...
...
@@ -155,7 +155,7 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
insertText
+=
'
,
'
;
}
}
let
item
:
CompletionItem
=
{
kind
:
CompletionItemKind
.
Property
,
label
:
name
,
insertText
:
insertText
,
filterText
:
JSON
.
stringify
(
name
)
};
let
item
:
CompletionItem
=
{
kind
:
CompletionItemKind
.
Property
,
label
:
name
,
insertText
:
insertText
,
filterText
:
JSON
.
stringify
(
name
)
};
if
(
!
this
.
completeWithCache
(
name
,
item
))
{
item
.
data
=
RESOLVE_ID
+
name
;
}
...
...
@@ -181,7 +181,7 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
let
queryUrl
=
service
+
currentKey
+
'
/index.json
'
;
return
this
.
makeJSONRequest
<
any
>
(
queryUrl
).
then
(
obj
=>
{
if
(
Array
.
isArray
(
obj
.
versions
))
{
let
results
=
<
any
[]
>
obj
.
versions
;
let
results
=
<
any
[]
>
obj
.
versions
;
for
(
let
i
=
0
;
i
<
results
.
length
;
i
++
)
{
let
curr
=
results
[
i
];
let
name
=
JSON
.
stringify
(
curr
);
...
...
@@ -205,15 +205,15 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
public
getInfoContribution
(
resource
:
string
,
location
:
JSONPath
):
Thenable
<
MarkedString
[]
>
{
if
(
this
.
isProjectJSONFile
(
resource
)
&&
(
matches
(
location
,
[
'
dependencies
'
,
'
*
'
])
||
matches
(
location
,
[
'
frameworks
'
,
'
*
'
,
'
dependencies
'
,
'
*
'
])
||
matches
(
location
,
[
'
frameworks
'
,
'
*
'
,
'
frameworkAssemblies
'
,
'
*
'
])))
{
let
pack
=
<
string
>
location
[
location
.
length
-
1
];
let
pack
=
<
string
>
location
[
location
.
length
-
1
];
return
this
.
getNugetService
(
'
SearchQueryService
'
).
then
(
service
=>
{
let
queryUrl
=
service
+
'
?q=
'
+
encodeURIComponent
(
pack
)
+
'
&take=
'
+
5
;
let
queryUrl
=
service
+
'
?q=
'
+
encodeURIComponent
(
pack
)
+
'
&take=
'
+
5
;
return
this
.
makeJSONRequest
<
any
>
(
queryUrl
).
then
(
resultObj
=>
{
let
htmlContent
:
MarkedString
[]
=
[];
let
htmlContent
:
MarkedString
[]
=
[];
htmlContent
.
push
(
localize
(
'
json.nugget.package.hover
'
,
'
{0}
'
,
pack
));
if
(
Array
.
isArray
(
resultObj
.
data
))
{
let
results
=
<
any
[]
>
resultObj
.
data
;
let
results
=
<
any
[]
>
resultObj
.
data
;
for
(
let
i
=
0
;
i
<
results
.
length
;
i
++
)
{
let
res
=
results
[
i
];
this
.
addCached
(
res
.
id
,
res
.
version
,
res
.
description
);
...
...
@@ -233,24 +233,24 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
return
null
;
});
},
(
error
)
=>
{
return
null
;
return
null
;
});
}
return
null
;
}
public
resolveSuggestion
(
item
:
CompletionItem
)
:
Thenable
<
CompletionItem
>
{
public
resolveSuggestion
(
item
:
CompletionItem
):
Thenable
<
CompletionItem
>
{
if
(
item
.
data
&&
Strings
.
startsWith
(
item
.
data
,
RESOLVE_ID
))
{
let
pack
=
item
.
data
.
substring
(
RESOLVE_ID
.
length
);
if
(
this
.
completeWithCache
(
pack
,
item
))
{
return
Promise
.
resolve
(
item
);
}
return
this
.
getNugetService
(
'
SearchQueryService
'
).
then
(
service
=>
{
let
queryUrl
=
service
+
'
?q=
'
+
encodeURIComponent
(
pack
)
+
'
&take=
'
+
10
;
let
queryUrl
=
service
+
'
?q=
'
+
encodeURIComponent
(
pack
)
+
'
&take=
'
+
10
;
return
this
.
makeJSONRequest
<
any
>
(
queryUrl
).
then
(
resultObj
=>
{
let
itemResolved
=
false
;
if
(
Array
.
isArray
(
resultObj
.
data
))
{
let
results
=
<
any
[]
>
resultObj
.
data
;
let
results
=
<
any
[]
>
resultObj
.
data
;
for
(
let
i
=
0
;
i
<
results
.
length
;
i
++
)
{
let
curr
=
results
[
i
];
this
.
addCached
(
curr
.
id
,
curr
.
version
,
curr
.
description
);
...
...
extensions/json/server/src/languageModelCache.ts
浏览文件 @
507b5514
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TextDocument
}
from
'
vscode-languageserver
'
;
import
{
TextDocument
}
from
'
vscode-languageserver
'
;
export
interface
LanguageModelCache
<
T
>
{
get
(
document
:
TextDocument
):
T
;
...
...
@@ -12,8 +12,8 @@ export interface LanguageModelCache<T> {
dispose
():
void
;
}
export
function
getLanguageModelCache
<
T
>
(
maxEntries
:
number
,
cleanupIntervalTimeInSec
:
number
,
parse
:
(
document
:
TextDocument
)
=>
T
)
:
LanguageModelCache
<
T
>
{
let
languageModels
:
{
[
uri
:
string
]:
{
version
:
number
,
languageId
:
string
,
cTime
:
number
,
languageModel
:
T
}
}
=
{};
export
function
getLanguageModelCache
<
T
>
(
maxEntries
:
number
,
cleanupIntervalTimeInSec
:
number
,
parse
:
(
document
:
TextDocument
)
=>
T
):
LanguageModelCache
<
T
>
{
let
languageModels
:
{
[
uri
:
string
]:
{
version
:
number
,
languageId
:
string
,
cTime
:
number
,
languageModel
:
T
}
}
=
{};
let
nModels
=
0
;
let
cleanupInterval
=
void
0
;
...
...
@@ -32,7 +32,7 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
}
return
{
get
(
document
:
TextDocument
)
:
T
{
get
(
document
:
TextDocument
):
T
{
let
version
=
document
.
version
;
let
languageId
=
document
.
languageId
;
let
languageModelInfo
=
languageModels
[
document
.
uri
];
...
...
@@ -41,7 +41,7 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
return
languageModelInfo
.
languageModel
;
}
let
languageModel
=
parse
(
document
);
languageModels
[
document
.
uri
]
=
{
languageModel
,
version
,
languageId
,
cTime
:
Date
.
now
()};
languageModels
[
document
.
uri
]
=
{
languageModel
,
version
,
languageId
,
cTime
:
Date
.
now
()
};
if
(
!
languageModelInfo
)
{
nModels
++
;
}
...
...
extensions/json/server/src/typings/promise.d.ts
浏览文件 @
507b5514
...
...
@@ -31,8 +31,8 @@ interface Thenable<R> {
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Thenable
<
TResult
>
;
}
/**
...
...
@@ -45,15 +45,15 @@ interface Promise<T> extends Thenable<T> {
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Promise
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Promise
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Promise
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Promise
<
TResult
>
;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch
(
onrejected
?:
(
reason
:
any
)
=>
T
|
Thenable
<
T
>
):
Promise
<
T
>
;
catch
(
onrejected
?:
(
reason
:
any
)
=>
T
|
Thenable
<
T
>
):
Promise
<
T
>
;
}
interface
PromiseConstructor
{
...
...
@@ -63,7 +63,7 @@ interface PromiseConstructor {
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new
<
T
>
(
executor
:
(
resolve
:
(
value
?:
T
|
Thenable
<
T
>
)
=>
void
,
reject
:
(
reason
?:
any
)
=>
void
)
=>
void
):
Promise
<
T
>
;
new
<
T
>
(
executor
:
(
resolve
:
(
value
?:
T
|
Thenable
<
T
>
)
=>
void
,
reject
:
(
reason
?:
any
)
=>
void
)
=>
void
):
Promise
<
T
>
;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
...
...
@@ -71,7 +71,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
all
<
T
>
(
values
:
Array
<
T
|
Thenable
<
T
>>
):
Promise
<
T
[]
>
;
all
<
T
>
(
values
:
Array
<
T
|
Thenable
<
T
>>
):
Promise
<
T
[]
>
;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
...
...
@@ -79,34 +79,34 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race
<
T
>
(
values
:
Array
<
T
|
Thenable
<
T
>>
):
Promise
<
T
>
;
race
<
T
>
(
values
:
Array
<
T
|
Thenable
<
T
>>
):
Promise
<
T
>
;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject
(
reason
:
any
):
Promise
<
void
>
;
reject
(
reason
:
any
):
Promise
<
void
>
;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject
<
T
>
(
reason
:
any
):
Promise
<
T
>
;
reject
<
T
>
(
reason
:
any
):
Promise
<
T
>
;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve
<
T
>
(
value
:
T
|
Thenable
<
T
>
):
Promise
<
T
>
;
resolve
<
T
>
(
value
:
T
|
Thenable
<
T
>
):
Promise
<
T
>
;
/**
* Creates a new resolved promise .
* @returns A resolved promise.
*/
resolve
():
Promise
<
void
>
;
resolve
():
Promise
<
void
>
;
}
declare
var
Promise
:
PromiseConstructor
;
extensions/json/server/src/utils/uri.ts
浏览文件 @
507b5514
...
...
@@ -302,7 +302,7 @@ export default class URI {
// when occurring in paths - otherwise the result
// cannot be parsed back again
let
lastIdx
=
0
;
while
(
true
)
{
while
(
true
)
{
let
idx
=
path
.
indexOf
(
URI
.
_slash
,
lastIdx
);
if
(
idx
===
-
1
)
{
parts
.
push
(
encoder
(
path
.
substring
(
lastIdx
)).
replace
(
/
[
#?
]
/
,
_encode
));
...
...
@@ -323,7 +323,7 @@ export default class URI {
}
public
toJSON
():
any
{
return
<
UriState
>
{
return
<
UriState
>
{
scheme
:
this
.
scheme
,
authority
:
this
.
authority
,
path
:
this
.
path
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录