Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a5e9bdcd
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,发现更多精彩内容 >>
提交
a5e9bdcd
编写于
6月 17, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify
上级
4a9ab748
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
29 deletion
+29
-29
src/Features/Core/Portable/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs
...pping/BinaryExpression/AbstractBinaryExpressionWrapper.cs
+2
-2
src/Features/Core/Portable/Wrapping/BinaryExpression/BinaryExpressionCodeActionComputer.cs
...ng/BinaryExpression/BinaryExpressionCodeActionComputer.cs
+4
-4
src/Features/Core/Portable/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs
...ing/ChainedExpression/AbstractChainedExpressionWrapper.cs
+3
-3
src/Features/Core/Portable/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs
.../ChainedExpression/ChainedExpressionCodeActionComputer.cs
+6
-6
src/Features/Core/Portable/Wrapping/SeparatedSyntaxList/SeparatedSyntaxListCodeActionComputer.cs
...aratedSyntaxList/SeparatedSyntaxListCodeActionComputer.cs
+14
-14
未找到文件。
src/Features/Core/Portable/Wrapping/BinaryExpression/AbstractBinaryExpressionWrapper.cs
浏览文件 @
a5e9bdcd
...
...
@@ -99,9 +99,9 @@ internal abstract partial class AbstractBinaryExpressionWrapper<TBinaryExpressio
private
ImmutableArray
<
SyntaxNodeOrToken
>
GetExpressionsAndOperators
(
PrecedenceKind
precedence
,
TBinaryExpressionSyntax
binaryExpr
)
{
var
result
=
ArrayBuilder
<
SyntaxNodeOrToken
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
SyntaxNodeOrToken
>.
GetInstance
(
out
var
result
);
AddExpressionsAndOperators
(
precedence
,
binaryExpr
,
result
);
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
private
void
AddExpressionsAndOperators
(
...
...
src/Features/Core/Portable/Wrapping/BinaryExpression/BinaryExpressionCodeActionComputer.cs
浏览文件 @
a5e9bdcd
...
...
@@ -83,7 +83,7 @@ private Task<WrapItemsAction> GetUnwrapCodeActionAsync()
private
ImmutableArray
<
Edit
>
GetWrapEdits
(
bool
align
)
{
var
result
=
ArrayBuilder
<
Edit
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
Edit
>.
GetInstance
(
out
var
result
);
var
indentationTrivia
=
align
?
_indentAndAlignTrivia
:
_smartIndentTrivia
;
for
(
var
i
=
1
;
i
<
_exprsAndOperators
.
Length
;
i
+=
2
)
...
...
@@ -114,12 +114,12 @@ private ImmutableArray<Edit> GetWrapEdits(bool align)
}
}
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
private
ImmutableArray
<
Edit
>
GetUnwrapEdits
()
{
var
result
=
ArrayBuilder
<
Edit
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
Edit
>.
GetInstance
(
out
var
result
);
for
(
var
i
=
0
;
i
<
_exprsAndOperators
.
Length
-
1
;
i
++)
{
...
...
@@ -128,7 +128,7 @@ private ImmutableArray<Edit> GetUnwrapEdits()
NoTrivia
,
_exprsAndOperators
[
i
+
1
]));
}
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
}
}
...
...
src/Features/Core/Portable/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs
浏览文件 @
a5e9bdcd
...
...
@@ -123,7 +123,7 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
// nodes and tokens we want to treat as individual elements. i.e. an
// element that would be kept together. For example, the arg-list of an
// invocation is an element we do not want to ever break-up/wrap.
using
var
_
=
ArrayBuilder
<
SyntaxNodeOrToken
>.
GetInstance
(
out
var
pieces
);
using
var
_
1
=
ArrayBuilder
<
SyntaxNodeOrToken
>.
GetInstance
(
out
var
pieces
);
Decompose
(
node
,
pieces
);
// Now that we have the pieces, find 'chunks' similar to the form:
...
...
@@ -134,9 +134,9 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
//
// Here 'remainder' is everything up to the next <c>. Name (...)</c> chunk.
var
chunks
=
ArrayBuilder
<
ImmutableArray
<
SyntaxNodeOrToken
>>.
GetInstance
(
);
using
var
_2
=
ArrayBuilder
<
ImmutableArray
<
SyntaxNodeOrToken
>>.
GetInstance
(
out
var
chunks
);
BreakPiecesIntoChunks
(
pieces
,
chunks
);
return
chunks
.
ToImmutable
AndFree
();
return
chunks
.
ToImmutable
();
}
private
void
BreakPiecesIntoChunks
(
...
...
src/Features/Core/Portable/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs
浏览文件 @
a5e9bdcd
...
...
@@ -92,13 +92,13 @@ private class CallExpressionCodeActionComputer :
protected
override
async
Task
<
ImmutableArray
<
WrappingGroup
>>
ComputeWrappingGroupsAsync
()
{
var
actions
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
out
var
actions
);
await
AddWrapCodeActionAsync
(
actions
).
ConfigureAwait
(
false
);
await
AddUnwrapCodeActionAsync
(
actions
).
ConfigureAwait
(
false
);
await
AddWrapLongCodeActionAsync
(
actions
).
ConfigureAwait
(
false
);
return
ImmutableArray
.
Create
(
new
WrappingGroup
(
isInlinable
:
true
,
actions
.
ToImmutable
AndFree
()));
return
ImmutableArray
.
Create
(
new
WrappingGroup
(
isInlinable
:
true
,
actions
.
ToImmutable
()));
}
// Pass 0 as the wrapping column as we effectively always want to wrap each chunk
...
...
@@ -120,7 +120,7 @@ private async Task AddWrapLongCodeActionAsync(ArrayBuilder<WrapItemsAction> acti
private
ImmutableArray
<
Edit
>
GetWrapEdits
(
int
wrappingColumn
,
bool
align
)
{
var
result
=
ArrayBuilder
<
Edit
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
Edit
>.
GetInstance
(
out
var
result
);
// First, normalize the first chunk.
var
firstChunk
=
_chunks
[
0
];
...
...
@@ -160,7 +160,7 @@ private ImmutableArray<Edit> GetWrapEdits(int wrappingColumn, bool align)
position
+=
NormalizedWidth
(
chunk
);
}
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
private
static
int
NormalizedWidth
(
ImmutableArray
<
SyntaxNodeOrToken
>
chunk
)
...
...
@@ -168,14 +168,14 @@ private static int NormalizedWidth(ImmutableArray<SyntaxNodeOrToken> chunk)
private
ImmutableArray
<
Edit
>
GetUnwrapEdits
()
{
var
result
=
ArrayBuilder
<
Edit
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
Edit
>.
GetInstance
(
out
var
result
);
// Flatten all the chunks into one long list. Then delete all the spaces
// between each piece in that full list.
var
flattened
=
_chunks
.
SelectMany
(
c
=>
c
).
ToImmutableArray
();
DeleteAllSpacesInChunk
(
result
,
flattened
);
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
private
static
void
DeleteAllSpacesInChunk
(
...
...
src/Features/Core/Portable/Wrapping/SeparatedSyntaxList/SeparatedSyntaxListCodeActionComputer.cs
浏览文件 @
a5e9bdcd
...
...
@@ -100,9 +100,9 @@ private SyntaxTrivia GetIndentationTrivia(WrappingStyle wrappingStyle)
protected
override
async
Task
<
ImmutableArray
<
WrappingGroup
>>
ComputeWrappingGroupsAsync
()
{
var
result
=
ArrayBuilder
<
WrappingGroup
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
WrappingGroup
>.
GetInstance
(
out
var
result
);
await
AddWrappingGroupsAsync
(
result
).
ConfigureAwait
(
false
);
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
private
async
Task
AddWrappingGroupsAsync
(
ArrayBuilder
<
WrappingGroup
>
result
)
...
...
@@ -116,7 +116,7 @@ private async Task AddWrappingGroupsAsync(ArrayBuilder<WrappingGroup> result)
private
async
Task
<
WrappingGroup
>
GetUnwrapGroupAsync
()
{
var
unwrapActions
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
out
var
unwrapActions
);
var
parentTitle
=
Wrapper
.
Unwrap_list
;
...
...
@@ -129,7 +129,7 @@ private async Task<WrappingGroup> GetUnwrapGroupAsync()
// The 'unwrap' title strings are unique and do not collide with any other code
// actions we're computing. So they can be inlined if possible.
return
new
WrappingGroup
(
isInlinable
:
true
,
unwrapActions
.
ToImmutable
AndFree
());
return
new
WrappingGroup
(
isInlinable
:
true
,
unwrapActions
.
ToImmutable
());
}
private
async
Task
<
WrapItemsAction
>
GetUnwrapAllCodeActionAsync
(
string
parentTitle
,
WrappingStyle
wrappingStyle
)
...
...
@@ -144,7 +144,7 @@ private async Task<WrapItemsAction> GetUnwrapAllCodeActionAsync(string parentTit
private
ImmutableArray
<
Edit
>
GetUnwrapAllEdits
(
WrappingStyle
wrappingStyle
)
{
var
result
=
ArrayBuilder
<
Edit
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
Edit
>.
GetInstance
(
out
var
result
);
AddTextChangeBetweenOpenAndFirstItem
(
wrappingStyle
,
result
);
...
...
@@ -155,7 +155,7 @@ private ImmutableArray<Edit> GetUnwrapAllEdits(WrappingStyle wrappingStyle)
}
result
.
Add
(
Edit
.
DeleteBetween
(
_listItems
.
Last
(),
_listSyntax
.
GetLastToken
()));
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
#
endregion
...
...
@@ -165,7 +165,7 @@ private ImmutableArray<Edit> GetUnwrapAllEdits(WrappingStyle wrappingStyle)
private
async
Task
<
WrappingGroup
>
GetWrapLongGroupAsync
()
{
var
parentTitle
=
Wrapper
.
Wrap_long_list
;
var
codeActions
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
out
var
codeActions
);
// MethodName(int a, int b, int c,
// int d, int e, int f,
...
...
@@ -198,7 +198,7 @@ private async Task<WrappingGroup> GetWrapLongGroupAsync()
// We can't in-line these nested actions because the parent title is necessary to
// determine which situation each child action applies to.
return
new
WrappingGroup
(
isInlinable
:
false
,
codeActions
.
ToImmutable
AndFree
());
return
new
WrappingGroup
(
isInlinable
:
false
,
codeActions
.
ToImmutable
());
}
private
async
Task
<
WrapItemsAction
>
GetWrapLongLineCodeActionAsync
(
...
...
@@ -215,7 +215,7 @@ private async Task<WrappingGroup> GetWrapLongGroupAsync()
private
ImmutableArray
<
Edit
>
GetWrapLongLinesEdits
(
WrappingStyle
wrappingStyle
,
SyntaxTrivia
indentationTrivia
)
{
var
result
=
ArrayBuilder
<
Edit
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
Edit
>.
GetInstance
(
out
var
result
);
AddTextChangeBetweenOpenAndFirstItem
(
wrappingStyle
,
result
);
...
...
@@ -258,7 +258,7 @@ private async Task<WrappingGroup> GetWrapLongGroupAsync()
currentOffset
+=
nextToken
.
Span
.
Length
;
}
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
#
endregion
...
...
@@ -269,7 +269,7 @@ private async Task<WrappingGroup> GetWrapEveryGroupAsync()
{
var
parentTitle
=
Wrapper
.
Wrap_every_item
;
var
codeActions
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
WrapItemsAction
>.
GetInstance
(
out
var
codeActions
);
// MethodName(int a,
// int b,
...
...
@@ -295,7 +295,7 @@ private async Task<WrappingGroup> GetWrapEveryGroupAsync()
// See comment in GetWrapLongTopLevelCodeActionAsync for explanation of why we're
// not inlinable.
return
new
WrappingGroup
(
isInlinable
:
false
,
codeActions
.
ToImmutable
AndFree
());
return
new
WrappingGroup
(
isInlinable
:
false
,
codeActions
.
ToImmutable
());
}
private
async
Task
<
WrapItemsAction
>
GetWrapEveryNestedCodeActionAsync
(
...
...
@@ -321,7 +321,7 @@ private string GetNestedCodeActionTitle(WrappingStyle wrappingStyle)
private
ImmutableArray
<
Edit
>
GetWrapEachEdits
(
WrappingStyle
wrappingStyle
,
SyntaxTrivia
indentationTrivia
)
{
var
result
=
ArrayBuilder
<
Edit
>.
GetInstance
(
);
using
var
_
=
ArrayBuilder
<
Edit
>.
GetInstance
(
out
var
result
);
AddTextChangeBetweenOpenAndFirstItem
(
wrappingStyle
,
result
);
...
...
@@ -345,7 +345,7 @@ private string GetNestedCodeActionTitle(WrappingStyle wrappingStyle)
// last item. Delete whatever is between it and the close token of the list.
result
.
Add
(
Edit
.
DeleteBetween
(
_listItems
.
Last
(),
_listSyntax
.
GetLastToken
()));
return
result
.
ToImmutable
AndFree
();
return
result
.
ToImmutable
();
}
#
endregion
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录