Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a3510550
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,发现更多精彩内容 >>
提交
a3510550
编写于
1月 22, 2016
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SchemaService: Use Thenable in signatures
上级
cbb50c74
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
15 deletion
+15
-15
extensions/json/server/src/jsonSchemaService.ts
extensions/json/server/src/jsonSchemaService.ts
+15
-15
未找到文件。
extensions/json/server/src/jsonSchemaService.ts
浏览文件 @
a3510550
...
...
@@ -34,7 +34,7 @@ export interface IJSONSchemaService {
/**
* Looks up the appropriate schema for the given URI
*/
getSchemaForResource
(
resource
:
string
,
document
:
Parser
.
JSONDocument
):
Promis
e
<
ResolvedSchema
>
;
getSchemaForResource
(
resource
:
string
,
document
:
Parser
.
JSONDocument
):
Thenabl
e
<
ResolvedSchema
>
;
}
export
interface
ISchemaContributions
{
...
...
@@ -51,12 +51,12 @@ export interface ISchemaHandle {
/**
* The schema from the file, with potential $ref references
*/
getUnresolvedSchema
():
Promis
e
<
UnresolvedSchema
>
;
getUnresolvedSchema
():
Thenabl
e
<
UnresolvedSchema
>
;
/**
* The schema from the file, with references resolved
*/
getResolvedSchema
():
Promis
e
<
ResolvedSchema
>
;
getResolvedSchema
():
Thenabl
e
<
ResolvedSchema
>
;
}
...
...
@@ -100,8 +100,8 @@ class SchemaHandle implements ISchemaHandle {
public
url
:
string
;
private
resolvedSchema
:
Promis
e
<
ResolvedSchema
>
;
private
unresolvedSchema
:
Promis
e
<
UnresolvedSchema
>
;
private
resolvedSchema
:
Thenabl
e
<
ResolvedSchema
>
;
private
unresolvedSchema
:
Thenabl
e
<
UnresolvedSchema
>
;
private
service
:
JSONSchemaService
;
constructor
(
service
:
JSONSchemaService
,
url
:
string
,
unresolvedSchemaContent
?:
IJSONSchema
)
{
...
...
@@ -112,14 +112,14 @@ class SchemaHandle implements ISchemaHandle {
}
}
public
getUnresolvedSchema
():
Promis
e
<
UnresolvedSchema
>
{
public
getUnresolvedSchema
():
Thenabl
e
<
UnresolvedSchema
>
{
if
(
!
this
.
unresolvedSchema
)
{
this
.
unresolvedSchema
=
this
.
service
.
loadSchema
(
this
.
url
);
}
return
this
.
unresolvedSchema
;
}
public
getResolvedSchema
():
Promis
e
<
ResolvedSchema
>
{
public
getResolvedSchema
():
Thenabl
e
<
ResolvedSchema
>
{
if
(
!
this
.
resolvedSchema
)
{
this
.
resolvedSchema
=
this
.
getUnresolvedSchema
().
then
(
unresolved
=>
{
return
this
.
service
.
resolveSchemaContent
(
unresolved
);
...
...
@@ -204,7 +204,7 @@ export interface IWorkspaceContextService {
}
export
interface
IRequestService
{
(
options
:
IXHROptions
):
Promis
e
<
IXHRResponse
>
(
options
:
IXHROptions
):
Thenabl
e
<
IXHRResponse
>
}
export
class
JSONSchemaService
implements
IJSONSchemaService
{
...
...
@@ -328,7 +328,7 @@ export class JSONSchemaService implements IJSONSchemaService {
}
}
public
getResolvedSchema
(
schemaId
:
string
):
Promis
e
<
ResolvedSchema
>
{
public
getResolvedSchema
(
schemaId
:
string
):
Thenabl
e
<
ResolvedSchema
>
{
let
id
=
this
.
normalizeId
(
schemaId
);
let
schemaHandle
=
this
.
schemasById
[
id
];
if
(
schemaHandle
)
{
...
...
@@ -337,7 +337,7 @@ export class JSONSchemaService implements IJSONSchemaService {
return
Promise
.
resolve
(
null
);
}
public
loadSchema
(
url
:
string
):
Promis
e
<
UnresolvedSchema
>
{
public
loadSchema
(
url
:
string
):
Thenabl
e
<
UnresolvedSchema
>
{
if
(
this
.
telemetryService
&&
Strings
.
startsWith
(
url
,
'
https://schema.management.azure.com
'
))
{
this
.
telemetryService
.
log
(
'
json.schema
'
,
{
schemaURL
:
url
...
...
@@ -365,7 +365,7 @@ export class JSONSchemaService implements IJSONSchemaService {
);
}
public
resolveSchemaContent
(
schemaToResolve
:
UnresolvedSchema
):
Promis
e
<
ResolvedSchema
>
{
public
resolveSchemaContent
(
schemaToResolve
:
UnresolvedSchema
):
Thenabl
e
<
ResolvedSchema
>
{
let
resolveErrors
:
string
[]
=
schemaToResolve
.
errors
.
slice
(
0
);
let
schema
=
schemaToResolve
.
schema
;
...
...
@@ -396,7 +396,7 @@ export class JSONSchemaService implements IJSONSchemaService {
delete
node
.
$ref
;
}
let
resolveExternalLink
=
(
node
:
any
,
uri
:
string
,
linkPath
:
string
):
Promis
e
<
any
>
=>
{
let
resolveExternalLink
=
(
node
:
any
,
uri
:
string
,
linkPath
:
string
):
Thenabl
e
<
any
>
=>
{
return
this
.
getOrAddSchemaHandle
(
uri
).
getUnresolvedSchema
().
then
(
unresolvedSchema
=>
{
if
(
unresolvedSchema
.
errors
.
length
)
{
let
loc
=
linkPath
?
uri
+
'
#
'
+
linkPath
:
uri
;
...
...
@@ -407,11 +407,11 @@ export class JSONSchemaService implements IJSONSchemaService {
});
}
let
resolveRefs
=
(
node
:
any
,
parentSchema
:
any
):
Promis
e
<
any
>
=>
{
let
resolveRefs
=
(
node
:
any
,
parentSchema
:
any
):
Thenabl
e
<
any
>
=>
{
let
toWalk
=
[
node
];
let
seen
:
any
[]
=
[];
let
openPromises
:
Promis
e
<
any
>
[]
=
[];
let
openPromises
:
Thenabl
e
<
any
>
[]
=
[];
while
(
toWalk
.
length
)
{
let
next
=
toWalk
.
pop
();
...
...
@@ -444,7 +444,7 @@ export class JSONSchemaService implements IJSONSchemaService {
return
resolveRefs
(
schema
,
schema
).
then
(
_
=>
new
ResolvedSchema
(
schema
,
resolveErrors
));
}
public
getSchemaForResource
(
resource
:
string
,
document
:
Parser
.
JSONDocument
):
Promis
e
<
ResolvedSchema
>
{
public
getSchemaForResource
(
resource
:
string
,
document
:
Parser
.
JSONDocument
):
Thenabl
e
<
ResolvedSchema
>
{
// first use $schema if present
if
(
document
&&
document
.
root
&&
document
.
root
.
type
===
'
object
'
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录