Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
5e7a2894
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,发现更多精彩内容 >>
提交
5e7a2894
编写于
8月 09, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplifying code now that it doesn't need to support multiple purposes.
上级
90759e0c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
38 deletion
+24
-38
src/Features/CSharp/Portable/CodeFixes/Async/CSharpAddAwaitCodeFixProvider.cs
...Portable/CodeFixes/Async/CSharpAddAwaitCodeFixProvider.cs
+3
-5
src/Features/Core/Portable/CodeFixes/Async/AbstractAddAwaitCodeFixProvider.cs
...rtable/CodeFixes/Async/AbstractAddAwaitCodeFixProvider.cs
+7
-15
src/Features/Core/Portable/CodeFixes/Async/AbstractAsyncCodeFix.cs
...res/Core/Portable/CodeFixes/Async/AbstractAsyncCodeFix.cs
+3
-3
src/Features/Core/Portable/CodeFixes/Async/AbstractChangeToAsyncCodeFixProvider.cs
...e/CodeFixes/Async/AbstractChangeToAsyncCodeFixProvider.cs
+9
-11
src/Features/VisualBasic/Portable/CodeFixes/Async/VisualBasicAddAwaitCodeFixProvider.vb
...ble/CodeFixes/Async/VisualBasicAddAwaitCodeFixProvider.vb
+2
-4
未找到文件。
src/Features/CSharp/Portable/CodeFixes/Async/CSharpAddAwaitCodeFixProvider.cs
浏览文件 @
5e7a2894
...
...
@@ -38,19 +38,17 @@ internal class CSharpAddAwaitCodeFixProvider : AbstractAddAwaitCodeFixProvider
public
override
ImmutableArray
<
string
>
FixableDiagnosticIds
=>
ImmutableArray
.
Create
(
CS0029
,
CS4014
,
CS4016
);
protected
override
async
Task
<
IList
<
DescriptionAndNode
>>
GetDescriptionsAndNodes
Async
(
protected
override
async
Task
<
DescriptionAndNode
>
GetDescriptionAndNode
Async
(
SyntaxNode
root
,
SyntaxNode
oldNode
,
SemanticModel
semanticModel
,
Diagnostic
diagnostic
,
Document
document
,
CancellationToken
cancellationToken
)
{
var
newRoot
=
await
GetNewRootAsync
(
root
,
oldNode
,
semanticModel
,
diagnostic
,
document
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
newRoot
==
null
)
{
return
null
;
return
default
(
DescriptionAndNode
)
;
}
return
SpecializedCollections
.
SingletonList
(
new
DescriptionAndNode
(
CSharpFeaturesResources
.
Insert_await
,
newRoot
));
return
new
DescriptionAndNode
(
CSharpFeaturesResources
.
Insert_await
,
newRoot
);
}
private
Task
<
SyntaxNode
>
GetNewRootAsync
(
...
...
src/Features/Core/Portable/CodeFixes/Async/AbstractAddAwaitCodeFixProvider.cs
浏览文件 @
5e7a2894
...
...
@@ -10,31 +10,23 @@ namespace Microsoft.CodeAnalysis.CodeFixes.Async
{
internal
abstract
partial
class
AbstractAddAwaitCodeFixProvider
:
AbstractAsyncCodeFix
{
protected
abstract
Task
<
IList
<
DescriptionAndNode
>>
GetDescriptionsAndNodes
Async
(
protected
abstract
Task
<
DescriptionAndNode
>
GetDescriptionAndNode
Async
(
SyntaxNode
root
,
SyntaxNode
oldNode
,
SemanticModel
semanticModel
,
Diagnostic
diagnostic
,
Document
document
,
CancellationToken
cancellationToken
);
protected
override
async
Task
<
IList
<
CodeAction
>>
GetCodeActions
Async
(
protected
override
async
Task
<
CodeAction
>
GetCodeAction
Async
(
SyntaxNode
root
,
SyntaxNode
node
,
Document
document
,
Diagnostic
diagnostic
,
CancellationToken
cancellationToken
)
{
var
semanticModel
=
await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
data
=
await
this
.
GetDescription
sAndNodes
Async
(
root
,
node
,
semanticModel
,
diagnostic
,
document
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
data
==
null
)
var
data
=
await
this
.
GetDescription
AndNode
Async
(
root
,
node
,
semanticModel
,
diagnostic
,
document
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
data
.
Node
==
null
)
{
return
null
;
}
var
result
=
new
List
<
CodeAction
>();
foreach
(
var
item
in
data
)
{
var
action
=
new
MyCodeAction
(
item
.
Description
,
c
=>
Task
.
FromResult
(
document
.
WithSyntaxRoot
(
item
.
Node
)));
result
.
Add
(
action
);
}
return
result
;
return
new
MyCodeAction
(
data
.
Description
,
c
=>
Task
.
FromResult
(
document
.
WithSyntaxRoot
(
data
.
Node
)));
}
protected
static
bool
TryGetExpressionType
(
...
...
src/Features/Core/Portable/CodeFixes/Async/AbstractAsyncCodeFix.cs
浏览文件 @
5e7a2894
...
...
@@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes.Async
{
internal
abstract
partial
class
AbstractAsyncCodeFix
:
CodeFixProvider
{
protected
abstract
Task
<
IList
<
CodeAction
>>
GetCodeActions
Async
(
protected
abstract
Task
<
CodeAction
>
GetCodeAction
Async
(
SyntaxNode
root
,
SyntaxNode
node
,
Document
document
,
Diagnostic
diagnostic
,
CancellationToken
cancellationToken
);
public
sealed
override
async
Task
RegisterCodeFixesAsync
(
CodeFixContext
context
)
...
...
@@ -27,9 +27,9 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
var
diagnostic
=
context
.
Diagnostics
.
FirstOrDefault
();
var
codeAction
s
=
await
GetCodeActions
Async
(
var
codeAction
=
await
GetCodeAction
Async
(
root
,
node
,
context
.
Document
,
diagnostic
,
context
.
CancellationToken
).
ConfigureAwait
(
false
);
context
.
Register
Fixes
(
codeActions
,
context
.
Diagnostics
);
context
.
Register
CodeFix
(
codeAction
,
context
.
Diagnostics
);
}
private
bool
TryGetNode
(
SyntaxNode
root
,
TextSpan
span
,
out
SyntaxNode
node
)
...
...
src/Features/Core/Portable/CodeFixes/Async/AbstractChangeToAsyncCodeFixProvider.cs
浏览文件 @
5e7a2894
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CodeActions
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CodeFixes.Async
{
...
...
@@ -14,23 +12,23 @@ internal abstract partial class AbstractChangeToAsyncCodeFixProvider : AbstractA
protected
abstract
Task
<
string
>
GetDescription
(
Diagnostic
diagnostic
,
SyntaxNode
node
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
);
protected
abstract
Task
<
Tuple
<
SyntaxTree
,
SyntaxNode
>>
GetRootInOtherSyntaxTree
(
SyntaxNode
node
,
SemanticModel
semanticModel
,
Diagnostic
diagnostic
,
CancellationToken
cancellationToken
);
protected
override
async
Task
<
IList
<
CodeAction
>>
GetCodeActions
Async
(
protected
override
async
Task
<
CodeAction
>
GetCodeAction
Async
(
SyntaxNode
root
,
SyntaxNode
node
,
Document
document
,
Diagnostic
diagnostic
,
CancellationToken
cancellationToken
)
{
var
semanticModel
=
await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
result
=
await
GetRootInOtherSyntaxTree
(
node
,
semanticModel
,
diagnostic
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
result
!
=
null
)
if
(
result
=
=
null
)
{
var
syntaxTree
=
result
.
Item1
;
var
newRoot
=
result
.
Item2
;
var
otherDocument
=
document
.
Project
.
Solution
.
GetDocument
(
syntaxTree
);
return
SpecializedCollections
.
SingletonList
<
CodeAction
>(
new
MyCodeAction
(
await
this
.
GetDescription
(
diagnostic
,
node
,
semanticModel
,
cancellationToken
).
ConfigureAwait
(
false
),
token
=>
Task
.
FromResult
(
otherDocument
.
WithSyntaxRoot
(
newRoot
))));
return
null
;
}
return
null
;
var
syntaxTree
=
result
.
Item1
;
var
newRoot
=
result
.
Item2
;
var
otherDocument
=
document
.
Project
.
Solution
.
GetDocument
(
syntaxTree
);
return
new
MyCodeAction
(
await
this
.
GetDescription
(
diagnostic
,
node
,
semanticModel
,
cancellationToken
).
ConfigureAwait
(
false
),
token
=>
Task
.
FromResult
(
otherDocument
.
WithSyntaxRoot
(
newRoot
)));
}
private
class
MyCodeAction
:
CodeAction
.
DocumentChangeAction
...
...
src/Features/VisualBasic/Portable/CodeFixes/Async/VisualBasicAddAwaitCodeFixProvider.vb
浏览文件 @
5e7a2894
...
...
@@ -29,16 +29,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Async
End
Get
End
Property
Protected
Overrides
Async
Function
GetDescription
sAndNodesAsync
(
root
As
SyntaxNode
,
oldNode
As
SyntaxNode
,
semanticModel
As
SemanticModel
,
diagnostic
As
Diagnostic
,
document
As
Document
,
cancellationToken
As
CancellationToken
)
As
Task
(
Of
IList
(
Of
DescriptionAndNode
)
)
Protected
Overrides
Async
Function
GetDescription
AndNodeAsync
(
root
As
SyntaxNode
,
oldNode
As
SyntaxNode
,
semanticModel
As
SemanticModel
,
diagnostic
As
Diagnostic
,
document
As
Document
,
cancellationToken
As
CancellationToken
)
As
Task
(
Of
DescriptionAndNode
)
Dim
newRoot
=
Await
GetNewRootAsync
(
root
,
oldNode
,
semanticModel
,
diagnostic
,
document
,
cancellationToken
).
ConfigureAwait
(
False
)
If
newRoot
Is
Nothing
Then
Return
Nothing
End
If
Return
SpecializedCollections
.
SingletonList
(
New
DescriptionAndNode
(
VBFeaturesResources
.
Insert_Await
,
newRoot
))
Return
New
DescriptionAndNode
(
VBFeaturesResources
.
Insert_Await
,
newRoot
)
End
Function
Private
Function
GetNewRootAsync
(
root
As
SyntaxNode
,
oldNode
As
SyntaxNode
,
semanticModel
As
SemanticModel
,
diagnostic
As
Diagnostic
,
document
As
Document
,
cancellationToken
As
CancellationToken
)
As
Task
(
Of
SyntaxNode
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录