Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
15b00bf6
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,发现更多精彩内容 >>
提交
15b00bf6
编写于
7月 18, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use deconstruction
上级
57944d5b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
48 addition
and
48 deletion
+48
-48
src/Workspaces/Core/Portable/CodeCleanup/AbstractCodeCleanerService.cs
...s/Core/Portable/CodeCleanup/AbstractCodeCleanerService.cs
+11
-11
src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs
...rtable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs
+2
-2
src/Workspaces/Core/Portable/CodeGeneration/AbstractFlagsEnumGenerator.cs
...ore/Portable/CodeGeneration/AbstractFlagsEnumGenerator.cs
+3
-3
src/Workspaces/Core/Portable/Formatting/Context/FormattingContext.cs
...ces/Core/Portable/Formatting/Context/FormattingContext.cs
+4
-4
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs
...Services/SyntaxFactsService/AbstractSyntaxFactsService.cs
+4
-4
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs
...ortable/Rename/ConflictEngine/ConflictResolver.Session.cs
+9
-9
src/Workspaces/Core/Portable/Rename/ConflictEngine/RenamedSpansTracker.cs
...ore/Portable/Rename/ConflictEngine/RenamedSpansTracker.cs
+12
-12
src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs
...spaces/Core/Portable/Shared/Collections/IntervalTree`1.cs
+3
-3
未找到文件。
src/Workspaces/Core/Portable/CodeCleanup/AbstractCodeCleanerService.cs
浏览文件 @
15b00bf6
...
...
@@ -50,23 +50,23 @@ public async Task<Document> CleanupAsync(Document document, ImmutableArray<TextS
Debug
.
Assert
(
syntaxFactsService
!=
null
);
// We need to track spans between cleaners. Annotate the tree with the provided spans.
var
newNodeAndAnnotations
=
AnnotateNodeForTextSpans
(
syntaxFactsService
,
root
,
normalizedSpan
,
cancellationToken
);
var
(
newNode
,
annotations
)
=
AnnotateNodeForTextSpans
(
syntaxFactsService
,
root
,
normalizedSpan
,
cancellationToken
);
// If it urns out we don't need to annotate anything since all spans are merged to one span that covers the whole node...
if
(
newNode
AndAnnotations
.
newNode
==
null
)
if
(
newNode
==
null
)
{
// ... then we are cleaning up the whole document, so there is no need to do expansive span tracking between cleaners.
return
await
IterateAllCodeCleanupProvidersAsync
(
document
,
document
,
n
=>
ImmutableArray
.
Create
(
n
.
FullSpan
),
codeCleaners
,
cancellationToken
).
ConfigureAwait
(
false
);
}
// Replace the initial node and document with the annotated node.
var
annotatedRoot
=
newNode
AndAnnotations
.
newNode
;
var
annotatedRoot
=
newNode
;
var
annotatedDocument
=
document
.
WithSyntaxRoot
(
annotatedRoot
);
// Run the actual cleanup.
return
await
IterateAllCodeCleanupProvidersAsync
(
document
,
annotatedDocument
,
r
=>
GetTextSpansFromAnnotation
(
r
,
newNodeAndAnnotations
.
annotations
,
cancellationToken
),
r
=>
GetTextSpansFromAnnotation
(
r
,
annotations
,
cancellationToken
),
codeCleaners
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
...
...
@@ -95,22 +95,22 @@ public async Task<SyntaxNode> CleanupAsync(SyntaxNode root, ImmutableArray<TextS
Debug
.
Assert
(
syntaxFactsService
!=
null
);
// We need to track spans between cleaners. Annotate the tree with the provided spans.
var
newNodeAndAnnotations
=
AnnotateNodeForTextSpans
(
syntaxFactsService
,
root
,
normalizedSpan
,
cancellationToken
);
var
(
newNode
,
annotations
)
=
AnnotateNodeForTextSpans
(
syntaxFactsService
,
root
,
normalizedSpan
,
cancellationToken
);
// If it urns out we don't need to annotate anything since all spans are merged to one span that covers the whole node...
if
(
newNode
AndAnnotations
.
newNode
==
null
)
if
(
newNode
==
null
)
{
// ... then we are cleaning up the whole document, so there is no need to do expansive span tracking between cleaners.
return
await
IterateAllCodeCleanupProvidersAsync
(
root
,
root
,
n
=>
ImmutableArray
.
Create
(
n
.
FullSpan
),
workspace
,
codeCleaners
,
cancellationToken
).
ConfigureAwait
(
false
);
}
// Replace the initial node and document with the annotated node.
var
annotatedRoot
=
newNode
AndAnnotations
.
newNode
;
var
annotatedRoot
=
newNode
;
// Run the actual cleanup.
return
await
IterateAllCodeCleanupProvidersAsync
(
root
,
annotatedRoot
,
r
=>
GetTextSpansFromAnnotation
(
r
,
newNodeAndAnnotations
.
annotations
,
cancellationToken
),
r
=>
GetTextSpansFromAnnotation
(
r
,
annotations
,
cancellationToken
),
workspace
,
codeCleaners
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
...
...
@@ -123,12 +123,12 @@ public async Task<SyntaxNode> CleanupAsync(SyntaxNode root, ImmutableArray<TextS
// Now try to retrieve the text span from the annotations injected into the node.
var
builder
=
ArrayBuilder
<
TextSpan
>.
GetInstance
();
foreach
(
var
annotationPair
in
annotations
)
foreach
(
var
(
previousAnnotation
,
nextAnnotation
)
in
annotations
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
var
previousMarkerAnnotation
=
annotationPair
.
previousAnnotation
;
var
nextMarkerAnnotation
=
annotationPair
.
nextAnnotation
;
var
previousMarkerAnnotation
=
previousAnnotation
;
var
nextMarkerAnnotation
=
nextAnnotation
;
var
previousTokenMarker
=
SpanMarker
.
FromAnnotation
(
previousMarkerAnnotation
);
var
nextTokenMarker
=
SpanMarker
.
FromAnnotation
(
nextMarkerAnnotation
);
...
...
src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs
浏览文件 @
15b00bf6
...
...
@@ -256,11 +256,11 @@ public virtual string GetFixAllTitle(FixAllState fixAllState)
// For each changed document, also keep track of the associated code action that
// produced it.
var
getChangedDocumentsTasks
=
new
List
<
Task
>();
foreach
(
var
diagnosticAndCodeAction
in
diagnosticsAndCodeActions
)
foreach
(
var
(
diagnostic
,
action
)
in
diagnosticsAndCodeActions
)
{
getChangedDocumentsTasks
.
Add
(
GetChangedDocumentsAsync
(
oldSolution
,
documentIdToChangedDocuments
,
diagnosticAndCodeAction
.
action
,
cancellationToken
));
action
,
cancellationToken
));
}
await
Task
.
WhenAll
(
getChangedDocumentsTasks
).
ConfigureAwait
(
false
);
...
...
src/Workspaces/Core/Portable/CodeGeneration/AbstractFlagsEnumGenerator.cs
浏览文件 @
15b00bf6
...
...
@@ -158,10 +158,10 @@ private IFieldSymbol GetZeroField(List<(IFieldSymbol field, ulong value)> allFie
{
for
(
var
i
=
allFieldsAndValues
.
Count
-
1
;
i
>=
0
;
i
--)
{
var
tuple
=
allFieldsAndValues
[
i
];
if
(
tuple
.
value
==
0
)
var
(
field
,
value
)
=
allFieldsAndValues
[
i
];
if
(
value
==
0
)
{
return
tuple
.
field
;
return
field
;
}
}
...
...
src/Workspaces/Core/Portable/Formatting/Context/FormattingContext.cs
浏览文件 @
15b00bf6
...
...
@@ -94,11 +94,11 @@ public FormattingContext(AbstractFormatEngine engine, TokenStream tokenStream, s
}
var
initialContextFinder
=
new
InitialContextFinder
(
_tokenStream
,
formattingRules
,
rootNode
);
var
results
=
initialContextFinder
.
Do
(
startToken
,
endToken
);
var
(
indentOperations
,
suppressOperations
)
=
initialContextFinder
.
Do
(
startToken
,
endToken
);
if
(
results
.
indentOperations
!=
null
)
if
(
indentOperations
!=
null
)
{
var
indentationOperations
=
results
.
indentOperations
;
var
indentationOperations
=
indentOperations
;
var
initialOperation
=
indentationOperations
[
0
];
var
baseIndentationFinder
=
new
BottomUpBaseIndentationFinder
(
...
...
@@ -119,7 +119,7 @@ public FormattingContext(AbstractFormatEngine engine, TokenStream tokenStream, s
_initialIndentBlockOperations
=
indentationOperations
;
}
results
.
suppressOperations
?.
Do
(
o
=>
this
.
AddInitialSuppressOperation
(
o
));
suppressOperations
?.
Do
(
o
=>
this
.
AddInitialSuppressOperation
(
o
));
}
public
void
AddIndentBlockOperations
(
...
...
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs
浏览文件 @
15b00bf6
...
...
@@ -162,10 +162,10 @@ public bool IsOnSingleLine(SyntaxNode node, bool fullSpan)
{
while
(
stack
.
Count
>
0
)
{
var
current
=
stack
.
Pop
();
var
currentNodeOrToken
=
current
.
nodeOrToken
;
var
currentLeading
=
current
.
leading
;
var
currentTrailing
=
current
.
trailing
;
var
(
nodeOrToken
,
leading
,
trailing
)
=
stack
.
Pop
();
var
currentNodeOrToken
=
nodeOrToken
;
var
currentLeading
=
leading
;
var
currentTrailing
=
trailing
;
if
(
currentNodeOrToken
.
IsToken
)
{
...
...
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs
浏览文件 @
15b00bf6
...
...
@@ -318,12 +318,12 @@ private async Task DebugVerifyNoErrorsAsync(ConflictResolution conflictResolutio
var
syntaxRoot
=
await
newDocument
.
GetSyntaxRootAsync
(
_cancellationToken
).
ConfigureAwait
(
false
);
var
nodesOrTokensWithConflictCheckAnnotations
=
GetNodesOrTokensToCheckForConflicts
(
documentId
,
syntaxRoot
);
foreach
(
var
nodeOrToken
in
nodesOrTokensWithConflictCheckAnnotations
)
foreach
(
var
(
syntax
,
annotation
)
in
nodesOrTokensWithConflictCheckAnnotations
)
{
if
(
nodeOrToken
.
annotation
.
IsRenameLocation
)
if
(
annotation
.
IsRenameLocation
)
{
conflictResolution
.
AddRelatedLocation
(
new
RelatedLocation
(
nodeOrToken
.
annotation
.
OriginalSpan
,
documentId
,
RelatedLocationType
.
UnresolvedConflict
));
annotation
.
OriginalSpan
,
documentId
,
RelatedLocationType
.
UnresolvedConflict
));
}
}
}
...
...
@@ -351,10 +351,10 @@ private async Task DebugVerifyNoErrorsAsync(ConflictResolution conflictResolutio
.
Where
(
t
=>
t
.
DocumentId
==
documentId
)
.
Select
(
t
=>
t
.
OriginalIdentifierSpan
).
ToSet
();
foreach
(
var
nodeAndAnnotation
in
nodesOrTokensWithConflictCheckAnnotations
)
foreach
(
var
(
syntax
,
annotation
)
in
nodesOrTokensWithConflictCheckAnnotations
)
{
var
tokenOrNode
=
nodeAndAnnotation
.
syntax
;
var
conflictAnnotation
=
nodeAndAnnotation
.
annotation
;
var
tokenOrNode
=
syntax
;
var
conflictAnnotation
=
annotation
;
reverseMappedLocations
[
tokenOrNode
.
GetLocation
()]
=
baseSyntaxTree
.
GetLocation
(
conflictAnnotation
.
OriginalSpan
);
var
originalLocation
=
conflictAnnotation
.
OriginalSpan
;
IEnumerable
<
ISymbol
>
newReferencedSymbols
=
null
;
...
...
@@ -434,10 +434,10 @@ private async Task DebugVerifyNoErrorsAsync(ConflictResolution conflictResolutio
var
baseSyntaxTree
=
await
baseDocument
.
GetSyntaxTreeAsync
(
_cancellationToken
).
ConfigureAwait
(
false
);
var
nodesOrTokensWithConflictCheckAnnotations
=
GetNodesOrTokensToCheckForConflicts
(
unprocessedDocumentIdWithPotentialDeclarationConflicts
,
syntaxRoot
);
foreach
(
var
nodeAndAnnotation
in
nodesOrTokensWithConflictCheckAnnotations
)
foreach
(
var
(
syntax
,
annotation
)
in
nodesOrTokensWithConflictCheckAnnotations
)
{
var
tokenOrNode
=
nodeAndAnnotation
.
syntax
;
var
conflictAnnotation
=
nodeAndAnnotation
.
annotation
;
var
tokenOrNode
=
syntax
;
var
conflictAnnotation
=
annotation
;
reverseMappedLocations
[
tokenOrNode
.
GetLocation
()]
=
baseSyntaxTree
.
GetLocation
(
conflictAnnotation
.
OriginalSpan
);
}
}
...
...
src/Workspaces/Core/Portable/Rename/ConflictEngine/RenamedSpansTracker.cs
浏览文件 @
15b00bf6
...
...
@@ -79,9 +79,9 @@ internal int GetAdjustedPosition(int startingPosition, DocumentId documentId)
SpecializedCollections
.
EmptyEnumerable
<(
TextSpan
oldSpan
,
TextSpan
newSpan
)>();
var
adjustedStartingPosition
=
startingPosition
;
foreach
(
var
textSpanPair
in
documentReplacementSpans
)
foreach
(
var
(
oldSpan
,
newSpan
)
in
documentReplacementSpans
)
{
adjustedStartingPosition
+=
textSpanPair
.
newSpan
.
Length
-
textSpanPair
.
oldSpan
.
Length
;
adjustedStartingPosition
+=
newSpan
.
Length
-
oldSpan
.
Length
;
}
var
documentComplexifiedSpans
=
_documentToComplexifiedSpansMap
.
ContainsKey
(
documentId
)
...
...
@@ -98,17 +98,17 @@ internal int GetAdjustedPosition(int startingPosition, DocumentId documentId)
}
else
{
foreach
(
var
modifiedSpan
in
c
.
ModifiedSubSpans
.
OrderByDescending
(
t
=>
t
.
oldSpan
.
Start
))
foreach
(
var
(
oldSpan
,
newSpan
)
in
c
.
ModifiedSubSpans
.
OrderByDescending
(
t
=>
t
.
oldSpan
.
Start
))
{
if
(!
appliedTextSpans
.
Any
(
s
=>
s
.
Contains
(
modifiedSpan
.
oldSpan
)))
if
(!
appliedTextSpans
.
Any
(
s
=>
s
.
Contains
(
oldSpan
)))
{
if
(
startingPosition
==
modifiedSpan
.
oldSpan
.
Start
)
if
(
startingPosition
==
oldSpan
.
Start
)
{
return
startingPosition
+
modifiedSpan
.
newSpan
.
Start
-
modifiedSpan
.
oldSpan
.
Start
;
return
startingPosition
+
newSpan
.
Start
-
oldSpan
.
Start
;
}
else
if
(
startingPosition
>
modifiedSpan
.
oldSpan
.
Start
)
else
if
(
startingPosition
>
oldSpan
.
Start
)
{
return
startingPosition
+
modifiedSpan
.
newSpan
.
End
-
modifiedSpan
.
oldSpan
.
End
;
return
startingPosition
+
newSpan
.
End
-
oldSpan
.
End
;
}
}
}
...
...
@@ -251,9 +251,9 @@ internal async Task<Solution> SimplifyAsync(Solution solution, IEnumerable<Docum
var
result
=
new
Dictionary
<
TextSpan
,
TextSpan
>();
if
(
_documentToModifiedSpansMap
.
TryGetValue
(
documentId
,
out
var
modifiedSpans
))
{
foreach
(
var
pair
in
modifiedSpans
)
foreach
(
var
(
oldSpan
,
newSpan
)
in
modifiedSpans
)
{
result
[
pair
.
oldSpan
]
=
pair
.
newSpan
;
result
[
oldSpan
]
=
newSpan
;
}
}
...
...
@@ -261,9 +261,9 @@ internal async Task<Solution> SimplifyAsync(Solution solution, IEnumerable<Docum
{
foreach
(
var
complexifiedSpan
in
complexifiedSpans
)
{
foreach
(
var
pair
in
complexifiedSpan
.
ModifiedSubSpans
)
foreach
(
var
(
oldSpan
,
newSpan
)
in
complexifiedSpan
.
ModifiedSubSpans
)
{
result
[
pair
.
oldSpan
]
=
pair
.
newSpan
;
result
[
oldSpan
]
=
newSpan
;
}
}
}
...
...
src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs
浏览文件 @
15b00bf6
...
...
@@ -297,11 +297,11 @@ public IEnumerator<T> GetEnumerator()
candidates
.
Push
((
root
,
firstTime
:
true
));
while
(
candidates
.
Count
!=
0
)
{
var
currentTuple
=
candidates
.
Pop
();
var
currentNode
=
currentTuple
.
node
;
var
(
node
,
firstTime
)
=
candidates
.
Pop
();
var
currentNode
=
node
;
if
(
currentNode
!=
null
)
{
if
(
currentTuple
.
firstTime
)
if
(
firstTime
)
{
// First time seeing this node. Mark that we've been seen and recurse
// down the left side. The next time we see this node we'll yield it
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录