Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
42e45995
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,发现更多精彩内容 >>
提交
42e45995
编写于
5月 11, 2015
作者:
D
David Poeschl
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2622 from dpoeschl/ExpandReduceExpressionBodiedMembers
Expand/Reduce in expression-bodied members and lambdas
上级
1f333680
fb7ef977
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
69 addition
and
5 deletion
+69
-5
src/EditorFeatures/Test2/Rename/RenameEngineTests.CSharpConflicts.vb
...eatures/Test2/Rename/RenameEngineTests.CSharpConflicts.vb
+51
-4
src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
...rp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
+18
-1
未找到文件。
src/EditorFeatures/Test2/Rename/RenameEngineTests.CSharpConflicts.vb
浏览文件 @
42e45995
...
...
@@ -219,13 +219,14 @@ using System.Linq;
public
class
B
{
public
readonly
int
z
=
0
;
public
int
X
(
int
[|$$
x
|]
)
=>
[|
x
|]
+
{
|
resolve
:
z
|
}
;
public
int
X
(
int
[|$$
x
|]
)
=>
{
|
direct
:
x
|
}
+
{
|
resolve
:
z
|
}
;
}
</
Document
>
</
Project
>
</
Workspace
>
,
renameTo
:
=
"z"
)
result
.
AssertLabeledSpansAre
(
"resolve"
,
"this.z"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
result
.
AssertLabeledSpansAre
(
"direct"
,
"z + this.z"
,
RelatedLocationType
.
NoConflict
)
result
.
AssertLabeledSpansAre
(
"resolve"
,
"z + this.z"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
End
Using
End
Sub
...
...
@@ -244,13 +245,14 @@ using System.Linq;
public
class
B
{
public
static
readonly
int
z
=
0
;
public
int
X
(
int
[|$$
x
|]
)
=>
[|
x
|]
+
{
|
resolve
:
z
|
}
;
public
int
X
(
int
[|$$
x
|]
)
=>
{
|
direct
:
x
|
}
+
{
|
resolve
:
z
|
}
;
}
</
Document
>
</
Project
>
</
Workspace
>
,
renameTo
:
=
"z"
)
result
.
AssertLabeledSpansAre
(
"resolve"
,
"B.z"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
result
.
AssertLabeledSpansAre
(
"direct"
,
"z + B.z"
,
RelatedLocationType
.
NoConflict
)
result
.
AssertLabeledSpansAre
(
"resolve"
,
"z + B.z"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
End
Using
End
Sub
...
...
@@ -3003,5 +3005,50 @@ class C
result
.
AssertLabeledSpansAre
(
"ref"
,
"string x = nameof(this.zoo);"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
End
Using
End
Sub
<
WorkItem
(
1053
,
"https://github.com/dotnet/roslyn/issues/1053"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Rename
)
>
Public
Sub
RenameComplexifiesInLambdaBodyExpression
()
Using
result
=
RenameEngineResult
.
Create
(
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
FilePath
=
"Test.cs"
><
!
[
CDATA
[
class
C
{
static
int
[|$$
M
|]
(
int
b
)
=>
5
;
static
int
N
(
long
b
)
=>
5
;
System
.
Func
<
int
,
int
>
a
=
d
=>
{
|
resolved
:
N
|
}(
1
)
;
System
.
Func
<
int
>
b
=
()
=>
{
|
resolved
:
N
|
}(
1
)
;
}
]]
>
</
Document
>
</
Project
>
</
Workspace
>
,
renameTo
:
=
"N"
)
result
.
AssertLabeledSpansAre
(
"resolved"
,
"N((long)1)"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
End
Using
End
Sub
<
WorkItem
(
1053
,
"https://github.com/dotnet/roslyn/issues/1053"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Rename
)
>
Public
Sub
RenameComplexifiesInExpressionBodiedMembers
()
Using
result
=
RenameEngineResult
.
Create
(
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
FilePath
=
"Test.cs"
><
!
[
CDATA
[
class
C
{
int
f
=
new
C
().
{|
resolved1
:
N
|
}(
0
)
;
int
[|$$
M
|]
(
int
b
)
=>
{
|
resolved2
:
N
|
}(
0
)
;
int
N
(
long
b
)
=>
[|
M
|]
(
0
)
;
int
P
=>
{
|
resolved2
:
N
|
}(
0
)
;
}
]]
>
</
Document
>
</
Project
>
</
Workspace
>
,
renameTo
:
=
"N"
)
result
.
AssertLabeledSpansAre
(
"resolved1"
,
"new C().N((long)0)"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
result
.
AssertLabeledSpansAre
(
"resolved2"
,
"N((long)0)"
,
RelatedLocationType
.
ResolvedNonReferenceConflict
)
End
Using
End
Sub
End
Class
End
Namespace
src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
浏览文件 @
42e45995
...
...
@@ -1082,10 +1082,27 @@ private static SyntaxNode GetExpansionTarget(SyntaxToken token)
// get the directly enclosing statement
var
enclosingStatement
=
token
.
GetAncestors
(
n
=>
n
is
StatementSyntax
).
FirstOrDefault
();
//
see if there's an enclosing lambda expression
//
System.Func<int, int> myFunc = arg => X;
SyntaxNode
possibleLambdaExpression
=
enclosingStatement
==
null
?
token
.
GetAncestors
(
n
=>
n
is
SimpleLambdaExpressionSyntax
||
n
is
ParenthesizedLambdaExpressionSyntax
).
FirstOrDefault
()
:
null
;
if
(
possibleLambdaExpression
!=
null
)
{
var
lambdaExpression
=
((
LambdaExpressionSyntax
)
possibleLambdaExpression
);
if
(
lambdaExpression
.
Body
is
ExpressionSyntax
)
{
return
lambdaExpression
.
Body
;
}
}
// int M() => X;
var
possibleArrowExpressionClause
=
enclosingStatement
==
null
?
token
.
GetAncestors
<
ArrowExpressionClauseSyntax
>().
FirstOrDefault
()
:
null
;
if
(
possibleArrowExpressionClause
!=
null
)
{
return
possibleArrowExpressionClause
.
Expression
;
}
var
enclosingNameMemberCrefOrnull
=
token
.
GetAncestors
(
n
=>
n
is
NameMemberCrefSyntax
).
LastOrDefault
();
if
(
enclosingNameMemberCrefOrnull
!=
null
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录