提交 57226dcb 编写于 作者: C Cyrus Najmabadi

Use code tags

上级 cd3fed9b
...@@ -32,13 +32,13 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping.ChainedExpression ...@@ -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 /// Note: for the sake of simplicity, (arglist) is used both for the argument list of
/// an InvocationExpression and an ElementAccessExpression. /// 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 /// 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. /// 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 /// This approach gives an intuitive wrapping algorithm that matches the common way
/// many wrap dotted invocations, while also effectively not limiting the wrapper to /// 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> /// </summary>
internal abstract partial class AbstractChainedExpressionWrapper< internal abstract partial class AbstractChainedExpressionWrapper<
TNameSyntax, TNameSyntax,
...@@ -87,8 +87,8 @@ internal abstract partial class AbstractChainedExpressionWrapper< ...@@ -87,8 +87,8 @@ internal abstract partial class AbstractChainedExpressionWrapper<
// expression. Break it into the individual chunks. We need to have at least // expression. Break it into the individual chunks. We need to have at least
// two chunks or this to be worth wrapping. // two chunks or this to be worth wrapping.
// //
// i.e. if we only have `this.Goo(...)` there's nothing to wrap. However, we can // i.e. if we only have <c>this.Goo(...)</c> there's nothing to wrap. However, we can
// wrap when we have `this.Goo(...).Bar(...)`. // wrap when we have <c>this.Goo(...).Bar(...)</c>.
var chunks = GetChainChunks(node); var chunks = GetChainChunks(node);
if (chunks.Length <= 1) if (chunks.Length <= 1)
{ {
...@@ -130,7 +130,7 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN ...@@ -130,7 +130,7 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
// //
// These will be the chunks that are wrapped and aligned on that dot. // 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(); var chunks = ArrayBuilder<ImmutableArray<SyntaxNodeOrToken>>.GetInstance();
BreakPiecesIntoChunks(pieces, chunks); BreakPiecesIntoChunks(pieces, chunks);
...@@ -144,11 +144,13 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN ...@@ -144,11 +144,13 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
ArrayBuilder<ImmutableArray<SyntaxNodeOrToken>> chunks) ArrayBuilder<ImmutableArray<SyntaxNodeOrToken>> chunks)
{ {
// Have to look for the first chunk after the first piece. i.e. if the pieces // 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()`. // starts with <c>.Foo().Bar().Baz()</c> then the chunks would be <c>.Bar()</c>
// However, if we had `this.Foo().Bar().Baz()` then the chunks would be `.Foo()` // and <c>.Baz()</c>.
// `.Bar()` and `.Baz()`.
// //
// 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: // a 'with' statement. if we have that, we don't want to wrap it into:
// //
// <code> // <code>
...@@ -191,9 +193,9 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN ...@@ -191,9 +193,9 @@ private ImmutableArray<ImmutableArray<SyntaxNodeOrToken>> GetChainChunks(SyntaxN
} }
/// <summary> /// <summary>
/// Looks for the next sequence of `. Name (ArgList)`. Note, except for the first /// Looks for the next sequence of <c>. Name (ArgList)</c>. Note, except for the first
/// chunk, this cannot be of the form `? . Name (ArgList)` as we do not want to /// chunk, this cannot be of the form <c>? . Name (ArgList)</c> as we do not want to
/// wrap before a dot in a `?.` form. This doesn't matter for the first chunk as /// 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. /// we won't be wrapping that one.
/// </summary> /// </summary>
private int FindNextChunkStart( private int FindNextChunkStart(
...@@ -244,13 +246,13 @@ private bool IsToken(int tokenKind, ArrayBuilder<SyntaxNodeOrToken> pieces, int ...@@ -244,13 +246,13 @@ private bool IsToken(int tokenKind, ArrayBuilder<SyntaxNodeOrToken> pieces, int
private bool IsDecomposableChainPart(SyntaxNode node) private bool IsDecomposableChainPart(SyntaxNode node)
{ {
// This is the effective set of language constructs that can 'chain' // 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` // 1. <c>.Name</c> or <c>->Name</c>. i.e. <c>.M(...).Name</c>
// 2. `(...)`. i.e. `.M(...)(...)` // 2. <c>(...)</c>. i.e. <c>.M(...)(...)</c>
// 3. `[...]`. i.e. `.M(...)[...]` // 3. <c>[...]</c>. i.e. <c>.M(...)[...]</c>
// 4. `++`, `--`, `!`. i.e. `.M(...)++` // 4. <c>++</c>, </c>--</c>, </c>!</c>. i.e. <c>.M(...)++</c>
// 5. `?`. i.e. `.M(...)?. ...` or `.M(...)?[...]` // 5. <c>?</c>. i.e. <c>.M(...)?. ...</c> or <c>.M(...)?[...]</c>
// '5' handles both the ConditionalAccess and MemberBinding cases below. // '5' handles both the ConditionalAccess and MemberBinding cases below.
if (node != null) if (node != null)
......
...@@ -77,7 +77,7 @@ private class CallExpressionCodeActionComputer : ...@@ -77,7 +77,7 @@ private class CallExpressionCodeActionComputer :
// Both [0][0] indices are safe here. We can only get here if we had more than // 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 // 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]; var firstPeriod = chunks[0][0];
_indentAndAlignTrivia = new SyntaxTriviaList(generator.Whitespace( _indentAndAlignTrivia = new SyntaxTriviaList(generator.Whitespace(
...@@ -129,8 +129,7 @@ private ImmutableArray<Edit> GetWrapEdits(int wrappingColumn, bool align) ...@@ -129,8 +129,7 @@ private ImmutableArray<Edit> GetWrapEdits(int wrappingColumn, bool align)
DeleteAllSpacesInChunk(result, firstChunk); DeleteAllSpacesInChunk(result, firstChunk);
var indentationTrivia = align ? _indentAndAlignTrivia : _smartIndentTrivia; var indentationTrivia = align ? _indentAndAlignTrivia : _smartIndentTrivia;
var position = indentationTrivia.FullSpan.Length + NormalizedWidth(firstChunk);
var position = indentationTrivia.FullSpan.Length;// _indentationTrivia.FullSpan.Length + NormalizedWidth(firstChunk);
// Now, go to each subsequent chunk. If keeping it on the current line would // 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. // 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.
先完成此消息的编辑!
想要评论请 注册