Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
5867b96a
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,发现更多精彩内容 >>
提交
5867b96a
编写于
11月 14, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More Promise removal
上级
30b2a5fd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
22 deletion
+19
-22
src/vs/platform/search/common/search.ts
src/vs/platform/search/common/search.ts
+2
-3
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
+8
-9
src/vs/workbench/services/search/node/searchService.ts
src/vs/workbench/services/search/node/searchService.ts
+9
-10
未找到文件。
src/vs/platform/search/common/search.ts
浏览文件 @
5867b96a
...
...
@@ -12,7 +12,6 @@ import * as objects from 'vs/base/common/objects';
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
{
getNLines
}
from
'
vs/base/common/strings
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
Promise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFilesConfiguration
}
from
'
vs/platform/files/common/files
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -29,7 +28,7 @@ export interface ISearchService {
textSearch
(
query
:
ITextQuery
,
token
?:
CancellationToken
,
onProgress
?:
(
result
:
ISearchProgressItem
)
=>
void
):
Promise
<
ISearchComplete
>
;
fileSearch
(
query
:
IFileQuery
,
token
?:
CancellationToken
):
Promise
<
ISearchComplete
>
;
extendQuery
(
query
:
ITextQuery
|
IFileQuery
):
void
;
clearCache
(
cacheKey
:
string
):
Promis
e
<
void
>
;
clearCache
(
cacheKey
:
string
):
Thenabl
e
<
void
>
;
registerSearchResultProvider
(
scheme
:
string
,
type
:
SearchProviderType
,
provider
:
ISearchResultProvider
):
IDisposable
;
}
...
...
@@ -60,7 +59,7 @@ export const enum SearchProviderType {
export
interface
ISearchResultProvider
{
textSearch
(
query
:
ITextQuery
,
onProgress
?:
(
p
:
ISearchProgressItem
)
=>
void
,
token
?:
CancellationToken
):
Promise
<
ISearchComplete
>
;
fileSearch
(
query
:
IFileQuery
,
token
?:
CancellationToken
):
Promise
<
ISearchComplete
>
;
clearCache
(
cacheKey
:
string
):
Promis
e
<
void
>
;
clearCache
(
cacheKey
:
string
):
Thenabl
e
<
void
>
;
}
export
interface
IFolderQuery
<
U
extends
UriComponents
=
URI
>
{
...
...
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
浏览文件 @
5867b96a
...
...
@@ -7,7 +7,6 @@ import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFileMatch
,
IRawFileMatch2
,
ISearchComplete
,
ISearchCompleteStats
,
ISearchProgressItem
,
ISearchResultProvider
,
ISearchService
,
QueryType
,
SearchProviderType
,
ITextQuery
,
IFileQuery
}
from
'
vs/platform/search/common/search
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
...
...
@@ -108,17 +107,17 @@ class RemoteSearchProvider implements ISearchResultProvider, IDisposable {
dispose
(
this
.
_registrations
);
}
fileSearch
(
query
:
IFileQuery
,
token
:
CancellationToken
=
CancellationToken
.
None
):
T
Promise
<
ISearchComplete
>
{
fileSearch
(
query
:
IFileQuery
,
token
:
CancellationToken
=
CancellationToken
.
None
):
Promise
<
ISearchComplete
>
{
return
this
.
doSearch
(
query
,
null
,
token
);
}
textSearch
(
query
:
ITextQuery
,
onProgress
?:
(
p
:
ISearchProgressItem
)
=>
void
,
token
:
CancellationToken
=
CancellationToken
.
None
):
T
Promise
<
ISearchComplete
>
{
textSearch
(
query
:
ITextQuery
,
onProgress
?:
(
p
:
ISearchProgressItem
)
=>
void
,
token
:
CancellationToken
=
CancellationToken
.
None
):
Promise
<
ISearchComplete
>
{
return
this
.
doSearch
(
query
,
onProgress
,
token
);
}
doSearch
(
query
:
ITextQuery
|
IFileQuery
,
onProgress
?:
(
p
:
ISearchProgressItem
)
=>
void
,
token
:
CancellationToken
=
CancellationToken
.
None
):
T
Promise
<
ISearchComplete
>
{
doSearch
(
query
:
ITextQuery
|
IFileQuery
,
onProgress
?:
(
p
:
ISearchProgressItem
)
=>
void
,
token
:
CancellationToken
=
CancellationToken
.
None
):
Promise
<
ISearchComplete
>
{
if
(
isFalsyOrEmpty
(
query
.
folderQueries
))
{
return
TPromise
.
as
(
undefined
);
return
Promise
.
resolve
(
undefined
);
}
const
search
=
new
SearchOperation
(
onProgress
);
...
...
@@ -128,17 +127,17 @@ class RemoteSearchProvider implements ISearchResultProvider, IDisposable {
?
this
.
_proxy
.
$provideFileSearchResults
(
this
.
_handle
,
search
.
id
,
query
,
token
)
:
this
.
_proxy
.
$provideTextSearchResults
(
this
.
_handle
,
search
.
id
,
query
,
token
);
return
TPromise
.
wrap
(
searchP
).
then
((
result
:
ISearchCompleteStats
)
=>
{
return
Promise
.
resolve
(
searchP
).
then
((
result
:
ISearchCompleteStats
)
=>
{
this
.
_searches
.
delete
(
search
.
id
);
return
{
results
:
values
(
search
.
matches
),
stats
:
result
.
stats
,
limitHit
:
result
.
limitHit
};
},
err
=>
{
this
.
_searches
.
delete
(
search
.
id
);
return
TPromise
.
wrapError
(
err
);
return
Promise
.
reject
(
err
);
});
}
clearCache
(
cacheKey
:
string
):
T
Promise
<
void
>
{
return
TPromise
.
wrap
(
this
.
_proxy
.
$clearCache
(
cacheKey
));
clearCache
(
cacheKey
:
string
):
Promise
<
void
>
{
return
Promise
.
resolve
(
this
.
_proxy
.
$clearCache
(
cacheKey
));
}
handleFindMatch
(
session
:
number
,
dataOrUri
:
(
UriComponents
|
IRawFileMatch2
)[]):
void
{
...
...
src/vs/workbench/services/search/node/searchService.ts
浏览文件 @
5867b96a
...
...
@@ -14,7 +14,6 @@ import { Schemas } from 'vs/base/common/network';
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
StopWatch
}
from
'
vs/base/common/stopwatch
'
;
import
{
URI
as
uri
}
from
'
vs/base/common/uri
'
;
import
{
Promise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
getNextTickChannel
}
from
'
vs/base/parts/ipc/node/ipc
'
;
import
{
Client
,
IIPCOptions
}
from
'
vs/base/parts/ipc/node/ipc.cp
'
;
...
...
@@ -122,16 +121,16 @@ export class SearchService extends Disposable implements ISearchService {
private
doSearch
(
query
:
ISearchQuery
,
token
?:
CancellationToken
,
onProgress
?:
(
item
:
ISearchProgressItem
)
=>
void
):
Promise
<
ISearchComplete
>
{
const
schemesInQuery
=
this
.
getSchemesInQuery
(
query
);
const
providerActivations
:
Promise
<
any
>
[]
=
[
Promise
.
wrap
(
null
)];
const
providerActivations
:
Thenable
<
any
>
[]
=
[
Promise
.
resolve
(
null
)];
schemesInQuery
.
forEach
(
scheme
=>
providerActivations
.
push
(
this
.
extensionService
.
activateByEvent
(
`onSearch:
${
scheme
}
`
)));
providerActivations
.
push
(
this
.
extensionService
.
activateByEvent
(
'
onSearch:file
'
));
const
providerPromise
=
Promise
.
join
(
providerActivations
)
const
providerPromise
=
Promise
.
all
(
providerActivations
)
.
then
(()
=>
this
.
extensionService
.
whenInstalledExtensionsRegistered
())
.
then
(()
=>
{
// Cancel faster if search was canceled while waiting for extensions
if
(
token
&&
token
.
isCancellationRequested
)
{
return
Promise
.
wrapError
(
canceled
());
return
Promise
.
reject
(
canceled
());
}
const
progressCallback
=
(
item
:
ISearchProgressItem
)
=>
{
...
...
@@ -190,7 +189,7 @@ export class SearchService extends Disposable implements ISearchService {
const
e2eSW
=
StopWatch
.
create
(
false
);
const
diskSearchQueries
:
IFolderQuery
[]
=
[];
const
searchPs
:
Promis
e
<
ISearchComplete
>
[]
=
[];
const
searchPs
:
Thenabl
e
<
ISearchComplete
>
[]
=
[];
const
fqs
=
this
.
groupFolderQueriesByScheme
(
query
);
keys
(
fqs
).
forEach
(
scheme
=>
{
...
...
@@ -233,7 +232,7 @@ export class SearchService extends Disposable implements ISearchService {
this
.
diskSearch
.
textSearch
(
diskSearchQuery
,
onProviderProgress
,
token
));
}
return
Promise
.
join
(
searchPs
).
then
(
completes
=>
{
return
Promise
.
all
(
searchPs
).
then
(
completes
=>
{
const
endToEndTime
=
e2eSW
.
elapsed
();
this
.
logService
.
trace
(
`SearchService#search:
${
endToEndTime
}
ms`
);
completes
.
forEach
(
complete
=>
{
...
...
@@ -443,7 +442,7 @@ export class SearchService extends Disposable implements ISearchService {
...
values
(
this
.
fileIndexProviders
)
].
map
(
provider
=>
provider
&&
provider
.
clearCache
(
cacheKey
));
return
Promise
.
join
(
clearPs
)
return
Promise
.
all
(
clearPs
)
.
then
(()
=>
{
});
}
}
...
...
@@ -486,7 +485,7 @@ export class DiskSearch implements ISearchResultProvider {
textSearch
(
query
:
ITextQuery
,
onProgress
?:
(
p
:
ISearchProgressItem
)
=>
void
,
token
?:
CancellationToken
):
Promise
<
ISearchComplete
>
{
const
folderQueries
=
query
.
folderQueries
||
[];
return
Promise
.
join
(
folderQueries
.
map
(
q
=>
q
.
folder
.
scheme
===
Schemas
.
file
&&
pfs
.
exists
(
q
.
folder
.
fsPath
)))
return
Promise
.
all
(
folderQueries
.
map
(
q
=>
q
.
folder
.
scheme
===
Schemas
.
file
&&
pfs
.
exists
(
q
.
folder
.
fsPath
)))
.
then
(
exists
=>
{
if
(
token
&&
token
.
isCancellationRequested
)
{
throw
canceled
();
...
...
@@ -501,7 +500,7 @@ export class DiskSearch implements ISearchResultProvider {
fileSearch
(
query
:
IFileQuery
,
token
?:
CancellationToken
):
Promise
<
ISearchComplete
>
{
const
folderQueries
=
query
.
folderQueries
||
[];
return
Promise
.
join
(
folderQueries
.
map
(
q
=>
q
.
folder
.
scheme
===
Schemas
.
file
&&
pfs
.
exists
(
q
.
folder
.
fsPath
)))
return
Promise
.
all
(
folderQueries
.
map
(
q
=>
q
.
folder
.
scheme
===
Schemas
.
file
&&
pfs
.
exists
(
q
.
folder
.
fsPath
)))
.
then
(
exists
=>
{
if
(
token
&&
token
.
isCancellationRequested
)
{
throw
canceled
();
...
...
@@ -581,7 +580,7 @@ export class DiskSearch implements ISearchResultProvider {
return
fileMatch
;
}
public
clearCache
(
cacheKey
:
string
):
Promis
e
<
void
>
{
public
clearCache
(
cacheKey
:
string
):
Thenabl
e
<
void
>
{
return
this
.
raw
.
clearCache
(
cacheKey
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录