Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0f1c97b1
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,发现更多精彩内容 >>
提交
0f1c97b1
编写于
4月 23, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename FileSystemProvider2 to FileSystemProvider and the whole ripple.
keep the old proposed api as DeprecatedXYZ #47475
上级
35f1c86f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
78 addition
and
128 deletion
+78
-128
src/vs/platform/files/common/files.ts
src/vs/platform/files/common/files.ts
+3
-3
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+43
-76
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+4
-9
src/vs/workbench/api/node/extHostFileSystem.ts
src/vs/workbench/api/node/extHostFileSystem.ts
+25
-37
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+3
-3
未找到文件。
src/vs/platform/files/common/files.ts
浏览文件 @
0f1c97b1
...
...
@@ -185,9 +185,9 @@ export interface FileOptions {
}
export
interface
IStat
{
isFile
:
boolean
;
isDirectory
:
boolean
;
isSymbolicLink
:
boolean
;
isFile
?
:
boolean
;
isDirectory
?
:
boolean
;
isSymbolicLink
?
:
boolean
;
mtime
:
number
;
size
:
number
;
}
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
0f1c97b1
...
...
@@ -13,86 +13,40 @@ declare module 'vscode' {
//#region Joh: file system provider (OLD)
export
enum
FileChangeType
{
export
enum
Deprecated
FileChangeType
{
Updated
=
0
,
Added
=
1
,
Deleted
=
2
}
export
interface
FileChange
{
type
:
FileChangeType
;
export
interface
DeprecatedFileChange
{
type
:
DeprecatedFileChangeType
;
resource
:
Uri
;
}
export
enum
FileType
{
export
enum
DeprecatedFileType
{
File
=
0
,
Dir
=
1
,
Symlink
=
2
}
export
interface
FileStat
{
export
interface
DeprecatedFileStat
{
id
:
number
|
string
;
mtime
:
number
;
// atime: number;
size
:
number
;
type
:
FileType
;
type
:
Deprecated
FileType
;
}
// todo@joh discover files etc
// todo@joh CancellationToken everywhere
// todo@joh add open/close calls?
export
interface
FileSystemProvider
{
readonly
onDidChange
?:
Event
<
FileChange
[]
>
;
// more...
// @deprecated - will go away
utimes
(
resource
:
Uri
,
mtime
:
number
,
atime
:
number
):
Thenable
<
FileStat
>
;
stat
(
resource
:
Uri
):
Thenable
<
FileStat
>
;
export
interface
DeprecatedFileSystemProvider
{
readonly
onDidChange
?:
Event
<
DeprecatedFileChange
[]
>
;
utimes
(
resource
:
Uri
,
mtime
:
number
,
atime
:
number
):
Thenable
<
DeprecatedFileStat
>
;
stat
(
resource
:
Uri
):
Thenable
<
DeprecatedFileStat
>
;
read
(
resource
:
Uri
,
offset
:
number
,
length
:
number
,
progress
:
Progress
<
Uint8Array
>
):
Thenable
<
number
>
;
// todo@joh - have an option to create iff not exist
// todo@remote
// offset - byte offset to start
// count - number of bytes to write
// Thenable<number> - number of bytes actually written
write
(
resource
:
Uri
,
content
:
Uint8Array
):
Thenable
<
void
>
;
// todo@remote
// Thenable<FileStat>
move
(
resource
:
Uri
,
target
:
Uri
):
Thenable
<
FileStat
>
;
// todo@remote
// helps with performance bigly
// copy?(from: Uri, to: Uri): Thenable<void>;
// todo@remote
// Thenable<FileStat>
mkdir
(
resource
:
Uri
):
Thenable
<
FileStat
>
;
readdir
(
resource
:
Uri
):
Thenable
<
[
Uri
,
FileStat
][]
>
;
// todo@remote
// ? merge both
// ? recursive del
move
(
resource
:
Uri
,
target
:
Uri
):
Thenable
<
DeprecatedFileStat
>
;
mkdir
(
resource
:
Uri
):
Thenable
<
DeprecatedFileStat
>
;
readdir
(
resource
:
Uri
):
Thenable
<
[
Uri
,
DeprecatedFileStat
][]
>
;
rmdir
(
resource
:
Uri
):
Thenable
<
void
>
;
unlink
(
resource
:
Uri
):
Thenable
<
void
>
;
// todo@remote
// create(resource: Uri): Thenable<FileStat>;
}
export
type
DeprecatedFileChangeType
=
FileChangeType
;
export
type
DeprecatedFileType
=
FileType
;
export
type
DeprecatedFileChange
=
FileChange
;
export
type
DeprecatedFileStat
=
FileStat
;
export
type
DeprecatedFileSystemProvider
=
FileSystemProvider
;
export
namespace
workspace
{
export
function
registerDeprecatedFileSystemProvider
(
scheme
:
string
,
provider
:
DeprecatedFileSystemProvider
):
Disposable
;
export
function
registerFileSystemProvider
(
scheme
:
string
,
provider
:
FileSystemProvider
,
newProvider
?:
FileSystemProvider2
):
Disposable
;
}
//#endregion
...
...
@@ -103,7 +57,7 @@ declare module 'vscode' {
* A type that filesystem providers should use to signal errors.
*
* This class has factory methods for common error-cases, like `EntryNotFound` when
* a file or folder doesn't exist
. Use them like so `throw vscode.FileSystemError.EntryNotFound(u
ri);`
* a file or folder doesn't exist
, use them like so: `throw vscode.FileSystemError.EntryNotFound(someU
ri);`
*/
export
class
FileSystemError
extends
Error
{
...
...
@@ -140,9 +94,24 @@ declare module 'vscode' {
constructor
(
messageOrUri
?:
string
|
Uri
);
}
export
enum
FileChangeType2
{
/**
* Enumeration of file change types.
*/
export
enum
FileChangeType
{
/**
* The contents or metadata of a file have changed.
*/
Changed
=
1
,
/**
* A file has been created.
*/
Created
=
2
,
/**
* A file has been deleted.
*/
Deleted
=
3
,
}
...
...
@@ -152,9 +121,9 @@ declare module 'vscode' {
export
interface
FileChangeEvent
{
/**
*
*
The type of change.
*/
type
:
FileChangeType
2
;
type
:
FileChangeType
;
/**
* The uri of the file that has changed.
...
...
@@ -165,21 +134,21 @@ declare module 'vscode' {
/**
* The `FileStat`-type represents metadata about a file.
*/
export
interface
FileStat
2
{
export
interface
FileStat
{
/**
* The file is a regular file.
*/
isFile
:
boolean
;
isFile
?
:
boolean
;
/**
* The file is a directory.
*/
isDirectory
:
boolean
;
isDirectory
?
:
boolean
;
/**
* The file is symbolic link to another file.
*/
isSymbolicLink
:
boolean
;
isSymbolicLink
?
:
boolean
;
/**
* The modification timestamp in milliseconds.
...
...
@@ -226,9 +195,7 @@ declare module 'vscode' {
* -use posix-path-math
* -etc...
*/
export
interface
FileSystemProvider2
{
_version
:
9
;
export
interface
FileSystemProvider
{
/**
* An event to signal that a resource has been created, changed, or deleted. This
...
...
@@ -252,7 +219,7 @@ declare module 'vscode' {
* @param token A cancellation token.
* @return The file metadata about the file.
*/
stat
(
uri
:
Uri
,
options
:
{
/*future: followSymlinks*/
},
token
:
CancellationToken
):
FileStat
2
|
Thenable
<
FileStat2
>
;
stat
(
uri
:
Uri
,
options
:
{
/*future: followSymlinks*/
},
token
:
CancellationToken
):
FileStat
|
Thenable
<
FileStat
>
;
/**
* Retrieve the meta data of all entries of a [directory](#FileType2.Directory)
...
...
@@ -261,7 +228,7 @@ declare module 'vscode' {
* @param token A cancellation token.
* @return A thenable that resolves to an array of tuples of file names and files stats.
*/
readDirectory
(
uri
:
Uri
,
options
:
{
/*future: onlyType?*/
},
token
:
CancellationToken
):
[
string
,
FileStat
2
][]
|
Thenable
<
[
string
,
FileStat2
][]
>
;
readDirectory
(
uri
:
Uri
,
options
:
{
/*future: onlyType?*/
},
token
:
CancellationToken
):
[
string
,
FileStat
][]
|
Thenable
<
[
string
,
FileStat
][]
>
;
/**
* Create a new directory. *Note* that new files are created via `write`-calls.
...
...
@@ -269,7 +236,7 @@ declare module 'vscode' {
* @param uri The uri of the *new* folder.
* @param token A cancellation token.
*/
createDirectory
(
uri
:
Uri
,
options
:
{
/*future: permissions?*/
},
token
:
CancellationToken
):
FileStat
2
|
Thenable
<
FileStat2
>
;
createDirectory
(
uri
:
Uri
,
options
:
{
/*future: permissions?*/
},
token
:
CancellationToken
):
FileStat
|
Thenable
<
FileStat
>
;
/**
* Read the entire contents of a file.
...
...
@@ -305,7 +272,7 @@ declare module 'vscode' {
* @param newUri The target location.
* @param token A cancellation token.
*/
rename
(
oldUri
:
Uri
,
newUri
:
Uri
,
options
:
FileOptions
,
token
:
CancellationToken
):
FileStat
2
|
Thenable
<
FileStat2
>
;
rename
(
oldUri
:
Uri
,
newUri
:
Uri
,
options
:
FileOptions
,
token
:
CancellationToken
):
FileStat
|
Thenable
<
FileStat
>
;
/**
* Copy files or folders. Implementing this function is optional but it will speedup
...
...
@@ -315,11 +282,11 @@ declare module 'vscode' {
* @param target The target location.
* @param token A cancellation token.
*/
copy
?(
uri
:
Uri
,
target
:
Uri
,
options
:
FileOptions
,
token
:
CancellationToken
):
FileStat
2
|
Thenable
<
FileStat2
>
;
copy
?(
uri
:
Uri
,
target
:
Uri
,
options
:
FileOptions
,
token
:
CancellationToken
):
FileStat
|
Thenable
<
FileStat
>
;
}
export
namespace
workspace
{
export
function
registerFileSystemProvider
2
(
scheme
:
string
,
provider
:
FileSystemProvider2
,
options
:
{
isCaseSensitive
?:
boolean
}):
Disposable
;
export
function
registerFileSystemProvider
(
scheme
:
string
,
provider
:
FileSystemProvider
,
options
:
{
isCaseSensitive
?:
boolean
}):
Disposable
;
}
//#endregion
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
0f1c97b1
...
...
@@ -550,11 +550,8 @@ export function createApiFactory(
onDidEndTask
:
(
listeners
,
thisArgs
?,
disposables
?)
=>
{
return
extHostTask
.
onDidEndTask
(
listeners
,
thisArgs
,
disposables
);
},
registerFileSystemProvider
:
proposedApiFunction
(
extension
,
(
scheme
,
provider
,
newProvider
?)
=>
{
return
extHostFileSystem
.
registerFileSystemProvider
(
scheme
,
provider
,
newProvider
);
}),
registerFileSystemProvider2
:
proposedApiFunction
(
extension
,
(
scheme
,
provider
,
options
)
=>
{
return
extHostFileSystem
.
registerFileSystemProvider2
(
scheme
,
provider
,
options
);
registerFileSystemProvider
:
proposedApiFunction
(
extension
,
(
scheme
,
provider
,
options
)
=>
{
return
extHostFileSystem
.
registerFileSystemProvider
(
scheme
,
provider
,
options
);
}),
registerDeprecatedFileSystemProvider
:
proposedApiFunction
(
extension
,
(
scheme
,
provider
)
=>
{
return
extHostFileSystem
.
registerDeprecatedFileSystemProvider
(
scheme
,
provider
);
...
...
@@ -701,11 +698,9 @@ export function createApiFactory(
ConfigurationTarget
:
extHostTypes
.
ConfigurationTarget
,
RelativePattern
:
extHostTypes
.
RelativePattern
,
DeprecatedFileChangeType
:
extHostTypes
.
DeprecatedFileChangeType
,
DeprecatedFileType
:
extHostTypes
.
DeprecatedFileType
,
FileChangeType
:
extHostTypes
.
FileChangeType
,
FileType
:
extHostTypes
.
FileType
,
DeprecatedFileChangeType
:
extHostTypes
.
FileChangeType
,
DeprecatedFileType
:
extHostTypes
.
FileType
,
FileChangeType2
:
extHostTypes
.
FileChangeType2
,
FileSystemError
:
extHostTypes
.
FileSystemError
,
FoldingRange
:
extHostTypes
.
FoldingRange
,
FoldingRangeKind
:
extHostTypes
.
FoldingRangeKind
...
...
src/vs/workbench/api/node/extHostFileSystem.ts
浏览文件 @
0f1c97b1
...
...
@@ -14,7 +14,7 @@ import * as path from 'path';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
Range
,
FileType
,
FileChangeType
,
FileChangeType2
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
Range
,
DeprecatedFileType
,
DeprecatedFileChangeType
,
FileChangeType
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
ExtHostLanguageFeatures
}
from
'
vs/workbench/api/node/extHostLanguageFeatures
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
...
...
@@ -57,9 +57,7 @@ class FsLinkProvider implements vscode.DocumentLinkProvider {
}
}
class
FileSystemProviderShim
implements
vscode
.
FileSystemProvider2
{
_version
:
9
=
9
;
class
FileSystemProviderShim
implements
vscode
.
FileSystemProvider
{
onDidChangeFile
:
vscode
.
Event
<
vscode
.
FileChangeEvent
[]
>
;
...
...
@@ -77,19 +75,19 @@ class FileSystemProviderShim implements vscode.FileSystemProvider2 {
return
{
dispose
()
{
}
};
}
stat
(
resource
:
vscode
.
Uri
):
Thenable
<
vscode
.
FileStat
2
>
{
stat
(
resource
:
vscode
.
Uri
):
Thenable
<
vscode
.
FileStat
>
{
return
this
.
_delegate
.
stat
(
resource
).
then
(
stat
=>
FileSystemProviderShim
.
_modernizeFileStat
(
stat
));
}
rename
(
oldUri
:
vscode
.
Uri
,
newUri
:
vscode
.
Uri
):
Thenable
<
vscode
.
FileStat
2
>
{
rename
(
oldUri
:
vscode
.
Uri
,
newUri
:
vscode
.
Uri
):
Thenable
<
vscode
.
FileStat
>
{
return
this
.
_delegate
.
move
(
oldUri
,
newUri
).
then
(
stat
=>
FileSystemProviderShim
.
_modernizeFileStat
(
stat
));
}
readDirectory
(
resource
:
vscode
.
Uri
):
Thenable
<
[
string
,
vscode
.
FileStat
2
][]
>
{
readDirectory
(
resource
:
vscode
.
Uri
):
Thenable
<
[
string
,
vscode
.
FileStat
][]
>
{
return
this
.
_delegate
.
readdir
(
resource
).
then
(
tuples
=>
{
return
tuples
.
map
(
tuple
=>
<
[
string
,
vscode
.
FileStat
2
]
>
[
path
.
posix
.
basename
(
tuple
[
0
].
path
),
FileSystemProviderShim
.
_modernizeFileStat
(
tuple
[
1
])]);
return
tuples
.
map
(
tuple
=>
<
[
string
,
vscode
.
FileStat
]
>
[
path
.
posix
.
basename
(
tuple
[
0
].
path
),
FileSystemProviderShim
.
_modernizeFileStat
(
tuple
[
1
])]);
});
}
private
static
_modernizeFileStat
(
stat
:
vscode
.
DeprecatedFileStat
):
vscode
.
FileStat
2
{
private
static
_modernizeFileStat
(
stat
:
vscode
.
DeprecatedFileStat
):
vscode
.
FileStat
{
let
{
mtime
,
size
,
type
}
=
stat
;
let
isFile
=
false
;
let
isDirectory
=
false
;
...
...
@@ -97,13 +95,13 @@ class FileSystemProviderShim implements vscode.FileSystemProvider2 {
// no support for bitmask, effectively no support for symlinks
switch
(
type
)
{
case
FileType
.
Dir
:
case
Deprecated
FileType
.
Dir
:
isDirectory
=
true
;
break
;
case
FileType
.
File
:
case
Deprecated
FileType
.
File
:
isFile
=
true
;
break
;
case
FileType
.
Symlink
:
case
Deprecated
FileType
.
Symlink
:
isSymbolicLink
=
true
;
break
;
}
...
...
@@ -112,16 +110,16 @@ class FileSystemProviderShim implements vscode.FileSystemProvider2 {
private
static
_modernizeFileChange
(
e
:
vscode
.
DeprecatedFileChange
):
vscode
.
FileChangeEvent
{
let
{
resource
,
type
}
=
e
;
let
newType
:
vscode
.
FileChangeType
2
;
let
newType
:
vscode
.
FileChangeType
;
switch
(
type
)
{
case
FileChangeType
.
Updated
:
newType
=
FileChangeType
2
.
Changed
;
case
Deprecated
FileChangeType
.
Updated
:
newType
=
FileChangeType
.
Changed
;
break
;
case
FileChangeType
.
Added
:
newType
=
FileChangeType
2
.
Created
;
case
Deprecated
FileChangeType
.
Added
:
newType
=
FileChangeType
.
Created
;
break
;
case
FileChangeType
.
Deleted
:
newType
=
FileChangeType
2
.
Deleted
;
case
Deprecated
FileChangeType
.
Deleted
:
newType
=
FileChangeType
.
Deleted
;
break
;
}
...
...
@@ -132,14 +130,14 @@ class FileSystemProviderShim implements vscode.FileSystemProvider2 {
delete
(
resource
:
vscode
.
Uri
):
Thenable
<
void
>
{
return
this
.
_delegate
.
stat
(
resource
).
then
(
stat
=>
{
if
(
stat
.
type
===
FileType
.
Dir
)
{
if
(
stat
.
type
===
Deprecated
FileType
.
Dir
)
{
return
this
.
_delegate
.
rmdir
(
resource
);
}
else
{
return
this
.
_delegate
.
unlink
(
resource
);
}
});
}
createDirectory
(
resource
:
vscode
.
Uri
):
Thenable
<
vscode
.
FileStat
2
>
{
createDirectory
(
resource
:
vscode
.
Uri
):
Thenable
<
vscode
.
FileStat
>
{
return
this
.
_delegate
.
mkdir
(
resource
).
then
(
stat
=>
FileSystemProviderShim
.
_modernizeFileStat
(
stat
));
}
...
...
@@ -165,7 +163,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
private
readonly
_proxy
:
MainThreadFileSystemShape
;
private
readonly
_linkProvider
=
new
FsLinkProvider
();
private
readonly
_fsProvider
=
new
Map
<
number
,
vscode
.
FileSystemProvider
2
>
();
private
readonly
_fsProvider
=
new
Map
<
number
,
vscode
.
FileSystemProvider
>
();
private
readonly
_usedSchemes
=
new
Set
<
string
>
();
private
readonly
_watches
=
new
Map
<
number
,
IDisposable
>
();
...
...
@@ -187,20 +185,10 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
}
registerDeprecatedFileSystemProvider
(
scheme
:
string
,
provider
:
vscode
.
DeprecatedFileSystemProvider
)
{
return
this
.
registerFileSystemProvider2
(
scheme
,
new
FileSystemProviderShim
(
provider
),
{
isCaseSensitive
:
false
});
}
registerFileSystemProvider
(
scheme
:
string
,
provider
:
vscode
.
DeprecatedFileSystemProvider
,
newProvider
:
vscode
.
FileSystemProvider2
)
{
if
(
newProvider
&&
newProvider
.
_version
===
9
)
{
return
this
.
registerFileSystemProvider2
(
scheme
,
newProvider
,
{
isCaseSensitive
:
false
});
}
else
if
(
provider
)
{
return
this
.
registerFileSystemProvider2
(
scheme
,
new
FileSystemProviderShim
(
provider
),
{
isCaseSensitive
:
false
});
}
else
{
throw
new
Error
(
'
FAILED to register file system provider, the new provider does not meet the version-constraint and there is no old provider
'
);
}
return
this
.
registerFileSystemProvider
(
scheme
,
new
FileSystemProviderShim
(
provider
),
{
isCaseSensitive
:
false
});
}
registerFileSystemProvider
2
(
scheme
:
string
,
provider
:
vscode
.
FileSystemProvider2
,
options
:
{
isCaseSensitive
?:
boolean
})
{
registerFileSystemProvider
(
scheme
:
string
,
provider
:
vscode
.
FileSystemProvider
,
options
:
{
isCaseSensitive
?:
boolean
})
{
if
(
this
.
_usedSchemes
.
has
(
scheme
))
{
throw
new
Error
(
`a provider for the scheme '
${
scheme
}
' is already registered`
);
...
...
@@ -231,13 +219,13 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
}
let
newType
:
files
.
FileChangeType
;
switch
(
type
)
{
case
FileChangeType
2
.
Changed
:
case
FileChangeType
.
Changed
:
newType
=
files
.
FileChangeType
.
UPDATED
;
break
;
case
FileChangeType
2
.
Created
:
case
FileChangeType
.
Created
:
newType
=
files
.
FileChangeType
.
ADDED
;
break
;
case
FileChangeType
2
.
Deleted
:
case
FileChangeType
.
Deleted
:
newType
=
files
.
FileChangeType
.
DELETED
;
break
;
}
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
0f1c97b1
...
...
@@ -1846,19 +1846,19 @@ export enum LogLevel {
//#region file api
// todo@remote
export
enum
FileChangeType
{
export
enum
Deprecated
FileChangeType
{
Updated
=
0
,
Added
=
1
,
Deleted
=
2
}
export
enum
FileChangeType
2
{
export
enum
FileChangeType
{
Changed
=
1
,
Created
=
2
,
Deleted
=
3
,
}
export
enum
FileType
{
export
enum
Deprecated
FileType
{
File
=
0
,
Dir
=
1
,
Symlink
=
2
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录