Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6ba5f8f9
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,发现更多精彩内容 >>
提交
6ba5f8f9
编写于
11月 07, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Final search TPromise removal #53526
上级
249b59ed
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
22 deletion
+19
-22
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
+13
-14
src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts
...h/services/search/test/node/textSearch.integrationTest.ts
+0
-1
src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts
.../test/electron-browser/textsearch.perf.integrationTest.ts
+6
-7
未找到文件。
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
浏览文件 @
6ba5f8f9
...
...
@@ -13,7 +13,6 @@ import * as resources from 'vs/base/common/resources';
import
{
StopWatch
}
from
'
vs/base/common/stopwatch
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
compareItemsByScore
,
IItemAccessor
,
prepareQuery
,
ScorerCache
}
from
'
vs/base/parts/quickopen/common/quickOpenScorer
'
;
import
{
ICachedSearchStats
,
IFileIndexProviderStats
,
IFileMatch
,
IFileQuery
,
IFileSearchStats
,
IFolderQuery
,
ISearchCompleteStats
}
from
'
vs/platform/search/common/search
'
;
import
{
IDirectoryEntry
,
IDirectoryTree
,
IInternalFileMatch
}
from
'
vs/workbench/services/search/node/fileSearchManager
'
;
...
...
@@ -65,11 +64,11 @@ export class FileIndexSearchEngine {
this
.
activeCancellationTokens
=
new
Set
();
}
public
search
(
_onResult
:
(
match
:
IInternalFileMatch
)
=>
void
):
T
Promise
<
{
isLimitHit
:
boolean
,
stats
:
IFileIndexProviderStats
}
>
{
public
search
(
_onResult
:
(
match
:
IInternalFileMatch
)
=>
void
):
Promise
<
{
isLimitHit
:
boolean
,
stats
:
IFileIndexProviderStats
}
>
{
// Searches a single folder
const
folderQuery
=
this
.
config
.
folderQueries
[
0
];
return
new
T
Promise
<
{
isLimitHit
:
boolean
,
stats
:
IFileIndexProviderStats
}
>
((
resolve
,
reject
)
=>
{
return
new
Promise
<
{
isLimitHit
:
boolean
,
stats
:
IFileIndexProviderStats
}
>
((
resolve
,
reject
)
=>
{
const
onResult
=
(
match
:
IInternalFileMatch
)
=>
{
this
.
resultCount
++
;
_onResult
(
match
);
...
...
@@ -116,9 +115,9 @@ export class FileIndexSearchEngine {
});
}
private
searchInFolder
(
fq
:
IFolderQuery
<
URI
>
,
onResult
:
(
match
:
IInternalFileMatch
)
=>
void
):
T
Promise
<
IFileIndexProviderStats
>
{
private
searchInFolder
(
fq
:
IFolderQuery
<
URI
>
,
onResult
:
(
match
:
IInternalFileMatch
)
=>
void
):
Promise
<
IFileIndexProviderStats
>
{
let
cancellation
=
new
CancellationTokenSource
();
return
new
T
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
options
=
this
.
getSearchOptionsForFolder
(
fq
);
const
tree
=
this
.
initDirectoryTree
();
...
...
@@ -146,7 +145,7 @@ export class FileIndexSearchEngine {
let
providerSW
:
StopWatch
;
let
providerTime
:
number
;
let
fileWalkTime
:
number
;
new
T
Promise
(
resolve
=>
process
.
nextTick
(
resolve
))
new
Promise
(
resolve
=>
process
.
nextTick
(
resolve
))
.
then
(()
=>
{
this
.
activeCancellationTokens
.
add
(
cancellation
);
providerSW
=
StopWatch
.
create
();
...
...
@@ -304,7 +303,7 @@ export class FileIndexSearchManager {
private
readonly
folderCacheKeys
=
new
Map
<
string
,
Set
<
string
>>
();
public
fileSearch
(
config
:
IFileQuery
,
provider
:
vscode
.
FileIndexProvider
,
onBatch
:
(
matches
:
IFileMatch
[])
=>
void
,
token
:
CancellationToken
):
T
Promise
<
ISearchCompleteStats
>
{
public
fileSearch
(
config
:
IFileQuery
,
provider
:
vscode
.
FileIndexProvider
,
onBatch
:
(
matches
:
IFileMatch
[])
=>
void
,
token
:
CancellationToken
):
Promise
<
ISearchCompleteStats
>
{
if
(
config
.
sortByScore
)
{
let
sortedSearch
=
this
.
trySortedSearchFromCache
(
config
,
token
);
if
(
!
sortedSearch
)
{
...
...
@@ -359,7 +358,7 @@ export class FileIndexSearchManager {
};
}
private
doSortedSearch
(
engine
:
FileIndexSearchEngine
,
config
:
IFileQuery
,
token
:
CancellationToken
):
T
Promise
<
IInternalSearchComplete
>
{
private
doSortedSearch
(
engine
:
FileIndexSearchEngine
,
config
:
IFileQuery
,
token
:
CancellationToken
):
Promise
<
IInternalSearchComplete
>
{
let
allResultsPromise
=
createCancelablePromise
<
IInternalSearchComplete
<
IFileIndexProviderStats
>>
(
token
=>
{
return
this
.
doSearch
(
engine
,
token
);
});
...
...
@@ -413,7 +412,7 @@ export class FileIndexSearchManager {
return
this
.
caches
[
cacheKey
]
=
new
Cache
();
}
private
trySortedSearchFromCache
(
config
:
IFileQuery
,
token
:
CancellationToken
):
T
Promise
<
IInternalSearchComplete
>
{
private
trySortedSearchFromCache
(
config
:
IFileQuery
,
token
:
CancellationToken
):
Promise
<
IInternalSearchComplete
>
{
const
folderCacheKey
=
this
.
getFolderCacheKey
(
config
);
const
cache
=
folderCacheKey
&&
this
.
caches
[
folderCacheKey
];
if
(
!
cache
)
{
...
...
@@ -447,7 +446,7 @@ export class FileIndexSearchManager {
return
undefined
;
}
private
sortResults
(
config
:
IFileQuery
,
results
:
IInternalFileMatch
[],
scorerCache
:
ScorerCache
,
token
:
CancellationToken
):
T
Promise
<
IInternalFileMatch
[]
>
{
private
sortResults
(
config
:
IFileQuery
,
results
:
IInternalFileMatch
[],
scorerCache
:
ScorerCache
,
token
:
CancellationToken
):
Promise
<
IInternalFileMatch
[]
>
{
// we use the same compare function that is used later when showing the results using fuzzy scoring
// this is very important because we are also limiting the number of results by config.maxResults
// and as such we want the top items to be included in this result set if the number of items
...
...
@@ -469,7 +468,7 @@ export class FileIndexSearchManager {
}
}
private
getResultsFromCache
(
cache
:
Cache
,
searchValue
:
string
,
token
:
CancellationToken
):
T
Promise
<
IInternalSearchComplete
<
ICachedSearchStats
>>
{
private
getResultsFromCache
(
cache
:
Cache
,
searchValue
:
string
,
token
:
CancellationToken
):
Promise
<
IInternalSearchComplete
<
ICachedSearchStats
>>
{
const
cacheLookupSW
=
StopWatch
.
create
();
if
(
path
.
isAbsolute
(
searchValue
))
{
...
...
@@ -503,7 +502,7 @@ export class FileIndexSearchManager {
const
cacheLookupTime
=
cacheLookupSW
.
elapsed
();
const
cacheFilterSW
=
StopWatch
.
create
();
return
new
T
Promise
<
IInternalSearchComplete
<
ICachedSearchStats
>>
((
c
,
e
)
=>
{
return
new
Promise
<
IInternalSearchComplete
<
ICachedSearchStats
>>
((
c
,
e
)
=>
{
token
.
onCancellationRequested
(()
=>
e
(
canceled
()));
cacheRow
.
promise
.
then
(
complete
=>
{
...
...
@@ -539,7 +538,7 @@ export class FileIndexSearchManager {
});
}
private
doSearch
(
engine
:
FileIndexSearchEngine
,
token
:
CancellationToken
):
T
Promise
<
IInternalSearchComplete
<
IFileIndexProviderStats
>>
{
private
doSearch
(
engine
:
FileIndexSearchEngine
,
token
:
CancellationToken
):
Promise
<
IInternalSearchComplete
<
IFileIndexProviderStats
>>
{
token
.
onCancellationRequested
(()
=>
engine
.
cancel
());
const
results
:
IInternalFileMatch
[]
=
[];
const
onResult
=
match
=>
results
.
push
(
match
);
...
...
@@ -553,7 +552,7 @@ export class FileIndexSearchManager {
});
}
public
clearCache
(
cacheKey
:
string
):
T
Promise
<
void
>
{
public
clearCache
(
cacheKey
:
string
):
Promise
<
void
>
{
if
(
!
this
.
folderCacheKeys
.
has
(
cacheKey
))
{
return
Promise
.
resolve
(
undefined
);
}
...
...
src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts
浏览文件 @
6ba5f8f9
...
...
@@ -354,7 +354,6 @@ suite('Search-integration', function () {
};
return
doRipgrepSearchTest
(
config
,
4
).
then
(
results
=>
{
console
.
log
(
JSON
.
stringify
(
results
));
assert
.
equal
(
results
.
length
,
4
);
assert
.
equal
((
<
ITextSearchContext
>
results
[
0
].
results
[
0
]).
lineNumber
,
25
);
assert
.
equal
((
<
ITextSearchContext
>
results
[
0
].
results
[
0
]).
text
,
'
compiler.addUnit(prog,"input.ts");
'
);
...
...
src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts
浏览文件 @
6ba5f8f9
...
...
@@ -19,7 +19,6 @@ import { SearchService } from 'vs/workbench/services/search/node/searchService';
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
TestEnvironmentService
,
TestContextService
,
TestEditorService
,
TestEditorGroupsService
,
TestTextResourcePropertiesService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
...
...
@@ -78,7 +77,7 @@ suite.skip('TextSearch performance (integration)', () => {
};
const
searchModel
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
function
runSearch
():
T
Promise
<
any
>
{
function
runSearch
():
Promise
<
any
>
{
const
queryBuilder
:
QueryBuilder
=
instantiationService
.
createInstance
(
QueryBuilder
);
const
query
=
queryBuilder
.
text
({
pattern
:
'
static_library(
'
},
[
URI
.
file
(
testWorkspacePath
)],
queryOptions
);
...
...
@@ -107,7 +106,7 @@ suite.skip('TextSearch performance (integration)', () => {
let
resolve
;
let
error
;
return
new
T
Promise
((
_resolve
,
_error
)
=>
{
return
new
Promise
((
_resolve
,
_error
)
=>
{
resolve
=
_resolve
;
error
=
_error
;
...
...
@@ -155,15 +154,15 @@ class TestTelemetryService implements ITelemetryService {
return
this
.
emitter
.
event
;
}
public
publicLog
(
eventName
:
string
,
data
?:
any
):
T
Promise
<
void
>
{
public
publicLog
(
eventName
:
string
,
data
?:
any
):
Promise
<
void
>
{
const
event
=
{
name
:
eventName
,
data
:
data
};
this
.
events
.
push
(
event
);
this
.
emitter
.
fire
(
event
);
return
TPromise
.
wrap
<
void
>
(
null
);
return
Promise
.
resolve
(
);
}
public
getTelemetryInfo
():
T
Promise
<
ITelemetryInfo
>
{
return
TPromise
.
wrap
({
public
getTelemetryInfo
():
Promise
<
ITelemetryInfo
>
{
return
Promise
.
resolve
({
instanceId
:
'
someValue.instanceId
'
,
sessionId
:
'
someValue.sessionId
'
,
machineId
:
'
someValue.machineId
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录