Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
78a997e9
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,发现更多精彩内容 >>
提交
78a997e9
编写于
8月 19, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Roll back previous change.
上级
69613224
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
12 addition
and
41 deletion
+12
-41
src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs
...dExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs
+1
-3
src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.CSharpCodeGenerator.cs
...xtractMethod/CSharpMethodExtractor.CSharpCodeGenerator.cs
+4
-9
src/Features/Core/Portable/ExtractMethod/MethodExtractor.CodeGenerator.cs
...e/Portable/ExtractMethod/MethodExtractor.CodeGenerator.cs
+2
-15
src/Features/VisualBasic/Portable/ExtractMethod/VisualBasicMethodExtractor.VisualBasicCodeGenerator.ExpressionCodeGenerator.vb
...actor.VisualBasicCodeGenerator.ExpressionCodeGenerator.vb
+1
-5
src/Features/VisualBasic/Portable/ExtractMethod/VisualBasicMethodExtractor.VisualBasicCodeGenerator.vb
...od/VisualBasicMethodExtractor.VisualBasicCodeGenerator.vb
+4
-9
未找到文件。
src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs
浏览文件 @
78a997e9
...
...
@@ -193,7 +193,7 @@ protected override async Task<SyntaxNode> GetStatementOrInitializerContainingInv
{
var
enclosingStatement
=
GetFirstStatementOrInitializerSelectedAtCallSite
();
var
(
invocation
,
invocationWithAwaitOpt
)
=
CreateCallSignatureParts
(
);
var
callSignature
=
CreateCallSignature
().
WithAdditionalAnnotations
(
CallSiteAnnotation
);
var
sourceNode
=
CSharpSelectionResult
.
GetContainingScope
();
Contract
.
ThrowIfTrue
(
...
...
@@ -220,8 +220,6 @@ protected override async Task<SyntaxNode> GetStatementOrInitializerContainingInv
// however complexification of names is prepended, so the last annotation should be the original one.
sourceNode
=
updatedRoot
.
GetAnnotatedNodesAndTokens
(
sourceNodeAnnotation
).
Last
().
AsNode
();
var
callSignature
=
(
ExpressionSyntax
)
invocationWithAwaitOpt
??
invocation
;
callSignature
=
callSignature
.
WithAdditionalAnnotations
(
CallSiteAnnotation
);
return
newEnclosingStatement
.
ReplaceNode
(
sourceNode
,
callSignature
);
}
}
...
...
src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.CSharpCodeGenerator.cs
浏览文件 @
78a997e9
...
...
@@ -30,12 +30,7 @@ namespace Microsoft.CodeAnalysis.CSharp.ExtractMethod
{
internal
partial
class
CSharpMethodExtractor
{
private
abstract
partial
class
CSharpCodeGenerator
:
CodeGenerator
<
StatementSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
,
AwaitExpressionSyntax
,
SyntaxNode
>
private
abstract
partial
class
CSharpCodeGenerator
:
CodeGenerator
<
StatementSyntax
,
ExpressionSyntax
,
SyntaxNode
>
{
private
readonly
SyntaxToken
_methodName
;
...
...
@@ -579,7 +574,7 @@ protected override StatementSyntax CreateReturnStatement(string identifierName =
:
SyntaxFactory
.
ReturnStatement
(
SyntaxFactory
.
IdentifierName
(
identifierName
));
}
protected
override
(
InvocationExpressionSyntax
invocation
,
AwaitExpressionSyntax
awaitExpressionOpt
)
CreateCallSignatureParts
()
protected
override
ExpressionSyntax
CreateCallSignature
()
{
var
methodName
=
CreateMethodNameForInvocation
().
WithAdditionalAnnotations
(
Simplifier
.
Annotation
);
...
...
@@ -598,7 +593,7 @@ protected override (InvocationExpressionSyntax invocation, AwaitExpressionSyntax
var
shouldPutAsyncModifier
=
CSharpSelectionResult
.
ShouldPutAsyncModifier
();
if
(!
shouldPutAsyncModifier
)
{
return
(
invocation
,
awaitExpressionOpt
:
null
)
;
return
invocation
;
}
if
(
CSharpSelectionResult
.
ShouldCallConfigureAwaitFalse
())
...
...
@@ -619,7 +614,7 @@ protected override (InvocationExpressionSyntax invocation, AwaitExpressionSyntax
}
}
return
(
invocation
,
SyntaxFactory
.
AwaitExpression
(
invocation
)
);
return
SyntaxFactory
.
AwaitExpression
(
invocation
);
}
protected
override
StatementSyntax
CreateAssignmentExpressionStatement
(
SyntaxToken
identifier
,
ExpressionSyntax
rvalue
)
...
...
src/Features/Core/Portable/ExtractMethod/MethodExtractor.CodeGenerator.cs
浏览文件 @
78a997e9
...
...
@@ -20,16 +20,9 @@ namespace Microsoft.CodeAnalysis.ExtractMethod
{
internal
abstract
partial
class
MethodExtractor
{
protected
abstract
partial
class
CodeGenerator
<
TStatement
,
TExpression
,
TInvocationExpression
,
TAwaitExpression
,
TNodeUnderContainer
>
protected
abstract
partial
class
CodeGenerator
<
TStatement
,
TExpression
,
TNodeUnderContainer
>
where
TStatement
:
SyntaxNode
where
TExpression
:
SyntaxNode
where
TInvocationExpression
:
TExpression
where
TAwaitExpression
:
TExpression
where
TNodeUnderContainer
:
SyntaxNode
{
protected
readonly
SyntaxAnnotation
MethodNameAnnotation
;
...
...
@@ -77,7 +70,7 @@ protected CodeGenerator(InsertionPoint insertionPoint, SelectionResult selection
protected
abstract
TNodeUnderContainer
GetLastStatementOrInitializerSelectedAtCallSite
();
protected
abstract
Task
<
TNodeUnderContainer
>
GetStatementOrInitializerContainingInvocationToExtractedMethodAsync
(
CancellationToken
cancellationToken
);
protected
abstract
(
TInvocationExpression
invocation
,
TAwaitExpression
awaitExpressionOpt
)
CreateCallSignatureParts
();
protected
abstract
TExpression
CreateCallSignature
();
protected
abstract
TStatement
CreateDeclarationStatement
(
VariableInfo
variable
,
TExpression
initialValue
,
CancellationToken
cancellationToken
);
protected
abstract
TStatement
CreateAssignmentExpressionStatement
(
SyntaxToken
identifier
,
TExpression
rvalue
);
protected
abstract
TStatement
CreateReturnStatement
(
string
identifierName
=
null
);
...
...
@@ -219,12 +212,6 @@ protected ImmutableArray<TStatement> AddReturnIfUnreachable(ImmutableArray<TStat
(
TStatement
)(
SyntaxNode
)
await
GetStatementOrInitializerContainingInvocationToExtractedMethodAsync
(
cancellationToken
).
ConfigureAwait
(
false
));
}
protected
TExpression
CreateCallSignature
()
{
var
(
invocation
,
awaitExpressionOpt
)
=
CreateCallSignatureParts
();
return
(
TExpression
)
awaitExpressionOpt
??
invocation
;
}
protected
ImmutableArray
<
TStatement
>
AddAssignmentStatementToCallSite
(
ImmutableArray
<
TStatement
>
statements
,
CancellationToken
cancellationToken
)
...
...
src/Features/VisualBasic/Portable/ExtractMethod/VisualBasicMethodExtractor.VisualBasicCodeGenerator.ExpressionCodeGenerator.vb
浏览文件 @
78a997e9
...
...
@@ -116,9 +116,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExtractMethod
Protected
Overrides
Async
Function
GetStatementOrInitializerContainingInvocationToExtractedMethodAsync
(
cancellationToken
As
CancellationToken
)
As
Task
(
Of
StatementSyntax
)
Dim
enclosingStatement
=
GetFirstStatementOrInitializerSelectedAtCallSite
()
Dim
callSignatureParts
=
CreateCallSignatureParts
()
Dim
invocation
=
callSignatureParts
.
invocation
Dim
invocationWithAwaitOpt
=
callSignatureParts
.
awaitExpressionOpt
Dim
callSignature
=
CreateCallSignature
().
WithAdditionalAnnotations
(
CallSiteAnnotation
)
Dim
sourceNode
=
VBSelectionResult
.
GetContainingScope
()
Contract
.
ThrowIfTrue
(
...
...
@@ -145,8 +143,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExtractMethod
' however complexification of names is prepended, so the last annotation should be the original one.
sourceNode
=
updatedRoot
.
GetAnnotatedNodesAndTokens
(
sourceNodeAnnotation
).
Last
().
AsNode
()
Dim
callSignature
=
If
(
DirectCast
(
invocationWithAwaitOpt
,
ExpressionSyntax
),
invocation
)
callSignature
=
callSignature
.
WithAdditionalAnnotations
(
CallSiteAnnotation
)
Return
newEnclosingStatement
.
ReplaceNode
(
sourceNode
,
callSignature
)
End
Function
End
Class
...
...
src/Features/VisualBasic/Portable/ExtractMethod/VisualBasicMethodExtractor.VisualBasicCodeGenerator.vb
浏览文件 @
78a997e9
...
...
@@ -16,12 +16,7 @@ Imports System.Collections.Immutable
Namespace
Microsoft.CodeAnalysis.VisualBasic.ExtractMethod
Partial
Friend
Class
VisualBasicMethodExtractor
Partial
Private
MustInherit
Class
VisualBasicCodeGenerator
Inherits
CodeGenerator
(
Of
StatementSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
,
AwaitExpressionSyntax
,
StatementSyntax
)
Inherits
CodeGenerator
(
Of
StatementSyntax
,
ExpressionSyntax
,
StatementSyntax
)
Private
ReadOnly
_methodName
As
SyntaxToken
...
...
@@ -324,7 +319,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExtractMethod
Return
statements
(
index
+
1
).
IsKind
(
SyntaxKind
.
ReturnStatement
,
SyntaxKind
.
ExitSubStatement
)
End
Function
Protected
Overrides
Function
CreateCallSignature
Parts
()
As
(
invocation
As
InvocationExpressionSyntax
,
awaitExpressionOpt
As
AwaitExpressionSyntax
)
Protected
Overrides
Function
CreateCallSignature
()
As
ExpressionSyntax
Dim
methodName
As
ExpressionSyntax
=
CreateMethodNameForInvocation
().
WithAdditionalAnnotations
(
Simplifier
.
Annotation
)
Dim
arguments
=
New
List
(
Of
ArgumentSyntax
)()
...
...
@@ -368,10 +363,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExtractMethod
SyntaxFactory
.
Token
(
SyntaxKind
.
FalseKeyword
))))))
End
If
End
If
Return
(
invocation
,
SyntaxFactory
.
AwaitExpression
(
invocation
)
)
Return
SyntaxFactory
.
AwaitExpression
(
invocation
)
End
If
Return
(
invocation
,
awaitExpressionOpt
:
=
Nothing
)
Return
invocation
End
Function
Private
Shared
Function
GetIdentifierName
(
name
As
String
)
As
ExpressionSyntax
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录