Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b74f60d1
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,发现更多精彩内容 >>
提交
b74f60d1
编写于
7月 25, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix tests.
上级
0ca1ff7d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
18 deletion
+23
-18
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.vb
...ditorFeatures/Test2/FindReferences/FindReferencesTests.vb
+16
-12
src/Features/Core/Portable/FindReferences/DefinitionLocation.DocumentDefinitionLocation.cs
...ferences/DefinitionLocation.DocumentDefinitionLocation.cs
+7
-6
未找到文件。
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.vb
浏览文件 @
b74f60d1
...
...
@@ -6,6 +6,7 @@ Imports System.Threading.Tasks
Imports
Microsoft.CodeAnalysis
Imports
Microsoft.CodeAnalysis.Editor.Navigation
Imports
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports
Microsoft.CodeAnalysis.FindReferences
Imports
Microsoft.CodeAnalysis.FindSymbols
Imports
Microsoft.CodeAnalysis.Text
Imports
Roslyn.Utilities
...
...
@@ -50,7 +51,9 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
d
.
Name
,
d
.
AnnotatedSpans
(
DefinitionKey
).
ToList
())).
ToList
()
Dim
actualDefinitions
=
GetFileNamesAndSpans
(
context
.
Definitions
.
Where
(
AddressOf
context
.
ShouldShow
))
context
.
Definitions
.
Where
(
AddressOf
context
.
ShouldShow
).
OfType
(
Of
DefinitionLocation
.
DocumentDefinitionLocation
).
Select
(
Function
(
d
)
d
.
Location
))
Assert
.
Equal
(
expectedDefinitions
,
actualDefinitions
)
...
...
@@ -60,21 +63,22 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
Select
(
Function
(
d
)
New
FileNameAndSpans
(
d
.
Name
,
d
.
SelectedSpans
.
ToList
())).
ToList
()
Dim
actualReferences
=
GetFileNamesAndSpans
(
context
.
References
)
Dim
actualReferences
=
GetFileNamesAndSpans
(
context
.
References
.
Select
(
Function
(
r
)
r
.
Location
))
Assert
.
Equal
(
expectedReferences
,
actualReferences
)
Next
End
Using
End
Function
Private
Function
GetFileNamesAndSpans
(
items
As
IEnumerable
(
Of
INavigableItem
))
As
List
(
Of
FileNameAndSpans
)
Private
Function
GetFileNamesAndSpans
(
items
As
IEnumerable
(
Of
DocumentLocation
))
As
List
(
Of
FileNameAndSpans
)
Return
items
.
Where
(
Function
(
i
)
i
.
Document
IsNot
Nothing
).
GroupBy
(
Function
(
i
)
i
.
Document
).
OrderBy
(
Function
(
g
)
g
.
Key
.
Name
).
Select
(
Function
(
g
)
GetFileNameAndSpans
(
g
)).
ToList
()
End
Function
Private
Function
GetFileNameAndSpans
(
g
As
IGrouping
(
Of
Document
,
INavigableItem
))
As
FileNameAndSpans
Private
Function
GetFileNameAndSpans
(
g
As
IGrouping
(
Of
Document
,
DocumentLocation
))
As
FileNameAndSpans
Return
New
FileNameAndSpans
(
g
.
Key
.
Name
,
g
.
Select
(
Function
(
i
)
i
.
SourceSpan
).
OrderBy
(
Function
(
s
)
s
.
Start
).
...
...
@@ -112,16 +116,16 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
Private
ReadOnly
gate
As
Object
=
New
Object
()
Private
ReadOnly
definitionToShouldShowWithNoReferences
As
Dictionary
(
Of
INavigableItem
,
Boolean
)
=
New
Dictionary
(
Of
INavigable
Item
,
Boolean
)
Public
ReadOnly
definitionToReferences
As
MultiDictionary
(
Of
INavigableItem
,
INavigableItem
)
=
New
MultiDictionary
(
Of
INavigableItem
,
INavigabl
eItem
)
Private
ReadOnly
definitionToShouldShowWithNoReferences
As
Dictionary
(
Of
DefinitionItem
,
Boolean
)
=
New
Dictionary
(
Of
Definition
Item
,
Boolean
)
Public
ReadOnly
definitionToReferences
As
MultiDictionary
(
Of
DefinitionItem
,
SourceReferenceItem
)
=
New
MultiDictionary
(
Of
DefinitionItem
,
SourceReferenc
eItem
)
Public
ReadOnly
Property
Definitions
As
IEnumerable
(
Of
INavigable
Item
)
Public
ReadOnly
Property
Definitions
As
IEnumerable
(
Of
Definition
Item
)
Get
Return
definitionToShouldShowWithNoReferences
.
Keys
End
Get
End
Property
Public
Iterator
Function
References
()
As
IEnumerable
(
Of
INavigabl
eItem
)
Public
Iterator
Function
References
()
As
IEnumerable
(
Of
SourceReferenc
eItem
)
For
Each
kvp
In
definitionToReferences
For
Each
value
In
kvp
.
Value
Yield
value
...
...
@@ -130,7 +134,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
End
Function
Public
Function
ShouldShow
(
definition
As
INavigable
Item
)
As
Boolean
Public
Function
ShouldShow
(
definition
As
Definition
Item
)
As
Boolean
If
definitionToReferences
(
definition
).
Count
>
0
Then
Return
True
End
If
...
...
@@ -138,16 +142,16 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
Return
definitionToShouldShowWithNoReferences
(
definition
)
End
Function
Public
Overrides
Sub
OnDefinitionFound
(
definition
As
INavigable
Item
,
Public
Overrides
Sub
OnDefinitionFound
(
definition
As
Definition
Item
,
shouldDisplayWithNoReferences
As
Boolean
)
SyncLock
gate
Me
.
definitionToShouldShowWithNoReferences
(
definition
)
=
shouldDisplayWithNoReferences
End
SyncLock
End
Sub
Public
Overrides
Sub
OnReferenceFound
(
definition
As
INavigableItem
,
reference
As
INavigabl
eItem
)
Public
Overrides
Sub
OnReferenceFound
(
reference
As
SourceReferenc
eItem
)
SyncLock
gate
definitionToReferences
.
Add
(
d
efinition
,
reference
)
definitionToReferences
.
Add
(
reference
.
D
efinition
,
reference
)
End
SyncLock
End
Sub
End
Class
...
...
src/Features/Core/Portable/FindReferences/DefinitionLocation.DocumentDefinitionLocation.cs
浏览文件 @
b74f60d1
...
...
@@ -10,13 +10,14 @@ internal partial class DefinitionLocation
/// Implementation of a <see cref="DefinitionLocation"/> that sits on top of a
/// <see cref="DocumentLocation"/>.
/// </summary>
private
sealed
class
DocumentDefinitionLocation
:
DefinitionLocation
// Internal for testing purposes only.
internal
sealed
class
DocumentDefinitionLocation
:
DefinitionLocation
{
p
rivate
readonly
DocumentLocation
_l
ocation
;
p
ublic
readonly
DocumentLocation
L
ocation
;
public
DocumentDefinitionLocation
(
DocumentLocation
location
)
{
_l
ocation
=
location
;
L
ocation
=
location
;
}
/// <summary>
...
...
@@ -24,10 +25,10 @@ public DocumentDefinitionLocation(DocumentLocation location)
/// Origination of this <see cref="DefinitionLocation"/>.
/// </summary>
public
override
ImmutableArray
<
TaggedText
>
OriginationParts
=>
ImmutableArray
.
Create
(
new
TaggedText
(
TextTags
.
Text
,
_l
ocation
.
Document
.
Project
.
Name
));
ImmutableArray
.
Create
(
new
TaggedText
(
TextTags
.
Text
,
L
ocation
.
Document
.
Project
.
Name
));
public
override
bool
CanNavigateTo
()
=>
_l
ocation
.
CanNavigateTo
();
public
override
bool
TryNavigateTo
()
=>
_l
ocation
.
TryNavigateTo
();
public
override
bool
CanNavigateTo
()
=>
L
ocation
.
CanNavigateTo
();
public
override
bool
TryNavigateTo
()
=>
L
ocation
.
TryNavigateTo
();
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录