Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
027d34a3
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
027d34a3
编写于
8月 31, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unreachable code.
上级
5b39d9b5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
25 deletion
+26
-25
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs
...es/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs
+14
-0
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
...es/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
+12
-25
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs
浏览文件 @
027d34a3
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -85,6 +86,7 @@ private SearchQuery(Func<string, bool> predicate)
throw
new
ArgumentNullException
(
nameof
(
predicate
));
}
Kind
=
SearchKind
.
Custom
;
_predicate
=
predicate
;
}
...
...
@@ -152,6 +154,10 @@ public static partial class SymbolFinder
internal
static
Task
<
IEnumerable
<
ISymbol
>>
FindDeclarationsAsync
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
)
{
// All entrypoints to this function are Find functions that are only searching
// for specific strings (i.e. they never do a custom search).
Debug
.
Assert
(
query
.
Kind
!=
SearchKind
.
Custom
);
if
(
project
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
project
));
...
...
@@ -171,6 +177,10 @@ public static partial class SymbolFinder
private
static
async
Task
<
IEnumerable
<
ISymbol
>>
FindDeclarationsAsyncImpl
(
Project
project
,
SearchQuery
query
,
SymbolFilter
criteria
,
CancellationToken
cancellationToken
)
{
// All entrypoints to this function are Find functions that are only searching
// for specific strings (i.e. they never do a custom search).
Debug
.
Assert
(
query
.
Kind
!=
SearchKind
.
Custom
);
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
list
=
new
List
<
ISymbol
>();
...
...
@@ -267,6 +277,10 @@ private static IEnumerable<ISymbol> TranslateNamespaces(List<ISymbol> symbols, C
Solution
solution
,
IAssemblySymbol
assembly
,
PortableExecutableReference
referenceOpt
,
SearchQuery
query
,
SymbolFilter
filter
,
List
<
ISymbol
>
list
,
CancellationToken
cancellationToken
)
{
// All entrypoints to this function are Find functions that are only searching
// for specific strings (i.e. they never do a custom search).
Debug
.
Assert
(
query
.
Kind
!=
SearchKind
.
Custom
);
using
(
Logger
.
LogBlock
(
FunctionId
.
SymbolFinder_Assembly_AddDeclarationsAsync
,
cancellationToken
))
{
if
(
referenceOpt
!=
null
)
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
浏览文件 @
027d34a3
...
...
@@ -82,12 +82,20 @@ internal partial class SymbolTreeInfo
public
Task
<
IEnumerable
<
ISymbol
>>
FindAsync
(
SearchQuery
query
,
IAssemblySymbol
assembly
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
)
{
// All entrypoints to this function are Find functions that are only searching
// for specific strings (i.e. they never do a custom search).
Debug
.
Assert
(
query
.
Kind
!=
SearchKind
.
Custom
);
return
this
.
FindAsync
(
query
,
new
AsyncLazy
<
IAssemblySymbol
>(
assembly
),
filter
,
cancellationToken
);
}
public
async
Task
<
IEnumerable
<
ISymbol
>>
FindAsync
(
SearchQuery
query
,
AsyncLazy
<
IAssemblySymbol
>
lazyAssembly
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
)
{
// All entrypoints to this function are Find functions that are only searching
// for specific strings (i.e. they never do a custom search).
Debug
.
Assert
(
query
.
Kind
!=
SearchKind
.
Custom
);
return
SymbolFinder
.
FilterByCriteria
(
await
FindAsyncWorker
(
query
,
lazyAssembly
,
cancellationToken
).
ConfigureAwait
(
false
),
filter
);
...
...
@@ -95,6 +103,10 @@ internal partial class SymbolTreeInfo
private
Task
<
IEnumerable
<
ISymbol
>>
FindAsyncWorker
(
SearchQuery
query
,
AsyncLazy
<
IAssemblySymbol
>
lazyAssembly
,
CancellationToken
cancellationToken
)
{
// All entrypoints to this function are Find functions that are only searching
// for specific strings (i.e. they never do a custom search).
Debug
.
Assert
(
query
.
Kind
!=
SearchKind
.
Custom
);
// If the query has a specific string provided, then call into the SymbolTreeInfo
// helpers optimized for lookup based on an exact name.
switch
(
query
.
Kind
)
...
...
@@ -105,9 +117,6 @@ private Task<IEnumerable<ISymbol>> FindAsyncWorker(SearchQuery query, AsyncLazy<
return
this
.
FindAsync
(
lazyAssembly
,
query
.
Name
,
ignoreCase
:
true
,
cancellationToken
:
cancellationToken
);
case
SearchKind
.
Fuzzy
:
return
this
.
FuzzyFindAsync
(
lazyAssembly
,
query
.
Name
,
cancellationToken
);
case
SearchKind
.
Custom
:
// Otherwise, we'll have to do a slow linear search over all possible symbols.
return
this
.
FindAsync
(
lazyAssembly
,
query
.
GetPredicate
(),
cancellationToken
);
}
throw
new
InvalidOperationException
();
...
...
@@ -162,28 +171,6 @@ private Task<IEnumerable<ISymbol>> FindAsyncWorker(SearchQuery query, AsyncLazy<
return
result
;
}
/// <summary>
/// Slow, linear scan of all the symbols in this assembly to look for matches.
/// </summary>
private
async
Task
<
IEnumerable
<
ISymbol
>>
FindAsync
(
AsyncLazy
<
IAssemblySymbol
>
lazyAssembly
,
Func
<
string
,
bool
>
predicate
,
CancellationToken
cancellationToken
)
{
var
result
=
new
List
<
ISymbol
>();
IAssemblySymbol
assembly
=
null
;
for
(
int
i
=
0
,
n
=
_nodes
.
Length
;
i
<
n
;
i
++)
{
cancellationToken
.
ThrowIfCancellationRequested
();
var
node
=
_nodes
[
i
];
if
(
predicate
(
node
.
Name
))
{
assembly
=
assembly
??
await
lazyAssembly
.
GetValueAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
result
.
AddRange
(
Bind
(
i
,
assembly
.
GlobalNamespace
,
cancellationToken
));
}
}
return
result
;
}
private
static
StringComparer
GetComparer
(
bool
ignoreCase
)
{
return
ignoreCase
?
CaseInsensitiveComparison
.
Comparer
:
StringComparer
.
Ordinal
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录