Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4e5de4b7
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,发现更多精彩内容 >>
提交
4e5de4b7
编写于
12月 15, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debounce and queue decoration request, fixes #40210
上级
6cb8c4c7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
11 deletion
+75
-11
src/vs/workbench/api/electron-browser/mainThreadDecorations.ts
...s/workbench/api/electron-browser/mainThreadDecorations.ts
+52
-4
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+8
-1
src/vs/workbench/api/node/extHostDecorations.ts
src/vs/workbench/api/node/extHostDecorations.ts
+15
-6
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadDecorations.ts
浏览文件 @
4e5de4b7
...
@@ -7,21 +7,69 @@
...
@@ -7,21 +7,69 @@
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ExtHostContext
,
MainContext
,
IExtHostContext
,
MainThreadDecorationsShape
,
ExtHostDecorationsShape
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainContext
,
IExtHostContext
,
MainThreadDecorationsShape
,
ExtHostDecorationsShape
,
DecorationData
,
DecorationRequest
}
from
'
../node/extHost.protocol
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
IDecorationsService
,
IDecorationData
}
from
'
vs/workbench/services/decorations/browser/decorations
'
;
import
{
IDecorationsService
,
IDecorationData
}
from
'
vs/workbench/services/decorations/browser/decorations
'
;
class
DecorationRequestsQueue
{
private
_idPool
=
0
;
private
_requests
:
DecorationRequest
[]
=
[];
private
_resolver
:
{
[
id
:
number
]:
Function
}
=
Object
.
create
(
null
);
private
_timer
:
number
;
constructor
(
private
_proxy
:
ExtHostDecorationsShape
)
{
//
}
enqueue
(
handle
:
number
,
uri
:
URI
):
Thenable
<
DecorationData
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
id
=
++
this
.
_idPool
;
this
.
_requests
.
push
({
id
,
handle
,
uri
});
this
.
_resolver
[
id
]
=
resolve
;
this
.
_processQueue
();
});
}
private
_processQueue
():
void
{
if
(
typeof
this
.
_timer
===
'
number
'
)
{
// already queued
return
;
}
this
.
_timer
=
setTimeout
(()
=>
{
// make request
const
requests
=
this
.
_requests
;
const
resolver
=
this
.
_resolver
;
this
.
_proxy
.
$provideDecorations
(
requests
).
then
(
data
=>
{
for
(
const
id
in
resolver
)
{
resolver
[
id
](
data
[
id
]);
}
});
// reset
this
.
_requests
=
[];
this
.
_resolver
=
[];
this
.
_timer
=
void
0
;
},
0
);
}
}
@
extHostNamedCustomer
(
MainContext
.
MainThreadDecorations
)
@
extHostNamedCustomer
(
MainContext
.
MainThreadDecorations
)
export
class
MainThreadDecorations
implements
MainThreadDecorationsShape
{
export
class
MainThreadDecorations
implements
MainThreadDecorationsShape
{
private
readonly
_provider
=
new
Map
<
number
,
[
Emitter
<
URI
[]
>
,
IDisposable
]
>
();
private
readonly
_provider
=
new
Map
<
number
,
[
Emitter
<
URI
[]
>
,
IDisposable
]
>
();
private
readonly
_proxy
:
ExtHostDecorationsShape
;
private
readonly
_proxy
:
ExtHostDecorationsShape
;
private
readonly
_requestQueue
:
DecorationRequestsQueue
;
constructor
(
constructor
(
context
:
IExtHostContext
,
context
:
IExtHostContext
,
@
IDecorationsService
private
readonly
_decorationsService
:
IDecorationsService
@
IDecorationsService
private
readonly
_decorationsService
:
IDecorationsService
)
{
)
{
this
.
_proxy
=
context
.
getProxy
(
ExtHostContext
.
ExtHostDecorations
);
this
.
_proxy
=
context
.
getProxy
(
ExtHostContext
.
ExtHostDecorations
);
this
.
_requestQueue
=
new
DecorationRequestsQueue
(
this
.
_proxy
);
}
}
dispose
()
{
dispose
()
{
...
@@ -30,12 +78,12 @@ export class MainThreadDecorations implements MainThreadDecorationsShape {
...
@@ -30,12 +78,12 @@ export class MainThreadDecorations implements MainThreadDecorationsShape {
}
}
$registerDecorationProvider
(
handle
:
number
,
label
:
string
):
void
{
$registerDecorationProvider
(
handle
:
number
,
label
:
string
):
void
{
le
t
emitter
=
new
Emitter
<
URI
[]
>
();
cons
t
emitter
=
new
Emitter
<
URI
[]
>
();
le
t
registration
=
this
.
_decorationsService
.
registerDecorationsProvider
({
cons
t
registration
=
this
.
_decorationsService
.
registerDecorationsProvider
({
label
,
label
,
onDidChange
:
emitter
.
event
,
onDidChange
:
emitter
.
event
,
provideDecorations
:
(
uri
)
=>
{
provideDecorations
:
(
uri
)
=>
{
return
this
.
_
proxy
.
$provideDecorations
(
handle
,
uri
).
then
(
data
=>
{
return
this
.
_
requestQueue
.
enqueue
(
handle
,
uri
).
then
(
data
=>
{
if
(
!
data
)
{
if
(
!
data
)
{
return
undefined
;
return
undefined
;
}
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
4e5de4b7
...
@@ -719,10 +719,17 @@ export interface ExtHostDebugServiceShape {
...
@@ -719,10 +719,17 @@ export interface ExtHostDebugServiceShape {
}
}
export
interface
DecorationRequest
{
readonly
id
:
number
;
readonly
handle
:
number
;
readonly
uri
:
UriComponents
;
}
export
type
DecorationData
=
[
number
,
boolean
,
string
,
string
,
ThemeColor
,
string
];
export
type
DecorationData
=
[
number
,
boolean
,
string
,
string
,
ThemeColor
,
string
];
export
type
DecorationReply
=
{
[
id
:
number
]:
DecorationData
};
export
interface
ExtHostDecorationsShape
{
export
interface
ExtHostDecorationsShape
{
$provideDecorations
(
handle
:
number
,
uri
:
UriComponents
):
TPromise
<
DecorationData
>
;
$provideDecorations
(
requests
:
DecorationRequest
[]):
TPromise
<
DecorationReply
>
;
}
}
export
interface
ExtHostWindowShape
{
export
interface
ExtHostWindowShape
{
...
...
src/vs/workbench/api/node/extHostDecorations.ts
浏览文件 @
4e5de4b7
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
'
use strict
'
;
'
use strict
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
MainContext
,
IMainContext
,
ExtHostDecorationsShape
,
MainThreadDecorationsShape
,
DecorationData
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
MainContext
,
IMainContext
,
ExtHostDecorationsShape
,
MainThreadDecorationsShape
,
DecorationData
,
DecorationRequest
,
DecorationReply
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Disposable
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
Disposable
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
...
@@ -38,10 +38,19 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
...
@@ -38,10 +38,19 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
});
});
}
}
$provideDecorations
(
handle
:
number
,
data
:
UriComponents
):
TPromise
<
DecorationData
>
{
$provideDecorations
(
requests
:
DecorationRequest
[]):
TPromise
<
DecorationReply
>
{
const
provider
=
this
.
_provider
.
get
(
handle
);
const
result
:
DecorationReply
=
Object
.
create
(
null
);
return
asWinJsPromise
(
token
=>
provider
.
provideDecoration
(
URI
.
revive
(
data
),
token
)).
then
(
data
=>
{
return
TPromise
.
join
(
requests
.
map
(
request
=>
{
return
data
&&
<
DecorationData
>
[
data
.
priority
,
data
.
bubble
,
data
.
title
,
data
.
abbreviation
,
data
.
color
,
data
.
source
];
const
{
handle
,
uri
,
id
}
=
request
;
const
provider
=
this
.
_provider
.
get
(
handle
);
return
asWinJsPromise
(
token
=>
provider
.
provideDecoration
(
URI
.
revive
(
uri
),
token
)).
then
(
data
=>
{
result
[
id
]
=
data
&&
<
DecorationData
>
[
data
.
priority
,
data
.
bubble
,
data
.
title
,
data
.
abbreviation
,
data
.
color
,
data
.
source
];
},
err
=>
{
console
.
error
(
err
);
});
})).
then
(()
=>
{
return
result
;
});
});
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录