Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eff23204
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,发现更多精彩内容 >>
提交
eff23204
编写于
11月 19, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check timeout on extension host, blame extension when exceeded, #43768
上级
2e9c9db0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
14 deletion
+22
-14
src/vs/base/common/event.ts
src/vs/base/common/event.ts
+2
-2
src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts
...workbench/api/browser/mainThreadFileSystemEventService.ts
+1
-1
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-1
src/vs/workbench/api/common/extHostFileSystemEventService.ts
src/vs/workbench/api/common/extHostFileSystemEventService.ts
+14
-7
src/vs/workbench/test/electron-browser/api/extHostFileSystemEventService.test.ts
...lectron-browser/api/extHostFileSystemEventService.test.ts
+3
-2
未找到文件。
src/vs/base/common/event.ts
浏览文件 @
eff23204
...
...
@@ -656,7 +656,7 @@ export class AsyncEmitter<T extends IWaitUntil> extends Emitter<T> {
private
_asyncDeliveryQueue
?:
LinkedList
<
[
Listener
<
T
>
,
Omit
<
T
,
'
waitUntil
'
>
]
>
;
async
fireAsync
(
data
:
Omit
<
T
,
'
waitUntil
'
>
,
token
:
CancellationToken
,
promiseJoin
?:
(
p
:
Promise
<
any
>
)
=>
Promise
<
any
>
):
Promise
<
void
>
{
async
fireAsync
(
data
:
Omit
<
T
,
'
waitUntil
'
>
,
token
:
CancellationToken
,
promiseJoin
?:
(
p
:
Promise
<
any
>
,
listener
:
Function
)
=>
Promise
<
any
>
):
Promise
<
void
>
{
if
(
!
this
.
_listeners
)
{
return
;
}
...
...
@@ -681,7 +681,7 @@ export class AsyncEmitter<T extends IWaitUntil> extends Emitter<T> {
throw
new
Error
(
'
waitUntil can NOT be called asynchronous
'
);
}
if
(
promiseJoin
)
{
p
=
promiseJoin
(
p
);
p
=
promiseJoin
(
p
,
typeof
listener
===
'
function
'
?
listener
:
listener
[
0
]
);
}
thenables
.
push
(
p
);
}
...
...
src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts
浏览文件 @
eff23204
...
...
@@ -88,7 +88,7 @@ export class MainThreadFileSystemEventService {
reject
(
new
Error
(
'
timeout
'
));
},
timeout
);
proxy
.
$onWillRunFileOperation
(
e
.
operation
,
e
.
target
,
e
.
source
,
cts
.
token
)
proxy
.
$onWillRunFileOperation
(
e
.
operation
,
e
.
target
,
e
.
source
,
timeout
,
cts
.
token
)
.
then
(
resolve
,
reject
)
.
finally
(()
=>
clearTimeout
(
timeoutHandle
));
});
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
eff23204
...
...
@@ -116,7 +116,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const
extHostDiagnostics
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDiagnostics
,
new
ExtHostDiagnostics
(
rpcProtocol
,
extHostLogService
));
const
extHostLanguageFeatures
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostLanguageFeatures
,
new
ExtHostLanguageFeatures
(
rpcProtocol
,
uriTransformer
,
extHostDocuments
,
extHostCommands
,
extHostDiagnostics
,
extHostLogService
));
const
extHostFileSystem
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostFileSystem
,
new
ExtHostFileSystem
(
rpcProtocol
,
extHostLanguageFeatures
));
const
extHostFileSystemEvent
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostFileSystemEventService
,
new
ExtHostFileSystemEventService
(
rpcProtocol
,
extHostDocumentsAndEditors
));
const
extHostFileSystemEvent
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostFileSystemEventService
,
new
ExtHostFileSystemEventService
(
rpcProtocol
,
extHost
LogService
,
extHost
DocumentsAndEditors
));
const
extHostQuickOpen
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostQuickOpen
,
new
ExtHostQuickOpen
(
rpcProtocol
,
extHostWorkspace
,
extHostCommands
));
const
extHostSCM
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostSCM
,
new
ExtHostSCM
(
rpcProtocol
,
extHostCommands
,
extHostLogService
));
const
extHostComment
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostComments
,
new
ExtHostComments
(
rpcProtocol
,
extHostCommands
,
extHostDocuments
));
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
eff23204
...
...
@@ -923,7 +923,7 @@ export interface FileSystemEvents {
export
interface
ExtHostFileSystemEventServiceShape
{
$onFileEvent
(
events
:
FileSystemEvents
):
void
;
$onWillRunFileOperation
(
operation
:
files
.
FileOperation
,
target
:
UriComponents
,
source
:
UriComponents
|
undefined
,
token
:
CancellationToken
):
Promise
<
any
>
;
$onWillRunFileOperation
(
operation
:
files
.
FileOperation
,
target
:
UriComponents
,
source
:
UriComponents
|
undefined
,
t
imeout
:
number
,
t
oken
:
CancellationToken
):
Promise
<
any
>
;
$onDidRunFileOperation
(
operation
:
files
.
FileOperation
,
target
:
UriComponents
,
source
:
UriComponents
|
undefined
):
void
;
}
...
...
src/vs/workbench/api/common/extHostFileSystemEventService.ts
浏览文件 @
eff23204
...
...
@@ -15,6 +15,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
import
{
FileOperation
}
from
'
vs/platform/files/common/files
'
;
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
class
FileSystemWatcher
implements
vscode
.
FileSystemWatcher
{
...
...
@@ -121,6 +122,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
constructor
(
mainContext
:
IMainContext
,
private
readonly
_logService
:
ILogService
,
private
readonly
_extHostDocumentsAndEditors
:
ExtHostDocumentsAndEditors
,
private
readonly
_mainThreadTextEditors
:
MainThreadTextEditorsShape
=
mainContext
.
getProxy
(
MainContext
.
MainThreadTextEditors
)
)
{
...
...
@@ -177,32 +179,37 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
};
}
async
$onWillRunFileOperation
(
operation
:
FileOperation
,
target
:
UriComponents
,
source
:
UriComponents
|
undefined
,
token
:
CancellationToken
):
Promise
<
any
>
{
async
$onWillRunFileOperation
(
operation
:
FileOperation
,
target
:
UriComponents
,
source
:
UriComponents
|
undefined
,
t
imeout
:
number
,
t
oken
:
CancellationToken
):
Promise
<
any
>
{
switch
(
operation
)
{
case
FileOperation
.
MOVE
:
await
this
.
_fireWillEvent
(
this
.
_onWillRenameFile
,
{
files
:
[{
oldUri
:
URI
.
revive
(
source
!
),
newUri
:
URI
.
revive
(
target
)
}]
},
token
);
await
this
.
_fireWillEvent
(
this
.
_onWillRenameFile
,
{
files
:
[{
oldUri
:
URI
.
revive
(
source
!
),
newUri
:
URI
.
revive
(
target
)
}]
},
t
imeout
,
t
oken
);
break
;
case
FileOperation
.
DELETE
:
await
this
.
_fireWillEvent
(
this
.
_onWillDeleteFile
,
{
files
:
[
URI
.
revive
(
target
)]
},
token
);
await
this
.
_fireWillEvent
(
this
.
_onWillDeleteFile
,
{
files
:
[
URI
.
revive
(
target
)]
},
t
imeout
,
t
oken
);
break
;
case
FileOperation
.
CREATE
:
await
this
.
_fireWillEvent
(
this
.
_onWillCreateFile
,
{
files
:
[
URI
.
revive
(
target
)]
},
token
);
await
this
.
_fireWillEvent
(
this
.
_onWillCreateFile
,
{
files
:
[
URI
.
revive
(
target
)]
},
t
imeout
,
t
oken
);
break
;
default
:
//ignore, dont send
}
}
private
async
_fireWillEvent
<
E
extends
IWaitUntil
>
(
emitter
:
AsyncEmitter
<
E
>
,
data
:
Omit
<
E
,
'
waitUntil
'
>
,
token
:
CancellationToken
):
Promise
<
any
>
{
private
async
_fireWillEvent
<
E
extends
IWaitUntil
>
(
emitter
:
AsyncEmitter
<
E
>
,
data
:
Omit
<
E
,
'
waitUntil
'
>
,
t
imeout
:
number
,
t
oken
:
CancellationToken
):
Promise
<
any
>
{
const
edits
:
WorkspaceEdit
[]
=
[];
await
emitter
.
fireAsync
(
data
,
token
,
async
p
=>
{
await
emitter
.
fireAsync
(
data
,
token
,
async
(
thenable
,
listener
:
IExtensionListener
<
E
>
)
=>
{
// ignore all results except for WorkspaceEdits. Those are stored in an array.
const
result
=
await
Promise
.
resolve
(
p
);
const
now
=
Date
.
now
();
const
result
=
await
Promise
.
resolve
(
thenable
);
if
(
result
instanceof
WorkspaceEdit
)
{
edits
.
push
(
result
);
}
if
(
Date
.
now
()
-
now
>
timeout
)
{
this
.
_logService
.
warn
(
'
SLOW file-participant
'
,
listener
.
extension
?.
identifier
);
}
});
if
(
token
.
isCancellationRequested
)
{
...
...
src/vs/workbench/test/electron-browser/api/extHostFileSystemEventService.test.ts
浏览文件 @
eff23204
...
...
@@ -5,6 +5,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
ExtHostFileSystemEventService
}
from
'
vs/workbench/api/common/extHostFileSystemEventService
'
;
import
{
IMainContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
NullLogService
}
from
'
vs/platform/log/common/log
'
;
suite
(
'
ExtHostFileSystemEventService
'
,
()
=>
{
...
...
@@ -17,12 +18,12 @@ suite('ExtHostFileSystemEventService', () => {
assertRegistered
:
undefined
!
};
const
watcher1
=
new
ExtHostFileSystemEventService
(
protocol
,
undefined
!
).
createFileSystemWatcher
(
'
**/somethingInteresting
'
,
false
,
false
,
false
);
const
watcher1
=
new
ExtHostFileSystemEventService
(
protocol
,
new
NullLogService
(),
undefined
!
).
createFileSystemWatcher
(
'
**/somethingInteresting
'
,
false
,
false
,
false
);
assert
.
equal
(
watcher1
.
ignoreChangeEvents
,
false
);
assert
.
equal
(
watcher1
.
ignoreCreateEvents
,
false
);
assert
.
equal
(
watcher1
.
ignoreDeleteEvents
,
false
);
const
watcher2
=
new
ExtHostFileSystemEventService
(
protocol
,
undefined
!
).
createFileSystemWatcher
(
'
**/somethingBoring
'
,
true
,
true
,
true
);
const
watcher2
=
new
ExtHostFileSystemEventService
(
protocol
,
new
NullLogService
(),
undefined
!
).
createFileSystemWatcher
(
'
**/somethingBoring
'
,
true
,
true
,
true
);
assert
.
equal
(
watcher2
.
ignoreChangeEvents
,
true
);
assert
.
equal
(
watcher2
.
ignoreCreateEvents
,
true
);
assert
.
equal
(
watcher2
.
ignoreDeleteEvents
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录