Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
81c11b82
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,发现更多精彩内容 >>
提交
81c11b82
编写于
5月 15, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EH search - file search sibling clauses and test
上级
32783ae2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
121 addition
and
9 deletion
+121
-9
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+15
-5
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
...workbench/test/electron-browser/api/extHostSearch.test.ts
+106
-4
未找到文件。
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
81c11b82
...
...
@@ -349,12 +349,12 @@ class FileSearchEngine {
config
.
folderQueries
.
forEach
(
folderQuery
=>
{
const
folderExcludeExpression
:
glob
.
IExpression
=
{
...(
folderQuery
.
excludePattern
||
{}),
...(
this
.
config
.
excludePattern
||
{})
...(
this
.
config
.
excludePattern
||
{}),
...(
folderQuery
.
excludePattern
||
{})
};
// Add excludes for other root folders
const
folderString
=
URI
.
from
(
folderQuery
.
folder
).
toString
()
;
const
folderString
=
URI
.
from
(
folderQuery
.
folder
).
fsPath
;
config
.
folderQueries
.
map
(
rootFolderQuery
=>
rootFolderQuery
.
folder
)
.
filter
(
rootFolder
=>
rootFolder
!==
folderQuery
.
folder
)
...
...
@@ -469,8 +469,8 @@ class FileSearchEngine {
this
.
addDirectoryEntries
(
tree
,
folderStr
,
relativePath
,
onResult
);
};
// TODO@roblou
const
noSiblingsClauses
=
true
;
const
allFolderExcludes
=
this
.
folderExcludePatterns
.
get
(
fq
.
folder
.
fsPath
);
const
noSiblingsClauses
=
!
allFolderExcludes
||
!
allFolderExcludes
.
hasSiblingClauses
()
;
new
TPromise
(
resolve
=>
process
.
nextTick
(
resolve
))
.
then
(()
=>
{
this
.
activeCancellationTokens
.
add
(
cancellation
);
...
...
@@ -691,6 +691,8 @@ class AbsoluteAndRelativeParsedExpression {
private
absoluteParsedExpr
:
glob
.
ParsedExpression
;
private
relativeParsedExpr
:
glob
.
ParsedExpression
;
private
_hasSiblingClauses
=
false
;
constructor
(
public
expression
:
glob
.
IExpression
,
private
root
:
string
)
{
this
.
init
(
expression
);
}
...
...
@@ -711,12 +713,20 @@ class AbsoluteAndRelativeParsedExpression {
relativeGlobExpr
=
relativeGlobExpr
||
glob
.
getEmptyExpression
();
relativeGlobExpr
[
key
]
=
expr
[
key
];
}
if
(
typeof
expr
[
key
]
!==
'
boolean
'
)
{
this
.
_hasSiblingClauses
=
true
;
}
});
this
.
absoluteParsedExpr
=
absoluteGlobExpr
&&
glob
.
parse
(
absoluteGlobExpr
,
{
trimForExclusions
:
true
});
this
.
relativeParsedExpr
=
relativeGlobExpr
&&
glob
.
parse
(
relativeGlobExpr
,
{
trimForExclusions
:
true
});
}
public
hasSiblingClauses
():
boolean
{
return
this
.
_hasSiblingClauses
;
}
public
test
(
_path
:
string
,
basename
?:
string
,
siblingsFn
?:
()
=>
string
[]
|
TPromise
<
string
[]
>
):
string
|
TPromise
<
string
>
{
return
(
this
.
relativeParsedExpr
&&
this
.
relativeParsedExpr
(
_path
,
basename
,
siblingsFn
))
||
(
this
.
absoluteParsedExpr
&&
this
.
absoluteParsedExpr
(
path
.
join
(
this
.
root
,
_path
),
basename
,
siblingsFn
));
...
...
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
浏览文件 @
81c11b82
...
...
@@ -103,13 +103,15 @@ suite('ExtHostSearch', () => {
function
makeFileResult
(
root
:
URI
,
relativePath
:
string
):
URI
{
return
URI
.
file
(
path
.
join
(
root
.
toString
()
,
relativePath
));
path
.
join
(
root
.
fsPath
,
relativePath
));
}
function
compareURIs
(
a
:
URI
[],
b
:
URI
[])
{
function
compareURIs
(
actual
:
URI
[],
expected
:
URI
[])
{
const
sortAndStringify
=
(
arr
:
URI
[])
=>
arr
.
sort
().
map
(
u
=>
u
.
toString
());
assert
.
deepEqual
(
a
.
map
(
u
=>
u
.
toString
()
),
b
.
map
(
u
=>
u
.
toString
()
));
sortAndStringify
(
actual
),
sortAndStringify
(
expected
));
}
test
(
'
no results
'
,
async
()
=>
{
...
...
@@ -315,6 +317,106 @@ suite('ExtHostSearch', () => {
await
runFileSearch
(
query
);
});
test
(
'
basic sibling exclude clause
'
,
async
()
=>
{
const
reportedResults
=
[
makeFileResult
(
rootFolderA
,
'
file1.ts
'
),
makeFileResult
(
rootFolderA
,
'
file1.js
'
),
];
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
}
});
const
query
:
ISearchQuery
=
{
type
:
QueryType
.
File
,
filePattern
:
''
,
excludePattern
:
{
'
*.js
'
:
{
when
:
'
$(basename).ts
'
}
},
folderQueries
:
[
{
folder
:
rootFolderA
}
]
};
const
results
=
await
runFileSearch
(
query
);
compareURIs
(
results
,
[
makeFileResult
(
rootFolderA
,
'
file1.ts
'
)
]);
});
test
(
'
multiroot sibling exclude clause
'
,
async
()
=>
{
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
let
reportedResults
;
if
(
options
.
folder
.
fsPath
===
rootFolderA
.
fsPath
)
{
reportedResults
=
[
makeFileResult
(
rootFolderA
,
'
folder/fileA.scss
'
),
makeFileResult
(
rootFolderA
,
'
folder/fileA.css
'
),
makeFileResult
(
rootFolderA
,
'
folder/file2.css
'
)
];
}
else
{
reportedResults
=
[
makeFileResult
(
rootFolderB
,
'
fileB.ts
'
),
makeFileResult
(
rootFolderB
,
'
fileB.js
'
),
makeFileResult
(
rootFolderB
,
'
file3.js
'
)
];
}
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
}
});
const
query
:
ISearchQuery
=
{
type
:
QueryType
.
File
,
filePattern
:
''
,
excludePattern
:
{
'
*.js
'
:
{
when
:
'
$(basename).ts
'
},
'
*.css
'
:
true
},
folderQueries
:
[
{
folder
:
rootFolderA
,
excludePattern
:
{
'
folder/*.css
'
:
{
when
:
'
$(basename).scss
'
}
}
},
{
folder
:
rootFolderB
,
excludePattern
:
{
'
*.js
'
:
false
}
}
]
};
const
results
=
await
runFileSearch
(
query
);
compareURIs
(
results
,
[
makeFileResult
(
rootFolderA
,
'
folder/fileA.scss
'
),
makeFileResult
(
rootFolderA
,
'
folder/file2.css
'
),
makeFileResult
(
rootFolderB
,
'
fileB.ts
'
),
makeFileResult
(
rootFolderB
,
'
fileB.js
'
),
makeFileResult
(
rootFolderB
,
'
file3.js
'
),
]);
});
// Mock fs?
// test('Returns result for absolute path', async () => {
// const queriedFile = makeFileResult(rootFolderA, 'file2.ts');
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录