Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
dfb98d6d
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dfb98d6d
编写于
6月 22, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first cut of FileWillRenameEvent with support for workspace edit, #43768
上级
e73417d2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
26 deletion
+70
-26
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-1
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+2
-2
src/vs/workbench/api/node/extHostFileSystemEventService.ts
src/vs/workbench/api/node/extHostFileSystemEventService.ts
+67
-23
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
dfb98d6d
...
...
@@ -663,7 +663,7 @@ declare module 'vscode' {
export
interface
FileWillRenameEvent
{
readonly
oldUri
:
Uri
;
readonly
newUri
:
Uri
;
waitUntil
(
thenable
:
Thenable
<
any
>
):
void
;
waitUntil
(
thenable
:
Thenable
<
WorkspaceEdit
>
):
void
;
}
export
namespace
workspace
{
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
dfb98d6d
...
...
@@ -116,7 +116,7 @@ export function createApiFactory(
const
extHostDiagnostics
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDiagnostics
,
new
ExtHostDiagnostics
(
rpcProtocol
));
const
extHostLanguageFeatures
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostLanguageFeatures
,
new
ExtHostLanguageFeatures
(
rpcProtocol
,
schemeTransformer
,
extHostDocuments
,
extHostCommands
,
extHostHeapService
,
extHostDiagnostics
));
const
extHostFileSystem
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostFileSystem
,
new
ExtHostFileSystem
(
rpcProtocol
,
extHostLanguageFeatures
));
const
extHostFileSystemEvent
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostFileSystemEventService
,
new
ExtHostFileSystemEventService
());
const
extHostFileSystemEvent
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostFileSystemEventService
,
new
ExtHostFileSystemEventService
(
rpcProtocol
,
extHostDocumentsAndEditors
));
const
extHostQuickOpen
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostQuickOpen
,
new
ExtHostQuickOpen
(
rpcProtocol
,
extHostWorkspace
,
extHostCommands
));
const
extHostTerminalService
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostTerminalService
,
new
ExtHostTerminalService
(
rpcProtocol
,
extHostConfiguration
,
extHostLogService
));
const
extHostDebugService
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDebugService
,
new
ExtHostDebugService
(
rpcProtocol
,
extHostWorkspace
,
extensionService
,
extHostDocumentsAndEditors
,
extHostConfiguration
,
extHostTerminalService
));
...
...
@@ -580,7 +580,7 @@ export function createApiFactory(
return
extHostFileSystemEvent
.
onDidRenameFile
(
listener
,
thisArg
,
disposables
);
}),
onWillRenameFile
:
proposedApiFunction
(
extension
,
(
listener
,
thisArg
?,
disposables
?)
=>
{
return
extHostFileSystemEvent
.
onWillRenameFile
(
listener
,
thisArg
,
disposables
);
return
extHostFileSystemEvent
.
getOnWillRenameFileEvent
(
extension
)
(
listener
,
thisArg
,
disposables
);
})
};
...
...
src/vs/workbench/api/node/extHostFileSystemEventService.ts
浏览文件 @
dfb98d6d
...
...
@@ -4,13 +4,17 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
AsyncEmitter
,
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
IRelativePattern
,
parse
}
from
'
vs/base/common/glob
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
ExtHostFileSystemEventServiceShape
,
FileSystemEvents
}
from
'
./extHost.protocol
'
;
import
{
Disposable
}
from
'
./extHostTypes
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/node/extHostDocumentsAndEditors
'
;
import
{
IExtensionDescription
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
ExtHostFileSystemEventServiceShape
,
FileSystemEvents
,
IMainContext
,
MainContext
,
ResourceFileEditDto
,
ResourceTextEditDto
,
MainThreadTextEditorsShape
}
from
'
./extHost.protocol
'
;
import
*
as
typeConverter
from
'
./extHostTypeConverters
'
;
import
{
Disposable
,
WorkspaceEdit
}
from
'
./extHostTypes
'
;
class
FileSystemWatcher
implements
vscode
.
FileSystemWatcher
{
...
...
@@ -94,16 +98,25 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
}
}
interface
WillRenameListener
{
extension
:
IExtensionDescription
;
(
e
:
vscode
.
FileWillRenameEvent
):
any
;
}
export
class
ExtHostFileSystemEventService
implements
ExtHostFileSystemEventServiceShape
{
private
_onFileEvent
=
new
Emitter
<
FileSystemEvents
>
();
private
_onDidRenameFile
=
new
Emitter
<
vscode
.
FileRenameEvent
>
();
private
_onWillRenameFile
=
new
Emitter
<
vscode
.
FileWillRenameEvent
>
();
private
readonly
_onFileEvent
=
new
Emitter
<
FileSystemEvents
>
();
private
readonly
_onDidRenameFile
=
new
Emitter
<
vscode
.
FileRenameEvent
>
();
private
readonly
_onWillRenameFile
=
new
Async
Emitter
<
vscode
.
FileWillRenameEvent
>
();
readonly
onDidRenameFile
:
Event
<
vscode
.
FileRenameEvent
>
=
this
.
_onDidRenameFile
.
event
;
readonly
onWillRenameFile
:
Event
<
vscode
.
FileWillRenameEvent
>
=
this
.
_onWillRenameFile
.
event
;
constructor
()
{
constructor
(
mainContext
:
IMainContext
,
private
readonly
_extHostDocumentsAndEditors
:
ExtHostDocumentsAndEditors
,
private
readonly
_mainThreadTextEditors
:
MainThreadTextEditorsShape
=
mainContext
.
getProxy
(
MainContext
.
MainThreadTextEditors
)
)
{
//
}
public
createFileSystemWatcher
(
globPattern
:
string
|
IRelativePattern
,
ignoreCreateEvents
?:
boolean
,
ignoreChangeEvents
?:
boolean
,
ignoreDeleteEvents
?:
boolean
):
vscode
.
FileSystemWatcher
{
...
...
@@ -118,23 +131,54 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
this
.
_onDidRenameFile
.
fire
(
Object
.
freeze
({
oldUri
:
URI
.
revive
(
oldUri
),
newUri
:
URI
.
revive
(
newUri
)
}));
}
$onWillRename
(
oldUri
:
UriComponents
,
newUri
:
UriComponents
):
TPromise
<
any
>
{
let
thenables
:
Thenable
<
any
>
[]
=
[];
getOnWillRenameFileEvent
(
extension
:
IExtensionDescription
):
Event
<
vscode
.
FileWillRenameEvent
>
{
return
(
listener
,
thisArg
,
disposables
)
=>
{
let
wrappedListener
=
<
WillRenameListener
><
any
>
function
()
{
listener
.
apply
(
thisArg
,
arguments
);
};
wrappedListener
.
extension
=
extension
;
return
this
.
_onWillRenameFile
.
event
(
wrappedListener
,
undefined
,
disposables
);
};
}
this
.
_onWillRenameFile
.
fire
({
oldUri
:
URI
.
revive
(
oldUri
),
newUri
:
URI
.
revive
(
newUri
),
waitUntil
(
thenable
:
Thenable
<
any
>
):
void
{
if
(
Object
.
isFrozen
(
thenables
))
{
throw
new
Error
(
'
waitUntil cannot be called async
'
);
$onWillRename
(
oldUriDto
:
UriComponents
,
newUriDto
:
UriComponents
):
TPromise
<
any
>
{
const
oldUri
=
URI
.
revive
(
oldUriDto
);
const
newUri
=
URI
.
revive
(
newUriDto
);
const
edits
:
WorkspaceEdit
[]
=
[];
return
this
.
_onWillRenameFile
.
fireAsync
((
bucket
,
listener
)
=>
{
return
{
oldUri
,
newUri
,
waitUntil
:
(
thenable
:
Thenable
<
vscode
.
WorkspaceEdit
>
):
void
=>
{
if
(
Object
.
isFrozen
(
bucket
))
{
throw
new
TypeError
(
'
waitUntil cannot be called async
'
);
}
const
index
=
bucket
.
length
;
const
wrappedThenable
=
TPromise
.
as
(
thenable
).
then
(
result
=>
{
// ignore all results except for WorkspaceEdits. Those
// are stored in a spare array
if
(
result
instanceof
WorkspaceEdit
)
{
edits
[
index
]
=
result
;
}
});
bucket
.
push
(
wrappedThenable
);
}
};
}).
then
(()
=>
{
if
(
edits
.
length
===
0
)
{
return
undefined
;
}
// flatten all WorkspaceEdits collected via waitUntil-call
// and apply them in one go.
let
allEdits
=
new
Array
<
(
ResourceFileEditDto
|
ResourceTextEditDto
)[]
>
();
for
(
let
edit
of
edits
)
{
if
(
edit
)
{
// sparse array
let
{
edits
}
=
typeConverter
.
WorkspaceEdit
.
from
(
edit
,
this
.
_extHostDocumentsAndEditors
);
allEdits
.
push
(
edits
);
}
thenables
.
push
(
thenable
.
then
(
undefined
,
err
=>
console
.
error
(
err
)));
}
return
this
.
_mainThreadTextEditors
.
$tryApplyWorkspaceEdit
({
edits
:
flatten
(
allEdits
)
});
});
Object
.
freeze
(
thenables
);
return
TPromise
.
join
(
thenables
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录