Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
34a820cd
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,发现更多精彩内容 >>
提交
34a820cd
编写于
3月 05, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Limit cascading when finding the set of members to update when switching member to be explicit.
上级
f94a0963
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
71 addition
and
28 deletion
+71
-28
src/Features/CSharp/Portable/ImplementInterface/CSharpImplementExplicitlyCodeRefactoringProvider.cs
...rface/CSharpImplementExplicitlyCodeRefactoringProvider.cs
+9
-3
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesOptions.cs
...table/FindSymbols/FindReferences/FindReferencesOptions.cs
+23
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchOptions.cs
...FindSymbols/FindReferences/FindReferencesSearchOptions.cs
+18
-13
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs
...Symbols/FindReferences/Finders/AbstractReferenceFinder.cs
+8
-5
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindReferences_Legacy.cs
...ortable/FindSymbols/SymbolFinder_FindReferences_Legacy.cs
+7
-5
src/Workspaces/Core/Portable/Remote/RemoteArguments.cs
src/Workspaces/Core/Portable/Remote/RemoteArguments.cs
+6
-2
未找到文件。
src/Features/CSharp/Portable/ImplementInterface/CSharpImplementExplicitlyCodeRefactoringProvider.cs
浏览文件 @
34a820cd
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
#
nullable
enable
#
nullable
enable
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
using
System.Composition
;
using
System.Composition
;
using
System.Linq
;
using
System.Linq
;
...
@@ -49,11 +48,18 @@ protected override bool CheckMemberCanBeConverted(ISymbol member)
...
@@ -49,11 +48,18 @@ protected override bool CheckMemberCanBeConverted(ISymbol member)
{
{
var
solution
=
project
.
Solution
;
var
solution
=
project
.
Solution
;
// We don't need to cascade in this search, we're only explicitly looking for direct
// calls to our instance member (and not anyone else already calling through the
// interface already).
//
// This can save a lot of extra time spent finding callers, especially for methods with
// high fan-out (like IDisposable.Dispose()).
var
findRefsOptions
=
FindReferencesSearchOptions
.
Default
.
WithCascade
(
false
);
var
references
=
await
SymbolFinder
.
FindReferencesAsync
(
var
references
=
await
SymbolFinder
.
FindReferencesAsync
(
new
SymbolAndProjectId
(
implMember
,
project
.
Id
),
new
SymbolAndProjectId
(
implMember
,
project
.
Id
),
solution
,
cancellationToken
).
ConfigureAwait
(
false
);
solution
,
findRefsOptions
,
cancellationToken
).
ConfigureAwait
(
false
);
var
implReferences
=
references
.
FirstOrDefault
(
r
=>
implMember
.
Equals
(
r
.
Definition
)
);
var
implReferences
=
references
.
FirstOrDefault
();
if
(
implReferences
==
null
)
if
(
implReferences
==
null
)
return
;
return
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesOptions.cs
0 → 100644
浏览文件 @
34a820cd
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace
Microsoft.CodeAnalysis.FindSymbols
{
internal
class
FindReferencesOptions
{
public
static
readonly
FindReferencesOptions
Default
=
new
FindReferencesOptions
(
cascade
:
true
);
/// <summary>
/// Whether or not we should automatically cascade to members when doing a find-references
/// search. Default to <see langword="true"/>.
/// </summary>
public
readonly
bool
Cascade
;
public
FindReferencesOptions
(
bool
cascade
)
{
Cascade
=
cascade
;
}
}
}
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchOptions.cs
浏览文件 @
34a820cd
...
@@ -2,17 +2,16 @@
...
@@ -2,17 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// See the LICENSE file in the project root for more information.
using
System.Collections.Generic
;
using
Microsoft.CodeAnalysis.FindSymbols.Finders
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.FindSymbols
namespace
Microsoft.CodeAnalysis.FindSymbols
{
{
internal
class
FindReferencesSearchOptions
internal
class
FindReferencesSearchOptions
{
{
public
static
readonly
FindReferencesSearchOptions
Default
=
public
static
readonly
FindReferencesSearchOptions
Default
=
new
FindReferencesSearchOptions
(
associatePropertyReferencesWithSpecificAccessor
:
false
);
new
FindReferencesSearchOptions
(
associatePropertyReferencesWithSpecificAccessor
:
false
,
cascade
:
true
);
/// <summary>
/// <summary>
/// When searching for property, associate specific references we find to the relevant
/// When searching for property, associate specific references we find to the relevant
...
@@ -28,17 +27,25 @@ internal class FindReferencesSearchOptions
...
@@ -28,17 +27,25 @@ internal class FindReferencesSearchOptions
/// </summary>
/// </summary>
public
bool
AssociatePropertyReferencesWithSpecificAccessor
{
get
;
}
public
bool
AssociatePropertyReferencesWithSpecificAccessor
{
get
;
}
/// <summary>
/// Whether or not we should cascade from the original search symbol to new symbols as we're
/// doing the find-references search.
/// </summary>
public
bool
Cascade
{
get
;
}
public
FindReferencesSearchOptions
(
public
FindReferencesSearchOptions
(
bool
associatePropertyReferencesWithSpecificAccessor
)
bool
associatePropertyReferencesWithSpecificAccessor
,
bool
cascade
)
{
{
AssociatePropertyReferencesWithSpecificAccessor
=
associatePropertyReferencesWithSpecificAccessor
;
AssociatePropertyReferencesWithSpecificAccessor
=
associatePropertyReferencesWithSpecificAccessor
;
Cascade
=
cascade
;
}
}
public
FindReferencesSearchOptions
WithAssociatePropertyReferencesWithSpecificAccessor
(
public
FindReferencesSearchOptions
WithAssociatePropertyReferencesWithSpecificAccessor
(
bool
associatePropertyReferencesWithSpecificAccessor
)
bool
associatePropertyReferencesWithSpecificAccessor
)
=>
new
FindReferencesSearchOptions
(
associatePropertyReferencesWithSpecificAccessor
,
Cascade
);
{
return
new
FindReferencesSearchOptions
(
associatePropertyReferencesWithSpecificAccessor
);
public
FindReferencesSearchOptions
WithCascade
(
bool
cascade
)
}
=>
new
FindReferencesSearchOptions
(
AssociatePropertyReferencesWithSpecificAccessor
,
cascade
);
/// <summary>
/// <summary>
/// For IDE features, if the user starts searching on an accessor, then we want to give
/// For IDE features, if the user starts searching on an accessor, then we want to give
...
@@ -46,8 +53,6 @@ internal class FindReferencesSearchOptions
...
@@ -46,8 +53,6 @@ internal class FindReferencesSearchOptions
/// then associate everything with the property.
/// then associate everything with the property.
/// </summary>
/// </summary>
public
static
FindReferencesSearchOptions
GetFeatureOptionsForStartingSymbol
(
ISymbol
symbol
)
public
static
FindReferencesSearchOptions
GetFeatureOptionsForStartingSymbol
(
ISymbol
symbol
)
=>
symbol
.
IsPropertyAccessor
()
=>
Default
.
WithAssociatePropertyReferencesWithSpecificAccessor
(
symbol
.
IsPropertyAccessor
());
?
new
FindReferencesSearchOptions
(
associatePropertyReferencesWithSpecificAccessor
:
true
)
:
FindReferencesSearchOptions
.
Default
;
}
}
}
}
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs
浏览文件 @
34a820cd
...
@@ -825,12 +825,15 @@ public override Task<ImmutableArray<Project>> DetermineProjectsToSearchAsync(ISy
...
@@ -825,12 +825,15 @@ public override Task<ImmutableArray<Project>> DetermineProjectsToSearchAsync(ISy
SymbolAndProjectId
symbolAndProjectId
,
Solution
solution
,
IImmutableSet
<
Project
>
projects
,
SymbolAndProjectId
symbolAndProjectId
,
Solution
solution
,
IImmutableSet
<
Project
>
projects
,
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
{
{
var
symbol
=
symbolAndProjectId
.
Symbol
;
if
(
options
.
Cascade
)
if
(
symbol
is
TSymbol
typedSymbol
&&
CanFind
(
typedSymbol
))
{
{
return
DetermineCascadedSymbolsAsync
(
var
symbol
=
symbolAndProjectId
.
Symbol
;
symbolAndProjectId
.
WithSymbol
(
typedSymbol
),
if
(
symbol
is
TSymbol
typedSymbol
&&
CanFind
(
typedSymbol
))
solution
,
projects
,
options
,
cancellationToken
);
{
return
DetermineCascadedSymbolsAsync
(
symbolAndProjectId
.
WithSymbol
(
typedSymbol
),
solution
,
projects
,
options
,
cancellationToken
);
}
}
}
return
SpecializedTasks
.
EmptyImmutableArray
<
SymbolAndProjectId
>();
return
SpecializedTasks
.
EmptyImmutableArray
<
SymbolAndProjectId
>();
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindReferences_Legacy.cs
浏览文件 @
34a820cd
...
@@ -30,17 +30,19 @@ public static partial class SymbolFinder
...
@@ -30,17 +30,19 @@ public static partial class SymbolFinder
return
FindReferencesAsync
(
new
SymbolAndProjectId
(
symbol
,
projectId
:
null
),
solution
,
cancellationToken
);
return
FindReferencesAsync
(
new
SymbolAndProjectId
(
symbol
,
projectId
:
null
),
solution
,
cancellationToken
);
}
}
internal
static
Task
<
IEnumerable
<
ReferencedSymbol
>>
FindReferencesAsync
(
SymbolAndProjectId
symbolAndProjectId
,
Solution
solution
,
CancellationToken
cancellationToken
)
=>
FindReferencesAsync
(
symbolAndProjectId
,
solution
,
FindReferencesSearchOptions
.
Default
,
cancellationToken
);
internal
static
async
Task
<
IEnumerable
<
ReferencedSymbol
>>
FindReferencesAsync
(
internal
static
async
Task
<
IEnumerable
<
ReferencedSymbol
>>
FindReferencesAsync
(
SymbolAndProjectId
symbolAndProjectId
,
SymbolAndProjectId
symbolAndProjectId
,
Solution
solution
,
Solution
solution
,
CancellationToken
cancellationToken
=
default
)
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
{
{
var
progressCollector
=
new
StreamingProgressCollector
(
StreamingFindReferencesProgress
.
Instance
);
var
progressCollector
=
new
StreamingProgressCollector
(
StreamingFindReferencesProgress
.
Instance
);
await
FindReferencesAsync
(
await
FindReferencesAsync
(
symbolAndProjectId
,
symbolAndProjectId
,
solution
,
progressCollector
,
solution
,
progress
:
progressCollector
,
documents
:
null
,
documents
:
null
,
options
,
cancellationToken
).
ConfigureAwait
(
false
);
options
:
FindReferencesSearchOptions
.
Default
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
return
progressCollector
.
GetReferencedSymbols
();
return
progressCollector
.
GetReferencedSymbols
();
}
}
...
...
src/Workspaces/Core/Portable/Remote/RemoteArguments.cs
浏览文件 @
34a820cd
...
@@ -19,18 +19,22 @@ namespace Microsoft.CodeAnalysis.Remote
...
@@ -19,18 +19,22 @@ namespace Microsoft.CodeAnalysis.Remote
internal
class
SerializableFindReferencesSearchOptions
internal
class
SerializableFindReferencesSearchOptions
{
{
public
bool
AssociatePropertyReferencesWithSpecificAccessor
;
public
bool
AssociatePropertyReferencesWithSpecificAccessor
;
public
bool
Cascade
;
public
static
SerializableFindReferencesSearchOptions
Dehydrate
(
FindReferencesSearchOptions
options
)
public
static
SerializableFindReferencesSearchOptions
Dehydrate
(
FindReferencesSearchOptions
options
)
{
{
return
new
SerializableFindReferencesSearchOptions
return
new
SerializableFindReferencesSearchOptions
{
{
AssociatePropertyReferencesWithSpecificAccessor
=
options
.
AssociatePropertyReferencesWithSpecificAccessor
AssociatePropertyReferencesWithSpecificAccessor
=
options
.
AssociatePropertyReferencesWithSpecificAccessor
,
Cascade
=
options
.
Cascade
,
};
};
}
}
public
FindReferencesSearchOptions
Rehydrate
()
public
FindReferencesSearchOptions
Rehydrate
()
{
{
return
new
FindReferencesSearchOptions
(
AssociatePropertyReferencesWithSpecificAccessor
);
return
new
FindReferencesSearchOptions
(
associatePropertyReferencesWithSpecificAccessor
:
AssociatePropertyReferencesWithSpecificAccessor
,
cascade
:
Cascade
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录