Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1e83b5b8
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,发现更多精彩内容 >>
提交
1e83b5b8
编写于
8月 31, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove less dependency on static methods.
上级
155ce00d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
39 addition
and
22 deletion
+39
-22
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
...es/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
+38
-21
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
...le/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
+1
-1
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
浏览文件 @
1e83b5b8
...
...
@@ -70,12 +70,31 @@ internal partial class SymbolTreeInfo
private
SymbolTreeInfo
(
VersionStamp
version
,
ImmutableArray
<
Node
>
sortedNodes
,
OrderPreservingMultiDictionary
<
int
,
int
>
inheritanceMap
,
Task
<
SpellChecker
>
spellCheckerTask
,
OrderPreservingMultiDictionary
<
string
,
string
>
inheritanceMap
)
:
this
(
version
,
sortedNodes
,
spellCheckerTask
)
{
var
indexBasedInheritanceMap
=
CreateIndexBasedInheritanceMap
(
inheritanceMap
);
_inheritanceMap
=
indexBasedInheritanceMap
;
}
private
SymbolTreeInfo
(
VersionStamp
version
,
ImmutableArray
<
Node
>
sortedNodes
,
Task
<
SpellChecker
>
spellCheckerTask
,
OrderPreservingMultiDictionary
<
int
,
int
>
inheritanceMap
)
:
this
(
version
,
sortedNodes
,
spellCheckerTask
)
{
_inheritanceMap
=
inheritanceMap
;
}
private
SymbolTreeInfo
(
VersionStamp
version
,
ImmutableArray
<
Node
>
sortedNodes
,
Task
<
SpellChecker
>
spellCheckerTask
)
{
_version
=
version
;
_nodes
=
sortedNodes
;
_inheritanceMap
=
inheritanceMap
;
_spellCheckerTask
=
spellCheckerTask
;
}
...
...
@@ -151,7 +170,7 @@ private Task<IEnumerable<ISymbol>> FindAsyncWorker(SearchQuery query, AsyncLazy<
var
result
=
new
List
<
ISymbol
>();
IAssemblySymbol
assemblySymbol
=
null
;
foreach
(
var
node
in
FindNodeIndices
(
_nodes
,
name
,
comparer
))
foreach
(
var
node
in
FindNodeIndices
(
name
,
comparer
))
{
cancellationToken
.
ThrowIfCancellationRequested
();
assemblySymbol
=
assemblySymbol
??
await
lazyAssembly
.
GetValueAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -192,35 +211,35 @@ private static StringComparer GetComparer(bool ignoreCase)
/// <summary>
/// Gets all the node indices with matching names per the <paramref name="comparer" />.
/// </summary>
private
static
IEnumerable
<
int
>
FindNodeIndices
(
ImmutableArray
<
Node
>
nodes
,
string
name
,
StringComparer
comparer
)
private
IEnumerable
<
int
>
FindNodeIndices
(
string
name
,
StringComparer
comparer
)
{
// find any node that matches case-insensitively
var
startingPosition
=
BinarySearch
(
n
odes
,
n
ame
);
var
startingPosition
=
BinarySearch
(
name
);
if
(
startingPosition
!=
-
1
)
{
// yield if this matches by the actual given comparer
if
(
comparer
.
Equals
(
name
,
nodes
[
startingPosition
].
Name
))
if
(
comparer
.
Equals
(
name
,
_
nodes
[
startingPosition
].
Name
))
{
yield
return
startingPosition
;
}
int
position
=
startingPosition
;
while
(
position
>
0
&&
s_caseInsensitiveComparer
.
Equals
(
nodes
[
position
-
1
].
Name
,
name
))
while
(
position
>
0
&&
s_caseInsensitiveComparer
.
Equals
(
_
nodes
[
position
-
1
].
Name
,
name
))
{
position
--;
if
(
comparer
.
Equals
(
nodes
[
position
].
Name
,
name
))
if
(
comparer
.
Equals
(
_
nodes
[
position
].
Name
,
name
))
{
yield
return
position
;
}
}
position
=
startingPosition
;
while
(
position
+
1
<
nodes
.
Length
&&
s_caseInsensitiveComparer
.
Equals
(
nodes
[
position
+
1
].
Name
,
name
))
while
(
position
+
1
<
_nodes
.
Length
&&
s_caseInsensitiveComparer
.
Equals
(
_
nodes
[
position
+
1
].
Name
,
name
))
{
position
++;
if
(
comparer
.
Equals
(
nodes
[
position
].
Name
,
name
))
if
(
comparer
.
Equals
(
_
nodes
[
position
].
Name
,
name
))
{
yield
return
position
;
}
...
...
@@ -231,16 +250,16 @@ private static StringComparer GetComparer(bool ignoreCase)
/// <summary>
/// Searches for a name in the ordered list that matches per the <see cref="s_caseInsensitiveComparer" />.
/// </summary>
private
static
int
BinarySearch
(
ImmutableArray
<
Node
>
nodes
,
string
name
)
private
int
BinarySearch
(
string
name
)
{
int
max
=
nodes
.
Length
-
1
;
int
max
=
_
nodes
.
Length
-
1
;
int
min
=
0
;
while
(
max
>=
min
)
{
int
mid
=
min
+
((
max
-
min
)
>>
1
);
var
comparison
=
s_caseInsensitiveComparer
.
Compare
(
nodes
[
mid
].
Name
,
name
);
var
comparison
=
s_caseInsensitiveComparer
.
Compare
(
_
nodes
[
mid
].
Name
,
name
);
if
(
comparison
<
0
)
{
min
=
mid
+
1
;
...
...
@@ -437,12 +456,10 @@ internal void AssertEquivalentTo(SymbolTreeInfo other)
var
sortedNodes
=
SortNodes
(
unsortedNodes
);
var
createSpellCheckerTask
=
GetSpellCheckerTask
(
solution
,
version
,
filePath
,
sortedNodes
);
var
indexBasedInheritanceMap
=
CreateIndexBasedInheritanceMap
(
sortedNodes
,
inheritanceMap
);
return
new
SymbolTreeInfo
(
version
,
sortedNodes
,
indexBasedInheritanceMap
,
createSpellCheckerTask
);
return
new
SymbolTreeInfo
(
version
,
sortedNodes
,
createSpellCheckerTask
,
inheritanceMap
);
}
private
static
OrderPreservingMultiDictionary
<
int
,
int
>
CreateIndexBasedInheritanceMap
(
ImmutableArray
<
Node
>
sortedNodes
,
private
OrderPreservingMultiDictionary
<
int
,
int
>
CreateIndexBasedInheritanceMap
(
OrderPreservingMultiDictionary
<
string
,
string
>
inheritanceMap
)
{
// All names in metadata will be case sensitive.
...
...
@@ -452,12 +469,12 @@ internal void AssertEquivalentTo(SymbolTreeInfo other)
foreach
(
var
kvp
in
inheritanceMap
)
{
var
baseName
=
kvp
.
Key
;
var
baseNameIndex
=
BinarySearch
(
sortedNodes
,
baseName
);
var
baseNameIndex
=
BinarySearch
(
baseName
);
Debug
.
Assert
(
baseNameIndex
>=
0
);
foreach
(
var
derivedName
in
kvp
.
Value
)
{
foreach
(
var
derivedNameIndex
in
FindNodeIndices
(
sortedNodes
,
derivedName
,
comparer
))
foreach
(
var
derivedNameIndex
in
FindNodeIndices
(
derivedName
,
comparer
))
{
result
.
Add
(
baseNameIndex
,
derivedNameIndex
);
}
...
...
@@ -470,7 +487,7 @@ internal void AssertEquivalentTo(SymbolTreeInfo other)
public
IEnumerable
<
INamedTypeSymbol
>
GetDerivedMetadataTypes
(
string
baseTypeName
,
Compilation
compilation
,
CancellationToken
cancellationToken
)
{
var
baseTypeNameIndex
=
BinarySearch
(
_nodes
,
baseTypeName
);
var
baseTypeNameIndex
=
BinarySearch
(
baseTypeName
);
var
derivedTypeIndices
=
_inheritanceMap
[
baseTypeNameIndex
];
return
from
derivedTypeIndex
in
derivedTypeIndices
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
浏览文件 @
1e83b5b8
...
...
@@ -240,7 +240,7 @@ internal static SymbolTreeInfo ReadSymbolTreeInfo_ForTestingPurposesOnly(ObjectR
}
var
spellCheckerTask
=
createSpellCheckerTask
(
version
,
nodes
);
return
new
SymbolTreeInfo
(
version
,
nodes
,
inheritanceMap
,
spellCheckerTask
);
return
new
SymbolTreeInfo
(
version
,
nodes
,
spellCheckerTask
,
inheritanceMap
);
}
}
catch
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录