Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f4eae9a5
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
f4eae9a5
编写于
3月 28, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
files2 - polish method names
上级
7081def4
变更
44
展开全部
隐藏空白更改
内联
并排
Showing
44 changed file
with
256 addition
and
256 deletion
+256
-256
src/vs/platform/configuration/node/configuration.ts
src/vs/platform/configuration/node/configuration.ts
+2
-2
src/vs/platform/files/common/files.ts
src/vs/platform/files/common/files.ts
+17
-17
src/vs/workbench/api/browser/mainThreadDocuments.ts
src/vs/workbench/api/browser/mainThreadDocuments.ts
+1
-1
src/vs/workbench/browser/dnd.ts
src/vs/workbench/browser/dnd.ts
+1
-1
src/vs/workbench/browser/nodeless.simpleservices.ts
src/vs/workbench/browser/nodeless.simpleservices.ts
+8
-8
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
+1
-1
src/vs/workbench/common/editor/binaryEditorModel.ts
src/vs/workbench/common/editor/binaryEditorModel.ts
+1
-1
src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts
...ntrib/extensions/electron-browser/extensionTipsService.ts
+1
-1
src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts
.../contrib/extensions/electron-browser/extensionsActions.ts
+1
-1
src/vs/workbench/contrib/externalTerminal/electron-browser/externalTerminal.contribution.ts
...erminal/electron-browser/externalTerminal.contribution.ts
+1
-1
src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts
...kbench/contrib/files/browser/editors/fileEditorTracker.ts
+4
-4
src/vs/workbench/contrib/files/browser/fileActions.ts
src/vs/workbench/contrib/files/browser/fileActions.ts
+2
-2
src/vs/workbench/contrib/files/browser/fileCommands.ts
src/vs/workbench/contrib/files/browser/fileCommands.ts
+1
-1
src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
...s/workbench/contrib/files/browser/views/explorerViewer.ts
+4
-4
src/vs/workbench/contrib/files/common/explorerModel.ts
src/vs/workbench/contrib/files/common/explorerModel.ts
+1
-1
src/vs/workbench/contrib/files/common/explorerService.ts
src/vs/workbench/contrib/files/common/explorerService.ts
+2
-2
src/vs/workbench/contrib/search/browser/openFileHandler.ts
src/vs/workbench/contrib/search/browser/openFileHandler.ts
+1
-1
src/vs/workbench/contrib/search/browser/search.contribution.ts
...s/workbench/contrib/search/browser/search.contribution.ts
+1
-1
src/vs/workbench/contrib/search/browser/searchView.ts
src/vs/workbench/contrib/search/browser/searchView.ts
+1
-1
src/vs/workbench/contrib/snippets/browser/configureSnippets.ts
...s/workbench/contrib/snippets/browser/configureSnippets.ts
+1
-1
src/vs/workbench/contrib/snippets/browser/snippetsService.ts
src/vs/workbench/contrib/snippets/browser/snippetsService.ts
+4
-4
src/vs/workbench/contrib/stats/node/workspaceStats.ts
src/vs/workbench/contrib/stats/node/workspaceStats.ts
+6
-6
src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts
...bench/contrib/tasks/electron-browser/task.contribution.ts
+2
-2
src/vs/workbench/contrib/tasks/node/processRunnerDetector.ts
src/vs/workbench/contrib/tasks/node/processRunnerDetector.ts
+4
-4
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
...workbench/contrib/terminal/browser/terminalLinkHandler.ts
+1
-1
src/vs/workbench/contrib/terminal/common/terminalService.ts
src/vs/workbench/contrib/terminal/common/terminalService.ts
+1
-1
src/vs/workbench/contrib/terminal/electron-browser/terminalService.ts
...ench/contrib/terminal/electron-browser/terminalService.ts
+1
-1
src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts
src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts
+1
-1
src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts
...vs/workbench/services/bulkEdit/browser/bulkEditService.ts
+3
-3
src/vs/workbench/services/configuration/common/configurationEditingService.ts
...vices/configuration/common/configurationEditingService.ts
+1
-1
src/vs/workbench/services/configuration/common/jsonEditingService.ts
...bench/services/configuration/common/jsonEditingService.ts
+1
-1
src/vs/workbench/services/configuration/node/configuration.ts
...vs/workbench/services/configuration/node/configuration.ts
+3
-3
src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts
...vs/workbench/services/dialogs/browser/remoteFileDialog.ts
+10
-10
src/vs/workbench/services/files/node/fileService.ts
src/vs/workbench/services/files/node/fileService.ts
+20
-20
src/vs/workbench/services/files/node/remoteFileService.ts
src/vs/workbench/services/files/node/remoteFileService.ts
+13
-13
src/vs/workbench/services/files/test/electron-browser/fileService.test.ts
.../services/files/test/electron-browser/fileService.test.ts
+6
-6
src/vs/workbench/services/files2/common/fileService2.ts
src/vs/workbench/services/files2/common/fileService2.ts
+25
-25
src/vs/workbench/services/files2/test/node/diskFileService.test.ts
...rkbench/services/files2/test/node/diskFileService.test.ts
+82
-82
src/vs/workbench/services/keybinding/common/keybindingEditing.ts
...workbench/services/keybinding/common/keybindingEditing.ts
+1
-1
src/vs/workbench/services/output/common/outputChannelModel.ts
...vs/workbench/services/output/common/outputChannelModel.ts
+1
-1
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+1
-1
src/vs/workbench/services/textfile/common/textFileService.ts
src/vs/workbench/services/textfile/common/textFileService.ts
+3
-3
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
...orkbench/services/themes/browser/workbenchThemeService.ts
+4
-4
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+10
-10
未找到文件。
src/vs/platform/configuration/node/configuration.ts
浏览文件 @
f4eae9a5
...
...
@@ -70,8 +70,8 @@ export class FileServiceBasedUserConfiguration extends Disposable {
this
.
_register
(
fileService
.
onFileChanges
(
e
=>
this
.
handleFileEvents
(
e
)));
this
.
reloadConfigurationScheduler
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
reload
().
then
(
configurationModel
=>
this
.
_onDidChangeConfiguration
.
fire
(
configurationModel
)),
50
));
this
.
fileService
.
watch
FileChanges
(
this
.
configurationResource
);
this
.
_register
(
toDisposable
(()
=>
this
.
fileService
.
unwatch
FileChanges
(
this
.
configurationResource
)));
this
.
fileService
.
watch
(
this
.
configurationResource
);
this
.
_register
(
toDisposable
(()
=>
this
.
fileService
.
unwatch
(
this
.
configurationResource
)));
}
initialize
():
Promise
<
ConfigurationModel
>
{
...
...
src/vs/platform/files/common/files.ts
浏览文件 @
f4eae9a5
...
...
@@ -70,7 +70,7 @@ export interface IFileService {
/**
* Allows to listen for file changes. The event will fire for every file within the opened workspace
* (if any) as well as all files that have been watched explicitly using the #watch
FileChanges
() API.
* (if any) as well as all files that have been watched explicitly using the #watch() API.
*/
readonly
onFileChanges
:
Event
<
FileChangesEvent
>
;
...
...
@@ -80,7 +80,7 @@ export interface IFileService {
readonly
onAfterOperation
:
Event
<
FileOperationEvent
>
;
/**
* Resolve the properties of a file identified by the resource.
* Resolve the properties of a file
/folder
identified by the resource.
*
* If the optional parameter "resolveTo" is specified in options, the stat service is asked
* to provide a stat object that should contain the full graph of folders up to all of the
...
...
@@ -93,20 +93,20 @@ export interface IFileService {
* If the optional parameter "resolveMetadata" is specified in options,
* the stat will contain metadata information such as size, mtime and etag.
*/
resolve
File
(
resource
:
URI
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
File
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
resolve
(
resource
:
URI
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
/**
* Same as resolve
File
but supports resolving multiple resources in parallel.
* Same as resolve
()
but supports resolving multiple resources in parallel.
* If one of the resolve targets fails to resolve returns a fake IFileStat instead of making the whole call fail.
*/
resolve
Files
(
toResolve
:
{
resource
:
URI
,
options
:
IResolveMetadataFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
;
resolve
Files
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
;
resolve
All
(
toResolve
:
{
resource
:
URI
,
options
:
IResolveMetadataFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
;
resolve
All
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
;
/**
* Finds out if a file identified by the resource exists.
* Finds out if a file
/folder
identified by the resource exists.
*/
exists
File
(
resource
:
URI
):
Promise
<
boolean
>
;
exists
(
resource
:
URI
):
Promise
<
boolean
>
;
/**
* Resolve the contents of a file identified by the resource.
...
...
@@ -128,18 +128,18 @@ export interface IFileService {
updateContent
(
resource
:
URI
,
value
:
string
|
ITextSnapshot
,
options
?:
IUpdateContentOptions
):
Promise
<
IFileStatWithMetadata
>
;
/**
* Moves the file to a new path identified by the resource.
* Moves the file
/folder
to a new path identified by the resource.
*
* The optional parameter overwrite can be set to replace an existing file at the location.
*/
move
File
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
;
move
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
;
/**
* Copies the file to a path identified by the resource.
* Copies the file
/folder
to a path identified by the resource.
*
* The optional parameter overwrite can be set to replace an existing file at the location.
*/
copy
File
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
;
copy
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
;
/**
* Creates a new file with the given path. The returned promise
...
...
@@ -165,12 +165,12 @@ export interface IFileService {
/**
* Allows to start a watcher that reports file change events on the provided resource.
*/
watch
FileChanges
(
resource
:
URI
):
void
;
watch
(
resource
:
URI
):
void
;
/**
* Allows to stop a watcher on the provided resource or absolute fs path.
*/
unwatch
FileChanges
(
resource
:
URI
):
void
;
unwatch
(
resource
:
URI
):
void
;
/**
* Frees up any resources occupied by this service.
...
...
@@ -1135,7 +1135,7 @@ export interface ILegacyFileService {
createFile
(
resource
:
URI
,
content
?:
string
,
options
?:
ICreateFileOptions
):
Promise
<
IFileStat
>
;
watch
FileChanges
(
resource
:
URI
):
void
;
watch
(
resource
:
URI
):
void
;
unwatch
FileChanges
(
resource
:
URI
):
void
;
unwatch
(
resource
:
URI
):
void
;
}
\ No newline at end of file
src/vs/workbench/api/browser/mainThreadDocuments.ts
浏览文件 @
f4eae9a5
...
...
@@ -215,7 +215,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
private
_handleUntitledScheme
(
uri
:
URI
):
Promise
<
boolean
>
{
const
asFileUri
=
uri
.
with
({
scheme
:
Schemas
.
file
});
return
this
.
_fileService
.
resolve
File
(
asFileUri
).
then
(
stats
=>
{
return
this
.
_fileService
.
resolve
(
asFileUri
).
then
(
stats
=>
{
// don't create a new file ontop of an existing file
return
Promise
.
reject
(
new
Error
(
'
file already exists on disk
'
));
},
err
=>
{
...
...
src/vs/workbench/browser/dnd.ts
浏览文件 @
f4eae9a5
...
...
@@ -269,7 +269,7 @@ export class ResourcesDropHandler {
}
// Check for Folder
return
this
.
fileService
.
resolve
File
(
fileOnDiskResource
).
then
(
stat
=>
{
return
this
.
fileService
.
resolve
(
fileOnDiskResource
).
then
(
stat
=>
{
if
(
stat
.
isDirectory
)
{
workspaceResources
.
folders
.
push
({
uri
:
stat
.
resource
,
typeHint
:
'
folder
'
});
}
...
...
src/vs/workbench/browser/nodeless.simpleservices.ts
浏览文件 @
f4eae9a5
...
...
@@ -695,16 +695,16 @@ export class SimpleRemoteFileService implements IFileService {
readonly
onDidChangeFileSystemProviderRegistrations
=
Event
.
None
;
readonly
onWillActivateFileSystemProvider
=
Event
.
None
;
resolve
File
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStatWithMetadata
>
{
resolve
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStatWithMetadata
>
{
// @ts-ignore
return
Promise
.
resolve
(
fileMap
.
get
(
resource
));
}
resolve
Files
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
{
return
Promise
.
all
(
toResolve
.
map
(
resourceAndOption
=>
this
.
resolve
File
(
resourceAndOption
.
resource
,
resourceAndOption
.
options
))).
then
(
stats
=>
stats
.
map
(
stat
=>
({
stat
,
success
:
true
})));
resolve
All
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
{
return
Promise
.
all
(
toResolve
.
map
(
resourceAndOption
=>
this
.
resolve
(
resourceAndOption
.
resource
,
resourceAndOption
.
options
))).
then
(
stats
=>
stats
.
map
(
stat
=>
({
stat
,
success
:
true
})));
}
exists
File
(
resource
:
URI
):
Promise
<
boolean
>
{
exists
(
resource
:
URI
):
Promise
<
boolean
>
{
return
Promise
.
resolve
(
fileMap
.
has
(
resource
));
}
...
...
@@ -761,9 +761,9 @@ export class SimpleRemoteFileService implements IFileService {
});
}
move
File
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
return
Promise
.
resolve
(
null
!
);
}
move
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
return
Promise
.
resolve
(
null
!
);
}
copy
File
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
any
>
{
copy
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
any
>
{
const
parent
=
fileMap
.
get
(
dirname
(
_target
));
if
(
!
parent
)
{
return
Promise
.
resolve
(
undefined
);
...
...
@@ -802,9 +802,9 @@ export class SimpleRemoteFileService implements IFileService {
del
(
_resource
:
URI
,
_options
?:
{
useTrash
?:
boolean
,
recursive
?:
boolean
}):
Promise
<
void
>
{
return
Promise
.
resolve
();
}
watch
FileChanges
(
_resource
:
URI
):
void
{
}
watch
(
_resource
:
URI
):
void
{
}
unwatch
FileChanges
(
_resource
:
URI
):
void
{
}
unwatch
(
_resource
:
URI
):
void
{
}
getWriteEncoding
(
_resource
:
URI
):
IResourceEncoding
{
return
{
encoding
:
'
utf8
'
,
hasBOM
:
false
};
}
...
...
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
浏览文件 @
f4eae9a5
...
...
@@ -228,7 +228,7 @@ class FileDataSource implements IAsyncDataSource<IWorkspace | URI, IWorkspaceFol
}
else
{
uri
=
element
.
resource
;
}
return
this
.
_fileService
.
resolve
File
(
uri
).
then
(
stat
=>
{
return
this
.
_fileService
.
resolve
(
uri
).
then
(
stat
=>
{
for
(
const
child
of
stat
.
children
||
[])
{
this
.
_parents
.
set
(
stat
,
child
);
}
...
...
src/vs/workbench/common/editor/binaryEditorModel.ts
浏览文件 @
f4eae9a5
...
...
@@ -76,7 +76,7 @@ export class BinaryEditorModel extends EditorModel {
// Make sure to resolve up to date stat for file resources
if
(
this
.
fileService
.
canHandleResource
(
this
.
resource
))
{
return
this
.
fileService
.
resolve
File
(
this
.
resource
,
{
resolveMetadata
:
true
}).
then
(
stat
=>
{
return
this
.
fileService
.
resolve
(
this
.
resource
,
{
resolveMetadata
:
true
}).
then
(
stat
=>
{
this
.
etag
=
stat
.
etag
;
if
(
typeof
stat
.
size
===
'
number
'
)
{
this
.
size
=
stat
.
size
;
...
...
src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts
浏览文件 @
f4eae9a5
...
...
@@ -335,7 +335,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
private
resolveWorkspaceFolderExtensionConfig
(
workspaceFolder
:
IWorkspaceFolder
):
Promise
<
IExtensionsConfigContent
|
null
>
{
const
extensionsJsonUri
=
workspaceFolder
.
toResource
(
EXTENSIONS_CONFIG
);
return
Promise
.
resolve
(
this
.
fileService
.
resolve
File
(
extensionsJsonUri
)
return
Promise
.
resolve
(
this
.
fileService
.
resolve
(
extensionsJsonUri
)
.
then
(()
=>
this
.
fileService
.
resolveContent
(
extensionsJsonUri
))
.
then
(
content
=>
<
IExtensionsConfigContent
>
json
.
parse
(
content
.
value
),
err
=>
null
));
}
...
...
src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts
浏览文件 @
f4eae9a5
...
...
@@ -2528,7 +2528,7 @@ export class OpenExtensionsFolderAction extends Action {
run
():
Promise
<
void
>
{
const
extensionsHome
=
URI
.
file
(
this
.
environmentService
.
extensionsPath
);
return
Promise
.
resolve
(
this
.
fileService
.
resolve
File
(
extensionsHome
)).
then
(
file
=>
{
return
Promise
.
resolve
(
this
.
fileService
.
resolve
(
extensionsHome
)).
then
(
file
=>
{
let
itemToShow
:
URI
;
if
(
file
.
children
&&
file
.
children
.
length
>
0
)
{
itemToShow
=
file
.
children
[
0
].
resource
;
...
...
src/vs/workbench/contrib/externalTerminal/electron-browser/externalTerminal.contribution.ts
浏览文件 @
f4eae9a5
...
...
@@ -90,7 +90,7 @@ CommandsRegistry.registerCommand({
const
terminalService
=
accessor
.
get
(
IExternalTerminalService
);
const
resources
=
getMultiSelectedResources
(
resource
,
accessor
.
get
(
IListService
),
editorService
);
return
fileService
.
resolve
Files
(
resources
.
map
(
r
=>
({
resource
:
r
}))).
then
(
stats
=>
{
return
fileService
.
resolve
All
(
resources
.
map
(
r
=>
({
resource
:
r
}))).
then
(
stats
=>
{
const
directoriesToOpen
=
distinct
(
stats
.
filter
(
data
=>
data
.
success
).
map
(({
stat
})
=>
stat
!
.
isDirectory
?
stat
!
.
resource
.
fsPath
:
paths
.
dirname
(
stat
!
.
resource
.
fsPath
)));
return
directoriesToOpen
.
map
(
dir
=>
{
if
(
configurationService
.
getValue
<
IExternalTerminalConfiguration
>
().
terminal
.
explorerKind
===
'
integrated
'
)
{
...
...
src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts
浏览文件 @
f4eae9a5
...
...
@@ -171,7 +171,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// flag.
let
checkExists
:
Promise
<
boolean
>
;
if
(
isExternal
)
{
checkExists
=
timeout
(
100
).
then
(()
=>
this
.
fileService
.
exists
File
(
resource
));
checkExists
=
timeout
(
100
).
then
(()
=>
this
.
fileService
.
exists
(
resource
));
}
else
{
checkExists
=
Promise
.
resolve
(
false
);
}
...
...
@@ -352,7 +352,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// Handle no longer visible out of workspace resources
this
.
activeOutOfWorkspaceWatchers
.
forEach
(
resource
=>
{
if
(
!
visibleOutOfWorkspacePaths
.
get
(
resource
))
{
this
.
fileService
.
unwatch
FileChanges
(
resource
);
this
.
fileService
.
unwatch
(
resource
);
this
.
activeOutOfWorkspaceWatchers
.
delete
(
resource
);
}
});
...
...
@@ -360,7 +360,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// Handle newly visible out of workspace resources
visibleOutOfWorkspacePaths
.
forEach
(
resource
=>
{
if
(
!
this
.
activeOutOfWorkspaceWatchers
.
get
(
resource
))
{
this
.
fileService
.
watch
FileChanges
(
resource
);
this
.
fileService
.
watch
(
resource
);
this
.
activeOutOfWorkspaceWatchers
.
set
(
resource
,
resource
);
}
});
...
...
@@ -370,7 +370,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
super
.
dispose
();
// Dispose watchers if any
this
.
activeOutOfWorkspaceWatchers
.
forEach
(
resource
=>
this
.
fileService
.
unwatch
FileChanges
(
resource
));
this
.
activeOutOfWorkspaceWatchers
.
forEach
(
resource
=>
this
.
fileService
.
unwatch
(
resource
));
this
.
activeOutOfWorkspaceWatchers
.
clear
();
}
}
src/vs/workbench/contrib/files/browser/fileActions.ts
浏览文件 @
f4eae9a5
...
...
@@ -492,7 +492,7 @@ class PasteFileAction extends BaseErrorReportingAction {
throw
new
Error
(
nls
.
localize
(
'
fileIsAncestor
'
,
"
File to paste is an ancestor of the destination folder
"
));
}
return
this
.
fileService
.
resolve
File
(
fileToPaste
).
then
(
fileToPasteStat
=>
{
return
this
.
fileService
.
resolve
(
fileToPaste
).
then
(
fileToPasteStat
=>
{
// Find target
let
target
:
ExplorerItem
;
...
...
@@ -505,7 +505,7 @@ class PasteFileAction extends BaseErrorReportingAction {
const
targetFile
=
findValidPasteFileTarget
(
target
,
{
resource
:
fileToPaste
,
isDirectory
:
fileToPasteStat
.
isDirectory
,
allowOverwirte
:
pasteShouldMove
});
// Copy File
const
promise
=
pasteShouldMove
?
this
.
fileService
.
move
File
(
fileToPaste
,
targetFile
)
:
this
.
fileService
.
copyFile
(
fileToPaste
,
targetFile
);
const
promise
=
pasteShouldMove
?
this
.
fileService
.
move
(
fileToPaste
,
targetFile
)
:
this
.
fileService
.
copy
(
fileToPaste
,
targetFile
);
return
promise
.
then
<
ITextEditor
|
undefined
>
(
stat
=>
{
if
(
pasteShouldMove
)
{
// Cut is done. Make sure to clear cut state.
...
...
src/vs/workbench/contrib/files/browser/fileCommands.ts
浏览文件 @
f4eae9a5
...
...
@@ -270,7 +270,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
// Set side input
if
(
resources
.
length
)
{
return
fileService
.
resolve
Files
(
resources
.
map
(
resource
=>
({
resource
}))).
then
(
resolved
=>
{
return
fileService
.
resolve
All
(
resources
.
map
(
resource
=>
({
resource
}))).
then
(
resolved
=>
{
const
editors
=
resolved
.
filter
(
r
=>
r
.
stat
&&
r
.
success
&&
!
r
.
stat
.
isDirectory
).
map
(
r
=>
({
resource
:
r
.
stat
!
.
resource
}));
...
...
src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
浏览文件 @
f4eae9a5
...
...
@@ -607,7 +607,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
const
droppedResources
=
extractResources
(
originalEvent
,
true
);
// Check for dropped external files to be folders
return
this
.
fileService
.
resolve
Files
(
droppedResources
).
then
(
result
=>
{
return
this
.
fileService
.
resolve
All
(
droppedResources
).
then
(
result
=>
{
// Pass focus to window
this
.
windowService
.
focusWindow
();
...
...
@@ -648,7 +648,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
if
(
resources
&&
resources
.
length
>
0
)
{
// Resolve target to check for name collisions and ask user
return
this
.
fileService
.
resolve
File
(
target
.
resource
).
then
(
targetStat
=>
{
return
this
.
fileService
.
resolve
(
target
.
resource
).
then
(
targetStat
=>
{
// Check for name collisions
const
targetNames
=
new
Set
<
string
>
();
...
...
@@ -694,7 +694,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
return
revertPromise
.
then
(()
=>
{
const
copyTarget
=
joinPath
(
target
.
resource
,
basename
(
sourceFile
));
return
this
.
fileService
.
copy
File
(
sourceFile
,
copyTarget
,
true
).
then
(
stat
=>
{
return
this
.
fileService
.
copy
(
sourceFile
,
copyTarget
,
true
).
then
(
stat
=>
{
// if we only add one file, just open it directly
if
(
resources
.
length
===
1
)
{
...
...
@@ -794,7 +794,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
// Reuse duplicate action if user copies
if
(
isCopy
)
{
return
this
.
fileService
.
copy
File
(
source
.
resource
,
findValidPasteFileTarget
(
target
,
{
resource
:
source
.
resource
,
isDirectory
:
source
.
isDirectory
,
allowOverwirte
:
false
})).
then
(
stat
=>
{
return
this
.
fileService
.
copy
(
source
.
resource
,
findValidPasteFileTarget
(
target
,
{
resource
:
source
.
resource
,
isDirectory
:
source
.
isDirectory
,
allowOverwirte
:
false
})).
then
(
stat
=>
{
if
(
!
stat
.
isDirectory
)
{
return
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
options
:
{
pinned
:
true
}
}).
then
(()
=>
undefined
);
}
...
...
src/vs/workbench/contrib/files/common/explorerModel.ts
浏览文件 @
f4eae9a5
...
...
@@ -249,7 +249,7 @@ export class ExplorerItem {
// Resolve metadata only when the mtime is needed since this can be expensive
// Mtime is only used when the sort order is 'modified'
const
resolveMetadata
=
explorerService
.
sortOrder
===
'
modified
'
;
promise
=
fileService
.
resolve
File
(
this
.
resource
,
{
resolveSingleChildDescendants
:
true
,
resolveMetadata
}).
then
(
stat
=>
{
promise
=
fileService
.
resolve
(
this
.
resource
,
{
resolveSingleChildDescendants
:
true
,
resolveMetadata
}).
then
(
stat
=>
{
const
resolved
=
ExplorerItem
.
create
(
stat
,
this
);
ExplorerItem
.
mergeLocalWithDisk
(
resolved
,
this
);
this
.
_isDirectoryResolved
=
true
;
...
...
src/vs/workbench/contrib/files/common/explorerService.ts
浏览文件 @
f4eae9a5
...
...
@@ -151,7 +151,7 @@ export class ExplorerService implements IExplorerService {
const
workspaceFolder
=
this
.
contextService
.
getWorkspaceFolder
(
resource
);
const
rootUri
=
workspaceFolder
?
workspaceFolder
.
uri
:
this
.
roots
[
0
].
resource
;
const
root
=
this
.
roots
.
filter
(
r
=>
r
.
resource
.
toString
()
===
rootUri
.
toString
()).
pop
()
!
;
return
this
.
fileService
.
resolve
File
(
rootUri
,
options
).
then
(
stat
=>
{
return
this
.
fileService
.
resolve
(
rootUri
,
options
).
then
(
stat
=>
{
// Convert to model
const
modelStat
=
ExplorerItem
.
create
(
stat
,
undefined
,
options
.
resolveTo
);
...
...
@@ -193,7 +193,7 @@ export class ExplorerService implements IExplorerService {
parents
.
forEach
(
p
=>
{
// We have to check if the parent is resolved #29177
const
resolveMetadata
=
this
.
sortOrder
===
`modified`
;
const
thenable
:
Promise
<
IFileStat
|
undefined
>
=
p
.
isDirectoryResolved
?
Promise
.
resolve
(
undefined
)
:
this
.
fileService
.
resolve
File
(
p
.
resource
,
{
resolveMetadata
});
const
thenable
:
Promise
<
IFileStat
|
undefined
>
=
p
.
isDirectoryResolved
?
Promise
.
resolve
(
undefined
)
:
this
.
fileService
.
resolve
(
p
.
resource
,
{
resolveMetadata
});
thenable
.
then
(
stat
=>
{
if
(
stat
)
{
const
modelStat
=
ExplorerItem
.
create
(
stat
,
p
.
parent
);
...
...
src/vs/workbench/contrib/search/browser/openFileHandler.ts
浏览文件 @
f4eae9a5
...
...
@@ -191,7 +191,7 @@ export class OpenFileHandler extends QuickOpenHandler {
workspaceFolders
[
0
].
uri
.
with
({
path
:
detildifiedQuery
})
:
URI
.
file
(
detildifiedQuery
);
return
this
.
fileService
.
resolve
File
(
resource
).
then
(
return
this
.
fileService
.
resolve
(
resource
).
then
(
stat
=>
stat
.
isDirectory
?
undefined
:
resource
,
error
=>
undefined
);
}
...
...
src/vs/workbench/contrib/search/browser/search.contribution.ts
浏览文件 @
f4eae9a5
...
...
@@ -367,7 +367,7 @@ const searchInFolderCommand: ICommandHandler = (accessor, resource?: URI) => {
return
openSearchView
(
viewletService
,
panelService
,
configurationService
,
true
).
then
(
searchView
=>
{
if
(
resources
&&
resources
.
length
&&
searchView
)
{
return
fileService
.
resolve
Files
(
resources
.
map
(
resource
=>
({
resource
}))).
then
(
results
=>
{
return
fileService
.
resolve
All
(
resources
.
map
(
resource
=>
({
resource
}))).
then
(
results
=>
{
const
folders
:
URI
[]
=
[];
results
.
forEach
(
result
=>
{
...
...
src/vs/workbench/contrib/search/browser/searchView.ts
浏览文件 @
f4eae9a5
...
...
@@ -1200,7 +1200,7 @@ export class SearchView extends ViewletPanel {
// Validate folderQueries
const
folderQueriesExistP
=
query
.
folderQueries
.
map
(
fq
=>
{
return
this
.
fileService
.
exists
File
(
fq
.
folder
);
return
this
.
fileService
.
exists
(
fq
.
folder
);
});
return
Promise
.
resolve
(
folderQueriesExistP
).
then
(
existResults
=>
{
...
...
src/vs/workbench/contrib/snippets/browser/configureSnippets.ts
浏览文件 @
f4eae9a5
...
...
@@ -164,7 +164,7 @@ async function createSnippetFile(scope: string, defaultPath: URI, windowService:
}
async
function
createLanguageSnippetFile
(
pick
:
ISnippetPick
,
fileService
:
IFileService
)
{
if
(
await
fileService
.
exists
File
(
URI
.
file
(
pick
.
filepath
)))
{
if
(
await
fileService
.
exists
(
URI
.
file
(
pick
.
filepath
)))
{
return
;
}
const
contents
=
[
...
...
src/vs/workbench/contrib/snippets/browser/snippetsService.ts
浏览文件 @
f4eae9a5
...
...
@@ -121,11 +121,11 @@ function watch(service: IFileService, resource: URI, callback: (type: FileChange
}
}
});
service
.
watch
FileChanges
(
resource
);
service
.
watch
(
resource
);
return
{
dispose
()
{
listener
.
dispose
();
service
.
unwatch
FileChanges
(
resource
);
service
.
unwatch
(
resource
);
}
};
}
...
...
@@ -277,7 +277,7 @@ class SnippetsService implements ISnippetsService {
private
_initWorkspaceFolderSnippets
(
workspace
:
IWorkspace
,
bucket
:
IDisposable
[]):
Promise
<
any
>
{
let
promises
=
workspace
.
folders
.
map
(
folder
=>
{
const
snippetFolder
=
folder
.
toResource
(
'
.vscode
'
);
return
this
.
_fileService
.
exists
File
(
snippetFolder
).
then
(
value
=>
{
return
this
.
_fileService
.
exists
(
snippetFolder
).
then
(
value
=>
{
if
(
value
)
{
this
.
_initFolderSnippets
(
SnippetSource
.
Workspace
,
snippetFolder
,
bucket
);
}
else
{
...
...
@@ -305,7 +305,7 @@ class SnippetsService implements ISnippetsService {
if
(
type
===
FileChangeType
.
DELETED
)
{
return
Promise
.
resolve
();
}
return
this
.
_fileService
.
resolve
File
(
folder
).
then
(
stat
=>
{
return
this
.
_fileService
.
resolve
(
folder
).
then
(
stat
=>
{
for
(
const
entry
of
stat
.
children
||
[])
{
disposables
.
push
(
this
.
_addSnippetFile
(
entry
.
resource
,
source
));
}
...
...
src/vs/workbench/contrib/stats/node/workspaceStats.ts
浏览文件 @
f4eae9a5
...
...
@@ -196,7 +196,7 @@ export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: bool
export
function
getHashedRemotesFromUri
(
workspaceUri
:
URI
,
fileService
:
IFileService
,
stripEndingDotGit
:
boolean
=
false
):
Promise
<
string
[]
>
{
const
path
=
workspaceUri
.
path
;
const
uri
=
workspaceUri
.
with
({
path
:
`
${
path
!==
'
/
'
?
path
:
''
}
/.git/config`
});
return
fileService
.
exists
File
(
uri
).
then
(
exists
=>
{
return
fileService
.
exists
(
uri
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
[];
}
...
...
@@ -364,7 +364,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
return
Promise
.
resolve
(
tags
);
}
return
this
.
fileService
.
resolve
Files
(
folders
.
map
(
resource
=>
({
resource
}))).
then
((
files
:
IResolveFileResult
[])
=>
{
return
this
.
fileService
.
resolve
All
(
folders
.
map
(
resource
=>
({
resource
}))).
then
((
files
:
IResolveFileResult
[])
=>
{
const
names
=
(
<
IFileStat
[]
>
[]).
concat
(...
files
.
map
(
result
=>
result
.
success
?
(
result
.
stat
!
.
children
||
[])
:
[])).
map
(
c
=>
c
.
name
);
const
nameSet
=
names
.
reduce
((
s
,
n
)
=>
s
.
add
(
n
.
toLowerCase
()),
new
Set
());
...
...
@@ -437,7 +437,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
function
getFilePromises
(
filename
:
string
,
fileService
:
IFileService
,
contentHandler
:
(
content
:
IContent
)
=>
void
):
Promise
<
void
>
[]
{
return
!
nameSet
.
has
(
filename
)
?
[]
:
(
folders
as
URI
[]).
map
(
workspaceUri
=>
{
const
uri
=
workspaceUri
.
with
({
path
:
`
${
workspaceUri
.
path
!==
'
/
'
?
workspaceUri
.
path
:
''
}
/
${
filename
}
`
});
return
fileService
.
exists
File
(
uri
).
then
(
exists
=>
{
return
fileService
.
exists
(
uri
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
undefined
;
}
...
...
@@ -620,7 +620,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
Promise
.
all
<
string
[]
>
(
workspaceUris
.
map
(
workspaceUri
=>
{
const
path
=
workspaceUri
.
path
;
const
uri
=
workspaceUri
.
with
({
path
:
`
${
path
!==
'
/
'
?
path
:
''
}
/.git/config`
});
return
this
.
fileService
.
exists
File
(
uri
).
then
(
exists
=>
{
return
this
.
fileService
.
exists
(
uri
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
[];
}
...
...
@@ -666,7 +666,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
const
path
=
workspaceUri
.
path
;
return
workspaceUri
.
with
({
path
:
`
${
path
!==
'
/
'
?
path
:
''
}
/node_modules`
});
});
return
this
.
fileService
.
resolve
Files
(
uris
.
map
(
resource
=>
({
resource
}))).
then
(
return
this
.
fileService
.
resolve
All
(
uris
.
map
(
resource
=>
({
resource
}))).
then
(
results
=>
{
const
names
=
(
<
IFileStat
[]
>
[]).
concat
(...
results
.
map
(
result
=>
result
.
success
?
(
result
.
stat
!
.
children
||
[])
:
[])).
map
(
c
=>
c
.
name
);
const
referencesAzure
=
WorkspaceStats
.
searchArray
(
names
,
/azure/i
);
...
...
@@ -689,7 +689,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
return
Promise
.
all
(
workspaceUris
.
map
(
workspaceUri
=>
{
const
path
=
workspaceUri
.
path
;
const
uri
=
workspaceUri
.
with
({
path
:
`
${
path
!==
'
/
'
?
path
:
''
}
/pom.xml`
});
return
this
.
fileService
.
exists
File
(
uri
).
then
(
exists
=>
{
return
this
.
fileService
.
exists
(
uri
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
false
;
}
...
...
src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts
浏览文件 @
f4eae9a5
...
...
@@ -2318,7 +2318,7 @@ class TaskService extends Disposable implements ITaskService {
let
openTaskFile
=
(
workspaceFolder
:
IWorkspaceFolder
):
void
=>
{
let
resource
=
workspaceFolder
.
toResource
(
'
.vscode/tasks.json
'
);
let
configFileCreated
=
false
;
this
.
fileService
.
resolve
File
(
resource
).
then
((
stat
)
=>
stat
,
()
=>
undefined
).
then
((
stat
)
=>
{
this
.
fileService
.
resolve
(
resource
).
then
((
stat
)
=>
stat
,
()
=>
undefined
).
then
((
stat
)
=>
{
if
(
stat
)
{
return
stat
.
resource
;
}
...
...
@@ -2375,7 +2375,7 @@ class TaskService extends Disposable implements ITaskService {
}
let
stats
=
this
.
contextService
.
getWorkspace
().
folders
.
map
<
Promise
<
IFileStat
|
undefined
>>
((
folder
)
=>
{
return
this
.
fileService
.
resolve
File
(
folder
.
toResource
(
'
.vscode/tasks.json
'
)).
then
(
stat
=>
stat
,
()
=>
undefined
);
return
this
.
fileService
.
resolve
(
folder
.
toResource
(
'
.vscode/tasks.json
'
)).
then
(
stat
=>
stat
,
()
=>
undefined
);
});
let
createLabel
=
nls
.
localize
(
'
TaskService.createJsonFile
'
,
'
Create tasks.json file from template
'
);
...
...
src/vs/workbench/contrib/tasks/node/processRunnerDetector.ts
浏览文件 @
f4eae9a5
...
...
@@ -230,7 +230,7 @@ export class ProcessRunnerDetector {
}
private
tryDetectGulp
(
workspaceFolder
:
IWorkspaceFolder
,
list
:
boolean
):
Promise
<
DetectorResult
>
{
return
Promise
.
resolve
(
this
.
fileService
.
resolve
File
(
workspaceFolder
.
toResource
(
'
gulpfile.js
'
))).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return
Promise
.
resolve
(
this
.
fileService
.
resolve
(
workspaceFolder
.
toResource
(
'
gulpfile.js
'
))).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
let
config
=
ProcessRunnerDetector
.
detectorConfig
(
'
gulp
'
);
let
process
=
new
LineProcess
(
'
gulp
'
,
[
config
.
arg
,
'
--no-color
'
],
true
,
{
cwd
:
this
.
_cwd
});
return
this
.
runDetection
(
process
,
'
gulp
'
,
true
,
config
.
matcher
,
ProcessRunnerDetector
.
DefaultProblemMatchers
,
list
);
...
...
@@ -240,7 +240,7 @@ export class ProcessRunnerDetector {
}
private
tryDetectGrunt
(
workspaceFolder
:
IWorkspaceFolder
,
list
:
boolean
):
Promise
<
DetectorResult
>
{
return
Promise
.
resolve
(
this
.
fileService
.
resolve
File
(
workspaceFolder
.
toResource
(
'
Gruntfile.js
'
))).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return
Promise
.
resolve
(
this
.
fileService
.
resolve
(
workspaceFolder
.
toResource
(
'
Gruntfile.js
'
))).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
let
config
=
ProcessRunnerDetector
.
detectorConfig
(
'
grunt
'
);
let
process
=
new
LineProcess
(
'
grunt
'
,
[
config
.
arg
,
'
--no-color
'
],
true
,
{
cwd
:
this
.
_cwd
});
return
this
.
runDetection
(
process
,
'
grunt
'
,
true
,
config
.
matcher
,
ProcessRunnerDetector
.
DefaultProblemMatchers
,
list
);
...
...
@@ -255,10 +255,10 @@ export class ProcessRunnerDetector {
let
process
=
new
LineProcess
(
'
jake
'
,
[
config
.
arg
],
true
,
{
cwd
:
this
.
_cwd
});
return
this
.
runDetection
(
process
,
'
jake
'
,
true
,
config
.
matcher
,
ProcessRunnerDetector
.
DefaultProblemMatchers
,
list
);
};
return
Promise
.
resolve
(
this
.
fileService
.
resolve
File
(
workspaceFolder
.
toResource
(
'
Jakefile
'
))).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return
Promise
.
resolve
(
this
.
fileService
.
resolve
(
workspaceFolder
.
toResource
(
'
Jakefile
'
))).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return
run
();
},
(
err
:
any
)
=>
{
return
this
.
fileService
.
resolve
File
(
workspaceFolder
.
toResource
(
'
Jakefile.js
'
)).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return
this
.
fileService
.
resolve
(
workspaceFolder
.
toResource
(
'
Jakefile.js
'
)).
then
((
stat
)
=>
{
// TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return
run
();
},
(
err
:
any
)
=>
{
return
null
;
...
...
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
浏览文件 @
f4eae9a5
...
...
@@ -305,7 +305,7 @@ export class TerminalLinkHandler {
uri
=
URI
.
file
(
linkUrl
);
}
return
this
.
_fileService
.
resolve
File
(
uri
).
then
(
stat
=>
{
return
this
.
_fileService
.
resolve
(
uri
).
then
(
stat
=>
{
if
(
stat
.
isDirectory
)
{
return
null
;
}
...
...
src/vs/workbench/contrib/terminal/common/terminalService.ts
浏览文件 @
f4eae9a5
...
...
@@ -416,7 +416,7 @@ export abstract class TerminalService implements ITerminalService {
return
Promise
.
resolve
(
null
);
}
const
current
=
potentialPaths
.
shift
();
return
this
.
_fileService
.
exists
File
(
URI
.
file
(
current
!
)).
then
(
exists
=>
{
return
this
.
_fileService
.
exists
(
URI
.
file
(
current
!
)).
then
(
exists
=>
{
if
(
!
exists
)
{
return
this
.
_validateShellPaths
(
label
,
potentialPaths
);
}
...
...
src/vs/workbench/contrib/terminal/electron-browser/terminalService.ts
浏览文件 @
f4eae9a5
...
...
@@ -82,7 +82,7 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
const
interval
=
setInterval
(()
=>
{
if
(
!
running
)
{
running
=
true
;
this
.
_fileService
.
exists
File
(
path
).
then
(
exists
=>
{
this
.
_fileService
.
exists
(
path
).
then
(
exists
=>
{
running
=
false
;
if
(
!
exists
)
{
...
...
src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts
浏览文件 @
f4eae9a5
...
...
@@ -69,7 +69,7 @@ export class WelcomePageContribution implements IWorkbenchContribution {
if
(
openWithReadme
)
{
return
Promise
.
all
(
contextService
.
getWorkspace
().
folders
.
map
(
folder
=>
{
const
folderUri
=
folder
.
uri
;
return
fileService
.
resolve
File
(
folderUri
)
return
fileService
.
resolve
(
folderUri
)
.
then
(
folder
=>
{
const
files
=
folder
.
children
?
folder
.
children
.
map
(
child
=>
child
.
name
)
:
[];
...
...
src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts
浏览文件 @
f4eae9a5
...
...
@@ -318,14 +318,14 @@ export class BulkEdit {
if
(
edit
.
newUri
&&
edit
.
oldUri
)
{
// rename
if
(
options
.
overwrite
===
undefined
&&
options
.
ignoreIfExists
&&
await
this
.
_fileService
.
exists
File
(
edit
.
newUri
))
{
if
(
options
.
overwrite
===
undefined
&&
options
.
ignoreIfExists
&&
await
this
.
_fileService
.
exists
(
edit
.
newUri
))
{
continue
;
// not overwriting, but ignoring, and the target file exists
}
await
this
.
_textFileService
.
move
(
edit
.
oldUri
,
edit
.
newUri
,
options
.
overwrite
);
}
else
if
(
!
edit
.
newUri
&&
edit
.
oldUri
)
{
// delete file
if
(
await
this
.
_fileService
.
exists
File
(
edit
.
oldUri
))
{
if
(
await
this
.
_fileService
.
exists
(
edit
.
oldUri
))
{
let
useTrash
=
this
.
_configurationService
.
getValue
<
boolean
>
(
'
files.enableTrash
'
);
if
(
useTrash
&&
!
(
await
this
.
_fileService
.
hasCapability
(
edit
.
oldUri
,
FileSystemProviderCapabilities
.
Trash
)))
{
useTrash
=
false
;
// not supported by provider
...
...
@@ -336,7 +336,7 @@ export class BulkEdit {
}
}
else
if
(
edit
.
newUri
&&
!
edit
.
oldUri
)
{
// create file
if
(
options
.
overwrite
===
undefined
&&
options
.
ignoreIfExists
&&
await
this
.
_fileService
.
exists
File
(
edit
.
newUri
))
{
if
(
options
.
overwrite
===
undefined
&&
options
.
ignoreIfExists
&&
await
this
.
_fileService
.
exists
(
edit
.
newUri
))
{
continue
;
// not overwriting, but ignoring, and the target file exists
}
await
this
.
_textFileService
.
create
(
edit
.
newUri
,
undefined
,
{
overwrite
:
options
.
overwrite
});
...
...
src/vs/workbench/services/configuration/common/configurationEditingService.ts
浏览文件 @
f4eae9a5
...
...
@@ -373,7 +373,7 @@ export class ConfigurationEditingService {
}
private
async
resolveModelReference
(
resource
:
URI
):
Promise
<
IReference
<
IResolvedTextEditorModel
>>
{
const
exists
=
await
this
.
fileService
.
exists
File
(
resource
);
const
exists
=
await
this
.
fileService
.
exists
(
resource
);
if
(
!
exists
)
{
await
this
.
fileService
.
updateContent
(
resource
,
'
{}
'
,
{
encoding
:
'
utf8
'
});
}
...
...
src/vs/workbench/services/configuration/common/jsonEditingService.ts
浏览文件 @
f4eae9a5
...
...
@@ -84,7 +84,7 @@ export class JSONEditingService implements IJSONEditingService {
}
private
async
resolveModelReference
(
resource
:
URI
):
Promise
<
IReference
<
IResolvedTextEditorModel
>>
{
const
exists
=
await
this
.
fileService
.
exists
File
(
resource
);
const
exists
=
await
this
.
fileService
.
exists
(
resource
);
if
(
!
exists
)
{
await
this
.
fileService
.
updateContent
(
resource
,
'
{}
'
,
{
encoding
:
'
utf8
'
});
}
...
...
src/vs/workbench/services/configuration/node/configuration.ts
浏览文件 @
f4eae9a5
...
...
@@ -369,13 +369,13 @@ class FileServiceBasedWorkspaceConfiguration extends AbstractWorkspaceConfigurat
private
watchWorkspaceConfigurationFile
():
void
{
if
(
this
.
workspaceConfig
)
{
this
.
fileService
.
watch
FileChanges
(
this
.
workspaceConfig
);
this
.
fileService
.
watch
(
this
.
workspaceConfig
);
}
}
private
unWatchWorkspaceConfigurtionFile
():
void
{
if
(
this
.
workspaceConfig
)
{
this
.
fileService
.
unwatch
FileChanges
(
this
.
workspaceConfig
);
this
.
fileService
.
unwatch
(
this
.
workspaceConfig
);
}
}
...
...
@@ -638,7 +638,7 @@ export class FileServiceBasedFolderConfiguration extends AbstractFolderConfigura
private
doLoadFolderConfigurationContents
():
Promise
<
Array
<
{
resource
:
URI
,
value
:
string
}
>>
{
const
workspaceFilePathToConfiguration
:
{
[
relativeWorkspacePath
:
string
]:
Promise
<
IContent
|
undefined
>
}
=
Object
.
create
(
null
);
const
bulkContentFetchromise
=
Promise
.
resolve
(
this
.
fileService
.
resolve
File
(
this
.
folderConfigurationPath
))
const
bulkContentFetchromise
=
Promise
.
resolve
(
this
.
fileService
.
resolve
(
this
.
folderConfigurationPath
))
.
then
(
stat
=>
{
if
(
stat
.
isDirectory
&&
stat
.
children
)
{
stat
.
children
...
...
src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts
浏览文件 @
f4eae9a5
...
...
@@ -87,7 +87,7 @@ export class RemoteFileDialog {
return
this
.
pickResource
().
then
(
async
fileFolderUri
=>
{
if
(
fileFolderUri
)
{
const
stat
=
await
this
.
fileService
.
resolve
File
(
fileFolderUri
);
const
stat
=
await
this
.
fileService
.
resolve
(
fileFolderUri
);
return
<
IURIToOpen
[]
>
[{
uri
:
fileFolderUri
,
typeHint
:
stat
.
isDirectory
?
'
folder
'
:
'
file
'
}];
}
...
...
@@ -163,7 +163,7 @@ export class RemoteFileDialog {
let
ext
:
string
=
resources
.
extname
(
homedir
);
if
(
this
.
options
.
defaultUri
)
{
try
{
stat
=
await
this
.
fileService
.
resolve
File
(
this
.
options
.
defaultUri
);
stat
=
await
this
.
fileService
.
resolve
(
this
.
options
.
defaultUri
);
}
catch
(
e
)
{
// The file or folder doesn't exist
}
...
...
@@ -296,8 +296,8 @@ export class RemoteFileDialog {
let
stat
:
IFileStat
|
undefined
;
let
statDirname
:
IFileStat
|
undefined
;
try
{
statDirname
=
await
this
.
fileService
.
resolve
File
(
inputUriDirname
);
stat
=
await
this
.
fileService
.
resolve
File
(
inputUri
);
statDirname
=
await
this
.
fileService
.
resolve
(
inputUriDirname
);
stat
=
await
this
.
fileService
.
resolve
(
inputUri
);
}
catch
(
e
)
{
// do nothing
}
...
...
@@ -339,7 +339,7 @@ export class RemoteFileDialog {
if
(
this
.
endsWithSlash
(
value
)
||
(
!
resources
.
isEqual
(
this
.
currentFolder
,
resources
.
dirname
(
valueUri
),
true
)
&&
resources
.
isEqualOrParent
(
this
.
currentFolder
,
resources
.
dirname
(
valueUri
),
true
)))
{
let
stat
:
IFileStat
|
undefined
;
try
{
stat
=
await
this
.
fileService
.
resolve
File
(
valueUri
);
stat
=
await
this
.
fileService
.
resolve
(
valueUri
);
}
catch
(
e
)
{
// do nothing
}
...
...
@@ -350,7 +350,7 @@ export class RemoteFileDialog {
if
(
!
resources
.
isEqual
(
this
.
currentFolder
,
inputUriDirname
,
true
))
{
let
statWithoutTrailing
:
IFileStat
|
undefined
;
try
{
statWithoutTrailing
=
await
this
.
fileService
.
resolve
File
(
inputUriDirname
);
statWithoutTrailing
=
await
this
.
fileService
.
resolve
(
inputUriDirname
);
}
catch
(
e
)
{
// do nothing
}
...
...
@@ -391,8 +391,8 @@ export class RemoteFileDialog {
let
stat
:
IFileStat
|
undefined
;
let
statDirname
:
IFileStat
|
undefined
;
try
{
statDirname
=
await
this
.
fileService
.
resolve
File
(
resources
.
dirname
(
uri
));
stat
=
await
this
.
fileService
.
resolve
File
(
uri
);
statDirname
=
await
this
.
fileService
.
resolve
(
resources
.
dirname
(
uri
));
stat
=
await
this
.
fileService
.
resolve
(
uri
);
}
catch
(
e
)
{
// do nothing
}
...
...
@@ -513,7 +513,7 @@ export class RemoteFileDialog {
const
backDir
=
this
.
createBackItem
(
currentFolder
);
try
{
const
folder
=
await
this
.
fileService
.
resolve
File
(
currentFolder
);
const
folder
=
await
this
.
fileService
.
resolve
(
currentFolder
);
const
fileNames
=
folder
.
children
?
folder
.
children
.
map
(
child
=>
child
.
name
)
:
[];
const
items
=
await
Promise
.
all
(
fileNames
.
map
(
fileName
=>
this
.
createItem
(
fileName
,
currentFolder
)));
for
(
let
item
of
items
)
{
...
...
@@ -562,7 +562,7 @@ export class RemoteFileDialog {
private
async
createItem
(
filename
:
string
,
parent
:
URI
):
Promise
<
FileQuickPickItem
|
undefined
>
{
let
fullPath
=
resources
.
joinPath
(
parent
,
filename
);
try
{
const
stat
=
await
this
.
fileService
.
resolve
File
(
fullPath
);
const
stat
=
await
this
.
fileService
.
resolve
(
fullPath
);
if
(
stat
.
isDirectory
)
{
filename
=
this
.
basenameWithTrailingSlash
(
fullPath
);
return
{
label
:
filename
,
uri
:
fullPath
,
isFolder
:
true
,
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
fullPath
||
undefined
,
FileKind
.
FOLDER
)
};
...
...
src/vs/workbench/services/files/node/fileService.ts
浏览文件 @
f4eae9a5
...
...
@@ -280,7 +280,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return
Promise
.
reject
(
error
);
};
const
statsPromise
=
this
.
resolve
File
(
resource
).
then
(
stat
=>
{
const
statsPromise
=
this
.
resolve
(
resource
).
then
(
stat
=>
{
result
.
resource
=
stat
.
resource
;
result
.
name
=
stat
.
name
;
result
.
mtime
=
stat
.
mtime
;
...
...
@@ -812,11 +812,11 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
));
}
move
File
(
source
:
uri
,
target
:
uri
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
move
(
source
:
uri
,
target
:
uri
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
return
this
.
moveOrCopyFile
(
source
,
target
,
false
,
!!
overwrite
);
}
copy
File
(
source
:
uri
,
target
:
uri
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
copy
(
source
:
uri
,
target
:
uri
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
return
this
.
moveOrCopyFile
(
source
,
target
,
true
,
!!
overwrite
);
}
...
...
@@ -828,7 +828,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return
this
.
doMoveOrCopyFile
(
sourcePath
,
targetPath
,
keepCopy
,
overwrite
).
then
(()
=>
{
// 2.) resolve
return
this
.
r
esolve
(
target
,
{
resolveMetadata
:
true
}).
then
(
result
=>
{
return
this
.
doR
esolve
(
target
,
{
resolveMetadata
:
true
}).
then
(
result
=>
{
// Events (unless it was a no-op because paths are identical)
if
(
sourcePath
!==
targetPath
)
{
...
...
@@ -952,9 +952,9 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return
paths
.
normalize
(
resource
.
fsPath
);
}
private
r
esolve
(
resource
:
uri
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
private
r
esolve
(
resource
:
uri
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
private
r
esolve
(
resource
:
uri
,
options
:
IResolveFileOptions
=
Object
.
create
(
null
)):
Promise
<
IFileStat
>
{
private
doR
esolve
(
resource
:
uri
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
private
doR
esolve
(
resource
:
uri
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
private
doR
esolve
(
resource
:
uri
,
options
:
IResolveFileOptions
=
Object
.
create
(
null
)):
Promise
<
IFileStat
>
{
return
this
.
toStatResolver
(
resource
).
then
(
model
=>
model
.
resolve
(
options
));
}
...
...
@@ -966,7 +966,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
watch
FileChanges
(
resource
:
uri
):
void
{
watch
(
resource
:
uri
):
void
{
assert
.
ok
(
resource
&&
resource
.
scheme
===
Schemas
.
file
,
`Invalid resource for watching:
${
resource
}
`
);
// Check for existing watcher first
...
...
@@ -1000,11 +1000,11 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
// Wait a bit and try to install watcher again, assuming that the file was renamed quickly ("Atomic Save")
setTimeout
(()
=>
{
this
.
exists
File
(
resource
).
then
(
exists
=>
{
this
.
exists
(
resource
).
then
(
exists
=>
{
// File still exists, so reapply the watcher
if
(
exists
)
{
this
.
watch
FileChanges
(
resource
);
this
.
watch
(
resource
);
}
// File seems to be really gone, so emit a deleted event
...
...
@@ -1063,7 +1063,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
unwatch
FileChanges
(
resource
:
uri
):
void
{
unwatch
(
resource
:
uri
):
void
{
const
watcher
=
this
.
activeFileChangesWatchers
.
get
(
resource
);
if
(
watcher
&&
--
watcher
.
count
===
0
)
{
watcher
.
unwatch
();
...
...
@@ -1092,14 +1092,14 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
// Tests only
resolve
File
(
resource
:
uri
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
resolve
File
(
resource
:
uri
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
File
(
resource
:
uri
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
return
this
.
r
esolve
(
resource
,
options
);
resolve
(
resource
:
uri
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
resolve
(
resource
:
uri
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
(
resource
:
uri
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
return
this
.
doR
esolve
(
resource
,
options
);
}
resolve
Files
(
toResolve
:
{
resource
:
uri
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
{
return
Promise
.
all
(
toResolve
.
map
(
resourceAndOptions
=>
this
.
r
esolve
(
resourceAndOptions
.
resource
,
resourceAndOptions
.
options
)
resolve
All
(
toResolve
:
{
resource
:
uri
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
{
return
Promise
.
all
(
toResolve
.
map
(
resourceAndOptions
=>
this
.
doR
esolve
(
resourceAndOptions
.
resource
,
resourceAndOptions
.
options
)
.
then
(
stat
=>
({
stat
,
success
:
true
}),
error
=>
({
stat
:
undefined
,
success
:
false
}))));
}
...
...
@@ -1110,7 +1110,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return
pfs
.
mkdirp
(
absolutePath
).
then
(()
=>
{
// 2.) Resolve
return
this
.
r
esolve
(
resource
,
{
resolveMetadata
:
true
}).
then
(
result
=>
{
return
this
.
doR
esolve
(
resource
,
{
resolveMetadata
:
true
}).
then
(
result
=>
{
// Events
this
.
_onAfterOperation
.
fire
(
new
FileOperationEvent
(
resource
,
FileOperation
.
CREATE
,
result
));
...
...
@@ -1120,8 +1120,8 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
exists
File
(
resource
:
uri
):
Promise
<
boolean
>
{
return
this
.
resolve
File
(
resource
).
then
(()
=>
true
,
()
=>
false
);
exists
(
resource
:
uri
):
Promise
<
boolean
>
{
return
this
.
resolve
(
resource
).
then
(()
=>
true
,
()
=>
false
);
}
}
...
...
src/vs/workbench/services/files/node/remoteFileService.ts
浏览文件 @
f4eae9a5
...
...
@@ -140,18 +140,18 @@ class WorkspaceWatchLogic extends Disposable {
}
}
this
.
_watches
.
set
(
resource
.
toString
(),
resource
);
this
.
_fileService
.
watch
FileChanges
(
resource
,
{
recursive
:
true
,
excludes
});
this
.
_fileService
.
watch
(
resource
,
{
recursive
:
true
,
excludes
});
}
private
_unwatchWorkspace
(
resource
:
URI
)
{
if
(
this
.
_watches
.
has
(
resource
.
toString
()))
{
this
.
_fileService
.
unwatch
FileChanges
(
resource
);
this
.
_fileService
.
unwatch
(
resource
);
this
.
_watches
.
delete
(
resource
.
toString
());
}
}
private
_unwatchWorkspaces
()
{
this
.
_watches
.
forEach
(
uri
=>
this
.
_fileService
.
unwatch
FileChanges
(
uri
));
this
.
_watches
.
forEach
(
uri
=>
this
.
_fileService
.
unwatch
(
uri
));
this
.
_watches
.
clear
();
}
}
...
...
@@ -223,11 +223,11 @@ export class RemoteFileService extends FileService {
});
}
resolve
File
(
resource
:
URI
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
File
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
resolve
File
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
resolve
(
resource
:
URI
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
resolve
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
if
(
resource
.
scheme
===
Schemas
.
file
)
{
return
super
.
resolve
File
(
resource
,
options
);
return
super
.
resolve
(
resource
,
options
);
}
else
{
return
this
.
_doResolveFiles
([{
resource
,
options
}]).
then
(
data
=>
{
if
(
data
.
length
!==
1
||
!
data
[
0
].
success
)
{
...
...
@@ -279,7 +279,7 @@ export class RemoteFileService extends FileService {
private
_readFile
(
resource
:
URI
,
options
:
IResolveContentOptions
=
Object
.
create
(
null
)):
Promise
<
IStreamContent
>
{
return
this
.
_withProvider
(
resource
).
then
(
provider
=>
{
return
this
.
resolve
File
(
resource
).
then
(
fileStat
=>
{
return
this
.
resolve
(
resource
).
then
(
fileStat
=>
{
if
(
fileStat
.
isDirectory
)
{
// todo@joh cannot copy a folder
...
...
@@ -409,7 +409,7 @@ export class RemoteFileService extends FileService {
target
.
once
(
'
error
'
,
err
=>
reject
(
err
));
target
.
once
(
'
finish
'
,
(
_
:
unknown
)
=>
resolve
(
undefined
));
}).
then
(
_
=>
{
return
this
.
resolve
File
(
resource
,
{
resolveMetadata
:
true
})
as
Promise
<
IFileStatWithMetadata
>
;
return
this
.
resolve
(
resource
,
{
resolveMetadata
:
true
})
as
Promise
<
IFileStatWithMetadata
>
;
});
}
...
...
@@ -433,9 +433,9 @@ export class RemoteFileService extends FileService {
private
_activeWatches
=
new
Map
<
string
,
{
unwatch
:
Promise
<
IDisposable
>
,
count
:
number
}
>
();
watch
FileChanges
(
resource
:
URI
,
opts
:
IWatchOptions
=
{
recursive
:
false
,
excludes
:
[]
}):
void
{
watch
(
resource
:
URI
,
opts
:
IWatchOptions
=
{
recursive
:
false
,
excludes
:
[]
}):
void
{
if
(
resource
.
scheme
===
Schemas
.
file
)
{
return
super
.
watch
FileChanges
(
resource
);
return
super
.
watch
(
resource
);
}
const
key
=
resource
.
toString
();
...
...
@@ -455,9 +455,9 @@ export class RemoteFileService extends FileService {
});
}
unwatch
FileChanges
(
resource
:
URI
):
void
{
unwatch
(
resource
:
URI
):
void
{
if
(
resource
.
scheme
===
Schemas
.
file
)
{
return
super
.
unwatch
FileChanges
(
resource
);
return
super
.
unwatch
(
resource
);
}
let
entry
=
this
.
_activeWatches
.
get
(
resource
.
toString
());
if
(
entry
&&
--
entry
.
count
===
0
)
{
...
...
src/vs/workbench/services/files/test/electron-browser/fileService.test.ts
浏览文件 @
f4eae9a5
...
...
@@ -348,15 +348,15 @@ suite('FileService', () => {
});
});
test
(
'
watch
FileChanges
'
,
function
(
done
)
{
test
(
'
watch
'
,
function
(
done
)
{
const
toWatch
=
uri
.
file
(
path
.
join
(
testDir
,
'
index.html
'
));
service
.
watch
FileChanges
(
toWatch
);
service
.
watch
(
toWatch
);
service
.
onFileChanges
((
e
:
FileChangesEvent
)
=>
{
assert
.
ok
(
e
);
service
.
unwatch
FileChanges
(
toWatch
);
service
.
unwatch
(
toWatch
);
done
();
});
...
...
@@ -365,15 +365,15 @@ suite('FileService', () => {
},
100
);
});
// test('watch
FileChanges
- support atomic save', function (done) {
// test('watch - support atomic save', function (done) {
// const toWatch = uri.file(path.join(testDir, 'index.html'));
// service.watch
FileChanges
(toWatch);
// service.watch(toWatch);
// service.onFileChanges((e: FileChangesEvent) => {
// assert.ok(e);
// service.unwatch
FileChanges
(toWatch);
// service.unwatch(toWatch);
// done();
// });
...
...
src/vs/workbench/services/files2/common/fileService2.ts
浏览文件 @
f4eae9a5
...
...
@@ -152,9 +152,9 @@ export class FileService2 extends Disposable implements IFileService {
//#region File Metadata Resolving
async
resolve
File
(
resource
:
URI
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
async
resolve
File
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
async
resolve
File
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
async
resolve
(
resource
:
URI
,
options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
async
resolve
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
async
resolve
(
resource
:
URI
,
options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
try
{
return
await
this
.
doResolveFile
(
resource
,
options
);
}
catch
(
error
)
{
...
...
@@ -251,9 +251,9 @@ export class FileService2 extends Disposable implements IFileService {
return
Promise
.
resolve
(
fileStat
);
}
async
resolve
Files
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
;
async
resolve
Files
(
toResolve
:
{
resource
:
URI
,
options
:
IResolveMetadataFileOptions
}[]):
Promise
<
IResolveFileResultWithMetadata
[]
>
;
async
resolve
Files
(
toResolve
:
{
resource
:
URI
;
options
?:
IResolveFileOptions
;
}[]):
Promise
<
IResolveFileResult
[]
>
{
async
resolve
All
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
;
async
resolve
All
(
toResolve
:
{
resource
:
URI
,
options
:
IResolveMetadataFileOptions
}[]):
Promise
<
IResolveFileResultWithMetadata
[]
>
;
async
resolve
All
(
toResolve
:
{
resource
:
URI
;
options
?:
IResolveFileOptions
;
}[]):
Promise
<
IResolveFileResult
[]
>
{
return
Promise
.
all
(
toResolve
.
map
(
async
entry
=>
{
try
{
return
{
stat
:
await
this
.
doResolveFile
(
entry
.
resource
,
entry
.
options
),
success
:
true
};
...
...
@@ -265,9 +265,9 @@ export class FileService2 extends Disposable implements IFileService {
}));
}
async
exists
File
(
resource
:
URI
):
Promise
<
boolean
>
{
async
exists
(
resource
:
URI
):
Promise
<
boolean
>
{
try
{
return
!!
(
await
this
.
resolve
File
(
resource
));
return
!!
(
await
this
.
resolve
(
resource
));
}
catch
(
error
)
{
return
false
;
}
...
...
@@ -295,7 +295,7 @@ export class FileService2 extends Disposable implements IFileService {
// validate overwrite
const
overwrite
=
!!
(
options
&&
options
.
overwrite
);
if
(
await
this
.
exists
File
(
resource
))
{
if
(
await
this
.
exists
(
resource
))
{
if
(
!
overwrite
)
{
throw
new
FileOperationError
(
localize
(
'
fileExists
'
,
"
File to create already exists ({0})
"
,
resource
.
toString
(
true
)),
FileOperationResult
.
FILE_MODIFIED_SINCE
,
options
);
}
...
...
@@ -328,7 +328,7 @@ export class FileService2 extends Disposable implements IFileService {
}
// events
const
fileStat
=
await
this
.
resolve
File
(
resource
,
{
resolveMetadata
:
true
});
const
fileStat
=
await
this
.
resolve
(
resource
,
{
resolveMetadata
:
true
});
this
.
_onAfterOperation
.
fire
(
new
FileOperationEvent
(
resource
,
FileOperation
.
CREATE
,
fileStat
));
return
fileStat
;
...
...
@@ -350,7 +350,7 @@ export class FileService2 extends Disposable implements IFileService {
//#region Move/Copy/Delete/Create Folder
async
move
File
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
async
move
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
const
sourceProvider
=
this
.
throwIfFileSystemIsReadonly
(
await
this
.
withProvider
(
source
));
const
targetProvider
=
this
.
throwIfFileSystemIsReadonly
(
await
this
.
withProvider
(
target
));
...
...
@@ -358,13 +358,13 @@ export class FileService2 extends Disposable implements IFileService {
const
mode
=
await
this
.
doMoveCopy
(
sourceProvider
,
source
,
targetProvider
,
target
,
'
move
'
,
overwrite
);
// resolve and send events
const
fileStat
=
await
this
.
resolve
File
(
target
,
{
resolveMetadata
:
true
});
const
fileStat
=
await
this
.
resolve
(
target
,
{
resolveMetadata
:
true
});
this
.
_onAfterOperation
.
fire
(
new
FileOperationEvent
(
source
,
mode
===
'
move
'
?
FileOperation
.
MOVE
:
FileOperation
.
COPY
,
fileStat
));
return
fileStat
;
}
async
copy
File
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
async
copy
(
source
:
URI
,
target
:
URI
,
overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
const
sourceProvider
=
await
this
.
withProvider
(
source
);
const
targetProvider
=
this
.
throwIfFileSystemIsReadonly
(
await
this
.
withProvider
(
target
));
...
...
@@ -372,7 +372,7 @@ export class FileService2 extends Disposable implements IFileService {
const
mode
=
await
this
.
doMoveCopy
(
sourceProvider
,
source
,
targetProvider
,
target
,
'
copy
'
,
overwrite
);
// resolve and send events
const
fileStat
=
await
this
.
resolve
File
(
target
,
{
resolveMetadata
:
true
});
const
fileStat
=
await
this
.
resolve
(
target
,
{
resolveMetadata
:
true
});
this
.
_onAfterOperation
.
fire
(
new
FileOperationEvent
(
source
,
mode
===
'
copy
'
?
FileOperation
.
COPY
:
FileOperation
.
MOVE
,
fileStat
));
return
fileStat
;
...
...
@@ -409,7 +409,7 @@ export class FileService2 extends Disposable implements IFileService {
// when copying via buffer/unbuffered, we have to manually
// traverse the source if it is a folder and not a file
const
sourceFile
=
await
this
.
resolve
File
(
source
);
const
sourceFile
=
await
this
.
resolve
(
source
);
if
(
sourceFile
.
isDirectory
)
{
return
this
.
doCopyFolder
(
sourceProvider
,
sourceFile
,
targetProvider
,
target
,
overwrite
).
then
(()
=>
mode
);
}
else
{
...
...
@@ -467,7 +467,7 @@ export class FileService2 extends Disposable implements IFileService {
await
Promise
.
all
(
sourceFolder
.
children
.
map
(
async
sourceChild
=>
{
const
targetChild
=
joinPath
(
targetFolder
,
sourceChild
.
name
);
if
(
sourceChild
.
isDirectory
)
{
return
this
.
doCopyFolder
(
sourceProvider
,
await
this
.
resolve
File
(
sourceChild
.
resource
),
targetProvider
,
targetChild
,
overwrite
);
return
this
.
doCopyFolder
(
sourceProvider
,
await
this
.
resolve
(
sourceChild
.
resource
),
targetProvider
,
targetChild
,
overwrite
);
}
else
{
return
this
.
doCopyFile
(
sourceProvider
,
sourceChild
.
resource
,
targetProvider
,
targetChild
,
overwrite
);
}
...
...
@@ -489,7 +489,7 @@ export class FileService2 extends Disposable implements IFileService {
}
// Extra checks if target exists and this is not a rename
const
exists
=
await
this
.
exists
File
(
target
);
const
exists
=
await
this
.
exists
(
target
);
if
(
exists
&&
!
isCaseChange
)
{
// Bail out if target exists and we are not about to overwrite
...
...
@@ -514,7 +514,7 @@ export class FileService2 extends Disposable implements IFileService {
await
this
.
mkdirp
(
provider
,
resource
);
// events
const
fileStat
=
await
this
.
resolve
File
(
resource
,
{
resolveMetadata
:
true
});
const
fileStat
=
await
this
.
resolve
(
resource
,
{
resolveMetadata
:
true
});
this
.
_onAfterOperation
.
fire
(
new
FileOperationEvent
(
resource
,
FileOperation
.
CREATE
,
fileStat
));
return
fileStat
;
...
...
@@ -565,8 +565,8 @@ export class FileService2 extends Disposable implements IFileService {
// Validate recursive
const
recursive
=
!!
(
options
&&
options
.
recursive
);
if
(
!
recursive
&&
await
this
.
exists
File
(
resource
))
{
const
stat
=
await
this
.
resolve
File
(
resource
);
if
(
!
recursive
&&
await
this
.
exists
(
resource
))
{
const
stat
=
await
this
.
resolve
(
resource
);
if
(
stat
.
isDirectory
&&
Array
.
isArray
(
stat
.
children
)
&&
stat
.
children
.
length
>
0
)
{
throw
new
Error
(
localize
(
'
deleteFailed
'
,
"
Failed to delete non-empty folder '{0}'.
"
,
resource
.
toString
()));
}
...
...
@@ -586,12 +586,12 @@ export class FileService2 extends Disposable implements IFileService {
private
_onFileChanges
:
Emitter
<
FileChangesEvent
>
=
this
.
_register
(
new
Emitter
<
FileChangesEvent
>
());
get
onFileChanges
():
Event
<
FileChangesEvent
>
{
return
this
.
_onFileChanges
.
event
;
}
watch
FileChanges
(
resource
:
URI
):
void
{
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
watch
FileChanges
(
resource
));
watch
(
resource
:
URI
):
void
{
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
watch
(
resource
));
}
unwatch
FileChanges
(
resource
:
URI
):
void
{
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
unwatch
FileChanges
(
resource
));
unwatch
(
resource
:
URI
):
void
{
this
.
joinOnLegacy
.
then
(
legacy
=>
legacy
.
unwatch
(
resource
));
}
//#endregion
...
...
@@ -690,7 +690,7 @@ export class FileService2 extends Disposable implements IFileService {
private
async
doPipeBufferedToUnbuffered
(
sourceProvider
:
IFileSystemProviderWithOpenReadWriteCloseCapability
,
source
:
URI
,
targetProvider
:
IFileSystemProviderWithFileReadWriteCapability
,
target
:
URI
,
overwrite
:
boolean
):
Promise
<
void
>
{
// Determine file size
const
size
=
(
await
this
.
resolve
File
(
source
,
{
resolveMetadata
:
true
})).
size
;
const
size
=
(
await
this
.
resolve
(
source
,
{
resolveMetadata
:
true
})).
size
;
// Open handle
const
sourceHandle
=
await
sourceProvider
.
open
(
source
,
{
create
:
false
});
...
...
src/vs/workbench/services/files2/test/node/diskFileService.test.ts
浏览文件 @
f4eae9a5
此差异已折叠。
点击以展开。
src/vs/workbench/services/keybinding/common/keybindingEditing.ts
浏览文件 @
f4eae9a5
...
...
@@ -208,7 +208,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
private
resolveModelReference
():
Promise
<
IReference
<
IResolvedTextEditorModel
>>
{
return
this
.
fileService
.
exists
File
(
this
.
resource
)
return
this
.
fileService
.
exists
(
this
.
resource
)
.
then
(
exists
=>
{
const
EOL
=
this
.
configurationService
.
getValue
(
'
files
'
,
{
overrideIdentifier
:
'
json
'
})[
'
eol
'
];
const
result
:
Promise
<
any
>
=
exists
?
Promise
.
resolve
(
null
)
:
this
.
fileService
.
updateContent
(
this
.
resource
,
this
.
getEmptyContent
(
EOL
),
{
encoding
:
'
utf8
'
});
...
...
src/vs/workbench/services/output/common/outputChannelModel.ts
浏览文件 @
f4eae9a5
...
...
@@ -160,7 +160,7 @@ class OutputFileListener extends Disposable {
}
private
doWatch
():
Promise
<
void
>
{
return
this
.
fileService
.
resolve
File
(
this
.
file
,
{
resolveMetadata
:
true
})
return
this
.
fileService
.
resolve
(
this
.
file
,
{
resolveMetadata
:
true
})
.
then
(
stat
=>
{
if
(
stat
.
etag
!==
this
.
etag
)
{
this
.
etag
=
stat
.
etag
;
...
...
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
f4eae9a5
...
...
@@ -161,7 +161,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return
true
;
}
return
this
.
fileService
.
exists
File
(
this
.
resource
).
then
(
exists
=>
!
exists
);
return
this
.
fileService
.
exists
(
this
.
resource
).
then
(
exists
=>
!
exists
);
});
}
else
{
checkOrphanedPromise
=
Promise
.
resolve
(
false
);
...
...
src/vs/workbench/services/textfile/common/textFileService.ts
浏览文件 @
f4eae9a5
...
...
@@ -718,7 +718,7 @@ export class TextFileService extends Disposable implements ITextFileService {
}
// Otherwise we can only copy
return
this
.
fileService
.
copy
File
(
resource
,
target
).
then
(()
=>
true
);
return
this
.
fileService
.
copy
(
resource
,
target
).
then
(()
=>
true
);
}).
then
(
result
=>
{
// Return early if the operation was not running
...
...
@@ -748,7 +748,7 @@ export class TextFileService extends Disposable implements ITextFileService {
// Otherwise create the target file empty if it does not exist already and resolve it from there
else
{
targetModelResolver
=
this
.
fileService
.
exists
File
(
target
).
then
<
any
>
(
exists
=>
{
targetModelResolver
=
this
.
fileService
.
exists
(
target
).
then
<
any
>
(
exists
=>
{
targetExists
=
exists
;
// create target model adhoc if file does not exist yet
...
...
@@ -964,7 +964,7 @@ export class TextFileService extends Disposable implements ITextFileService {
return
this
.
revertAll
(
dirtySourceModels
.
map
(
dirtySourceModel
=>
dirtySourceModel
.
getResource
()),
{
soft
:
true
}).
then
(()
=>
{
// Rename to target
return
this
.
fileService
.
move
File
(
source
,
target
,
overwrite
).
then
(()
=>
{
return
this
.
fileService
.
move
(
source
,
target
,
overwrite
).
then
(()
=>
{
// Load models that were dirty before
return
Promise
.
all
(
dirtyTargetModels
.
map
(
dirtyTargetModel
=>
this
.
models
.
loadOrCreate
(
dirtyTargetModel
))).
then
(()
=>
undefined
);
...
...
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
浏览文件 @
f4eae9a5
...
...
@@ -394,12 +394,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if
(
this
.
fileService
&&
!
resources
.
isEqual
(
newTheme
.
location
,
this
.
watchedColorThemeLocation
))
{
if
(
this
.
watchedColorThemeLocation
)
{
this
.
fileService
.
unwatch
FileChanges
(
this
.
watchedColorThemeLocation
);
this
.
fileService
.
unwatch
(
this
.
watchedColorThemeLocation
);
this
.
watchedColorThemeLocation
=
undefined
;
}
if
(
newTheme
.
location
&&
(
newTheme
.
watch
||
!!
this
.
environmentService
.
extensionDevelopmentLocationURI
))
{
this
.
watchedColorThemeLocation
=
newTheme
.
location
;
this
.
fileService
.
watch
FileChanges
(
this
.
watchedColorThemeLocation
);
this
.
fileService
.
watch
(
this
.
watchedColorThemeLocation
);
}
}
...
...
@@ -512,12 +512,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if
(
this
.
fileService
&&
!
resources
.
isEqual
(
iconThemeData
.
location
,
this
.
watchedIconThemeLocation
))
{
if
(
this
.
watchedIconThemeLocation
)
{
this
.
fileService
.
unwatch
FileChanges
(
this
.
watchedIconThemeLocation
);
this
.
fileService
.
unwatch
(
this
.
watchedIconThemeLocation
);
this
.
watchedIconThemeLocation
=
undefined
;
}
if
(
iconThemeData
.
location
&&
(
iconThemeData
.
watch
||
!!
this
.
environmentService
.
extensionDevelopmentLocationURI
))
{
this
.
watchedIconThemeLocation
=
iconThemeData
.
location
;
this
.
fileService
.
watch
FileChanges
(
this
.
watchedIconThemeLocation
);
this
.
fileService
.
watch
(
this
.
watchedIconThemeLocation
);
}
}
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
f4eae9a5
...
...
@@ -929,9 +929,9 @@ export class TestFileService implements IFileService {
this
.
_onAfterOperation
.
fire
(
event
);
}
resolve
File
(
resource
:
URI
,
_options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
resolve
File
(
resource
:
URI
,
_options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
File
(
resource
:
URI
,
_options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
resolve
(
resource
:
URI
,
_options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
;
resolve
(
resource
:
URI
,
_options
:
IResolveMetadataFileOptions
):
Promise
<
IFileStatWithMetadata
>
;
resolve
(
resource
:
URI
,
_options
?:
IResolveFileOptions
):
Promise
<
IFileStat
>
{
return
Promise
.
resolve
({
resource
,
etag
:
Date
.
now
().
toString
(),
...
...
@@ -943,11 +943,11 @@ export class TestFileService implements IFileService {
});
}
resolve
Files
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
{
return
Promise
.
all
(
toResolve
.
map
(
resourceAndOption
=>
this
.
resolve
File
(
resourceAndOption
.
resource
,
resourceAndOption
.
options
))).
then
(
stats
=>
stats
.
map
(
stat
=>
({
stat
,
success
:
true
})));
resolve
All
(
toResolve
:
{
resource
:
URI
,
options
?:
IResolveFileOptions
}[]):
Promise
<
IResolveFileResult
[]
>
{
return
Promise
.
all
(
toResolve
.
map
(
resourceAndOption
=>
this
.
resolve
(
resourceAndOption
.
resource
,
resourceAndOption
.
options
))).
then
(
stats
=>
stats
.
map
(
stat
=>
({
stat
,
success
:
true
})));
}
exists
File
(
_resource
:
URI
):
Promise
<
boolean
>
{
exists
(
_resource
:
URI
):
Promise
<
boolean
>
{
return
Promise
.
resolve
(
true
);
}
...
...
@@ -996,11 +996,11 @@ export class TestFileService implements IFileService {
}));
}
move
File
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
move
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
return
Promise
.
resolve
(
null
!
);
}
copy
File
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
copy
(
_source
:
URI
,
_target
:
URI
,
_overwrite
?:
boolean
):
Promise
<
IFileStatWithMetadata
>
{
throw
new
Error
(
'
not implemented
'
);
}
...
...
@@ -1032,10 +1032,10 @@ export class TestFileService implements IFileService {
return
Promise
.
resolve
();
}
watch
FileChanges
(
_resource
:
URI
):
void
{
watch
(
_resource
:
URI
):
void
{
}
unwatch
FileChanges
(
_resource
:
URI
):
void
{
unwatch
(
_resource
:
URI
):
void
{
}
getWriteEncoding
(
_resource
:
URI
):
IResourceEncoding
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录