Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f7b4b1f1
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,发现更多精彩内容 >>
未验证
提交
f7b4b1f1
编写于
4月 04, 2020
作者:
M
msftbot[bot]
提交者:
GitHub
4月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #43066 from CyrusNajmabadi/renameOOP
Remove unnecessary rename parameters.
上级
8784363f
dd1e496a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
28 deletion
+22
-28
src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs
...tractEditorInlineRenameService.InlineRenameLocationSet.cs
+2
-2
src/EditorFeatures/Test2/Rename/RenameEngineResult.vb
src/EditorFeatures/Test2/Rename/RenameEngineResult.vb
+1
-1
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs
...ortable/Rename/ConflictEngine/ConflictResolver.Session.cs
+2
-4
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs
...s/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs
+1
-6
src/Workspaces/Core/Portable/Rename/RenameLocations.cs
src/Workspaces/Core/Portable/Rename/RenameLocations.cs
+15
-13
src/Workspaces/Core/Portable/Rename/Renamer.cs
src/Workspaces/Core/Portable/Rename/Renamer.cs
+1
-2
未找到文件。
src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs
浏览文件 @
f7b4b1f1
...
...
@@ -40,8 +40,8 @@ private InlineRenameLocation ConvertLocation(RenameLocation location)
public
async
Task
<
IInlineRenameReplacementInfo
>
GetReplacementsAsync
(
string
replacementText
,
OptionSet
optionSet
,
CancellationToken
cancellationToken
)
{
var
conflicts
=
await
ConflictResolver
.
ResolveConflictsAsync
(
_renameLocationSet
,
_rename
LocationSet
.
Symbol
.
Name
,
_renameInfo
.
GetFinalSymbolName
(
replacementText
),
optionSet
,
nonConflictSymbols
:
null
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
_renameLocationSet
,
_rename
Info
.
GetFinalSymbolName
(
replacementText
)
,
nonConflictSymbols
:
null
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
return
new
InlineRenameReplacementInfo
(
conflicts
);
}
...
...
src/EditorFeatures/Test2/Rename/RenameEngineResult.vb
浏览文件 @
f7b4b1f1
...
...
@@ -79,7 +79,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename
Dim
locations
=
RenameLocations
.
FindAsync
(
symbolAndProjectId
,
workspace
.
CurrentSolution
,
optionSet
,
CancellationToken
.
None
).
Result
Dim
originalName
=
symbol
.
Name
.
Split
(
"."
c
).
Last
()
Dim
result
=
ConflictResolver
.
ResolveConflictsAsync
(
locations
,
originalName
,
renameTo
,
optionSet
,
nonConflictSymbols
:
=
Nothing
,
cancellationToken
:
=
CancellationToken
.
None
).
Result
Dim
result
=
ConflictResolver
.
ResolveConflictsAsync
(
locations
,
renameTo
,
nonConflictSymbols
:
=
Nothing
,
cancellationToken
:
=
CancellationToken
.
None
).
Result
engineResult
=
New
RenameEngineResult
(
workspace
,
result
,
renameTo
)
engineResult
.
AssertUnlabeledSpansRenamedAndHaveNoConflicts
()
...
...
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs
浏览文件 @
f7b4b1f1
...
...
@@ -56,17 +56,15 @@ private class Session
public
Session
(
RenameLocations
renameLocationSet
,
Location
renameSymbolDeclarationLocation
,
string
originalText
,
string
replacementText
,
OptionSet
optionSet
,
ImmutableHashSet
<
ISymbol
>
nonConflictSymbols
,
CancellationToken
cancellationToken
)
{
_renameLocationSet
=
renameLocationSet
;
_renameSymbolDeclarationLocation
=
renameSymbolDeclarationLocation
;
_originalText
=
originalText
;
_originalText
=
renameLocationSet
.
Symbol
.
Name
;
_replacementText
=
replacementText
;
_optionSet
=
optionSet
;
_optionSet
=
renameLocationSet
.
Options
;
_nonConflictSymbols
=
nonConflictSymbols
;
_cancellationToken
=
cancellationToken
;
...
...
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs
浏览文件 @
f7b4b1f1
...
...
@@ -41,9 +41,7 @@ internal static partial class ConflictResolver
/// resolves them where possible.
/// </summary>
/// <param name="renameLocationSet">The locations to perform the renaming at.</param>
/// <param name="originalText">The original name of the identifier.</param>
/// <param name="replacementText">The new name of the identifier</param>
/// <param name="optionSet">The option for rename</param>
/// <param name="nonConflictSymbols">Used after renaming references. References that now bind to any of these
/// symbols are not considered to be in conflict. Useful for features that want to rename existing references to
/// point at some existing symbol. Normally this would be a conflict, but this can be used to override that
...
...
@@ -52,9 +50,7 @@ internal static partial class ConflictResolver
/// <returns>A conflict resolution containing the new solution.</returns>
public
static
Task
<
ConflictResolution
>
ResolveConflictsAsync
(
RenameLocations
renameLocationSet
,
string
originalText
,
string
replacementText
,
OptionSet
optionSet
,
ImmutableHashSet
<
ISymbol
>
nonConflictSymbols
,
CancellationToken
cancellationToken
)
{
...
...
@@ -70,8 +66,7 @@ internal static partial class ConflictResolver
var
session
=
new
Session
(
renameLocationSet
,
renameSymbolDeclarationLocation
,
originalText
,
replacementText
,
optionSet
,
nonConflictSymbols
,
cancellationToken
);
replacementText
,
nonConflictSymbols
,
cancellationToken
);
return
session
.
ResolveConflictsAsync
();
}
...
...
src/Workspaces/Core/Portable/Rename/RenameLocations.cs
浏览文件 @
f7b4b1f1
...
...
@@ -47,12 +47,12 @@ private class SearchResult
internal
OptionSet
Options
{
get
;
}
// can be default
private
readonly
ImmutableArray
<
SearchResult
>
_overloadsResult
;
private
readonly
ImmutableArray
<
RenameLocation
>
_stringsResult
;
private
readonly
ImmutableArray
<
RenameLocation
>
_commentsResult
;
// possibly null fields
private
readonly
SearchResult
_originalSymbolResult
;
private
readonly
List
<
SearchResult
>
_overloadsResult
;
internal
RenameLocations
(
ImmutableHashSet
<
RenameLocation
>
locations
,
...
...
@@ -73,7 +73,7 @@ private class SearchResult
Solution
solution
,
OptionSet
options
,
SearchResult
originalSymbolResult
,
List
<
SearchResult
>
overloadsResult
,
ImmutableArray
<
SearchResult
>
overloadsResult
,
ImmutableArray
<
RenameLocation
>
stringsResult
,
ImmutableArray
<
RenameLocation
>
commentsResult
)
{
...
...
@@ -101,7 +101,9 @@ private class SearchResult
var
renameMethodGroupReferences
=
options
.
GetOption
(
RenameOptions
.
RenameOverloads
)
||
!
GetOverloadedSymbols
(
symbolAndProjectId
).
Any
();
var
overloadsToMerge
=
(
options
.
GetOption
(
RenameOptions
.
RenameOverloads
)
?
overloadsResult
:
null
)
??
SpecializedCollections
.
EmptyEnumerable
<
SearchResult
>();
var
overloadsToMerge
=
options
.
GetOption
(
RenameOptions
.
RenameOverloads
)
?
overloadsResult
.
NullToEmpty
()
:
ImmutableArray
<
SearchResult
>.
Empty
;
foreach
(
var
result
in
overloadsToMerge
.
Concat
(
originalSymbolResult
))
{
mergedLocations
.
AddRange
(
renameMethodGroupReferences
...
...
@@ -135,7 +137,7 @@ private class SearchResult
symbolAndProjectId
=
await
ReferenceProcessing
.
FindDefinitionSymbolAsync
(
symbolAndProjectId
,
solution
,
cancellationToken
).
ConfigureAwait
(
false
);
var
originalSymbolResult
=
await
AddLocationsReferenceSymbolsAsync
(
symbolAndProjectId
,
solution
,
cancellationToken
).
ConfigureAwait
(
false
);
var
intermediateResult
=
new
RenameLocations
(
symbolAndProjectId
,
solution
,
optionSet
,
originalSymbolResult
,
overloadsResult
:
null
,
stringsResult
:
default
,
commentsResult
:
default
);
symbolAndProjectId
,
solution
,
optionSet
,
originalSymbolResult
,
overloadsResult
:
default
,
stringsResult
:
default
,
commentsResult
:
default
);
return
await
intermediateResult
.
FindWithUpdatedOptionsAsync
(
optionSet
,
cancellationToken
).
ConfigureAwait
(
false
);
}
...
...
@@ -146,9 +148,11 @@ internal async Task<RenameLocations> FindWithUpdatedOptionsAsync(OptionSet optio
Contract
.
ThrowIfNull
(
Options
,
"FindWithUpdatedOptionsAsync can only be called on a result of FindAsync"
);
using
(
Logger
.
LogBlock
(
FunctionId
.
Rename_AllRenameLocations
,
cancellationToken
))
{
var
overloadsResult
=
_overloadsResult
??
(
optionSet
.
GetOption
(
RenameOptions
.
RenameOverloads
)
?
await
GetOverloadsAsync
(
_symbolAndProjectId
,
_solution
,
cancellationToken
).
ConfigureAwait
(
false
)
:
null
);
var
overloadsResult
=
!
_overloadsResult
.
IsDefault
?
_overloadsResult
:
optionSet
.
GetOption
(
RenameOptions
.
RenameOverloads
)
?
await
GetOverloadsAsync
(
_symbolAndProjectId
,
_solution
,
cancellationToken
).
ConfigureAwait
(
false
)
:
default
;
var
stringsAndComments
=
await
ReferenceProcessing
.
GetRenamableLocationsInStringsAndCommentsAsync
(
_symbolAndProjectId
.
Symbol
,
...
...
@@ -160,22 +164,20 @@ internal async Task<RenameLocations> FindWithUpdatedOptionsAsync(OptionSet optio
return
new
RenameLocations
(
_symbolAndProjectId
,
_solution
,
optionSet
,
_originalSymbolResult
,
_overloadsResult
??
overloadsResult
,
_overloadsResult
.
IsDefault
?
overloadsResult
:
_
overloadsResult
,
_stringsResult
.
IsDefault
?
stringsAndComments
.
Item1
:
_stringsResult
,
_commentsResult
.
IsDefault
?
stringsAndComments
.
Item2
:
_commentsResult
);
}
}
private
static
async
Task
<
List
<
SearchResult
>>
GetOverloadsAsync
(
private
static
async
Task
<
ImmutableArray
<
SearchResult
>>
GetOverloadsAsync
(
SymbolAndProjectId
symbolAndProjectId
,
Solution
solution
,
CancellationToken
cancellationToken
)
{
var
overloadsResult
=
new
List
<
SearchResult
>(
);
using
var
_
=
ArrayBuilder
<
SearchResult
>.
GetInstance
(
out
var
overloadsResult
);
foreach
(
var
overloadedSymbol
in
GetOverloadedSymbols
(
symbolAndProjectId
))
{
overloadsResult
.
Add
(
await
AddLocationsReferenceSymbolsAsync
(
overloadedSymbol
,
solution
,
cancellationToken
).
ConfigureAwait
(
false
));
}
return
overloadsResult
;
return
overloadsResult
.
ToImmutable
()
;
}
internal
static
IEnumerable
<
SymbolAndProjectId
>
GetOverloadedSymbols
(
...
...
src/Workspaces/Core/Portable/Rename/Renamer.cs
浏览文件 @
f7b4b1f1
...
...
@@ -61,8 +61,7 @@ public static class Renamer
cancellationToken
.
ThrowIfCancellationRequested
();
var
conflictResolution
=
await
ConflictResolver
.
ResolveConflictsAsync
(
locations
,
locations
.
SymbolAndProjectId
.
Symbol
.
Name
,
newName
,
locations
.
Options
,
nonConflictSymbols
,
cancellationToken
).
ConfigureAwait
(
false
);
locations
,
newName
,
nonConflictSymbols
,
cancellationToken
).
ConfigureAwait
(
false
);
return
conflictResolution
.
NewSolution
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录