Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
57226dcb
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,发现更多精彩内容 >>
提交
57226dcb
编写于
7月 09, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use code tags
上级
cd3fed9b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
22 addition
and
21 deletion
+22
-21
src/EditorFeatures/Core/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs
...ing/ChainedExpression/AbstractChainedExpressionWrapper.cs
+20
-18
src/EditorFeatures/Core/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs
.../ChainedExpression/ChainedExpressionCodeActionComputer.cs
+2
-3
未找到文件。
src/EditorFeatures/Core/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs
浏览文件 @
57226dcb
...
...
@@ -32,13 +32,13 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping.ChainedExpression
/// Note: for the sake of simplicity, (arglist) is used both for the argument list of
/// an InvocationExpression and an ElementAccessExpression.
///
/// 'remainder' is all the postfix expression that can follow
`. name (arglist)`
. i.e.
/// 'remainder' is all the postfix expression that can follow
<c>. name (arglist)</c>
. i.e.
/// member-access expressions, conditional-access expressions, etc. Effectively, anything
/// the language allows at this point as long as it doesn't start another 'chunk' itself.
///
/// This approach gives an intuitive wrapping algorithm that matches the common way
/// many wrap dotted invocations, while also effectively not limiting the wrapper to
/// only simple forms like
`.a(...).b(...).c(...)`
.
/// only simple forms like
<c>.a(...).b(...).c(...)</c>
.
/// </summary>
internal
abstract
partial
class
AbstractChainedExpressionWrapper
<
TNameSyntax
,
...
...
@@ -87,8 +87,8 @@ internal abstract partial class AbstractChainedExpressionWrapper<
// expression. Break it into the individual chunks. We need to have at least
// two chunks or this to be worth wrapping.
//
// i.e. if we only have
`this.Goo(...)`
there's nothing to wrap. However, we can
// wrap when we have
`this.Goo(...).Bar(...)`
.
// i.e. if we only have
<c>this.Goo(...)</c>
there's nothing to wrap. However, we can
// wrap when we have
<c>this.Goo(...).Bar(...)</c>
.
var
chunks
=
GetChainChunks
(
node
);
if
(
chunks
.
Length
<=
1
)
{
...
...
@@ -130,7 +130,7 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
//
// These will be the chunks that are wrapped and aligned on that dot.
//
// Here 'remainder' is everything up to the next
`. Name (...)`
chunk.
// Here 'remainder' is everything up to the next
<c>. Name (...)</c>
chunk.
var
chunks
=
ArrayBuilder
<
ImmutableArray
<
SyntaxNodeOrToken
>>.
GetInstance
();
BreakPiecesIntoChunks
(
pieces
,
chunks
);
...
...
@@ -144,11 +144,13 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
ArrayBuilder
<
ImmutableArray
<
SyntaxNodeOrToken
>>
chunks
)
{
// Have to look for the first chunk after the first piece. i.e. if the pieces
// starts with `.Foo().Bar().Baz()` then the chunks would be `.Bar()` and `.Baz()`.
// However, if we had `this.Foo().Bar().Baz()` then the chunks would be `.Foo()`
// `.Bar()` and `.Baz()`.
// starts with <c>.Foo().Bar().Baz()</c> then the chunks would be <c>.Bar()</c>
// and <c>.Baz()</c>.
//
// Note: the only way to get the `.Foo().Bar().Baz()` case today is in VB in
// However, if we had <c>this.Foo().Bar().Baz()</c> then the chunks would be
// <c>.Foo()</c> <c>.Bar()</c> and <c>.Baz()</c>.
//
// Note: the only way to get the <c>.Foo().Bar().Baz()</c> case today is in VB in
// a 'with' statement. if we have that, we don't want to wrap it into:
//
// <code>
...
...
@@ -191,9 +193,9 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
}
/// <summary>
/// Looks for the next sequence of
`. Name (ArgList)`
. Note, except for the first
/// chunk, this cannot be of the form
`? . Name (ArgList)`
as we do not want to
/// wrap before a dot in a
`?.`
form. This doesn't matter for the first chunk as
/// Looks for the next sequence of
<c>. Name (ArgList)</c>
. Note, except for the first
/// chunk, this cannot be of the form
<c>? . Name (ArgList)</c>
as we do not want to
/// wrap before a dot in a
<c>?.</c>
form. This doesn't matter for the first chunk as
/// we won't be wrapping that one.
/// </summary>
private
int
FindNextChunkStart
(
...
...
@@ -244,13 +246,13 @@ private bool IsToken(int tokenKind, ArrayBuilder<SyntaxNodeOrToken> pieces, int
private
bool
IsDecomposableChainPart
(
SyntaxNode
node
)
{
// This is the effective set of language constructs that can 'chain'
// off of a call
`.M(...)`
. They are:
// off of a call
<c>.M(...)</c>
. They are:
//
// 1.
`.Name` or `->Name`. i.e. `.M(...).Name`
// 2.
`(...)`. i.e. `.M(...)(...)`
// 3.
`[...]`. i.e. `.M(...)[...]`
// 4.
`++`, `--`, `!`. i.e. `.M(...)++`
// 5.
`?`. i.e. `.M(...)?. ...` or `.M(...)?[...]`
// 1.
<c>.Name</c> or <c>->Name</c>. i.e. <c>.M(...).Name</c>
// 2.
<c>(...)</c>. i.e. <c>.M(...)(...)</c>
// 3.
<c>[...]</c>. i.e. <c>.M(...)[...]</c>
// 4.
<c>++</c>, </c>--</c>, </c>!</c>. i.e. <c>.M(...)++</c>
// 5.
<c>?</c>. i.e. <c>.M(...)?. ...</c> or <c>.M(...)?[...]</c>
// '5' handles both the ConditionalAccess and MemberBinding cases below.
if
(
node
!=
null
)
...
...
src/EditorFeatures/Core/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs
浏览文件 @
57226dcb
...
...
@@ -77,7 +77,7 @@ private class CallExpressionCodeActionComputer :
// Both [0][0] indices are safe here. We can only get here if we had more than
// two chunks to wrap. And each chunk is required to have at least three elements
// (i.e.
`. name (arglist)`
).
// (i.e.
<c>. name (arglist)</c>
).
var
firstPeriod
=
chunks
[
0
][
0
];
_indentAndAlignTrivia
=
new
SyntaxTriviaList
(
generator
.
Whitespace
(
...
...
@@ -129,8 +129,7 @@ private ImmutableArray<Edit> GetWrapEdits(int wrappingColumn, bool align)
DeleteAllSpacesInChunk
(
result
,
firstChunk
);
var
indentationTrivia
=
align
?
_indentAndAlignTrivia
:
_smartIndentTrivia
;
var
position
=
indentationTrivia
.
FullSpan
.
Length
;
// _indentationTrivia.FullSpan.Length + NormalizedWidth(firstChunk);
var
position
=
indentationTrivia
.
FullSpan
.
Length
+
NormalizedWidth
(
firstChunk
);
// Now, go to each subsequent chunk. If keeping it on the current line would
// cause us to go past the requested wrapping column, then wrap it and proceed.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录