Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c4f336d1
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,发现更多精彩内容 >>
提交
c4f336d1
编写于
7月 23, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #53887 - remove remaining PPromise usage in search
上级
74c270e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
52 deletion
+47
-52
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
+5
-5
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+42
-47
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
浏览文件 @
c4f336d1
...
...
@@ -5,14 +5,14 @@
'
use strict
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
IDisposable
,
dispos
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposabl
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
PPromise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFileMatch
,
ISearchComplete
,
ISearchProgressItem
,
ISearchQuery
,
ISearchResultProvider
,
ISearchService
,
QueryType
,
IRawFileMatch2
,
ISearchCompleteStats
}
from
'
vs/platform/search/common/search
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFileMatch
,
IRawFileMatch2
,
ISearchComplete
,
ISearchCompleteStats
,
ISearchProgressItem
,
ISearchQuery
,
ISearchResultProvider
,
ISearchService
,
QueryType
}
from
'
vs/platform/search/common/search
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
ExtHostContext
,
ExtHostSearchShape
,
IExtHostContext
,
MainContext
,
MainThreadSearchShape
}
from
'
../node/extHost.protocol
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
@
extHostNamedCustomer
(
MainContext
.
MainThreadSearch
)
export
class
MainThreadSearch
implements
MainThreadSearchShape
{
...
...
@@ -100,7 +100,7 @@ class RemoteSearchProvider implements ISearchResultProvider, IDisposable {
search
(
query
:
ISearchQuery
,
onProgress
?:
(
p
:
ISearchProgressItem
)
=>
void
):
TPromise
<
ISearchComplete
>
{
if
(
isFalsyOrEmpty
(
query
.
folderQueries
))
{
return
P
Promise
.
as
(
undefined
);
return
T
Promise
.
as
(
undefined
);
}
const
folderQueriesForScheme
=
query
.
folderQueries
.
filter
(
fq
=>
fq
.
folder
.
scheme
===
this
.
_scheme
);
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
c4f336d1
...
...
@@ -10,7 +10,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
PPromise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
import
{
IFileMatch
,
IFolderQuery
,
IPatternInfo
,
IRawSearchQuery
,
ISearchCompleteStats
,
ISearchQuery
}
from
'
vs/platform/search/common/search
'
;
import
*
as
vscode
from
'
vscode
'
;
...
...
@@ -58,12 +58,9 @@ export class ExtHostSearch implements ExtHostSearchShape {
}
const
query
=
reviveQuery
(
rawQuery
);
return
this
.
_fileSearchManager
.
fileSearch
(
query
,
provider
).
then
(
null
,
null
,
progress
=>
{
this
.
_proxy
.
$handleFileMatch
(
handle
,
session
,
progress
.
map
(
p
=>
p
.
resource
));
});
return
this
.
_fileSearchManager
.
fileSearch
(
query
,
provider
,
progress
=>
{
this
.
_proxy
.
$handleFileMatch
(
handle
,
session
,
progress
.
map
(
p
=>
p
.
resource
));
});
}
$clearCache
(
handle
:
number
,
cacheKey
:
string
):
TPromise
<
void
>
{
...
...
@@ -84,12 +81,7 @@ export class ExtHostSearch implements ExtHostSearchShape {
const
query
=
reviveQuery
(
rawQuery
);
const
engine
=
new
TextSearchEngine
(
pattern
,
query
,
provider
,
this
.
_extfs
);
return
engine
.
search
().
then
(
null
,
null
,
progress
=>
{
this
.
_proxy
.
$handleTextMatch
(
handle
,
session
,
progress
);
});
return
engine
.
search
(
progress
=>
this
.
_proxy
.
$handleTextMatch
(
handle
,
session
,
progress
));
}
}
...
...
@@ -380,11 +372,11 @@ class TextSearchEngine {
this
.
activeCancellationTokens
=
new
Set
();
}
public
search
(
):
PPromise
<
{
limitHit
:
boolean
},
IFileMatch
[]
>
{
public
search
(
onProgress
:
(
matches
:
IFileMatch
[])
=>
void
):
TPromise
<
{
limitHit
:
boolean
}
>
{
const
folderQueries
=
this
.
config
.
folderQueries
;
return
new
PPromise
<
{
limitHit
:
boolean
},
IFileMatch
[]
>
((
resolve
,
reject
,
_onResul
t
)
=>
{
this
.
collector
=
new
TextSearchResultsCollector
(
_onResult
);
return
new
TPromise
<
{
limitHit
:
boolean
}
>
((
resolve
,
rejec
t
)
=>
{
this
.
collector
=
new
TextSearchResultsCollector
(
onProgress
);
const
onResult
=
(
match
:
vscode
.
TextSearchResult
,
folderIdx
:
number
)
=>
{
if
(
this
.
isCanceled
)
{
...
...
@@ -403,8 +395,8 @@ class TextSearchEngine {
};
// For each root folder
P
Promise
.
join
(
folderQueries
.
map
((
fq
,
i
)
=>
{
return
this
.
searchInFolder
(
fq
).
then
(
null
,
null
,
r
=>
onResult
(
r
,
i
));
T
Promise
.
join
(
folderQueries
.
map
((
fq
,
i
)
=>
{
return
this
.
searchInFolder
(
fq
,
r
=>
onResult
(
r
,
i
));
})).
then
(()
=>
{
this
.
collector
.
flush
();
resolve
({
limitHit
:
this
.
isLimitHit
});
...
...
@@ -418,9 +410,9 @@ class TextSearchEngine {
});
}
private
searchInFolder
(
folderQuery
:
IFolderQuery
<
URI
>
):
PPromise
<
void
,
vscode
.
TextSearchResult
>
{
private
searchInFolder
(
folderQuery
:
IFolderQuery
<
URI
>
,
onResult
:
(
result
:
vscode
.
TextSearchResult
)
=>
void
):
TPromise
<
void
>
{
let
cancellation
=
new
CancellationTokenSource
();
return
new
PPromise
((
resolve
,
reject
,
onResul
t
)
=>
{
return
new
TPromise
((
resolve
,
rejec
t
)
=>
{
const
queryTester
=
new
QueryGlobTester
(
this
.
config
,
folderQuery
);
const
testingPs
=
[];
...
...
@@ -532,10 +524,10 @@ class FileSearchEngine {
this
.
activeCancellationTokens
=
new
Set
();
}
public
search
(
):
PPromise
<
IInternalSearchComplete
,
IInternalFileMatch
>
{
public
search
(
_onResult
:
(
match
:
IInternalFileMatch
)
=>
void
):
TPromise
<
IInternalSearchComplete
>
{
const
folderQueries
=
this
.
config
.
folderQueries
;
return
new
PPromise
((
resolve
,
reject
,
_onResul
t
)
=>
{
return
new
TPromise
((
resolve
,
rejec
t
)
=>
{
const
onResult
=
(
match
:
IInternalFileMatch
)
=>
{
this
.
resultCount
++
;
_onResult
(
match
);
...
...
@@ -562,8 +554,8 @@ class FileSearchEngine {
}
// For each root folder
P
Promise
.
join
(
folderQueries
.
map
(
fq
=>
{
return
this
.
searchInFolder
(
fq
).
then
(
null
,
null
,
onResult
);
T
Promise
.
join
(
folderQueries
.
map
(
fq
=>
{
return
this
.
searchInFolder
(
fq
,
onResult
);
})).
then
(
cacheKeys
=>
{
resolve
({
limitHit
:
this
.
isLimitHit
,
cacheKeys
});
},
(
errs
:
Error
[])
=>
{
...
...
@@ -576,9 +568,9 @@ class FileSearchEngine {
});
}
private
searchInFolder
(
fq
:
IFolderQuery
<
URI
>
):
PPromise
<
string
,
IInternalFileMatch
>
{
private
searchInFolder
(
fq
:
IFolderQuery
<
URI
>
,
onResult
:
(
match
:
IInternalFileMatch
)
=>
void
):
TPromise
<
string
>
{
let
cancellation
=
new
CancellationTokenSource
();
return
new
PPromise
((
resolve
,
reject
,
onResul
t
)
=>
{
return
new
TPromise
((
resolve
,
rejec
t
)
=>
{
const
options
=
this
.
getSearchOptionsForFolder
(
fq
);
const
tree
=
this
.
initDirectoryTree
();
...
...
@@ -748,12 +740,16 @@ class FileSearchManager {
private
readonly
expandedCacheKeys
=
new
Map
<
string
,
string
[]
>
();
fileSearch
(
config
:
ISearchQuery
,
provider
:
vscode
.
SearchProvider
):
PPromise
<
ISearchCompleteStats
,
IFileMatch
[]
>
{
let
searchP
:
P
Promise
;
return
new
PPromise
<
ISearchCompleteStats
,
IFileMatch
[]
>
((
c
,
e
,
p
)
=>
{
fileSearch
(
config
:
ISearchQuery
,
provider
:
vscode
.
SearchProvider
,
onResult
:
(
matches
:
IFileMatch
[])
=>
void
):
TPromise
<
ISearchCompleteStats
>
{
let
searchP
:
T
Promise
;
return
new
TPromise
<
ISearchCompleteStats
>
((
c
,
e
)
=>
{
const
engine
=
new
FileSearchEngine
(
config
,
provider
);
searchP
=
this
.
doSearch
(
engine
,
FileSearchManager
.
BATCH_SIZE
).
then
(
const
onInternalResult
=
(
progress
:
IInternalFileMatch
[])
=>
{
onResult
(
progress
.
map
(
m
=>
this
.
rawMatchToSearchItem
(
m
)));
};
searchP
=
this
.
doSearch
(
engine
,
FileSearchManager
.
BATCH_SIZE
,
onInternalResult
).
then
(
result
=>
{
if
(
config
.
cacheKey
)
{
this
.
expandedCacheKeys
.
set
(
config
.
cacheKey
,
result
.
cacheKeys
);
...
...
@@ -763,10 +759,7 @@ class FileSearchManager {
limitHit
:
result
.
limitHit
});
},
e
,
progress
=>
{
p
(
progress
.
map
(
m
=>
this
.
rawMatchToSearchItem
(
m
)));
});
e
);
},
()
=>
{
if
(
searchP
)
{
searchP
.
cancel
();
...
...
@@ -789,29 +782,31 @@ class FileSearchManager {
};
}
private
doSearch
(
engine
:
FileSearchEngine
,
batchSize
:
number
):
PPromise
<
IInternalSearchComplete
,
IInternalFileMatch
[]
>
{
return
new
PPromise
((
c
,
e
,
p
)
=>
{
private
doSearch
(
engine
:
FileSearchEngine
,
batchSize
:
number
,
onResultBatch
:
(
matches
:
IInternalFileMatch
[])
=>
void
):
TPromise
<
IInternalSearchComplete
>
{
return
new
TPromise
((
c
,
e
)
=>
{
const
_onResult
=
match
=>
{
if
(
match
)
{
batch
.
push
(
match
);
if
(
batchSize
>
0
&&
batch
.
length
>=
batchSize
)
{
onResultBatch
(
batch
);
batch
=
[];
}
}
};
let
batch
:
IInternalFileMatch
[]
=
[];
engine
.
search
().
then
(
result
=>
{
engine
.
search
(
_onResult
).
then
(
result
=>
{
if
(
batch
.
length
)
{
p
(
batch
);
onResultBatch
(
batch
);
}
c
(
result
);
},
error
=>
{
if
(
batch
.
length
)
{
p
(
batch
);
onResultBatch
(
batch
);
}
e
(
error
);
},
match
=>
{
if
(
match
)
{
batch
.
push
(
match
);
if
(
batchSize
>
0
&&
batch
.
length
>=
batchSize
)
{
p
(
batch
);
batch
=
[];
}
}
});
},
()
=>
{
engine
.
cancel
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录