Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a4364cde
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,发现更多精彩内容 >>
提交
a4364cde
编写于
11月 12, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use tuples in more cases.
上级
8610da89
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
22 deletion
+22
-22
src/Workspaces/Core/Portable/Rename/ConflictEngine/RenamedSpansTracker.cs
...ore/Portable/Rename/ConflictEngine/RenamedSpansTracker.cs
+22
-22
未找到文件。
src/Workspaces/Core/Portable/Rename/ConflictEngine/RenamedSpansTracker.cs
浏览文件 @
a4364cde
...
...
@@ -17,13 +17,13 @@ namespace Microsoft.CodeAnalysis.Rename.ConflictEngine
/// </summary>
internal
sealed
class
RenamedSpansTracker
{
private
readonly
Dictionary
<
DocumentId
,
List
<
ValueTuple
<
TextSpan
,
TextSpan
>
>>
_documentToModifiedSpansMap
;
private
readonly
Dictionary
<
DocumentId
,
List
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>>
_documentToModifiedSpansMap
;
private
readonly
Dictionary
<
DocumentId
,
List
<
ComplexifiedSpan
>>
_documentToComplexifiedSpansMap
;
public
RenamedSpansTracker
()
{
_documentToComplexifiedSpansMap
=
new
Dictionary
<
DocumentId
,
List
<
ComplexifiedSpan
>>();
_documentToModifiedSpansMap
=
new
Dictionary
<
DocumentId
,
List
<
ValueTuple
<
TextSpan
,
TextSpan
>
>>();
_documentToModifiedSpansMap
=
new
Dictionary
<
DocumentId
,
List
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>>();
}
internal
bool
IsDocumentChanged
(
DocumentId
documentId
)
...
...
@@ -33,17 +33,17 @@ internal bool IsDocumentChanged(DocumentId documentId)
internal
void
AddModifiedSpan
(
DocumentId
documentId
,
TextSpan
oldSpan
,
TextSpan
newSpan
)
{
List
<
ValueTuple
<
TextSpan
,
TextSpan
>
>
spans
;
List
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>
spans
;
if
(!
_documentToModifiedSpansMap
.
TryGetValue
(
documentId
,
out
spans
))
{
spans
=
new
List
<
ValueTuple
<
TextSpan
,
TextSpan
>
>();
spans
=
new
List
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>();
_documentToModifiedSpansMap
[
documentId
]
=
spans
;
}
spans
.
Add
(
ValueTuple
.
Create
(
oldSpan
,
newSpan
));
}
internal
void
AddComplexifiedSpan
(
DocumentId
documentId
,
TextSpan
oldSpan
,
TextSpan
newSpan
,
List
<
ValueTuple
<
TextSpan
,
TextSpan
>
>
modifiedSubSpans
)
internal
void
AddComplexifiedSpan
(
DocumentId
documentId
,
TextSpan
oldSpan
,
TextSpan
newSpan
,
List
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>
modifiedSubSpans
)
{
List
<
ComplexifiedSpan
>
spans
;
if
(!
_documentToComplexifiedSpansMap
.
TryGetValue
(
documentId
,
out
spans
))
...
...
@@ -78,13 +78,13 @@ internal TextSpan GetAdjustedComplexifiedSpan(TextSpan originalComplexifiedSpan,
internal
int
GetAdjustedPosition
(
int
startingPosition
,
DocumentId
documentId
)
{
var
documentReplacementSpans
=
_documentToModifiedSpansMap
.
ContainsKey
(
documentId
)
?
_documentToModifiedSpansMap
[
documentId
].
Where
(
pair
=>
pair
.
Item1
.
Start
<
startingPosition
)
:
SpecializedCollections
.
EmptyEnumerable
<
ValueTuple
<
TextSpan
,
TextSpan
>
>();
?
_documentToModifiedSpansMap
[
documentId
].
Where
(
pair
=>
pair
.
oldSpan
.
Start
<
startingPosition
)
:
SpecializedCollections
.
EmptyEnumerable
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>();
int
adjustedStartingPosition
=
startingPosition
;
foreach
(
var
textSpanPair
in
documentReplacementSpans
)
{
adjustedStartingPosition
+=
textSpanPair
.
Item2
.
Length
-
textSpanPair
.
Item1
.
Length
;
adjustedStartingPosition
+=
textSpanPair
.
newSpan
.
Length
-
textSpanPair
.
oldSpan
.
Length
;
}
var
documentComplexifiedSpans
=
_documentToComplexifiedSpansMap
.
ContainsKey
(
documentId
)
...
...
@@ -101,17 +101,17 @@ internal int GetAdjustedPosition(int startingPosition, DocumentId documentId)
}
else
{
foreach
(
var
modifiedSpan
in
c
.
ModifiedSubSpans
.
OrderByDescending
(
t
=>
t
.
Item1
.
Start
))
foreach
(
var
modifiedSpan
in
c
.
ModifiedSubSpans
.
OrderByDescending
(
t
=>
t
.
oldSpan
.
Start
))
{
if
(!
appliedTextSpans
.
Any
(
s
=>
s
.
Contains
(
modifiedSpan
.
Item1
)))
if
(!
appliedTextSpans
.
Any
(
s
=>
s
.
Contains
(
modifiedSpan
.
oldSpan
)))
{
if
(
startingPosition
==
modifiedSpan
.
Item1
.
Start
)
if
(
startingPosition
==
modifiedSpan
.
oldSpan
.
Start
)
{
return
startingPosition
+
modifiedSpan
.
Item2
.
Start
-
modifiedSpan
.
Item1
.
Start
;
return
startingPosition
+
modifiedSpan
.
newSpan
.
Start
-
modifiedSpan
.
oldSpan
.
Start
;
}
else
if
(
startingPosition
>
modifiedSpan
.
Item1
.
Start
)
else
if
(
startingPosition
>
modifiedSpan
.
oldSpan
.
Start
)
{
return
startingPosition
+
modifiedSpan
.
Item2
.
End
-
modifiedSpan
.
Item1
.
End
;
return
startingPosition
+
modifiedSpan
.
newSpan
.
End
-
modifiedSpan
.
oldSpan
.
End
;
}
}
}
...
...
@@ -128,9 +128,9 @@ internal int GetAdjustedPosition(int startingPosition, DocumentId documentId)
internal
TextSpan
GetResolutionTextSpan
(
TextSpan
originalSpan
,
DocumentId
documentId
)
{
if
(
_documentToModifiedSpansMap
.
ContainsKey
(
documentId
)
&&
_documentToModifiedSpansMap
[
documentId
].
Contains
(
t
=>
t
.
Item1
==
originalSpan
))
_documentToModifiedSpansMap
[
documentId
].
Contains
(
t
=>
t
.
oldSpan
==
originalSpan
))
{
return
_documentToModifiedSpansMap
[
documentId
].
First
(
t
=>
t
.
Item1
==
originalSpan
).
Item2
;
return
_documentToModifiedSpansMap
[
documentId
].
First
(
t
=>
t
.
oldSpan
==
originalSpan
).
newSpan
;
}
if
(
_documentToComplexifiedSpansMap
.
ContainsKey
(
documentId
))
...
...
@@ -166,7 +166,7 @@ private class ComplexifiedSpan
{
public
TextSpan
OriginalSpan
;
public
TextSpan
NewSpan
;
public
List
<
ValueTuple
<
TextSpan
,
TextSpan
>
>
ModifiedSubSpans
;
public
List
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>
ModifiedSubSpans
;
}
internal
void
ClearDocuments
(
IEnumerable
<
DocumentId
>
conflictLocationDocumentIds
)
...
...
@@ -180,7 +180,7 @@ internal void ClearDocuments(IEnumerable<DocumentId> conflictLocationDocumentIds
internal
bool
ContainsResolvedNonReferenceLocation
(
DocumentId
documentId
,
TextSpan
originalLocation
)
{
return
// (this.documentToModifiedSpansMap.Contains(documentId) && this.documentToModifiedSpansMap[documentId].Contains(t => t.
Item1
== originalLocation.SourceSpan)) ||
return
// (this.documentToModifiedSpansMap.Contains(documentId) && this.documentToModifiedSpansMap[documentId].Contains(t => t.
oldSpan
== originalLocation.SourceSpan)) ||
_documentToComplexifiedSpansMap
.
ContainsKey
(
documentId
)
&&
_documentToComplexifiedSpansMap
[
documentId
].
Contains
(
c
=>
c
.
OriginalSpan
.
Contains
(
originalLocation
));
}
...
...
@@ -225,7 +225,7 @@ internal async Task<Solution> SimplifyAsync(Solution solution, IEnumerable<Docum
var
nodeAnnotations
=
renameAnnotations
.
GetAnnotatedNodesAndTokens
<
RenameNodeSimplificationAnnotation
>(
root
)
.
Select
(
x
=>
Tuple
.
Create
(
renameAnnotations
.
GetAnnotations
<
RenameNodeSimplificationAnnotation
>(
x
).
First
(),
(
SyntaxNode
)
x
));
HashSet
<
SyntaxToken
>
modifiedTokensInComplexifiedStatements
=
new
HashSet
<
SyntaxToken
>();
var
modifiedTokensInComplexifiedStatements
=
new
HashSet
<
SyntaxToken
>();
foreach
(
var
annotationAndNode
in
nodeAnnotations
)
{
var
oldSpan
=
annotationAndNode
.
Item1
.
OriginalTextSpan
;
...
...
@@ -234,7 +234,7 @@ internal async Task<Solution> SimplifyAsync(Solution solution, IEnumerable<Docum
var
annotationAndTokens2
=
renameAnnotations
.
GetAnnotatedNodesAndTokens
<
RenameTokenSimplificationAnnotation
>(
node
)
.
Select
(
x
=>
Tuple
.
Create
(
renameAnnotations
.
GetAnnotations
<
RenameTokenSimplificationAnnotation
>(
x
).
First
(),
(
SyntaxToken
)
x
));
List
<
ValueTuple
<
TextSpan
,
TextSpan
>>
modifiedSubSpans
=
new
List
<
ValueTuple
<
TextSpan
,
TextSpan
>
>();
List
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)>
modifiedSubSpans
=
new
List
<(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>();
foreach
(
var
annotationAndToken
in
annotationAndTokens2
)
{
modifiedTokensInComplexifiedStatements
.
Add
(
annotationAndToken
.
Item2
);
...
...
@@ -294,14 +294,14 @@ internal async Task<Solution> SimplifyAsync(Solution solution, IEnumerable<Docum
return
result
;
}
internal
IEnumerable
<
ValueTuple
<
TextSpan
,
TextSpan
>
>
GetComplexifiedSpans
(
DocumentId
documentId
)
internal
IEnumerable
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>
GetComplexifiedSpans
(
DocumentId
documentId
)
{
if
(
_documentToComplexifiedSpansMap
.
ContainsKey
(
documentId
))
{
return
_documentToComplexifiedSpansMap
[
documentId
].
Select
(
c
=>
ValueTuple
.
Create
(
c
.
OriginalSpan
,
c
.
NewSpan
));
}
return
SpecializedCollections
.
EmptyEnumerable
<
ValueTuple
<
TextSpan
,
TextSpan
>
>();
return
SpecializedCollections
.
EmptyEnumerable
<
(
TextSpan
oldSpan
,
TextSpan
newSpan
)
>();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录