Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
263a9551
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,发现更多精彩内容 >>
提交
263a9551
编写于
12月 21, 2015
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - add toJSON methods to ext host types
上级
f8026782
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
139 addition
and
1 deletion
+139
-1
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+74
-0
src/vs/workbench/test/common/api/extHostTypes.test.ts
src/vs/workbench/test/common/api/extHostTypes.test.ts
+65
-1
未找到文件。
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
263a9551
...
...
@@ -148,6 +148,10 @@ export class Position {
}
return
new
Position
(
line
,
character
);
}
toJSON
():
any
{
return
[
this
.
line
,
this
.
character
];
}
}
export
class
Range
{
...
...
@@ -248,6 +252,10 @@ export class Range {
}
return
new
Range
(
start
,
end
);
}
toJSON
():
any
{
return
[
this
.
start
,
this
.
end
];
}
}
export
class
Selection
extends
Range
{
...
...
@@ -291,6 +299,15 @@ export class Selection extends Range {
get
isReversed
():
boolean
{
return
this
.
_anchor
===
this
.
_end
;
}
toJSON
()
{
return
{
start
:
this
.
start
,
end
:
this
.
end
,
active
:
this
.
active
,
anchor
:
this
.
anchor
}
}
}
export
class
TextEdit
{
...
...
@@ -334,6 +351,13 @@ export class TextEdit {
this
.
range
=
range
;
this
.
newText
=
newText
;
}
toJSON
():
any
{
return
{
range
:
this
.
range
,
newText
:
this
.
newText
};
}
}
export
class
Uri
extends
URI
{
};
...
...
@@ -387,6 +411,10 @@ export class WorkspaceEdit {
get
size
():
number
{
return
this
.
_values
.
length
;
}
toJSON
():
any
{
return
this
.
_values
;
}
}
export
enum
DiagnosticSeverity
{
...
...
@@ -412,6 +440,13 @@ export class Location {
throw
new
Error
(
'
Illegal argument
'
);
}
}
toJSON
():
any
{
return
{
uri
:
this
.
uri
,
range
:
this
.
range
};
}
}
export
class
Diagnostic
{
...
...
@@ -427,6 +462,16 @@ export class Diagnostic {
this
.
message
=
message
;
this
.
severity
=
severity
;
}
toJSON
():
any
{
return
{
severity
:
DiagnosticSeverity
[
this
.
severity
],
message
:
this
.
message
,
range
:
this
.
range
,
source
:
this
.
source
,
code
:
this
.
code
,
}
}
}
export
class
Hover
{
...
...
@@ -463,6 +508,13 @@ export class DocumentHighlight {
this
.
range
=
range
;
this
.
kind
=
kind
;
}
toJSON
():
any
{
return
{
range
:
this
.
range
,
kind
:
DocumentHighlightKind
[
this
.
kind
]
}
}
}
export
enum
SymbolKind
{
...
...
@@ -499,6 +551,15 @@ export class SymbolInformation {
this
.
location
=
new
Location
(
uri
,
range
);
this
.
containerName
=
containerName
;
}
toJSON
():
any
{
return
{
name
:
this
.
name
,
kind
:
SymbolKind
[
this
.
kind
],
location
:
this
.
location
,
containerName
:
this
.
containerName
}
}
}
export
class
CodeLens
{
...
...
@@ -587,6 +648,19 @@ export class CompletionItem {
constructor
(
label
:
string
)
{
this
.
label
=
label
;
}
toJSON
():
any
{
return
{
label
:
this
.
label
,
kind
:
CompletionItemKind
[
this
.
kind
],
detail
:
this
.
detail
,
documentation
:
this
.
documentation
,
sortText
:
this
.
sortText
,
filterText
:
this
.
filterText
,
insertText
:
this
.
insertText
,
textEdit
:
this
.
textEdit
}
}
}
export
enum
ViewColumn
{
...
...
src/vs/workbench/test/common/api/extHostTypes.test.ts
浏览文件 @
263a9551
...
...
@@ -9,7 +9,13 @@ import * as assert from 'assert';
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
types
from
'
vs/workbench/api/common/extHostTypes
'
;
suite
(
'
PluginHostTypes
'
,
function
()
{
function
assertToJSON
(
a
:
any
,
expected
:
any
)
{
const
raw
=
JSON
.
stringify
(
a
);
const
actual
=
JSON
.
parse
(
raw
);
assert
.
deepEqual
(
actual
,
expected
);
}
suite
(
'
ExtHostTypes
'
,
function
()
{
test
(
'
Disposable
'
,
function
()
{
...
...
@@ -47,6 +53,14 @@ suite('PluginHostTypes', function() {
assert
.
throws
(()
=>
pos
.
character
=
-
1
);
assert
.
throws
(()
=>
pos
.
line
=
12
);
let
[
line
,
character
]
=
pos
.
toJSON
();
assert
.
equal
(
line
,
0
);
assert
.
equal
(
character
,
0
);
});
test
(
'
Position, toJSON
'
,
function
()
{
let
pos
=
new
types
.
Position
(
4
,
2
);
assertToJSON
(
pos
,
[
4
,
2
])
});
test
(
'
Position, isBefore(OrEqual)?
'
,
function
()
{
...
...
@@ -133,6 +147,12 @@ suite('PluginHostTypes', function() {
assert
.
throws
(()
=>
range
.
start
=
new
types
.
Position
(
0
,
3
));
});
test
(
'
Range, toJSON
'
,
function
()
{
let
range
=
new
types
.
Range
(
1
,
2
,
3
,
4
);
assertToJSON
(
range
,
[[
1
,
2
],
[
3
,
4
]]);
});
test
(
'
Range, sorting
'
,
function
()
{
// sorts start/end
let
range
=
new
types
.
Range
(
1
,
0
,
0
,
0
);
...
...
@@ -249,6 +269,7 @@ suite('PluginHostTypes', function() {
let
range
=
new
types
.
Range
(
1
,
1
,
2
,
11
);
let
edit
=
new
types
.
TextEdit
(
range
,
undefined
);
assert
.
equal
(
edit
.
newText
,
''
);
assertToJSON
(
edit
,
{
range
:
[[
1
,
1
],
[
2
,
11
]],
newText
:
''
});
edit
=
new
types
.
TextEdit
(
range
,
null
);
assert
.
equal
(
edit
.
newText
,
''
);
...
...
@@ -268,11 +289,16 @@ suite('PluginHostTypes', function() {
edit
.
set
(
a
,
[
types
.
TextEdit
.
insert
(
new
types
.
Position
(
0
,
0
),
'
fff
'
)]);
assert
.
ok
(
edit
.
has
(
a
));
assert
.
equal
(
edit
.
size
,
1
);
assertToJSON
(
edit
,
[[
'
file://a.ts
'
,
[{
range
:
[[
0
,
0
],
[
0
,
0
]],
newText
:
'
fff
'
}]]]);
edit
.
insert
(
b
,
new
types
.
Position
(
1
,
1
),
'
fff
'
);
edit
.
delete
(
b
,
new
types
.
Range
(
0
,
0
,
0
,
0
));
assert
.
ok
(
edit
.
has
(
b
));
assert
.
equal
(
edit
.
size
,
2
);
assertToJSON
(
edit
,
[
[
'
file://a.ts
'
,
[{
range
:
[[
0
,
0
],
[
0
,
0
]],
newText
:
'
fff
'
}]],
[
'
file://b.ts
'
,
[{
range
:
[[
1
,
1
],
[
1
,
1
]],
newText
:
'
fff
'
},
{
range
:
[[
0
,
0
],
[
0
,
0
]],
newText
:
''
}]]
]);
edit
.
set
(
b
,
undefined
);
assert
.
ok
(
edit
.
has
(
b
));
...
...
@@ -280,5 +306,43 @@ suite('PluginHostTypes', function() {
edit
.
set
(
b
,
[
types
.
TextEdit
.
insert
(
new
types
.
Position
(
0
,
0
),
'
ffff
'
)]);
assert
.
equal
(
edit
.
get
(
b
).
length
,
1
);
});
test
(
'
toJSON & stringify
'
,
function
()
{
assertToJSON
(
new
types
.
Selection
(
3
,
4
,
2
,
1
),
{
start
:
[
2
,
1
],
end
:
[
3
,
4
],
anchor
:
[
3
,
4
],
active
:
[
2
,
1
]
});
assertToJSON
(
new
types
.
Location
(
types
.
Uri
.
file
(
'
u.ts
'
),
new
types
.
Range
(
1
,
2
,
3
,
4
)),
{
uri
:
'
file://u.ts
'
,
range
:
[[
1
,
2
],
[
3
,
4
]]
});
assertToJSON
(
new
types
.
Location
(
types
.
Uri
.
file
(
'
u.ts
'
),
new
types
.
Position
(
3
,
4
)),
{
uri
:
'
file://u.ts
'
,
range
:
[[
3
,
4
],
[
3
,
4
]]
});
let
diag
=
new
types
.
Diagnostic
(
new
types
.
Range
(
0
,
1
,
2
,
3
),
'
hello
'
);
assertToJSON
(
diag
,
{
severity
:
'
Error
'
,
message
:
'
hello
'
,
range
:
[[
0
,
1
],
[
2
,
3
]]
});
diag
.
source
=
'
me
'
assertToJSON
(
diag
,
{
severity
:
'
Error
'
,
message
:
'
hello
'
,
range
:
[[
0
,
1
],
[
2
,
3
]],
source
:
'
me
'
});
assertToJSON
(
new
types
.
DocumentHighlight
(
new
types
.
Range
(
2
,
3
,
4
,
5
)),
{
range
:
[[
2
,
3
],
[
4
,
5
]],
kind
:
'
Text
'
});
assertToJSON
(
new
types
.
DocumentHighlight
(
new
types
.
Range
(
2
,
3
,
4
,
5
),
types
.
DocumentHighlightKind
.
Read
),
{
range
:
[[
2
,
3
],
[
4
,
5
]],
kind
:
'
Read
'
});
assertToJSON
(
new
types
.
SymbolInformation
(
'
test
'
,
types
.
SymbolKind
.
Boolean
,
new
types
.
Range
(
0
,
1
,
2
,
3
)),
{
name
:
'
test
'
,
kind
:
'
Boolean
'
,
location
:
{
range
:
[[
0
,
1
],
[
2
,
3
]]
}
});
assertToJSON
(
new
types
.
CodeLens
(
new
types
.
Range
(
7
,
8
,
9
,
10
)),
{
range
:
[[
7
,
8
],
[
9
,
10
]]
});
assertToJSON
(
new
types
.
CodeLens
(
new
types
.
Range
(
7
,
8
,
9
,
10
),
{
command
:
'
id
'
,
title
:
'
title
'
}),
{
range
:
[[
7
,
8
],
[
9
,
10
]],
command
:
{
command
:
'
id
'
,
title
:
'
title
'
}
});
assertToJSON
(
new
types
.
CompletionItem
(
'
complete
'
),
{
label
:
'
complete
'
});
let
item
=
new
types
.
CompletionItem
(
'
complete
'
);
item
.
kind
=
types
.
CompletionItemKind
.
Interface
assertToJSON
(
item
,
{
label
:
'
complete
'
,
kind
:
'
Interface
'
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录