Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2344aade
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,体验更适合开发者的 AI 搜索 >>
提交
2344aade
编写于
3月 22, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
files2 - wait on legacy service to be there
上级
a94502f9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
22 deletion
+38
-22
src/vs/workbench/browser/workbench.ts
src/vs/workbench/browser/workbench.ts
+2
-2
src/vs/workbench/services/files/node/fileService.ts
src/vs/workbench/services/files/node/fileService.ts
+1
-1
src/vs/workbench/services/files2/common/fileService2.ts
src/vs/workbench/services/files2/common/fileService2.ts
+34
-18
src/vs/workbench/services/files2/test/node/diskFileService.test.ts
...rkbench/services/files2/test/node/diskFileService.test.ts
+1
-1
未找到文件。
src/vs/workbench/browser/workbench.ts
浏览文件 @
2344aade
...
...
@@ -192,8 +192,8 @@ export class Workbench extends Layout {
// TODO@Ben legacy file service
const
fileService
=
accessor
.
get
(
IFileService
)
as
any
;
if
(
typeof
fileService
.
set
Impl
===
'
function
'
)
{
fileService
.
set
Impl
(
accessor
.
get
(
ILegacyFileService
));
if
(
typeof
fileService
.
set
LegacyService
===
'
function
'
)
{
fileService
.
set
LegacyService
(
accessor
.
get
(
ILegacyFileService
));
}
// TODO@Sandeep debt around cyclic dependencies
...
...
src/vs/workbench/services/files/node/fileService.ts
浏览文件 @
2344aade
...
...
@@ -207,7 +207,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
}
registerProvider
(
scheme
:
string
,
provider
:
IFileSystemProvider
):
IDisposable
{
throw
new
Error
(
'
not implemented
'
)
;
return
Disposable
.
None
;
}
activateProvider
(
scheme
:
string
):
Promise
<
void
>
{
...
...
src/vs/workbench/services/files2/common/fileService2.ts
浏览文件 @
2344aade
...
...
@@ -19,25 +19,34 @@ export class FileService2 extends Disposable implements IFileService {
//#region TODO@Ben HACKS
private
_
impl
:
IFileService
;
private
_
legacy
:
IFileService
|
null
;
set
Impl
(
service
:
IFileService
):
void
{
this
.
_
impl
=
this
.
_register
(
service
);
set
LegacyService
(
legacy
:
IFileService
):
void
{
this
.
_
legacy
=
this
.
_register
(
legacy
);
this
.
_register
(
service
.
onFileChanges
(
e
=>
this
.
_onFileChanges
.
fire
(
e
)));
this
.
_register
(
service
.
onAfterOperation
(
e
=>
this
.
_onAfterOperation
.
fire
(
e
)));
this
.
_register
(
legacy
.
onFileChanges
(
e
=>
this
.
_onFileChanges
.
fire
(
e
)));
this
.
_register
(
legacy
.
onAfterOperation
(
e
=>
this
.
_onAfterOperation
.
fire
(
e
)));
this
.
provider
.
forEach
((
provider
,
scheme
)
=>
{
this
.
_impl
.
registerProvider
(
scheme
,
provider
);
legacy
.
registerProvider
(
scheme
,
provider
);
});
this
.
joinOnImplResolve
(
legacy
);
}
//#endregion
_serviceBrand
:
ServiceIdentifier
<
any
>
;
private
joinOnLegacy
:
Promise
<
IFileService
>
;
private
joinOnImplResolve
:
(
service
:
IFileService
)
=>
void
;
constructor
(@
ILogService
private
logService
:
ILogService
)
{
super
();
this
.
joinOnLegacy
=
new
Promise
(
resolve
=>
{
this
.
joinOnImplResolve
=
resolve
;
});
}
//#region File System Provider
...
...
@@ -56,8 +65,8 @@ export class FileService2 extends Disposable implements IFileService {
}
let
legacyDisposal
:
IDisposable
;
if
(
this
.
_
impl
)
{
legacyDisposal
=
this
.
_
impl
.
registerProvider
(
scheme
,
provider
);
if
(
this
.
_
legacy
)
{
legacyDisposal
=
this
.
_
legacy
.
registerProvider
(
scheme
,
provider
);
}
else
{
legacyDisposal
=
Disposable
.
None
;
}
...
...
@@ -285,22 +294,28 @@ export class FileService2 extends Disposable implements IFileService {
//#region File Reading/Writing
get
encoding
():
IResourceEncodings
{
return
this
.
_impl
.
encoding
;
}
get
encoding
():
IResourceEncodings
{
if
(
!
this
.
_legacy
)
{
throw
new
Error
(
'
Legacy file service not ready yet
'
);
}
return
this
.
_legacy
.
encoding
;
}
createFile
(
resource
:
URI
,
content
?:
string
,
options
?:
ICreateFileOptions
):
Promise
<
IFileStatWithMetadata
>
{
return
this
.
_impl
.
createFile
(
resource
,
content
,
options
);
return
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
createFile
(
resource
,
content
,
options
)
);
}
resolveContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IContent
>
{
return
this
.
_impl
.
resolveContent
(
resource
,
options
);
return
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
resolveContent
(
resource
,
options
)
);
}
resolveStreamContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IStreamContent
>
{
return
this
.
_impl
.
resolveStreamContent
(
resource
,
options
);
return
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
resolveStreamContent
(
resource
,
options
)
);
}
updateContent
(
resource
:
URI
,
value
:
string
|
ITextSnapshot
,
options
?:
IUpdateContentOptions
):
Promise
<
IFileStatWithMetadata
>
{
return
this
.
_impl
.
updateContent
(
resource
,
value
,
options
);
return
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
updateContent
(
resource
,
value
,
options
)
);
}
//#endregion
...
...
@@ -346,11 +361,11 @@ export class FileService2 extends Disposable implements IFileService {
return
this
.
doMoveCopyWithSameProvider
(
source
,
target
,
true
/* keep copy */
,
overwrite
);
}
return
this
.
_impl
.
copyFile
(
source
,
target
,
overwrite
);
// TODO@ben implement properly
return
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
copyFile
(
source
,
target
,
overwrite
));
}
private
async
doCopyWithDifferentProvider
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
return
this
.
_impl
.
copyFile
(
source
,
target
,
overwrite
);
// TODO@ben implement properly
return
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
copyFile
(
source
,
target
,
overwrite
));
}
private
async
doMoveCopyWithSameProvider
(
source
:
URI
,
target
:
URI
,
keepCopy
:
boolean
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
...
...
@@ -444,7 +459,8 @@ export class FileService2 extends Disposable implements IFileService {
async
del
(
resource
:
URI
,
options
?:
{
useTrash
?:
boolean
;
recursive
?:
boolean
;
}):
Promise
<
void
>
{
if
(
options
&&
options
.
useTrash
)
{
return
this
.
_impl
.
del
(
resource
,
options
);
//TODO@ben this is https://github.com/Microsoft/vscode/issues/48259
//TODO@ben this is https://github.com/Microsoft/vscode/issues/48259
return
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
del
(
resource
,
options
));
}
const
provider
=
this
.
throwIfFileSystemIsReadonly
(
await
this
.
withProvider
(
resource
));
...
...
@@ -464,11 +480,11 @@ export class FileService2 extends Disposable implements IFileService {
get
onFileChanges
():
Event
<
FileChangesEvent
>
{
return
this
.
_onFileChanges
.
event
;
}
watchFileChanges
(
resource
:
URI
):
void
{
this
.
_impl
.
watchFileChanges
(
resource
);
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
watchFileChanges
(
resource
)
);
}
unwatchFileChanges
(
resource
:
URI
):
void
{
this
.
_impl
.
unwatchFileChanges
(
resource
);
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
unwatchFileChanges
(
resource
)
);
}
//#endregion
...
...
src/vs/workbench/services/files2/test/node/diskFileService.test.ts
浏览文件 @
2344aade
...
...
@@ -55,7 +55,7 @@ suite('Disk File Service', () => {
await
copy
(
sourceDir
,
testDir
);
const
legacyService
=
new
FileService
(
new
TestContextService
(
new
Workspace
(
testDir
,
toWorkspaceFolders
([{
path
:
testDir
}]))),
TestEnvironmentService
,
new
TestTextResourceConfigurationService
(),
new
TestConfigurationService
(),
new
TestLifecycleService
(),
new
TestStorageService
(),
new
TestNotificationService
(),
{
disableWatcher
:
true
});
service
.
set
Impl
(
legacyService
);
service
.
set
LegacyService
(
legacyService
);
});
teardown
(
async
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录