Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
51b0bf3c
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,发现更多精彩内容 >>
提交
51b0bf3c
编写于
10月 10, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support `findFiles`
上级
0b03de63
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
7 deletion
+65
-7
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+3
-0
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
...vs/workbench/api/electron-browser/mainThreadFileSystem.ts
+51
-7
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+3
-0
src/vs/workbench/api/node/extHostFileSystem.ts
src/vs/workbench/api/node/extHostFileSystem.ts
+8
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
51b0bf3c
...
...
@@ -155,6 +155,9 @@ declare module 'vscode' {
// todo@remote
// create(resource: Uri): Thenable<FileStat>;
// find files by names
findFiles
?(
query
:
string
,
progress
:
Progress
<
Uri
>
,
token
:
CancellationToken
):
Thenable
<
void
>
;
}
export
namespace
workspace
{
...
...
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
浏览文件 @
51b0bf3c
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
,
PPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ExtHostContext
,
MainContext
,
IExtHostContext
,
MainThreadFileSystemShape
,
ExtHostFileSystemShape
}
from
'
../node/extHost.protocol
'
;
import
{
IFileService
,
IFileSystemProvider
,
IStat
,
IFileChange
}
from
'
vs/platform/files/common/files
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
...
...
@@ -13,6 +13,7 @@ import Event, { Emitter } from 'vs/base/common/event';
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
IProgress
}
from
'
vs/platform/progress/common/progress
'
;
import
{
IWorkspaceEditingService
}
from
'
vs/workbench/services/workspace/common/workspaceEditing
'
;
import
{
ISearchResultProvider
,
ISearchQuery
,
ISearchComplete
,
ISearchProgressItem
,
QueryType
,
IFileMatch
,
ISearchService
}
from
'
vs/platform/search/common/search
'
;
@
extHostNamedCustomer
(
MainContext
.
MainThreadFileSystem
)
export
class
MainThreadFileSystem
implements
MainThreadFileSystemShape
{
...
...
@@ -24,6 +25,7 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape {
constructor
(
extHostContext
:
IExtHostContext
,
@
IFileService
private
readonly
_fileService
:
IFileService
,
@
ISearchService
private
readonly
_searchService
:
ISearchService
,
@
IWorkspaceEditingService
private
readonly
_workspaceEditService
:
IWorkspaceEditingService
)
{
this
.
_proxy
=
extHostContext
.
get
(
ExtHostContext
.
ExtHostFileSystem
);
...
...
@@ -34,7 +36,7 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape {
}
$registerFileSystemProvider
(
handle
:
number
,
scheme
:
string
):
void
{
this
.
_provider
.
set
(
handle
,
new
RemoteFileSystemProvider
(
this
.
_fileService
,
scheme
,
handle
,
this
.
_proxy
));
this
.
_provider
.
set
(
handle
,
new
RemoteFileSystemProvider
(
this
.
_fileService
,
this
.
_searchService
,
scheme
,
handle
,
this
.
_proxy
));
}
$unregisterFileSystemProvider
(
handle
:
number
):
void
{
...
...
@@ -53,28 +55,38 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape {
$reportFileChunk
(
handle
:
number
,
resource
:
URI
,
chunk
:
number
[]):
void
{
this
.
_provider
.
get
(
handle
).
reportFileChunk
(
resource
,
chunk
);
}
// --- search
$handleSearchProgress
(
handle
:
number
,
session
:
number
,
resource
:
URI
):
void
{
this
.
_provider
.
get
(
handle
).
handleSearchProgress
(
session
,
resource
);
}
}
class
RemoteFileSystemProvider
implements
IFileSystemProvider
{
class
RemoteFileSystemProvider
implements
IFileSystemProvider
,
ISearchResultProvider
{
private
readonly
_onDidChange
=
new
Emitter
<
IFileChange
[]
>
();
private
readonly
_registration
:
IDisposable
;
private
readonly
_reads
=
new
Map
<
string
,
IProgress
<
Uint8Array
>>
();
private
readonly
_registrations
:
IDisposable
[];
readonly
onDidChange
:
Event
<
IFileChange
[]
>
=
this
.
_onDidChange
.
event
;
constructor
(
service
:
IFileService
,
fileService
:
IFileService
,
searchService
:
ISearchService
,
scheme
:
string
,
private
readonly
_handle
:
number
,
private
readonly
_proxy
:
ExtHostFileSystemShape
)
{
this
.
_registration
=
service
.
registerProvider
(
scheme
,
this
);
this
.
_registrations
=
[
fileService
.
registerProvider
(
scheme
,
this
),
searchService
.
registerSearchResultProvider
(
this
),
];
}
dispose
():
void
{
this
.
_registration
.
dispose
(
);
dispose
(
this
.
_registrations
);
this
.
_onDidChange
.
dispose
();
}
...
...
@@ -115,4 +127,36 @@ class RemoteFileSystemProvider implements IFileSystemProvider {
rmdir
(
resource
:
URI
):
TPromise
<
void
,
any
>
{
return
this
.
_proxy
.
$rmdir
(
this
.
_handle
,
resource
);
}
// --- search
private
_searches
=
new
Map
<
number
,
(
resource
:
URI
)
=>
void
>
();
private
_searchesIdPool
=
0
;
search
(
query
:
ISearchQuery
):
PPromise
<
ISearchComplete
,
ISearchProgressItem
>
{
if
(
query
.
type
===
QueryType
.
Text
)
{
return
PPromise
.
as
<
ISearchComplete
>
({
results
:
[],
stats
:
undefined
});
}
const
id
=
++
this
.
_searchesIdPool
;
const
matches
:
IFileMatch
[]
=
[];
return
new
PPromise
((
resolve
,
reject
,
report
)
=>
{
this
.
_proxy
.
$fileFiles
(
this
.
_handle
,
id
,
query
.
filePattern
).
then
(()
=>
{
this
.
_searches
.
delete
(
id
);
resolve
({
results
:
matches
,
stats
:
undefined
});
},
reject
);
this
.
_searches
.
set
(
id
,
resource
=>
{
const
match
:
IFileMatch
=
{
resource
};
matches
.
push
(
match
);
report
(
match
);
});
});
}
handleSearchProgress
(
session
:
number
,
resource
:
URI
):
void
{
this
.
_searches
.
get
(
session
)(
resource
);
}
}
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
51b0bf3c
...
...
@@ -324,6 +324,8 @@ export interface MainThreadFileSystemShape extends IDisposable {
$onDidAddFileSystemRoot
(
root
:
URI
):
void
;
$onFileSystemChange
(
handle
:
number
,
resource
:
IFileChange
[]):
void
;
$reportFileChunk
(
handle
:
number
,
resource
:
URI
,
chunk
:
number
[]
|
null
):
void
;
$handleSearchProgress
(
handle
:
number
,
session
:
number
,
resource
:
URI
):
void
;
}
export
interface
MainThreadTaskShape
extends
IDisposable
{
...
...
@@ -489,6 +491,7 @@ export interface ExtHostFileSystemShape {
$mkdir
(
handle
:
number
,
resource
:
URI
):
TPromise
<
IStat
>
;
$readdir
(
handle
:
number
,
resource
:
URI
):
TPromise
<
[
URI
,
IStat
][]
>
;
$rmdir
(
handle
:
number
,
resource
:
URI
):
TPromise
<
void
>
;
$fileFiles
(
handle
:
number
,
session
:
number
,
query
:
string
):
TPromise
<
void
>
;
}
export
interface
ExtHostExtensionServiceShape
{
...
...
src/vs/workbench/api/node/extHostFileSystem.ts
浏览文件 @
51b0bf3c
...
...
@@ -74,4 +74,12 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
$rmdir
(
handle
:
number
,
resource
:
URI
):
TPromise
<
void
,
any
>
{
return
asWinJsPromise
(
token
=>
this
.
_provider
.
get
(
handle
).
rmdir
(
resource
));
}
$fileFiles
(
handle
:
number
,
session
:
number
,
query
:
string
):
TPromise
<
void
>
{
const
provider
=
this
.
_provider
.
get
(
handle
);
if
(
!
provider
.
findFiles
)
{
return
TPromise
.
as
(
undefined
);
}
const
progress
=
{
report
:
(
uri
)
=>
this
.
_proxy
.
$handleSearchProgress
(
handle
,
session
,
uri
)
};
return
asWinJsPromise
(
token
=>
provider
.
findFiles
(
query
,
progress
,
token
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录