Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c267169e
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,发现更多精彩内容 >>
提交
c267169e
编写于
7月 21, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify find refs filtering.
上级
97e6eb79
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
26 deletion
+34
-26
src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs
...eferenceHighlighting/AbstractDocumentHighlightsService.cs
+1
-1
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.DelegateInvokeMethodSymbols.vb
...rences/FindReferencesTests.DelegateInvokeMethodSymbols.vb
+3
-3
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.vb
...ditorFeatures/Test2/FindReferences/FindReferencesTests.vb
+11
-10
src/VisualStudio/Core/Def/Implementation/Library/FindResults/LibraryManager_FindReferences.cs
...tion/Library/FindResults/LibraryManager_FindReferences.cs
+2
-6
src/Workspaces/Core/Portable/Shared/Extensions/IFindReferencesResultExtensions.cs
...able/Shared/Extensions/IFindReferencesResultExtensions.cs
+17
-6
未找到文件。
src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs
浏览文件 @
c267169e
...
...
@@ -98,7 +98,7 @@ private bool ShouldConsiderSymbol(ISymbol symbol)
private
async
Task
<
IEnumerable
<
DocumentHighlights
>>
FilterAndCreateSpansAsync
(
IEnumerable
<
ReferencedSymbol
>
references
,
Solution
solution
,
IImmutableSet
<
Document
>
documentsToSearch
,
ISymbol
symbol
,
CancellationToken
cancellationToken
)
{
references
=
references
.
Filter
UnreferencedSyntheticDefinitions
();
references
=
references
.
Filter
ToItemsToShow
();
references
=
references
.
FilterNonMatchingMethodNames
(
solution
,
symbol
);
references
=
references
.
FilterToAliasMatches
(
symbol
as
IAliasSymbol
);
...
...
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.DelegateInvokeMethodSymbols.vb
浏览文件 @
c267169e
...
...
@@ -17,9 +17,9 @@ Imports System.Linq
Module
Program
Function
Main
(
args
As
String
())
Dim
q
=
Function
(
e
As
Integer
)
Dim
q
=
{
|
Definition
:
Function
(
e
As
Integer
)
Return
True
End
Function
.
$$[|
Invoke
|]
(
42
)
End
Function
|
}
.
$$[|
Invoke
|]
(
42
)
Dim
r
=
Function
(
e2
As
Integer
)
Return
True
...
...
@@ -32,4 +32,4 @@ End Module
Await
TestAsync
(
input
)
End
Function
End
Class
End
Namespace
End
Namespace
\ No newline at end of file
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.vb
浏览文件 @
c267169e
...
...
@@ -11,6 +11,8 @@ Imports Xunit.Abstractions
Namespace
Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
Partial
Public
Class
FindReferencesTests
Private
Const
DefinitionKey
As
String
=
"Definition"
Private
ReadOnly
_outputHelper
As
ITestOutputHelper
Public
Sub
New
(
outputHelper
As
ITestOutputHelper
)
...
...
@@ -38,14 +40,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
End
If
Dim
actualDefinitions
=
result
.
FilterUnreferencedSyntheticDefinitions
().
Where
(
Function
(
r
)
Return
Not
r
.
Definition
.
IsImplicitlyDeclared
OrElse
(
r
.
Definition
.
Kind
=
SymbolKind
.
Property
AndAlso
r
.
Definition
.
ContainingSymbol
IsNot
Nothing
AndAlso
r
.
Definition
.
ContainingSymbol
.
Kind
=
SymbolKind
.
NamedType
AndAlso
DirectCast
(
r
.
Definition
.
ContainingSymbol
,
INamedTypeSymbol
).
IsAnonymousType
)
End
Function
).
result
.
FilterToItemsToShow
().
Where
(
Function
(
s
)
Not
IsImplicitNamespace
(
s
)).
SelectMany
(
Function
(
r
)
r
.
Definition
.
Locations
).
Where
(
Function
(
loc
)
IsInSource
(
workspace
,
loc
,
uiVisibleOnly
)).
GroupBy
(
Function
(
loc
)
loc
.
SourceTree
).
...
...
@@ -56,11 +52,11 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
Dim
documentsWithAnnotatedSpans
=
workspace
.
Documents
.
Where
(
Function
(
d
)
d
.
AnnotatedSpans
.
Any
())
Assert
.
Equal
(
Of
String
)(
documentsWithAnnotatedSpans
.
Select
(
Function
(
d
)
GetFilePathAndProjectLabel
(
workspace
,
d
)).
Order
(),
actualDefinitions
.
Keys
.
Order
())
For
Each
doc
In
documentsWithAnnotatedSpans
Assert
.
Equal
(
Of
Text
.
TextSpan
)(
doc
.
AnnotatedSpans
(
"Definition"
).
Order
(),
actualDefinitions
(
GetFilePathAndProjectLabel
(
workspace
,
doc
)).
Order
())
Assert
.
Equal
(
Of
Text
.
TextSpan
)(
doc
.
AnnotatedSpans
(
DefinitionKey
).
Order
(),
actualDefinitions
(
GetFilePathAndProjectLabel
(
workspace
,
doc
)).
Order
())
Next
Dim
actualReferences
=
result
.
Filter
UnreferencedSyntheticDefinitions
().
result
.
Filter
ToItemsToShow
().
SelectMany
(
Function
(
r
)
r
.
Locations
.
Select
(
Function
(
loc
)
loc
.
Location
)).
Where
(
Function
(
loc
)
IsInSource
(
workspace
,
loc
,
uiVisibleOnly
)).
Distinct
().
...
...
@@ -82,6 +78,11 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
End
Using
End
Function
Private
Function
IsImplicitNamespace
(
referencedSymbol
As
ReferencedSymbol
)
As
Boolean
Return
referencedSymbol
.
Definition
.
IsImplicitlyDeclared
AndAlso
referencedSymbol
.
Definition
.
Kind
=
SymbolKind
.
Namespace
End
Function
Private
Shared
Function
IsInSource
(
workspace
As
Workspace
,
loc
As
Location
,
uiVisibleOnly
As
Boolean
)
As
Boolean
If
uiVisibleOnly
Then
Return
loc
.
IsInSource
AndAlso
Not
loc
.
SourceTree
.
IsHiddenPosition
(
loc
.
SourceSpan
.
Start
)
...
...
src/VisualStudio/Core/Def/Implementation/Library/FindResults/LibraryManager_FindReferences.cs
浏览文件 @
c267169e
...
...
@@ -42,15 +42,10 @@ internal IList<AbstractTreeItem> CreateFindReferencesItems(Solution solution, IE
var
uniqueLocations
=
new
HashSet
<
ValueTuple
<
Document
,
TextSpan
>>();
var
symbolNavigationService
=
solution
.
Workspace
.
Services
.
GetService
<
ISymbolNavigationService
>();
referencedSymbols
=
referencedSymbols
.
Filter
UnreferencedSyntheticDefinitions
().
ToList
();
referencedSymbols
=
referencedSymbols
.
Filter
ToItemsToShow
().
ToList
();
foreach
(
var
referencedSymbol
in
referencedSymbols
.
OrderBy
(
GetDefinitionPrecedence
))
{
if
(!
IncludeDefinition
(
referencedSymbol
))
{
continue
;
}
var
definition
=
referencedSymbol
.
Definition
;
var
locations
=
definition
.
Locations
;
...
...
@@ -75,6 +70,7 @@ internal IList<AbstractTreeItem> CreateFindReferencesItems(Solution solution, IE
if
(
definitionItem
!=
null
)
{
definitions
.
Add
(
definitionItem
);
var
referenceItems
=
CreateReferenceItems
(
solution
,
uniqueLocations
,
referencedSymbol
.
Locations
.
Select
(
loc
=>
loc
.
Location
));
definitionItem
.
Children
.
AddRange
(
referenceItems
);
definitionItem
.
SetReferenceCount
(
referenceItems
.
Count
);
...
...
src/Workspaces/Core/Portable/Shared/Extensions/IFindReferencesResultExtensions.cs
浏览文件 @
c267169e
...
...
@@ -11,29 +11,40 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions
{
internal
static
partial
class
IFindReferencesResultExtensions
{
public
static
IEnumerable
<
ReferencedSymbol
>
Filter
UnreferencedSyntheticDefinitions
(
public
static
IEnumerable
<
ReferencedSymbol
>
Filter
ToItemsToShow
(
this
IEnumerable
<
ReferencedSymbol
>
result
)
{
return
result
.
Where
(
Should
Keep
);
return
result
.
Where
(
Should
Show
);
}
private
static
bool
Should
Keep
(
ReferencedSymbol
r
)
private
static
bool
Should
Show
(
ReferencedSymbol
referencedSymbol
)
{
if
(
r
.
Locations
.
Any
())
// If the reference has any locations then we will present it.
if
(
referencedSymbol
.
Locations
.
Any
())
{
return
true
;
}
if
(
r
.
Definition
.
IsImplicitlyDeclared
)
return
referencedSymbol
.
Definition
.
ShouldShowWithNoReferenceLocations
();
}
public
static
bool
ShouldShowWithNoReferenceLocations
(
this
ISymbol
definition
)
{
// If the definition is implicit and we have no references, then we don't want to
// clutter the UI with it.
if
(
definition
.
IsImplicitlyDeclared
)
{
return
false
;
}
if
(
r
.
Definition
.
IsPropertyAccessor
())
// We don't want to clutter the UI with property accessors if there are no direct
// references to them.
if
(
definition
.
IsPropertyAccessor
())
{
return
false
;
}
// Otherwise we still show the item even if there are no references to it.
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录